CaseRolesPresenter extends AbstractCaseInstancePresenter<CaseRolesPresenter.CaseRolesView> { void assignToRole(final CaseRoleItemView caseRole, final CaseRoleAssignmentSummary newRoleAssignments) { if (!newRoleAssignments.hasAssignment()) { caseRole.showErrorState(); caseRole.showAssignmentErrors(singletonList(translationService.format(PLEASE_INTRO_USER_OR_GROUP_TO_CREATE_ASSIGNMENT))); return; } List<String> caseRoleAssignmentErrors = caseRolesValidations.validateRolesAssignments(caseDefinition, singletonList(newRoleAssignments)); if (!caseRoleAssignmentErrors.isEmpty()) { caseRole.showAssignmentErrors(caseRoleAssignmentErrors); } else { caseRole.hideEditRoleAssignmentDialog(); final CaseRoleAssignmentSummary currentRoleAssignments = caseRole.getValue(); storeRoleAssignments(currentRoleAssignments, newRoleAssignments.getUsers(), newRoleAssignments.getGroups()); } }  @WorkbenchPartTitle String getTittle(); void filterCaseRoles(); void setCaseRoleActions(CaseRoleItemView caseRole); void setCaseRoleAssignments(CaseRoleItemView caseRole,
                                       final int assignmentsListMaxWidth); void storeRoleAssignments(final CaseRoleAssignmentSummary currentRoleAssignments,
                                     List<String> users,
                                     List<String> groups); static final String SCREEN_ID; static final String CASE_OWNER_ROLE; }
@Test public void testAssignToRole_noAssignmentsProvided() { final CaseRoleAssignmentSummary newRoleAssignments = CaseRoleAssignmentSummary.builder() .name(CASE_ROLE) .build(); presenter.assignToRole(caseRole, newRoleAssignments); verify(caseRole).showErrorState(); final ArgumentCaptor<List> errorList = ArgumentCaptor.forClass(List.class); verify(caseRole).showAssignmentErrors(errorList.capture()); final int errorsNumber = 1; assertEquals(errorsNumber, errorList.getValue().size()); assertEquals(PLEASE_INTRO_USER_OR_GROUP_TO_CREATE_ASSIGNMENT, errorList.getValue().get(0)); }
@Test public void testAssignToRole_providedAssignmentsInvalid() { final CaseRoleAssignmentSummary newRoleAssignments = CaseRoleAssignmentSummary.builder() .name(CASE_ROLE) .users(singletonList(USER)) .build(); final String error = "testError"; when(caseRolesValidations.validateRolesAssignments(caseDefinition, singletonList(newRoleAssignments))).thenReturn(singletonList(error)); presenter.assignToRole(caseRole, newRoleAssignments); final ArgumentCaptor<List> caseRoleAssignmentErrors = ArgumentCaptor.forClass(List.class); verify(caseRole).showAssignmentErrors(caseRoleAssignmentErrors.capture()); final int errorsNumber = 1; assertEquals(errorsNumber, caseRoleAssignmentErrors.getValue().size()); assertEquals(error, caseRoleAssignmentErrors.getValue().get(0)); verify(caseRole, never()).hideEditRoleAssignmentDialog(); }