@PUT("touched") public List<Grandchild> touchCollection(IdRef<Child> childId) { List<Grandchild> grandchilds = yawp(Grandchild.class).from(childId).list(); for (Grandchild grandchild : grandchilds) { grandchild.setName("touched " + grandchild.getName()); } return grandchilds; }
@Test public void testSaveGrandchild() { Parent parent = new Parent(); yawp.save(parent); Child child = new Child(); child.setParentId(parent.getId()); yawp.save(child); Grandchild grandchild = new Grandchild("xpto"); grandchild.setChildId(child.getId()); yawp.save(grandchild); Child retrievedChild = child.getId().fetch(); Grandchild retrievedGrandchild = grandchild.getId().fetch(); assertEquals(retrievedGrandchild.getChildId(), retrievedChild.getId()); assertEquals("xpto", retrievedGrandchild.getName()); }
@PUT("touched") public Grandchild touchObject(IdRef<Grandchild> id) { Grandchild grandchild = id.fetch(); grandchild.setName("touched " + grandchild.getName()); return grandchild; }