Search in sources :

Example 31 with IdmFormDto

use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto in project CzechIdMng by bcvsolutions.

the class ChangesOnSystemReportIntegrationTest method testProvisioningOperationReportWithoutIdentities.

@Test
public void testProvisioningOperationReportWithoutIdentities() throws IOException {
    IdmIdentityDto identityOne = getHelper().createIdentity((GuardedString) null);
    IdmIdentityDto identityTwo = getHelper().createIdentity((GuardedString) null);
    IdmTreeNodeDto position = getHelper().createTreeNode();
    getHelper().createContract(identityOne, position);
    SysSystemDto system = createSystemWithOperation();
    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());
    // 
    // 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\": \"" + getHelper().getDefaultMapping(system).getId() + "\", \"mappingAttributes\": [] }");
    filter.getValues().add(filterValue);
    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);
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) AccAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter) 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) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) RptReportDto(eu.bcvsolutions.idm.rpt.api.dto.RptReportDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 32 with IdmFormDto

use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto in project CzechIdMng by bcvsolutions.

the class ChangesOnSystemReportIntegrationTest method testProvisioningOperationReportWithIdentities.

@Test
public void testProvisioningOperationReportWithIdentities() 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);
    SysSystemAttributeMappingDto attributeName = attributeMappingService.findBySystemMappingAndName(defaultMapping.getId(), TestHelper.ATTRIBUTE_MAPPING_NAME);
    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());
    // 
    // 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\": [ \"" + attributeName.getId() + "\" ] }");
    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);
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) IdmFormDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) RptReportDto(eu.bcvsolutions.idm.rpt.api.dto.RptReportDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AccAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 33 with IdmFormDto

use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto in project CzechIdMng by bcvsolutions.

the class DefaultRptReportServiceIntegrationTest method testReportReferentialIntegrity.

@Test
public void testReportReferentialIntegrity() throws IOException {
    RptReportDto report = new RptReportDto();
    report.setExecutorName(TestFilterReportExecutor.REPORT_NAME);
    IdmFormDto filter = new IdmFormDto();
    TestFilterReportExecutor testReportExecutor = context.getAutowireCapableBeanFactory().createBean(TestFilterReportExecutor.class);
    IdmFormDefinitionDto definition = testReportExecutor.getFormDefinition();
    IdmFormValueDto username = new IdmFormValueDto(definition.getMappedAttributeByCode(IdmIdentity_.username.getName()));
    username.setValue(TestReportExecutor.identities.get(0).getUsername());
    filter.getValues().add(username);
    filter.setFormDefinition(definition.getId());
    report.setFilter(filter);
    // 
    report = reportManager.generate(report);
    final UUID reportId = report.getId();
    Assert.assertNotNull(reportId);
    Assert.assertNotNull(report.getData());
    Assert.assertNotNull(report.getFilter());
    Assert.assertFalse(commonFormService.getForms(report).isEmpty());
    Assert.assertFalse(attachmentManager.getAttachments(report, null).getTotalElements() == 0);
    // 
    // delete report
    reportService.delete(report);
    // check report is deleted
    Assert.assertNull(reportService.get(report.getId()));
    // check attachment was deleted
    Assert.assertTrue(attachmentManager.getAttachments(report, null).getTotalElements() == 0);
    // check filter is deleted
    Assert.assertTrue(commonFormService.getForms(report).isEmpty());
}
Also used : 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) RptReportDto(eu.bcvsolutions.idm.rpt.api.dto.RptReportDto) UUID(java.util.UUID) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 34 with IdmFormDto

use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto in project CzechIdMng by bcvsolutions.

the class DefaultRptReportServiceIntegrationTest method testReferentialIntegrityLrtIsDeleted.

@Test
public void testReferentialIntegrityLrtIsDeleted() throws IOException {
    RptReportDto report = new RptReportDto();
    report.setExecutorName(TestFilterReportExecutor.REPORT_NAME);
    IdmFormDto filter = new IdmFormDto();
    TestFilterReportExecutor testReportExecutor = context.getAutowireCapableBeanFactory().createBean(TestFilterReportExecutor.class);
    IdmFormDefinitionDto definition = testReportExecutor.getFormDefinition();
    IdmFormValueDto username = new IdmFormValueDto(definition.getMappedAttributeByCode(IdmIdentity_.username.getName()));
    username.setValue(TestReportExecutor.identities.get(0).getUsername());
    filter.getValues().add(username);
    filter.setFormDefinition(definition.getId());
    report.setFilter(filter);
    // 
    report = reportManager.generate(report);
    report = reportService.get(report);
    UUID reportId = report.getId();
    UUID longRunningTaskId = report.getLongRunningTask();
    Assert.assertNotNull(reportId);
    Assert.assertNotNull(longRunningTaskId);
    // 
    longRunningTaskService.deleteById(longRunningTaskId);
    report = reportService.get(report);
    // 
    Assert.assertNull(longRunningTaskService.get(longRunningTaskId));
    Assert.assertNull(report.getLongRunningTask());
}
Also used : 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) RptReportDto(eu.bcvsolutions.idm.rpt.api.dto.RptReportDto) UUID(java.util.UUID) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 35 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 = getHelper().createIdentity((GuardedString) null);
    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)

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