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);
helper.waitForResult(res -> {
return OperationState.isRunnable(reportService.get(reportId).getResult().getState());
});
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());
}
Aggregations