@Test public void testValidateRolesAssignments_roleCardinalityReached() { final Map<String, Integer> role = Collections.singletonMap("test", 1); final CaseDefinitionSummary cds = CaseDefinitionSummary.builder().roles(role).build(); final List<CaseRoleAssignmentSummary> roles = singletonList(CaseRoleAssignmentSummary.builder().name("test").users(singletonList("user1")).build()); final List<String> errors = caseRolesValidations.validateRolesAssignments(cds, roles); verify(translationService, never()).format(anyString(), anyString(), anyInt()); assertThat(errors).isEmpty(); }
public List<String> validateRolesAssignments(final CaseDefinitionSummary caseDefinition, final List<CaseRoleAssignmentSummary> assignments) { final List<String> errors = new ArrayList<>(); assignments.forEach(a -> { final Integer roleCardinality = caseDefinition.getRoles().get(a.getName()); if (roleCardinality == -1) { return; } final Integer roleAssignments = a.getUsers().size() + a.getGroups().size(); if (roleAssignments > roleCardinality) { errors.add(translationService.format(INVALID_ROLE_ASSIGNMENT, a.getName(), roleCardinality)); } }); return errors; }
CaseRolesValidations { public List<String> validateRolesAssignments(final CaseDefinitionSummary caseDefinition, final List<CaseRoleAssignmentSummary> assignments) { final List<String> errors = new ArrayList<>(); assignments.forEach(a -> { final Integer roleCardinality = caseDefinition.getRoles().get(a.getName()); if (roleCardinality == -1) { return; } final Integer roleAssignments = a.getUsers().size() + a.getGroups().size(); if (roleAssignments > roleCardinality) { errors.add(translationService.format(INVALID_ROLE_ASSIGNMENT, a.getName(), roleCardinality)); } }); return errors; } }
CaseRolesValidations { public List<String> validateRolesAssignments(final CaseDefinitionSummary caseDefinition, final List<CaseRoleAssignmentSummary> assignments) { final List<String> errors = new ArrayList<>(); assignments.forEach(a -> { final Integer roleCardinality = caseDefinition.getRoles().get(a.getName()); if (roleCardinality == -1) { return; } final Integer roleAssignments = a.getUsers().size() + a.getGroups().size(); if (roleAssignments > roleCardinality) { errors.add(translationService.format(INVALID_ROLE_ASSIGNMENT, a.getName(), roleCardinality)); } }); return errors; }  }
CaseRolesValidations { public List<String> validateRolesAssignments(final CaseDefinitionSummary caseDefinition, final List<CaseRoleAssignmentSummary> assignments) { final List<String> errors = new ArrayList<>(); assignments.forEach(a -> { final Integer roleCardinality = caseDefinition.getRoles().get(a.getName()); if (roleCardinality == -1) { return; } final Integer roleAssignments = a.getUsers().size() + a.getGroups().size(); if (roleAssignments > roleCardinality) { errors.add(translationService.format(INVALID_ROLE_ASSIGNMENT, a.getName(), roleCardinality)); } }); return errors; }  List<String> validateRolesAssignments(final CaseDefinitionSummary caseDefinition,
                                                 final List<CaseRoleAssignmentSummary> assignments); }
CaseRolesValidations { public List<String> validateRolesAssignments(final CaseDefinitionSummary caseDefinition, final List<CaseRoleAssignmentSummary> assignments) { final List<String> errors = new ArrayList<>(); assignments.forEach(a -> { final Integer roleCardinality = caseDefinition.getRoles().get(a.getName()); if (roleCardinality == -1) { return; } final Integer roleAssignments = a.getUsers().size() + a.getGroups().size(); if (roleAssignments > roleCardinality) { errors.add(translationService.format(INVALID_ROLE_ASSIGNMENT, a.getName(), roleCardinality)); } }); return errors; }  List<String> validateRolesAssignments(final CaseDefinitionSummary caseDefinition,
                                                 final List<CaseRoleAssignmentSummary> assignments);  }