TaskModel { public void save(Task task) { taskManager.save(task); bus.publish(new TaskSavedEvent(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 testSave() throws Exception { model.save(task1); assertEquals(1, events.size()); assertTrue(events.get(0) instanceof TaskSavedEvent); assertEquals(task1, ((TaskSavedEvent) events.get(0)).getTask()); events.clear(); Task task3 = model.create(client); assertEquals(0, events.size()); model.save(task3); assertTrue(events.get(0) instanceof TaskSavedEvent); assertEquals(task3, ((TaskSavedEvent) events.get(0)).getTask()); events.clear(); }