Search in sources :

Example 6 with DuplicateRolesDto

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

the class DefaultIdmIdentityRoleServiceIntegrationTest method testMarkDuplicatesOneConceptOneIdentityRoleWithContractValidity.

@Test
public void testMarkDuplicatesOneConceptOneIdentityRoleWithContractValidity() {
    IdmIdentityDto identity = this.getHelper().createIdentity((GuardedString) null);
    IdmRoleDto role = this.getHelper().createRole();
    IdmIdentityContractDto contract = this.getHelper().getPrimeContract(identity);
    contract.setValidTill(LocalDate.now().plusDays(5));
    contract = identityContractService.save(contract);
    IdmIdentityRoleDto identityRole = this.getHelper().createIdentityRole(contract, role, null, LocalDate.now().plusDays(5));
    IdmConceptRoleRequestDto concept = new IdmConceptRoleRequestDto();
    concept.setRole(role.getId());
    concept.setIdentityContract(contract.getId());
    Map<String, BaseDto> embedded = concept.getEmbedded();
    embedded.put(IdmConceptRoleRequest_.identityContract.getName(), contract);
    concept.setEmbedded(embedded);
    concept.setOperation(ConceptRoleRequestOperation.ADD);
    List<IdmConceptRoleRequestDto> duplicates = roleRequestService.markDuplicates(Lists.newArrayList(concept), Lists.newArrayList(identityRole));
    assertEquals(1, duplicates.size());
    DuplicateRolesDto duplicateWithRoles = duplicates.get(0).getDuplicates();
    assertTrue(concept.getDuplicate());
    assertFalse(duplicateWithRoles.getIdentityRoles().isEmpty());
    assertTrue(duplicateWithRoles.getConcepts().isEmpty());
    assertEquals(1, duplicateWithRoles.getIdentityRoles().size());
    assertNull(duplicates.get(0).getId());
    assertEquals(identityRole.getId(), duplicateWithRoles.getIdentityRoles().get(0));
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) DuplicateRolesDto(eu.bcvsolutions.idm.core.api.dto.DuplicateRolesDto) IdmConceptRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto) BaseDto(eu.bcvsolutions.idm.core.api.dto.BaseDto) 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)

Aggregations

DuplicateRolesDto (eu.bcvsolutions.idm.core.api.dto.DuplicateRolesDto)6 IdmConceptRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto)6 BaseDto (eu.bcvsolutions.idm.core.api.dto.BaseDto)4 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)4 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)4 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)4 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)4 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)4 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)4 Test (org.junit.Test)4 UUID (java.util.UUID)3 IdmFormInstanceDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1