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));
}
Aggregations