use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto in project CzechIdMng by bcvsolutions.
the class DefaultCommonFormServiceIntegrationTest method testCreateForm.
@Test
@Transactional
public void testCreateForm() {
Codeable owner = helper.createIdentity();
IdmFormAttributeDto attribute = createDefinition();
IdmFormValueDto formValue = new IdmFormValueDto(attribute);
formValue.setValue("testOne");
IdmFormDto formOne = new IdmFormDto();
formOne.setName("test");
formOne.setFormDefinition(attribute.getFormDefinition());
formOne.setValues(Lists.newArrayList(formValue));
formOne.setOwnerCode(owner.getCode());
//
commonFormService.saveForm(owner, formOne);
formOne = commonFormService.getForms(owner).get(0);
//
Assert.assertNotNull(formOne.getId());
Assert.assertEquals(owner.getCode(), formOne.getOwnerCode());
Assert.assertEquals(lookupService.lookupEntity(owner.getClass(), owner.getId()).getClass().getCanonicalName(), formOne.getOwnerType());
Assert.assertEquals(owner.getId(), formOne.getOwnerId());
Assert.assertEquals(formValue.getValue(), formOne.getValues().get(0).getValue());
//
commonFormService.deleteForms(owner);
Assert.assertTrue(commonFormService.getForms(owner).isEmpty());
}
use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto in project CzechIdMng by bcvsolutions.
the class ProvisioningOperationReportIntegrationTest method testProvisioningOperationReport.
@Test
public void testProvisioningOperationReport() throws IOException {
SysSystemDto systemOne = createSystemWithOperation();
SysSystemDto systemTwo = createSystemWithOperation();
// prepare report filter
RptReportDto report = new RptReportDto(UUID.randomUUID());
report.setExecutorName(reportExecutor.getName());
IdmFormDto filter = new IdmFormDto();
IdmFormDefinitionDto definition = reportExecutor.getFormDefinition();
IdmFormValueDto systemFilter = new IdmFormValueDto(definition.getMappedAttributeByCode(ProvisioningOperationReportExecutor.PARAMETER_SYSTEM));
systemFilter.setUuidValue(systemOne.getId());
filter.getValues().add(systemFilter);
filter.setFormDefinition(definition.getId());
report.setFilter(filter);
//
// generate report
report = reportExecutor.generate(report);
Assert.assertNotNull(report.getData());
List<RptProvisioningOperationDto> reportItems = mapper.readValue(attachmentManager.getAttachmentData(report.getData()), new TypeReference<List<RptProvisioningOperationDto>>() {
});
//
// test
Assert.assertTrue(reportItems.stream().anyMatch(ri -> ri.getSystem().equals(systemOne.getName())));
Assert.assertFalse(reportItems.stream().anyMatch(ri -> ri.getSystem().equals(systemTwo.getName())));
//
// 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 DefaultRptReportManagerIntegrationTest method testNotSendNotConfiguredNotificationAfterEnd.
@Test
public void testNotSendNotConfiguredNotificationAfterEnd() throws Exception {
IdmIdentityDto identity = getHelper().createIdentity();
//
try {
// report is sent to logged identity by default
getHelper().login(identity);
//
RptReportDto report = new RptReportDto();
report.setExecutorName(TestReportExecutor.REPORT_NAME);
IdmFormDto filter = new IdmFormDto();
TestReportExecutor testReportExecutor = context.getAutowireCapableBeanFactory().createBean(TestReportExecutor.class);
IdmFormDefinitionDto definition = testReportExecutor.getFormDefinition();
IdmFormValueDto topic = new IdmFormValueDto(definition.getMappedAttributeByCode(AbstractReportExecutor.PROPERTY_TOPIC_REPORT_GENERATE_SUCCESS));
filter.getValues().add(topic);
filter.setFormDefinition(definition.getId());
report.setFilter(filter);
report = manager.generate(report);
UUID reportId = report.getId();
Assert.assertNotNull(reportId);
Assert.assertNotNull(report.getData());
//
try (InputStream is = attachmentManager.getAttachmentData(report.getData())) {
Assert.assertEquals(mapper.writeValueAsString(TestReportExecutor.identities), IOUtils.toString(is));
}
reportService.delete(report);
attachmentManager.deleteAttachments(report);
//
// test notification is sent
IdmNotificationFilter notificationFilter = new IdmNotificationFilter();
notificationFilter.setRecipient(identity.getUsername());
notificationFilter.setNotificationType(IdmNotificationLog.class);
List<IdmNotificationLogDto> notifications = notificationService.find(notificationFilter, null).getContent();
Assert.assertTrue(notifications.isEmpty());
} finally {
logout();
}
}
use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto in project CzechIdMng by bcvsolutions.
the class DefaultRptReportManagerIntegrationTest method testSendConfiguredAdditionalNotificationAfterEnd.
@Test
public void testSendConfiguredAdditionalNotificationAfterEnd() throws Exception {
IdmIdentityDto identity = getHelper().createIdentity();
String recipient = getHelper().createName() + "@test-bcvsolutions.eu";
NotificationConfigurationDto config = createConfig(recipient, false);
//
try {
// report is sent to logged identity by default
getHelper().login(identity);
//
RptReportDto report = new RptReportDto();
report.setExecutorName(TestReportExecutor.REPORT_NAME);
IdmFormDto filter = new IdmFormDto();
TestReportExecutor testReportExecutor = context.getAutowireCapableBeanFactory().createBean(TestReportExecutor.class);
IdmFormDefinitionDto definition = testReportExecutor.getFormDefinition();
IdmFormValueDto topic = new IdmFormValueDto(definition.getMappedAttributeByCode(AbstractReportExecutor.PROPERTY_TOPIC_REPORT_GENERATE_SUCCESS));
topic.setValue(config.getTopic());
filter.getValues().add(topic);
filter.setFormDefinition(definition.getId());
report.setFilter(filter);
report = manager.generate(report);
UUID reportId = report.getId();
Assert.assertNotNull(reportId);
Assert.assertNotNull(report.getData());
//
try (InputStream is = attachmentManager.getAttachmentData(report.getData())) {
Assert.assertEquals(mapper.writeValueAsString(TestReportExecutor.identities), IOUtils.toString(is));
}
reportService.delete(report);
attachmentManager.deleteAttachments(report);
//
// test notification is sent
IdmNotificationFilter notificationFilter = new IdmNotificationFilter();
notificationFilter.setTopic(config.getTopic());
notificationFilter.setRecipient(identity.getUsername());
notificationFilter.setNotificationType(IdmNotificationLog.class);
List<IdmNotificationLogDto> notifications = notificationService.find(notificationFilter, null).getContent();
Assert.assertEquals(1, notifications.size());
//
IdmNotificationRecipientFilter recipientFilter = new IdmNotificationRecipientFilter();
recipientFilter.setRealRecipient(recipient);
List<IdmNotificationRecipientDto> recipients = notificationRecipientService.find(recipientFilter, null).getContent();
Assert.assertFalse(recipients.isEmpty());
Assert.assertEquals(config.getTopic(), notificationService.get(recipients.get(0).getNotification()).getTopic());
} finally {
logout();
}
}
use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto in project CzechIdMng by bcvsolutions.
the class IdentityRoleByIdentityDeduplicationExecutorTest method testExecuteReportOneContractMoreRoles.
@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);
}
Aggregations