WFClient { public void deleteList(WFList toDelete) throws IOException { checkLoggedIn(); long time = getClientTimeInSeconds(); Long prevLm = toDelete.lm; PushPoll.Operation deleteOp; synchronized (this) { toDelete.lm = time; List<WFList> toDeleteFrom = null; if (isRootList(toDelete)) { toDeleteFrom = session.rootLists; } else { WFList parent = getParentList(toDelete); if (parent != null) { toDeleteFrom = parent.ch; } } if (toDeleteFrom != null) { toDeleteFrom.remove(Utils.getIndexOfListWithId(toDeleteFrom, toDelete)); } deleteOp = PushPoll.buildDeleteOp(toDelete.id, prevLm, time); } executePushPoll(ImmutableList.of(deleteOp)); } 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 testDeleteList() throws IOException { String rootName = "root_" + UUID.randomUUID().toString(); WFList root = client.createRootList(0, rootName, null); WFList child = client.createList(root, 0, "child_" + rootName, null); assertTrue(root.getChildren().contains(child)); client.deleteList(child); assertFalse(root.getChildren().contains(child)); client.refresh(); root = client.getRootLists().get(0); assertNull(root.getChildren()); }