@Test public void testGetWorkingTask() throws Exception { assertNull(model.getWorkingTask()); model.startWork(task1); assertTrue(events.get(0) instanceof WorkStartedEvent); assertEquals(task1, ((WorkStartedEvent) events.get(0)).getTask()); assertEquals(task1, model.getWorkingTask()); assertNotNull(model.getWorkingTask()); assertNotNull(task1.getWorkStartTime()); long start1 = 30 * 1000; long end1 = start1 + 5 * 1000; task1.setWorkStartTime(new Date(start1)); model.stopWork(end1); assertTrue(events.get(1) instanceof WorkStoppedEvent); assertEquals(task1, ((WorkStoppedEvent) events.get(1)).getTask()); assertNull(model.getWorkingTask()); assertNull(task1.getWorkStartTime()); assertEquals(5, task1.getSecondsWorked()); assertEquals(1, task1.getWorkUnits().size()); assertEquals(start1, task1.getWorkUnits().get(0).getStartTime().getTime()); assertEquals(end1, task1.getWorkUnits().get(0).getEndTime().getTime()); model.startWork(task1); assertEquals(task1, model.getWorkingTask()); assertNotNull(model.getWorkingTask()); assertNotNull(task1.getWorkStartTime()); long start2 = 45 * 1000; long end2 = start2 + 10 * 1000; task1.setWorkStartTime(new Date(start2)); model.stopWork(end2); assertNull(model.getWorkingTask()); assertNull(task1.getWorkStartTime()); assertEquals(15, task1.getSecondsWorked()); assertEquals(2, task1.getWorkUnits().size()); assertEquals(start1, task1.getWorkUnits().get(0).getStartTime().getTime()); assertEquals(end1, task1.getWorkUnits().get(0).getEndTime().getTime()); assertEquals(start2, task1.getWorkUnits().get(1).getStartTime().getTime()); assertEquals(end2, task1.getWorkUnits().get(1).getEndTime().getTime()); }
public Task getWorkingTask() { for (int i = 0; i < count(); i++) { Task task = get(i); if (task.getWorkStartTime() != null) { return task; } } return null; }
TaskModel { public Task getWorkingTask() { for (int i = 0; i < count(); i++) { Task task = get(i); if (task.getWorkStartTime() != null) { return task; } } return null; } }
TaskModel { public Task getWorkingTask() { for (int i = 0; i < count(); i++) { Task task = get(i); if (task.getWorkStartTime() != null) { return task; } } return null; } TaskModel(ClientModel clientModel, TaskManager taskManager); }
TaskModel { public Task getWorkingTask() { for (int i = 0; i < count(); i++) { Task task = get(i); if (task.getWorkStartTime() != null) { return task; } } return null; } 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 Task getWorkingTask() { for (int i = 0; i < count(); i++) { Task task = get(i); if (task.getWorkStartTime() != null) { return task; } } return null; } 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();  }