TaskDetailsPresenter extends AbstractTaskPresenter { public void onTaskSelectionEvent(@Observes final TaskSelectionEvent event) { setSelectedTask(event); if (event.isForLog()) { setReadOnlyTaskDetail(); } setTaskDetails(translationService.format(event.getStatus()), event.getDescription(), event.getActualOwner(), event.getExpirationTime(), String.valueOf(event.getPriority()), event.getProcessInstanceId(), event.getProcessId(), event.getSlaCompliance()); } @Inject  TaskDetailsPresenter(TaskDetailsView view,
                                Caller<TaskService> taskService,
                                Event<TaskRefreshedEvent> taskRefreshed); @PostConstruct void init(); IsWidget getView(); void updateTask(final String taskDescription,
                           final Date dueDate,
                           final int priority); void setReadOnlyTaskDetail(); void onTaskSelectionEvent(@Observes final TaskSelectionEvent event); void onTaskRefreshedEvent(@Observes final TaskRefreshedEvent event); @Inject void setTranslationService(TranslationService translationService);  }
@Test public void testSetTaskDetails_isForLog() { when(translationService.format(any())).thenReturn("Completed"); boolean isForLog = true; String status = "Completed"; String description = "description"; String actualOwner = "Owner"; Date expirationTime = new Date(); int priority = 2; TaskSelectionEvent event = createTestTaskSelectionEvent(isForLog, status, description, actualOwner, expirationTime, priority, 1); presenter.onTaskSelectionEvent(event); verify(viewMock).setSelectedDate(expirationTime); verifySetTaskDetails(actualOwner, status, String.valueOf(priority)); verifyReadOnlyMode(1); }
@Test public void testSetTaskDetails_statusReady() { when(translationService.format(any())).thenReturn("Completed"); boolean isForLog = false; String status = "Completed"; String description = "description"; String actualOwner = "Owner"; Date expirationTime = new Date(); int priority = 2; TaskSelectionEvent event = createTestTaskSelectionEvent(isForLog, status, description, actualOwner, expirationTime, priority, 1); presenter.onTaskSelectionEvent(event); verify(viewMock).setSelectedDate(expirationTime); verifySetTaskDetails(actualOwner, status, String.valueOf(priority)); verifyReadOnlyMode(0); }
@Test public void testSetTaskDetailsWithWorkItemIdOnSelectionEvent() { when(translationService.format(any())).thenReturn("Completed"); boolean isForLog = false; String status = "Completed"; String description = "description"; String actualOwner = "Owner"; Date expirationTime = new Date(); int priority = 2; Integer slaCompliance = 1; TaskSelectionEvent event = createTestTaskSelectionEvent(isForLog, status, description, actualOwner, expirationTime, priority, slaCompliance); presenter.onTaskSelectionEvent(event); verify(viewMock).setSelectedDate(expirationTime); verifySetTaskDetails(actualOwner, status, String.valueOf(priority)); verify(viewMock).setSlaCompliance(slaCompliance); }