Search in sources :

Example 6 with IdmRoleRequestByIdentityDto

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

the class DefaultIdmRoleRequestServiceIntegrationTest method testCopyRolesByIdentityWithValid.

@Test
@Transactional
public void testCopyRolesByIdentityWithValid() {
    LocalDate validFrom = LocalDate.now().minusDays(5);
    LocalDate validTill = LocalDate.now().plusDays(55);
    IdmIdentityDto identityDto = this.getHelper().createIdentity((GuardedString) null);
    IdmRoleDto roleOne = this.getHelper().createRole();
    IdmRoleDto roleTwo = this.getHelper().createRole();
    IdmIdentityContractDto primeContract = this.getHelper().getPrimeContract(identityDto);
    this.getHelper().createIdentityRole(primeContract, roleOne);
    this.getHelper().createIdentityRole(primeContract, roleTwo);
    IdmIdentityDto newIdentity = this.getHelper().createIdentity((GuardedString) null);
    IdmIdentityContractDto newIdentityContract = this.getHelper().getPrimeContract(newIdentity);
    List<IdmIdentityRoleDto> allByIdentity = identityRoleService.findAllByIdentity(identityDto.getId());
    List<UUID> identityRolesId = allByIdentity.stream().map(IdmIdentityRoleDto::getId).collect(Collectors.toList());
    IdmRoleRequestDto createdRequest = roleRequestService.createRequest(newIdentityContract);
    IdmRoleRequestByIdentityDto requestByIdentityDto = new IdmRoleRequestByIdentityDto();
    requestByIdentityDto.setIdentityContract(newIdentityContract.getId());
    requestByIdentityDto.setRoleRequest(createdRequest.getId());
    requestByIdentityDto.setIdentityRoles(identityRolesId);
    requestByIdentityDto.setValidFrom(validFrom);
    requestByIdentityDto.setValidTill(validTill);
    IdmRoleRequestDto copyRolesByIdentity = roleRequestService.copyRolesByIdentity(requestByIdentityDto);
    assertNotNull(copyRolesByIdentity);
    assertEquals(createdRequest.getId(), copyRolesByIdentity.getId());
    List<IdmConceptRoleRequestDto> concepts = conceptRoleRequestService.findAllByRoleRequest(copyRolesByIdentity.getId());
    assertEquals(2, concepts.size());
    IdmConceptRoleRequestDto conceptOne = concepts.stream().filter(concept -> {
        return concept.getRole().equals(roleOne.getId());
    }).findAny().orElse(null);
    assertNotNull(conceptOne);
    assertEquals(validFrom, conceptOne.getValidFrom());
    assertEquals(validTill, conceptOne.getValidTill());
    IdmConceptRoleRequestDto conceptTwo = concepts.stream().filter(concept -> {
        return concept.getRole().equals(roleTwo.getId());
    }).findAny().orElse(null);
    assertNotNull(conceptTwo);
    assertEquals(validFrom, conceptTwo.getValidFrom());
    assertEquals(validTill, conceptTwo.getValidTill());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmConceptRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) UUID(java.util.UUID) LocalDate(java.time.LocalDate) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) IdmRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto) IdmRoleRequestByIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestByIdentityDto) AbstractCoreWorkflowIntegrationTest(eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

AbstractCoreWorkflowIntegrationTest (eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest)6 IdmConceptRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto)6 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)6 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)6 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)6 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)6 IdmRoleRequestByIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestByIdentityDto)6 IdmRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto)6 UUID (java.util.UUID)6 Test (org.junit.Test)6 Transactional (org.springframework.transaction.annotation.Transactional)5 IdmFormAttributeDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto)3 IdmFormDefinitionDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto)3 IdmFormInstanceDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto)3 IdmFormValueDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto)2 IdmAttachmentDto (eu.bcvsolutions.idm.core.ecm.api.dto.IdmAttachmentDto)2 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)2 LocalDate (java.time.LocalDate)2 ImmutableList (com.google.common.collect.ImmutableList)1 Lists (com.google.common.collect.Lists)1