TaskAdminPresenter extends AbstractTaskPresenter { public void onTaskSelectionEvent(@Observes final TaskSelectionEvent event) { if (!event.isForLog()) { setSelectedTask(event); refreshTaskPotentialOwners(); } }  @Inject void setTaskService(final Caller<TaskService> taskService); @PostConstruct void init(); IsWidget getView(); void forwardTask(final String entity); void reminder(); void refreshTaskPotentialOwners(); void onTaskSelectionEvent(@Observes final TaskSelectionEvent event); void onTaskRefreshedEvent(@Observes final TaskRefreshedEvent event);  }
@Test public void taskSelectionEventIsForLogTask() { String serverTemplateId = "serverTemplateId"; String containerId = "containerId"; Long taskId = 1L; TaskAssignmentSummary ts = new TaskAssignmentSummary(); ts.setPotOwnersString(Arrays.asList("owner1", "owner2")); when(taskService.getTaskAssignmentDetails(eq(serverTemplateId), eq(containerId), eq(taskId))).thenReturn(ts); boolean isForLog = true; TaskSelectionEvent event = new TaskSelectionEvent(serverTemplateId, containerId, taskId, "task", true, isForLog); presenter.onTaskSelectionEvent(event); verifyNoMoreInteractions(taskService); }
@Test public void taskSelectionEventNotIsForLogTask() { String serverTemplateId = "serverTemplateId"; String containerId = "containerId"; Long taskId = 1L; TaskAssignmentSummary ts = new TaskAssignmentSummary(); ts.setPotOwnersString(Arrays.asList(OTHER_USER, OTHER_USER2)); ts.setActualOwner(CURRENT_USER); ts.setForwardAllowed(true); when(taskService.getTaskAssignmentDetails(eq(serverTemplateId), eq(containerId), eq(taskId))).thenReturn(ts); boolean isForLog = false; TaskSelectionEvent event = new TaskSelectionEvent(serverTemplateId, containerId, taskId, "task", true, isForLog); presenter.onTaskSelectionEvent(event); verify(taskService).getTaskAssignmentDetails(serverTemplateId, containerId, taskId); verify(viewMock).enableForwardButton(true); verify(viewMock).enableUserOrGroupText(true); verify(viewMock).enableReminderButton(true); verify(viewMock).setActualOwnerText(CURRENT_USER); verify(viewMock).setUsersGroupsControlsPanelText(Arrays.asList(OTHER_USER, OTHER_USER2)); }