WFClient { public void editList(WFList toEdit, String newName, String newDescription) throws IOException { checkLoggedIn(); long time = getClientTimeInSeconds(); Long prevLm = toEdit.lm; PushPoll.Operation editOp; synchronized (this) { if (newName != null) toEdit.nm = newName; if (newDescription != null) { toEdit.no = newDescription.isEmpty() ? null : newDescription; } toEdit.lm = time; editOp = PushPoll.buildEditOp(toEdit.id, newName, newDescription, prevLm, time); } executePushPoll(ImmutableList.of(editOp)); } WFClient(); void login(String username, String password); boolean isLoggedIn(); void logout(); void setSession(String session); String getSession(); String getUsername(); void refresh(); List<WFList> getRootLists(); WFList createRootList(Integer insertIndex, String name, String description); WFList createList(WFList parent, Integer insertIndex, String name, String description); void editList(WFList toEdit, String newName, String newDescription); void completeList(WFList toComplete, boolean isComplete); void deleteList(WFList toDelete); synchronized boolean isRootList(WFList list); synchronized boolean hasList(WFList list); synchronized WFList getParentList(WFList child); synchronized WFList getListById(final String listId); synchronized List<WFList> getAncestryPath(WFList list); static final Logger log; static final String LOGIN_URL; static final String API_URL; static final String USER_AGENT; static final int TIMEOUT_MS; static final String CLIENT_VERSION; }
@Test public void testEditList() throws IOException { String rootName = "root_" + UUID.randomUUID().toString(); WFList rootList = client.createRootList(0, rootName, null); String rootId = rootList.getId(); String childName = rootName + "_child"; WFList childList = client.createList(rootList, 0, childName, null); String childId = childList.getId(); client.refresh(); List<WFList> rootLists = client.getRootLists(); rootList = rootLists.get(0); childList = rootList.getChildren().get(0); assertEquals(rootId, rootList.getId()); assertEquals(rootName, rootList.getName()); assertEquals(childId, childList.getId()); assertEquals(childName, childList.getName()); String newRootName = "new_" + rootName; String newRootDesc = "desc_" + newRootName; String newChildName = "new_" + childName; String newChildDesc = "new_" + newRootDesc; client.editList(rootList, newRootName, newRootDesc); client.editList(childList, newChildName, null); client.editList(childList, null, newChildDesc); client.refresh(); List<WFList> newRootLists = client.getRootLists(); WFList newRootList = newRootLists.get(0); WFList newChildList = newRootList.getChildren().get(0); assertEquals(newRootLists.size(), 1); assertEquals(rootId, newRootList.getId()); assertEquals(childId, newChildList.getId()); assertEquals(newRootName, newRootList.getName()); assertEquals(newChildName, newChildList.getName()); assertEquals(newRootDesc, newRootList.getDescription()); assertEquals(newChildDesc, newChildList.getDescription()); assertEquals(newRootList.getChildren().size(), 1); client.editList(newRootList, "", ""); client.refresh(); List<WFList> newNewRootLists = client.getRootLists(); WFList newNewRootList = newNewRootLists.get(0); WFList newNewChildList = newNewRootList.getChildren().get(0); assertEquals(newNewRootLists.size(), 1); assertEquals(rootId, newNewRootList.getId()); assertEquals(childId, newNewChildList.getId()); assertEquals("", newNewRootList.getName()); assertEquals(null, newNewRootList.getDescription()); }