@PUT("touched") public List<Child> touchCollection(IdRef<Parent> parentId) { List<Child> childs = yawp(Child.class).from(parentId).order("name").list(); for (Child child : childs) { child.setName("touched " + child.getName()); } return childs; }
@Test public void testSaveChild() { Parent parent = new Parent(); yawp.save(parent); Child child = new Child("xpto"); child.setParentId(parent.getId()); yawp.save(child); Parent retrievedParent = parent.getId().fetch(); Child retrievedChild = child.getId().fetch(); assertEquals(retrievedChild.getParentId(), retrievedParent.getId()); assertEquals("xpto", retrievedChild.getName()); }
@PUT("touchedParams") public Child touchParams(IdRef<Child> id, Map<String, String> params) { Child child = id.fetch(); child.setName("touched " + child.getName() + " by " + params.get("arg")); return child; }
@PUT("touched") public Child touchObject(IdRef<Child> id) { Child child = id.fetch(); child.setName("touched " + child.getName()); return child; }