use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto in project CzechIdMng by bcvsolutions.
the class IdentityReportExecutorIntegrationTest method testDisabledIdentity.
@Test
@Transactional
public void testDisabledIdentity() throws IOException {
// prepare test identities
IdmIdentityDto identityOne = helper.createIdentity();
IdmIdentityDto identityDisabled = helper.createIdentity();
identityService.disable(identityDisabled.getId());
//
// prepare report filter
RptReportDto report = new RptReportDto(UUID.randomUUID());
report.setExecutorName(reportExecutor.getName());
IdmFormDto filter = new IdmFormDto();
IdmFormDefinitionDto definition = reportExecutor.getFormDefinition();
IdmFormValueDto disabled = new IdmFormValueDto(definition.getMappedAttributeByCode(IdmIdentityFilter.PARAMETER_DISABLED));
disabled.setValue(false);
filter.getValues().add(disabled);
filter.setFormDefinition(definition.getId());
report.setFilter(filter);
//
// generate report
report = reportExecutor.generate(report);
Assert.assertNotNull(report.getData());
List<IdmIdentityDto> identityRoles = mapper.readValue(attachmentManager.getAttachmentData(report.getData()), new TypeReference<List<IdmIdentityDto>>() {
});
//
// test
Assert.assertTrue(identityRoles.stream().anyMatch(i -> i.equals(identityOne)));
Assert.assertFalse(identityRoles.stream().anyMatch(i -> i.equals(identityDisabled)));
//
attachmentManager.deleteAttachments(report);
}
use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto in project CzechIdMng by bcvsolutions.
the class IdentityReportExecutorIntegrationTest method testDisabledIdentity.
@Test
@Transactional
public void testDisabledIdentity() throws IOException {
// prepare test identities
IdmIdentityDto identityOne = helper.createIdentity();
IdmIdentityDto identityDisabled = helper.createIdentity();
identityService.disable(identityDisabled.getId());
//
// prepare report filter
RptReportDto report = new RptReportDto(UUID.randomUUID());
report.setExecutorName(reportExecutor.getName());
IdmFormDto filter = new IdmFormDto();
IdmFormDefinitionDto definition = reportExecutor.getFormDefinition();
IdmFormValueDto disabled = new IdmFormValueDto(definition.getMappedAttributeByCode(IdmIdentityFilter.PARAMETER_DISABLED));
disabled.setValue(false);
filter.getValues().add(disabled);
filter.setFormDefinition(definition.getId());
report.setFilter(filter);
//
// generate report
report = reportExecutor.generate(report);
Assert.assertNotNull(report.getData());
List<IdmIdentityDto> identityRoles = mapper.readValue(attachmentManager.getAttachmentData(report.getData()), new TypeReference<List<IdmIdentityDto>>() {
});
//
// test
Assert.assertTrue(identityRoles.stream().anyMatch(i -> i.equals(identityOne)));
Assert.assertFalse(identityRoles.stream().anyMatch(i -> i.equals(identityDisabled)));
//
attachmentManager.deleteAttachments(report);
}
use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto in project CzechIdMng by bcvsolutions.
the class ChangesOnSystemReportIntegrationTest method testProvisioningOperationReportWithChanges.
@Test
public void testProvisioningOperationReportWithChanges() throws IOException {
IdmIdentityDto identityOne = getHelper().createIdentity((GuardedString) null);
IdmIdentityDto identityTwo = getHelper().createIdentity((GuardedString) null);
IdmTreeNodeDto position = getHelper().createTreeNode();
getHelper().createContract(identityTwo, position);
SysSystemDto system = createSystemWithOperation();
SysSystemMappingDto defaultMapping = getHelper().getDefaultMapping(system);
IdmRoleDto role = getHelper().createRole();
getHelper().createRoleSystem(role, system);
getHelper().createIdentityRole(identityTwo, role);
//
AccAccountFilter accountFilter = new AccAccountFilter();
accountFilter.setIdentityId(identityTwo.getId());
accountFilter.setSystemId(system.getId());
accountFilter.setEntityType(SystemEntityType.IDENTITY);
List<AccAccountDto> accounts = accountService.find(accountFilter, null).getContent();
Assert.assertEquals(1, accounts.size());
//
// change => readonly system
system.setDisabledProvisioning(true);
system.setReadonly(true);
system = systemService.save(system);
identityTwo.setLastName(getHelper().createName());
identityTwo = identityService.save(identityTwo);
system.setDisabledProvisioning(false);
system.setReadonly(false);
system = systemService.save(system);
//
// prepare report filter
RptReportDto report = new RptReportDto(UUID.randomUUID());
report.setExecutorName(reportExecutor.getName());
IdmFormDto filter = new IdmFormDto();
IdmFormDefinitionDto definition = reportExecutor.getFormDefinition();
IdmFormValueDto filterValue = new IdmFormValueDto(definition.getMappedAttributeByCode(ChangesOnSystemReportExecutor.PARAMETER_MAPPING_ATTRIBUTES));
// TODO: create json java POJO representation
filterValue.setStringValue("{ \"system\": \"" + system.getId() + "\", \"systemMapping\": \"" + defaultMapping.getId() + "\", \"mappingAttributes\": [ ] }");
filter.getValues().add(filterValue);
IdmFormValueDto filterIdentitites = new IdmFormValueDto(definition.getMappedAttributeByCode(ChangesOnSystemReportExecutor.PARAMETER_ONLY_IDENTITY));
filterIdentitites.setUuidValue(identityOne.getId());
filter.getValues().add(filterIdentitites);
IdmFormValueDto filterTreeNode = new IdmFormValueDto(definition.getMappedAttributeByCode(ChangesOnSystemReportExecutor.PARAMETER_TREE_NODE));
filterTreeNode.setUuidValue(position.getId());
filter.getValues().add(filterTreeNode);
filter.setFormDefinition(definition.getId());
report.setFilter(filter);
//
// generate report
report = reportExecutor.generate(report);
Assert.assertNotNull(report.getData());
//
// test renderer
Assert.assertNotNull(xlsxRenderer.render(report));
//
attachmentManager.deleteAttachments(report);
}
use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto in project CzechIdMng by bcvsolutions.
the class IdentityRoleByIdentityDeduplicationExecutorTest method testExecuteReportOneContractMoreRolesWithValidity.
@Test
public void testExecuteReportOneContractMoreRolesWithValidity() throws JsonParseException, JsonMappingException, IOException {
String roleCode = "test-" + System.currentTimeMillis();
IdmTreeNodeDto treeNode = getHelper().createTreeNode();
IdmIdentityDto identity = getHelper().createIdentity(new GuardedString());
IdmIdentityContractDto contact = getHelper().createContract(identity, treeNode);
IdmRoleDto role = getHelper().createRole(roleCode);
getHelper().createIdentityRole(contact, role, LocalDate.now().minusDays(40), LocalDate.now().plusDays(40));
getHelper().createIdentityRole(contact, role, LocalDate.now().minusDays(30), LocalDate.now().plusDays(30));
getHelper().createIdentityRole(contact, role, LocalDate.now().minusDays(20), LocalDate.now().plusDays(20));
getHelper().createIdentityRole(contact, role, LocalDate.now().minusDays(10), LocalDate.now().plusDays(10));
RptReportDto report = new RptReportDto(UUID.randomUUID());
report.setExecutorName(reportExecutor.getName());
IdmFormDto filter = new IdmFormDto();
IdmFormDefinitionDto definition = reportExecutor.getFormDefinition();
IdmFormValueDto treeNodeParameter = new IdmFormValueDto(definition.getMappedAttributeByCode(IdentityRoleByIdentityDeduplicationExecutor.PARAMETER_TREE_NODE));
treeNodeParameter.setValue(treeNode.getId());
filter.getValues().add(treeNodeParameter);
filter.setFormDefinition(definition.getId());
report.setFilter(filter);
report = reportExecutor.generate(report);
Assert.assertNotNull(report.getData());
List<RptIdentityRoleByRoleDeduplicationDto> reportItems = mapper.readValue(attachmentManager.getAttachmentData(report.getData()), new TypeReference<List<RptIdentityRoleByRoleDeduplicationDto>>() {
});
assertEquals(1, reportItems.size());
RptIdentityRoleByRoleDeduplicationDto item = reportItems.get(0);
List<RptIdentityRoleByRoleDeduplicationDuplicityDto> duplicities = item.getDuplicity();
assertEquals(3, duplicities.size());
for (RptIdentityRoleByRoleDeduplicationDuplicityDto duplicity : duplicities) {
assertEquals(role.getId(), duplicity.getRole().getId());
if (duplicity.getValidTill().isEqual(duplicity.getValidFrom())) {
fail();
}
if (!duplicity.getValidTill().isBefore(LocalDate.now().plusDays(35))) {
fail();
}
if (!duplicity.getValidFrom().isAfter(LocalDate.now().minusDays(35))) {
fail();
}
}
attachmentManager.deleteAttachments(report);
}
use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto in project CzechIdMng by bcvsolutions.
the class IdentityRoleByIdentityDeduplicationExecutorTest method testExecuteReportTwoContractNoDuplicity.
@Test
public void testExecuteReportTwoContractNoDuplicity() throws JsonParseException, JsonMappingException, IOException {
String roleCode = "test-" + System.currentTimeMillis();
IdmTreeNodeDto treeNode = getHelper().createTreeNode();
IdmIdentityDto identity = getHelper().createIdentity(new GuardedString());
IdmIdentityContractDto contactOne = getHelper().createContract(identity, treeNode);
IdmIdentityContractDto contactTwo = getHelper().createContract(identity, treeNode);
IdmRoleDto role = getHelper().createRole(roleCode);
getHelper().createIdentityRole(contactOne, role);
getHelper().createIdentityRole(contactTwo, role);
RptReportDto report = new RptReportDto(UUID.randomUUID());
report.setExecutorName(reportExecutor.getName());
IdmFormDto filter = new IdmFormDto();
IdmFormDefinitionDto definition = reportExecutor.getFormDefinition();
IdmFormValueDto treeNodeParameter = new IdmFormValueDto(definition.getMappedAttributeByCode(IdentityRoleByIdentityDeduplicationExecutor.PARAMETER_TREE_NODE));
treeNodeParameter.setValue(treeNode.getId());
filter.getValues().add(treeNodeParameter);
filter.setFormDefinition(definition.getId());
report.setFilter(filter);
report = reportExecutor.generate(report);
Assert.assertNotNull(report.getData());
List<RptIdentityRoleByRoleDeduplicationDto> reportItems = mapper.readValue(attachmentManager.getAttachmentData(report.getData()), new TypeReference<List<RptIdentityRoleByRoleDeduplicationDto>>() {
});
assertEquals(0, reportItems.size());
attachmentManager.deleteAttachments(report);
}
Aggregations