TaskAssignmentsPresenter extends AbstractTaskPresenter { public void delegateTask(String entity) { if (entity == null || "".equals(entity.trim())) { view.setHelpText(constants.PleaseEnterUserIdToPerformDelegation()); return; } taskService.call( new RemoteCallback<Void>() { @Override public void callback(Void nothing) { view.displayNotification(constants.TaskWithIdWasDelegated(String.valueOf(getTaskId()), entity)); view.setDelegateButtonActive(false); view.setHelpText(constants.TaskWithIdWasDelegated(String.valueOf(getTaskId()), entity)); taskRefreshed.fire(new TaskRefreshedEvent(getServerTemplateId(), getContainerId(), getTaskId())); refreshTaskPotentialOwners(); } }, new DefaultErrorCallback() { @Override public boolean error(Message message, Throwable throwable) { view.setDelegateButtonActive(true); view.setHelpText(constants.DelegationUnable()); view.displayNotification(constants.UnableToPerformReassignment(entity, throwable.getMessage())); return super.error(message, throwable); } } ).delegate(getServerTemplateId(), getContainerId(), getTaskId(), entity); } @Inject  TaskAssignmentsPresenter(TaskAssignmentsView view,
                                    Caller<TaskService> taskService,
                                    Event<TaskRefreshedEvent> taskRefreshed); @PostConstruct void init(); IsWidget getView(); void delegateTask(String entity); void refreshTaskPotentialOwners(); void onTaskSelectionEvent(@Observes final TaskSelectionEvent event); void onTaskRefreshedEvent(@Observes final TaskRefreshedEvent event);  }
@Test public void emptyDelegationUserOrGroup_notAccepted() { presenter.delegateTask(""); verify(viewMock).setHelpText(Constants.INSTANCE.PleaseEnterUserIdToPerformDelegation()); verify(taskService, never()) .delegate(anyString(), anyString(), anyLong(), anyString()); }
@Test public void nullDelegationUserOrGroup_notAccepted() { presenter.delegateTask(null); verify(viewMock).setHelpText(Constants.INSTANCE.PleaseEnterUserIdToPerformDelegation()); verify(taskService, never()) .delegate(anyString(), anyString(), anyLong(), anyString()); }