TaskModel { public void delete(Task task) { if (taskManager.delete(task)) { if (task.equals(selectedTask)) { selectTask(null); } bus.publish(new TaskDeletedEvent(task)); } } TaskModel(ClientModel clientModel, TaskManager taskManager); @Handler void selectedClientChanged(SelectedClientChangedEvent event); void subscribe(Object listener); void unsubscribe(Object listener); Task getSelectedTask(); void selectTask(Task newTask); Task create(Client client); int count(); int countUnfinished(); Task get(int index); List<Task> getForClient(Client client, boolean unfinishedOnly); void save(Task task); void delete(Task task); Task getWorkingTask(); void startWork(Task task); void stopWork();  }
@Test public void testDelete() throws Exception { model.delete(task1); assertEquals(1, events.size()); assertTrue(events.get(0) instanceof TaskDeletedEvent); assertEquals(task1, ((TaskDeletedEvent) events.get(0)).getTask()); events.clear(); assertEquals(1, taskManager.tasks.size()); assertFalse(taskManager.tasks.contains(task1)); model.delete(task1); assertEquals(0, events.size()); }