Search in sources :

Example 21 with IdmFormDto

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());
}
Also used : Codeable(eu.bcvsolutions.idm.core.api.domain.Codeable) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) IdmFormDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 22 with IdmFormDto

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);
}
Also used : LdapTestHelper(eu.bcvsolutions.idm.rpt.ldap.LdapTestHelper) Autowired(org.springframework.beans.factory.annotation.Autowired) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) RptProvisioningOperationDto(eu.bcvsolutions.idm.rpt.dto.RptProvisioningOperationDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) After(org.junit.After) IdmFormDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) TypeReference(com.fasterxml.jackson.core.type.TypeReference) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto) Before(org.junit.Before) AttachmentManager(eu.bcvsolutions.idm.core.ecm.api.service.AttachmentManager) SysProvisioningOperationService(eu.bcvsolutions.idm.acc.service.api.SysProvisioningOperationService) SysSystemService(eu.bcvsolutions.idm.acc.service.api.SysSystemService) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Assert.assertTrue(org.junit.Assert.assertTrue) IOException(java.io.IOException) Test(org.junit.Test) UUID(java.util.UUID) TestHelper(eu.bcvsolutions.idm.rpt.acc.TestHelper) RptReportDto(eu.bcvsolutions.idm.rpt.api.dto.RptReportDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) SysProvisioningOperationFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter) List(java.util.List) AccAccountService(eu.bcvsolutions.idm.acc.service.api.AccAccountService) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) Assert.assertFalse(org.junit.Assert.assertFalse) LdapServer(eu.bcvsolutions.idm.rpt.ldap.LdapServer) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) AccAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter) Assert(org.junit.Assert) Assert.assertEquals(org.junit.Assert.assertEquals) RptProvisioningOperationDto(eu.bcvsolutions.idm.rpt.dto.RptProvisioningOperationDto) IdmFormDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) List(java.util.List) RptReportDto(eu.bcvsolutions.idm.rpt.api.dto.RptReportDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 23 with IdmFormDto

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();
    }
}
Also used : InputStream(java.io.InputStream) IdmNotificationLogDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto) IdmFormDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) IdmNotificationFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter) RptReportDto(eu.bcvsolutions.idm.rpt.api.dto.RptReportDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) UUID(java.util.UUID) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 24 with IdmFormDto

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();
    }
}
Also used : NotificationConfigurationDto(eu.bcvsolutions.idm.core.notification.api.dto.NotificationConfigurationDto) InputStream(java.io.InputStream) IdmFormDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmNotificationFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter) RptReportDto(eu.bcvsolutions.idm.rpt.api.dto.RptReportDto) IdmNotificationRecipientFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationRecipientFilter) IdmNotificationLogDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) UUID(java.util.UUID) IdmNotificationRecipientDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationRecipientDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 25 with IdmFormDto

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);
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) RptIdentityRoleByRoleDeduplicationDuplicityDto(eu.bcvsolutions.idm.rpt.dto.RptIdentityRoleByRoleDeduplicationDuplicityDto) IdmFormDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) RptReportDto(eu.bcvsolutions.idm.rpt.api.dto.RptReportDto) RptIdentityRoleByRoleDeduplicationDto(eu.bcvsolutions.idm.rpt.dto.RptIdentityRoleByRoleDeduplicationDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) List(java.util.List) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

IdmFormDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto)35 IdmFormValueDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto)33 IdmFormDefinitionDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto)31 RptReportDto (eu.bcvsolutions.idm.rpt.api.dto.RptReportDto)31 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)31 Test (org.junit.Test)31 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)22 List (java.util.List)17 UUID (java.util.UUID)16 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)12 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)12 IdmTreeNodeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto)9 InputStream (java.io.InputStream)7 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)6 ArrayList (java.util.ArrayList)6 Transactional (org.springframework.transaction.annotation.Transactional)6 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)5 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)5 AccAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter)5 AttachmentManager (eu.bcvsolutions.idm.core.ecm.api.service.AttachmentManager)5