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);
}
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);
}
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());
}
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());
}
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());
}
Aggregations