TaskAdminPresenter extends AbstractTaskPresenter { public void refreshTaskPotentialOwners() { view.enableReminderButton(false); view.enableForwardButton(false); view.enableUserOrGroupText(false); view.setUsersGroupsControlsPanelText(emptyList()); view.clearUserOrGroupText(); view.setActualOwnerText(""); taskService.call((TaskAssignmentSummary ts) -> { if (ts == null) { return; } if (ts.getPotOwnersString() == null || ts.getPotOwnersString().isEmpty()) { view.setUsersGroupsControlsPanelText(singletonList(Constants.INSTANCE.No_Potential_Owners())); } else { view.setUsersGroupsControlsPanelText(ts.getPotOwnersString()); } view.enableForwardButton(ts.isForwardAllowed()); view.enableUserOrGroupText(ts.isForwardAllowed()); if (ts.getActualOwner() == null || ts.getActualOwner().equals("")) { view.enableReminderButton(false); view.setActualOwnerText(Constants.INSTANCE.No_Actual_Owner()); } else { view.enableReminderButton(true); view.setActualOwnerText(ts.getActualOwner()); } } ).getTaskAssignmentDetails(getServerTemplateId(), getContainerId(), getTaskId()); }  @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 testRefreshTaskPotentialOwners() { final String serverTemplateId = "serverTemplateId"; final String containerId = "containerId"; final Long taskId = 1L; final TaskSelectionEvent event = new TaskSelectionEvent(serverTemplateId, containerId, taskId, "task", true, false); final TaskAssignmentSummary summary = new TaskAssignmentSummary(); summary.setForwardAllowed(false); when(taskService.getTaskAssignmentDetails(serverTemplateId, containerId, taskId)).thenReturn(summary); presenter.onTaskSelectionEvent(event); InOrder inOrder = inOrder(viewMock); inOrder.verify(viewMock).enableReminderButton(false); inOrder.verify(viewMock).enableForwardButton(false); inOrder.verify(viewMock).enableUserOrGroupText(false); inOrder.verify(viewMock).setUsersGroupsControlsPanelText(emptyList()); inOrder.verify(viewMock).clearUserOrGroupText(); inOrder.verify(viewMock).setActualOwnerText(""); inOrder.verify(viewMock).setUsersGroupsControlsPanelText(singletonList(Constants.INSTANCE.No_Potential_Owners())); inOrder.verify(viewMock).enableForwardButton(false); inOrder.verify(viewMock).enableUserOrGroupText(false); inOrder.verify(viewMock).enableReminderButton(false); inOrder.verify(viewMock).setActualOwnerText(Constants.INSTANCE.No_Actual_Owner()); }