@Test public void testSelectTask() throws Exception { assertNull(model.getSelectedTask()); model.selectTask(task1); assertEquals(task1, model.getSelectedTask()); assertEquals(1, events.size()); assertTrue(events.get(0) instanceof SelectedTaskChangedEvent); assertNull(((SelectedTaskChangedEvent) events.get(0)).getOldTask()); assertEquals(task1, ((SelectedTaskChangedEvent) events.get(0)).getNewTask()); events.clear(); model.selectTask(task1); assertEquals(task1, model.getSelectedTask()); assertEquals(0, events.size()); events.clear(); model.selectTask(task2); assertEquals(task2, model.getSelectedTask()); assertEquals(1, events.size()); assertTrue(events.get(0) instanceof SelectedTaskChangedEvent); assertEquals(task1, ((SelectedTaskChangedEvent) events.get(0)).getOldTask()); assertEquals(task2, ((SelectedTaskChangedEvent) events.get(0)).getNewTask()); events.clear(); model.selectTask(null); assertNull(model.getSelectedTask()); assertEquals(1, events.size()); assertTrue(events.get(0) instanceof SelectedTaskChangedEvent); assertEquals(task2, ((SelectedTaskChangedEvent) events.get(0)).getOldTask()); assertNull(((SelectedTaskChangedEvent) events.get(0)).getNewTask()); events.clear(); model.selectTask(null); assertNull(model.getSelectedTask()); assertEquals(0, events.size()); events.clear(); }
public void selectTask(Task newTask) { Task oldTask = this.selectedTask; this.selectedTask = newTask; if (!Objects.equals(oldTask, newTask)) { bus.publish(new SelectedTaskChangedEvent(oldTask, newTask)); } }
TaskModel { public void selectTask(Task newTask) { Task oldTask = this.selectedTask; this.selectedTask = newTask; if (!Objects.equals(oldTask, newTask)) { bus.publish(new SelectedTaskChangedEvent(oldTask, newTask)); } } }
TaskModel { public void selectTask(Task newTask) { Task oldTask = this.selectedTask; this.selectedTask = newTask; if (!Objects.equals(oldTask, newTask)) { bus.publish(new SelectedTaskChangedEvent(oldTask, newTask)); } } TaskModel(ClientModel clientModel, TaskManager taskManager); }
TaskModel { public void selectTask(Task newTask) { Task oldTask = this.selectedTask; this.selectedTask = newTask; if (!Objects.equals(oldTask, newTask)) { bus.publish(new SelectedTaskChangedEvent(oldTask, newTask)); } } 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(); }
TaskModel { public void selectTask(Task newTask) { Task oldTask = this.selectedTask; this.selectedTask = newTask; if (!Objects.equals(oldTask, newTask)) { bus.publish(new SelectedTaskChangedEvent(oldTask, newTask)); } } 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();  }