Search in sources :

Example 6 with IdmRequestIdentityRoleDto

use of eu.bcvsolutions.idm.core.api.dto.IdmRequestIdentityRoleDto in project CzechIdMng by bcvsolutions.

the class IdmRequestIdentityRoleServiceIntegrationTest method testAssignRoles.

@Test
@Transactional
public void testAssignRoles() {
    IdmIdentityDto identity = this.getHelper().createIdentity(new GuardedString());
    IdmIdentityContractDto contract = this.getHelper().getPrimeContract(identity);
    IdmRoleDto role = this.getHelper().createRole();
    IdmRoleDto roleTwo = this.getHelper().createRole();
    IdmRoleDto roleThree = this.getHelper().createRole();
    Set<UUID> roles = Sets.newSet(role.getId(), roleTwo.getId(), roleThree.getId());
    // Create request for new identity-role
    IdmRequestIdentityRoleDto dto = new IdmRequestIdentityRoleDto();
    dto.setIdentityContract(contract.getId());
    dto.setRole(role.getId());
    dto.setRoles(Sets.newSet(roleTwo.getId(), roleThree.getId()));
    dto.setValidFrom(LocalDate.now().minusDays(1));
    dto.setValidTill(LocalDate.now().plusDays(10));
    IdmRequestIdentityRoleDto createdRequestIdentityRole = requestIdentityRoleService.save(dto);
    Assert.assertNotNull(createdRequestIdentityRole);
    // Request must been created
    Assert.assertNotNull(createdRequestIdentityRole.getRoleRequest());
    Assert.assertEquals(contract.getId(), createdRequestIdentityRole.getIdentityContract());
    IdmRoleRequestDto request = roleRequestService.get(createdRequestIdentityRole.getRoleRequest());
    Assert.assertNotNull(request);
    // Concepts are empty, because the request does not return them be default
    Assert.assertEquals(0, request.getConceptRoles().size());
    request = roleRequestService.get(createdRequestIdentityRole.getRoleRequest(), new IdmRoleRequestFilter(true));
    Assert.assertNotNull(request);
    // Concepts are not empty now
    Assert.assertEquals(3, request.getConceptRoles().size());
    // Applicant must be ours identity
    Assert.assertEquals(contract.getIdentity(), request.getApplicant());
    request.getConceptRoles().forEach(concept -> {
        Assert.assertEquals(contract.getId(), concept.getIdentityContract());
        Assert.assertTrue(roles.contains(concept.getRole()));
        Assert.assertEquals(createdRequestIdentityRole.getValidFrom(), concept.getValidFrom());
        Assert.assertEquals(createdRequestIdentityRole.getValidTill(), concept.getValidTill());
    });
    this.getHelper().executeRequest(request, false, true);
    List<IdmIdentityRoleDto> identityRoles = identityRoleService.findAllByContract(contract.getId());
    Assert.assertEquals(3, identityRoles.size());
    identityRoles.forEach(identityRole -> {
        Assert.assertTrue(roles.contains(identityRole.getRole()));
        Assert.assertEquals(createdRequestIdentityRole.getValidFrom(), identityRole.getValidFrom());
        Assert.assertEquals(createdRequestIdentityRole.getValidTill(), identityRole.getValidTill());
    });
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRequestIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRequestIdentityRoleDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmRoleRequestFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleRequestFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) UUID(java.util.UUID) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) IdmRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with IdmRequestIdentityRoleDto

use of eu.bcvsolutions.idm.core.api.dto.IdmRequestIdentityRoleDto in project CzechIdMng by bcvsolutions.

the class IdmRequestIdentityRoleServiceIntegrationTest method testUpdateAddingConcept.

@Test
@Transactional
public void testUpdateAddingConcept() {
    IdmIdentityDto identity = this.getHelper().createIdentity(new GuardedString());
    IdmIdentityContractDto contract = this.getHelper().getPrimeContract(identity);
    IdmRoleDto role = this.getHelper().createRole();
    // Create request for new identity-role
    IdmRequestIdentityRoleDto dto = new IdmRequestIdentityRoleDto();
    dto.setIdentityContract(contract.getId());
    dto.setRole(role.getId());
    IdmRequestIdentityRoleDto createdRequestIdentityRole = requestIdentityRoleService.save(dto);
    // We want to update created concept -> update validity
    createdRequestIdentityRole.setValidFrom(LocalDate.now().minusDays(1));
    createdRequestIdentityRole.setValidTill(LocalDate.now().plusDays(10));
    createdRequestIdentityRole = requestIdentityRoleService.save(createdRequestIdentityRole);
    Assert.assertNotNull(createdRequestIdentityRole);
    // Request must been created
    Assert.assertNotNull(createdRequestIdentityRole.getRoleRequest());
    Assert.assertEquals(role.getId(), createdRequestIdentityRole.getRole());
    Assert.assertEquals(contract.getId(), createdRequestIdentityRole.getIdentityContract());
    IdmRoleRequestDto request = roleRequestService.get(createdRequestIdentityRole.getRoleRequest(), new IdmRoleRequestFilter(true));
    Assert.assertNotNull(request);
    // Concepts are not empty now
    Assert.assertEquals(1, request.getConceptRoles().size());
    // Applicant must be ours identity
    Assert.assertEquals(contract.getIdentity(), request.getApplicant());
    IdmConceptRoleRequestDto concept = request.getConceptRoles().get(0);
    Assert.assertEquals(contract.getId(), concept.getIdentityContract());
    Assert.assertEquals(role.getId(), concept.getRole());
    Assert.assertEquals(createdRequestIdentityRole.getValidFrom(), concept.getValidFrom());
    Assert.assertEquals(createdRequestIdentityRole.getValidTill(), concept.getValidTill());
    Assert.assertEquals(ConceptRoleRequestOperation.ADD, concept.getOperation());
    this.getHelper().executeRequest(request, false, true);
    List<IdmIdentityRoleDto> identityRoles = identityRoleService.findAllByContract(contract.getId());
    Assert.assertEquals(1, identityRoles.size());
    Assert.assertEquals(role.getId(), identityRoles.get(0).getRole());
    Assert.assertEquals(LocalDate.now().minusDays(1), identityRoles.get(0).getValidFrom());
    Assert.assertEquals(LocalDate.now().plusDays(10), identityRoles.get(0).getValidTill());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRequestIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRequestIdentityRoleDto) IdmConceptRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmRoleRequestFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleRequestFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) IdmRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 8 with IdmRequestIdentityRoleDto

use of eu.bcvsolutions.idm.core.api.dto.IdmRequestIdentityRoleDto in project CzechIdMng by bcvsolutions.

the class IdmRequestIdentityRoleServiceIntegrationTest method testFind.

@Test
@Transactional
public void testFind() {
    IdmIdentityDto identity = this.getHelper().createIdentity(new GuardedString());
    IdmIdentityContractDto contract = this.getHelper().getPrimeContract(identity);
    IdmRoleDto assignedRole = this.getHelper().createRole();
    IdmIdentityRoleDto identityRole = this.getHelper().createIdentityRole(contract, assignedRole);
    IdmRoleDto role = this.getHelper().createRole();
    IdmRequestIdentityRoleFilter filter = new IdmRequestIdentityRoleFilter();
    filter.setIdentityId(identity.getId());
    // We expecting only one already assigned identity-role
    List<IdmRequestIdentityRoleDto> requestIdentityRoles = requestIdentityRoleService.find(filter, null).getContent();
    Assert.assertEquals(1, requestIdentityRoles.size());
    Assert.assertEquals(identityRole.getId(), requestIdentityRoles.get(0).getId());
    // Create request for new identity-role
    IdmRequestIdentityRoleDto dto = new IdmRequestIdentityRoleDto();
    dto.setIdentityContract(contract.getId());
    dto.setRole(role.getId());
    dto.setValidFrom(LocalDate.now().minusDays(1));
    dto.setValidTill(LocalDate.now().plusDays(10));
    IdmRequestIdentityRoleDto createdRequestIdentityRole = requestIdentityRoleService.save(dto);
    Assert.assertNotNull(createdRequestIdentityRole);
    // Request must been created
    Assert.assertNotNull(createdRequestIdentityRole.getRoleRequest());
    // Filter will be filtering by this request
    filter.setRoleRequestId(createdRequestIdentityRole.getRoleRequest());
    // We expecting two items, one assigned identity-role and one adding concept
    requestIdentityRoles = requestIdentityRoleService.find(filter, null).getContent();
    Assert.assertEquals(2, requestIdentityRoles.size());
    IdmRequestIdentityRoleDto addingConcept = requestIdentityRoles.stream().filter(requestIdentityRole -> ConceptRoleRequestOperation.ADD == requestIdentityRole.getOperation()).findFirst().orElse(null);
    Assert.assertNotNull(addingConcept);
    Assert.assertEquals(createdRequestIdentityRole.getRoleRequest(), addingConcept.getRoleRequest());
    Assert.assertEquals(role.getId(), addingConcept.getRole());
    Assert.assertEquals(dto.getValidFrom(), addingConcept.getValidFrom());
    Assert.assertEquals(dto.getValidTill(), addingConcept.getValidTill());
    // Create request for remove identity-role
    IdmRequestIdentityRoleDto dtoForRemove = new IdmRequestIdentityRoleDto();
    dtoForRemove.setRoleRequest(createdRequestIdentityRole.getRoleRequest());
    dtoForRemove.setIdentityRole(identityRole.getId());
    dtoForRemove.setId(identityRole.getId());
    // Remove existing identity-role -> new removing concept
    IdmRequestIdentityRoleDto deleteRequestIdentityRole = requestIdentityRoleService.deleteRequestIdentityRole(dtoForRemove);
    Assert.assertEquals(createdRequestIdentityRole.getRoleRequest(), deleteRequestIdentityRole.getRoleRequest());
    // We expecting two items, one adding concept and one removing concept
    requestIdentityRoles = requestIdentityRoleService.find(filter, null).getContent();
    Assert.assertEquals(2, requestIdentityRoles.size());
    IdmRequestIdentityRoleDto removingConcept = requestIdentityRoles.stream().filter(requestIdentityRole -> ConceptRoleRequestOperation.REMOVE == requestIdentityRole.getOperation()).findFirst().orElse(null);
    Assert.assertNotNull(removingConcept);
    Assert.assertEquals(createdRequestIdentityRole.getRoleRequest(), removingConcept.getRoleRequest());
    Assert.assertEquals(identityRole.getId(), removingConcept.getIdentityRole());
    Assert.assertNotEquals(removingConcept.getId(), removingConcept.getIdentityRole());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRequestIdentityRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRequestIdentityRoleFilter) IdmRequestIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRequestIdentityRoleDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 9 with IdmRequestIdentityRoleDto

use of eu.bcvsolutions.idm.core.api.dto.IdmRequestIdentityRoleDto in project CzechIdMng by bcvsolutions.

the class DefaultIdmRoleRequestServiceIntegrationTest method testClearIdOfAttributeValue.

@Test
public /**
 * If EAV value of concept is send with ID (from FE), then have to be cleared for new concept!
 */
void testClearIdOfAttributeValue() {
    IdmIdentityDto identity = getHelper().createIdentity((GuardedString) null);
    IdmIdentityContractDto identityContact = getHelper().createContract(identity);
    IdmRoleDto role = createRoleWithAttributes(true);
    IdmFormDefinitionDto definition = formService.getDefinition(role.getIdentityRoleAttributeDefinition());
    IdmFormAttributeDto ipAttributeDto = // 
    definition.getFormAttributes().stream().filter(// 
    attribute -> IP.equals(attribute.getCode())).findFirst().get();
    // 
    // Add value
    String valueOne = getHelper().createName();
    IdmFormValueDto formValue = new IdmFormValueDto(ipAttributeDto);
    // Set ID = simulation sending ID from FE.
    formValue.setId(UUID.randomUUID());
    formValue.setStringValue(valueOne);
    formValue.setPersistentType(PersistentType.TEXT);
    formValue.setFormAttribute(ipAttributeDto.getId());
    IdmFormInstanceDto formInstance = new IdmFormInstanceDto();
    formInstance.setFormDefinition(definition);
    formInstance.getValues().add(formValue);
    // Create requestTwo
    IdmRoleRequestDto request = new IdmRoleRequestDto();
    request.setApplicant(identity.getId());
    request.setRequestedByType(RoleRequestedByType.MANUALLY);
    request.setExecuteImmediately(true);
    request = roleRequestService.save(request);
    // Create concept
    IdmConceptRoleRequestDto conceptRole = new IdmConceptRoleRequestDto();
    conceptRole.setIdentityContract(identityContact.getId());
    conceptRole.setRole(role.getId());
    conceptRole.setOperation(ConceptRoleRequestOperation.ADD);
    conceptRole.setRoleRequest(request.getId());
    conceptRole.getEavs().add(formInstance);
    conceptRole = conceptRoleRequestService.save(conceptRole);
    // Start requestOne
    Map<String, Serializable> variables = new HashMap<>();
    variables.put(RoleRequestApprovalProcessor.CHECK_RIGHT_PROPERTY, Boolean.FALSE);
    RoleRequestEvent event = new RoleRequestEvent(RoleRequestEventType.EXCECUTE, request, variables);
    event.setPriority(PriorityType.HIGH);
    // 
    request = roleRequestService.startRequest(event);
    IdmRoleRequestDto roleRequestDtoOne = roleRequestService.get(request);
    assertEquals(RoleRequestState.EXECUTED, roleRequestDtoOne.getState());
    conceptRole = conceptRoleRequestService.get(conceptRole.getId());
    assertEquals(RoleRequestState.EXECUTED, conceptRole.getState());
    IdmRequestIdentityRoleFilter requestIdentityRoleFilter = new IdmRequestIdentityRoleFilter();
    requestIdentityRoleFilter.setIncludeEav(true);
    requestIdentityRoleFilter.setOnlyChanges(true);
    requestIdentityRoleFilter.setIdentityId(identity.getId());
    requestIdentityRoleFilter.setRoleRequestId(roleRequestDtoOne.getId());
    List<IdmRequestIdentityRoleDto> requestIdentityRoleDtos = requestIdentityRoleService.find(requestIdentityRoleFilter, null).getContent();
    assertEquals(1, requestIdentityRoleDtos.size());
    IdmRequestIdentityRoleDto requestIdentityRoleDto = requestIdentityRoleDtos.get(0);
    assertEquals(1, requestIdentityRoleDto.getEavs().size());
    assertEquals(1, requestIdentityRoleDto.getEavs().get(0).getValues().size());
    assertEquals(valueOne, requestIdentityRoleDto.getEavs().get(0).getValues().get(0).getValue());
    // Create second request for same role with EAV value with same ID.
    String valueTwo = getHelper().createName();
    IdmFormValueDto formValueTwo = new IdmFormValueDto(ipAttributeDto);
    // Set ID = simulation sending same ID from FE.
    formValueTwo.setId(formValue.getId());
    formValueTwo.setStringValue(valueTwo);
    formValueTwo.setPersistentType(PersistentType.TEXT);
    formValueTwo.setFormAttribute(ipAttributeDto.getId());
    IdmFormInstanceDto formInstanceTwo = new IdmFormInstanceDto();
    formInstanceTwo.setFormDefinition(definition);
    formInstanceTwo.getValues().add(formValueTwo);
    // Create requestTwo
    IdmRoleRequestDto requestTwo = new IdmRoleRequestDto();
    requestTwo.setApplicant(identity.getId());
    requestTwo.setRequestedByType(RoleRequestedByType.MANUALLY);
    requestTwo.setExecuteImmediately(true);
    requestTwo = roleRequestService.save(requestTwo);
    // Create concept
    IdmConceptRoleRequestDto conceptRoleTwo = new IdmConceptRoleRequestDto();
    conceptRoleTwo.setIdentityContract(identityContact.getId());
    conceptRoleTwo.setRole(role.getId());
    conceptRoleTwo.setOperation(ConceptRoleRequestOperation.ADD);
    conceptRoleTwo.setRoleRequest(requestTwo.getId());
    conceptRoleTwo.getEavs().add(formInstanceTwo);
    conceptRoleTwo = conceptRoleRequestService.save(conceptRoleTwo);
    // Start requestTwo
    variables = new HashMap<>();
    variables.put(RoleRequestApprovalProcessor.CHECK_RIGHT_PROPERTY, Boolean.FALSE);
    event = new RoleRequestEvent(RoleRequestEventType.EXCECUTE, requestTwo, variables);
    event.setPriority(PriorityType.HIGH);
    // 
    requestTwo = roleRequestService.startRequest(event);
    IdmRoleRequestDto roleRequestDtoTwo = roleRequestService.get(requestTwo);
    assertEquals(RoleRequestState.EXECUTED, roleRequestDtoTwo.getState());
    conceptRoleTwo = conceptRoleRequestService.get(conceptRoleTwo.getId());
    assertEquals(RoleRequestState.EXECUTED, conceptRoleTwo.getState());
    requestIdentityRoleFilter = new IdmRequestIdentityRoleFilter();
    requestIdentityRoleFilter.setIncludeEav(true);
    requestIdentityRoleFilter.setOnlyChanges(true);
    requestIdentityRoleFilter.setIdentityId(identity.getId());
    requestIdentityRoleFilter.setRoleRequestId(roleRequestDtoTwo.getId());
    requestIdentityRoleDtos = requestIdentityRoleService.find(requestIdentityRoleFilter, null).getContent();
    assertEquals(1, requestIdentityRoleDtos.size());
    requestIdentityRoleDto = requestIdentityRoleDtos.get(0);
    assertEquals(1, requestIdentityRoleDto.getEavs().size());
    assertEquals(1, requestIdentityRoleDto.getEavs().get(0).getValues().size());
    assertEquals(valueTwo, requestIdentityRoleDto.getEavs().get(0).getValues().get(0).getValue());
    // Check again requestOne!
    requestIdentityRoleFilter = new IdmRequestIdentityRoleFilter();
    requestIdentityRoleFilter.setIncludeEav(true);
    requestIdentityRoleFilter.setIdentityId(identity.getId());
    requestIdentityRoleFilter.setOnlyChanges(true);
    requestIdentityRoleFilter.setRoleRequestId(roleRequestDtoOne.getId());
    requestIdentityRoleDtos = requestIdentityRoleService.find(requestIdentityRoleFilter, null).getContent();
    assertEquals(1, requestIdentityRoleDtos.size());
    requestIdentityRoleDto = requestIdentityRoleDtos.get(0);
    assertEquals(1, requestIdentityRoleDto.getEavs().size());
    assertEquals(1, requestIdentityRoleDto.getEavs().get(0).getValues().size());
    assertEquals(valueOne, requestIdentityRoleDto.getEavs().get(0).getValues().get(0).getValue());
    // cleanup form definition
    getHelper().deleteIdentity(identity.getId());
    getHelper().deleteRole(role.getId());
    formService.deleteDefinition(definition);
}
Also used : IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) Serializable(java.io.Serializable) HashMap(java.util.HashMap) IdmRequestIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRequestIdentityRoleDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) RoleRequestEvent(eu.bcvsolutions.idm.core.model.event.RoleRequestEvent) IdmRequestIdentityRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRequestIdentityRoleFilter) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) IdmConceptRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) IdmRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto) AbstractCoreWorkflowIntegrationTest(eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest) Test(org.junit.Test)

Example 10 with IdmRequestIdentityRoleDto

use of eu.bcvsolutions.idm.core.api.dto.IdmRequestIdentityRoleDto in project CzechIdMng by bcvsolutions.

the class ChangeIdentityPermissionTest method testFindCandidatesWithoutSubprocess.

@Test
public void testFindCandidatesWithoutSubprocess() {
    // approve only by help desk
    configurationService.setValue(APPROVE_BY_USERMANAGER_ENABLE, "false");
    configurationService.setValue(APPROVE_BY_SECURITY_ENABLE, "false");
    configurationService.setValue(APPROVE_BY_MANAGER_ENABLE, "false");
    configurationService.setValue(APPROVE_BY_HELPDESK_ENABLE, "true");
    // 
    loginAsAdmin();
    IdmIdentityDto identity = getHelper().createIdentity();
    // 
    IdmRoleDto role = getHelper().createRole();
    // 
    // helpdesk role and identity
    IdmRoleDto helpdeskRole = getHelper().createRole();
    IdmIdentityDto helpdeskIdentity = getHelper().createIdentity();
    // add role directly
    getHelper().createIdentityRole(helpdeskIdentity, helpdeskRole);
    configurationService.setValue(APPROVE_BY_HELPDESK_ROLE, helpdeskRole.getCode());
    IdmIdentityContractDto contract = getHelper().getPrimeContract(identity.getId());
    loginAsNoAdmin(identity.getUsername());
    IdmRoleRequestDto request = createRoleRequest(identity);
    request = roleRequestService.save(request);
    IdmConceptRoleRequestDto concept = createRoleConcept(role, contract, request);
    concept = conceptRoleRequestService.save(concept);
    IdmRequestIdentityRoleFilter requestIdentityRoleFilter = new IdmRequestIdentityRoleFilter();
    requestIdentityRoleFilter.setIncludeCandidates(true);
    requestIdentityRoleFilter.setRoleRequestId(request.getId());
    requestIdentityRoleFilter.setIdentityId(identity.getId());
    List<IdmRequestIdentityRoleDto> requestIdentityRoles = requestIdentityRoleService.find(requestIdentityRoleFilter, null).getContent();
    assertEquals(1, requestIdentityRoles.size());
    IdmRequestIdentityRoleDto requestIdentityRoleDto = requestIdentityRoles.get(0);
    assertNull(requestIdentityRoleDto.getCandidates());
    roleRequestService.startRequestInternal(request.getId(), true);
    request = roleRequestService.get(request.getId());
    assertEquals(RoleRequestState.IN_PROGRESS, request.getState());
    Set<IdmIdentityDto> candidates = workflowProcessInstanceService.getApproversForProcess(request.getWfProcessId());
    assertEquals(1, candidates.size());
    candidates = workflowProcessInstanceService.getApproversForSubprocess(request.getWfProcessId());
    assertEquals(0, candidates.size());
    requestIdentityRoleFilter = new IdmRequestIdentityRoleFilter();
    requestIdentityRoleFilter.setIncludeCandidates(true);
    requestIdentityRoleFilter.setRoleRequestId(request.getId());
    requestIdentityRoleFilter.setIdentityId(identity.getId());
    requestIdentityRoles = requestIdentityRoleService.find(requestIdentityRoleFilter, null).getContent();
    assertEquals(1, requestIdentityRoles.size());
    requestIdentityRoleDto = requestIdentityRoles.get(0);
    assertNull(requestIdentityRoleDto.getCandidates());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRequestIdentityRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRequestIdentityRoleFilter) IdmRequestIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRequestIdentityRoleDto) IdmConceptRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) IdmRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto) AbstractCoreWorkflowIntegrationTest(eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest) Test(org.junit.Test)

Aggregations

IdmRequestIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRequestIdentityRoleDto)23 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)20 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)20 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)17 IdmRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto)17 IdmConceptRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto)16 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)16 Test (org.junit.Test)16 Transactional (org.springframework.transaction.annotation.Transactional)16 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)15 IdmRequestIdentityRoleFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmRequestIdentityRoleFilter)12 IdmRoleRequestFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleRequestFilter)12 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)12 IdmFormInstanceDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto)9 IdmIdentityRoleFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter)8 UUID (java.util.UUID)8 ConceptRoleRequestOperation (eu.bcvsolutions.idm.core.api.domain.ConceptRoleRequestOperation)7 IdmIdentityRoleService (eu.bcvsolutions.idm.core.api.service.IdmIdentityRoleService)7 IdmRequestIdentityRoleService (eu.bcvsolutions.idm.core.api.service.IdmRequestIdentityRoleService)7 IdmRoleRequestService (eu.bcvsolutions.idm.core.api.service.IdmRoleRequestService)7