TodoListManager { public final void deleteTodo(long id) { todoItems.remove(id); } @Inject  TodoListManager(ActionBus actionBus, DataBus dataBus); void onPause(); @Subscribe void reactToTodoAction(TodoAction action); @Produce RawTodoList produceTodoList(); final void addTodo(String description); final void toggleTodoComplete(long id); final void toggleAllTodosComplete(); final void editTodo(long id, String description); final void deleteTodo(long id); final void deleteAllCompleteTodos(); final void undoDeleteCompleteAllTodos();  }
@Test(timeout = 100) public void deleteTodoTest() throws InterruptedException { final AtomicBoolean testDone = new AtomicBoolean(false); final AtomicLong deletedId = new AtomicLong(-1); final ArrayList<TodoItem> todoItems = new ArrayList<TodoItem>(); createTodos(3); dataBus.register(new Object() { @Subscribe public void onListUpdated(RawTodoList rawTodoList) { todoItems.clear(); todoItems.addAll(rawTodoList.list); if (todoItems.size() == 3) { deletedId.set(todoItems.get(1).getId()); DataBundle<TodoAction.DataKeys> bundle = new DataBundle<>(); bundle.put(TodoAction.DataKeys.ID, todoItems.get(1).getId()); actionBus.post(new TodoAction(TodoAction.ActionTypes.DELETE, bundle)); } else { assertThat(todoItems.size()).isEqualTo(2); assertThat(todoItems.get(0).getId()).isNotEqualTo(deletedId.get()); assertThat(todoItems.get(1).getId()).isNotEqualTo(deletedId.get()); testDone.set(true); } } }); while (!testDone.get()) ; }