@Test public void testUsingAll() throws Exception { final List<Promise<Boolean>> promises = new ArrayList<>(3); final CountDownLatch latch = new CountDownLatch(1); final AtomicBoolean success = new AtomicBoolean(); final Todo todo = new Todo("write", "Write tutorial", timer.time()); final Promise<Boolean> promise = client.add(todo); promises.add(promise); promises.add(client.add(new Todo("callMom", "Call Mom", timer.time()))); promises.add(client.add(new Todo("callSis", "Call Sister", timer.time()))); Promises.all(promises).then(done -> { success.set(true); latch.countDown(); }).catchError(e-> { success.set(false); latch.countDown(); }); promises.forEach(Promise::invoke); latch.await(); assertTrue(success.get()); }
public void add(final Callback<Boolean> callback, final Todo todo) { todoMap.put(todo.getId(), todo); callback.resolve(true); }
TodoManagerImpl { public void add(final Callback<Boolean> callback, final Todo todo) { todoMap.put(todo.getId(), todo); callback.resolve(true); } }
TodoManagerImpl { public void add(final Callback<Boolean> callback, final Todo todo) { todoMap.put(todo.getId(), todo); callback.resolve(true); } TodoManagerImpl(); }
TodoManagerImpl { public void add(final Callback<Boolean> callback, final Todo todo) { todoMap.put(todo.getId(), todo); callback.resolve(true); } TodoManagerImpl(); void add(final Callback<Boolean> callback, final Todo todo); void remove(final Callback<Boolean> callback, final String id); void list(final Callback<ArrayList<Todo>> callback); }
TodoManagerImpl { public void add(final Callback<Boolean> callback, final Todo todo) { todoMap.put(todo.getId(), todo); callback.resolve(true); } TodoManagerImpl(); void add(final Callback<Boolean> callback, final Todo todo); void remove(final Callback<Boolean> callback, final String id); void list(final Callback<ArrayList<Todo>> callback);  }