IdentityRoleByIdentityDeduplicationExecutor extends AbstractReportExecutor { @Override public String getName() { return REPORT_NAME; }  @Override String getName(); @Override List<IdmFormAttributeDto> getFormAttributes(); static final String REPORT_NAME; static final String PARAMETER_TREE_NODE; }
@Test public void testExecuteReportOneContract() 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); getHelper().createIdentityRole(contact, 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(1, reportItems.size()); RptIdentityRoleByRoleDeduplicationDto item = reportItems.get(0); assertNotNull(item.getIdentity()); assertEquals(identity.getId(), item.getIdentity().getId()); assertNotNull(item.getWorkPosition()); assertEquals(treeNode.getId(), item.getWorkPosition().getId()); assertNotNull(item.getIdentityContract()); assertEquals(contact.getId(), item.getIdentityContract().getId()); List<RptIdentityRoleByRoleDeduplicationDuplicityDto> duplicities = item.getDuplicity(); assertEquals(1, duplicities.size()); RptIdentityRoleByRoleDeduplicationDuplicityDto duplicity = duplicities.get(0); assertNotNull(duplicity.getRole()); assertEquals(role.getId(), duplicity.getRole().getId()); attachmentManager.deleteAttachments(report); }
@Test public void testExecuteReportOneContractMoreRoles() 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); getHelper().createIdentityRole(contact, role); getHelper().createIdentityRole(contact, role); getHelper().createIdentityRole(contact, 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(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()); } attachmentManager.deleteAttachments(report); }
@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); }
@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); }
@Test public void testExecuteReportTwoContract() 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(contactOne, role); getHelper().createIdentityRole(contactTwo, 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(2, reportItems.size()); for (RptIdentityRoleByRoleDeduplicationDto item : reportItems) { assertNotNull(item.getIdentity()); assertEquals(identity.getId(), item.getIdentity().getId()); assertNotNull(item.getWorkPosition()); assertEquals(treeNode.getId(), item.getWorkPosition().getId()); assertNotNull(item.getIdentityContract()); if (item.getIdentityContract().getId().equals(contactOne.getId())) { } else if (item.getIdentityContract().getId().equals(contactTwo.getId())) { } else { fail(); } List<RptIdentityRoleByRoleDeduplicationDuplicityDto> duplicities = item.getDuplicity(); assertEquals(1, duplicities.size()); } attachmentManager.deleteAttachments(report); }
@Test public void testRenderers() { IdmTreeNodeDto treeNode = getHelper().createTreeNode(); IdmIdentityDto identity = getHelper().createIdentity(new GuardedString()); IdmIdentityContractDto contact = getHelper().createContract(identity, treeNode); IdmRoleDto role = getHelper().createRole(); getHelper().createIdentityRole(contact, role); getHelper().createIdentityRole(contact, 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()); Assert.assertNotNull(xlsxRenderer.render(report)); attachmentManager.deleteAttachments(report); }