CaseRolesPresenter extends AbstractCaseInstancePresenter<CaseRolesPresenter.CaseRolesView> { public void storeRoleAssignments(final CaseRoleAssignmentSummary currentRoleAssignments, List<String> users, List<String> groups) { final String roleName = currentRoleAssignments.getName(); List<String> prevUserAssignments = currentRoleAssignments.getUsers(); List<String> prevGroupsAssignments = currentRoleAssignments.getGroups(); List<String> newUserAssignments = users.stream().distinct().collect(toList()); List<String> newGroupsAssignments = groups.stream().distinct().collect(toList()); currentRoleAssignments.setUsers(new ArrayList<>(newUserAssignments)); currentRoleAssignments.setGroups(new ArrayList<>(newGroupsAssignments)); filterCaseRoles(); List<String> usersToRemove = new ArrayList<>(prevUserAssignments); usersToRemove.removeAll(newUserAssignments); usersToRemove.forEach( user -> caseService.call().removeUserFromRole(containerId, caseId, roleName, user)); newUserAssignments.removeAll(prevUserAssignments); newUserAssignments.forEach( user -> caseService.call().assignUserToRole(containerId, caseId, roleName, user)); List<String> groupsToRemove = new ArrayList<>(prevGroupsAssignments); groupsToRemove.removeAll(newGroupsAssignments); groupsToRemove.forEach( group -> caseService.call().removeGroupFromRole(containerId, caseId, roleName, group)); newGroupsAssignments.removeAll(prevGroupsAssignments); newGroupsAssignments.forEach( group -> caseService.call().assignGroupToRole(containerId, caseId, roleName, group)); }  @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 testStoreRoleAssignments_noChangesInRoleAssignments() { CaseRoleAssignmentSummary cras = CaseRoleAssignmentSummary.builder() .name(CASE_ROLE) .users(singletonList(USER)) .groups(singletonList(GROUP)).build(); when(view.getFilterValue()).thenReturn("All"); presenter.storeRoleAssignments(cras, new ArrayList<>(Arrays.asList(USER)), new ArrayList<>(Arrays.asList(GROUP))); verifyStoreRoleAssignmentsCalls(0, 0, 0, 0); }