Search in sources :

Example 6 with RptReportFilter

use of eu.bcvsolutions.idm.rpt.api.dto.filter.RptReportFilter in project CzechIdMng by bcvsolutions.

the class GeneralFormableEntityExportIntegrationTest method testReportWithoutValueSpecified.

@Test
public void testReportWithoutValueSpecified() throws IOException {
    // prepare test identities
    IdmIdentityDto identityOne = getHelper().createIdentity((GuardedString) null);
    IdmIdentityDto identityDisabled = getHelper().createIdentity((GuardedString) null);
    identityService.disable(identityDisabled.getId());
    IdmFormAttributeDto testAttrRpt = getHelper().createEavAttribute("testAttrRpt", IdmIdentity.class, PersistentType.SHORTTEXT);
    getHelper().setEavValue(identityOne, testAttrRpt, IdmIdentity.class, "TESTVAL", PersistentType.SHORTTEXT);
    IdmFormAttributeDto testAttrRptMulti = getHelper().createEavAttribute("testAttrRptMulti", IdmIdentity.class, PersistentType.SHORTTEXT);
    testAttrRptMulti.setMultiple(true);
    formAttributeService.save(testAttrRptMulti);
    // 
    formService.saveValues(identityOne, testAttrRptMulti, Arrays.asList("B", "A"));
    // 
    IdmBulkActionDto bulkAction = new IdmBulkActionDto();
    bulkAction.setEntityClass(IdmIdentity.class.getCanonicalName());
    bulkAction.setFilterClass(IdmIdentityFilter.class.getCanonicalName());
    bulkAction.setModule(RptModuleDescriptor.MODULE_ID);
    bulkAction.setIdentifiers(new HashSet<UUID>(Arrays.asList(identityOne.getId(), identityDisabled.getId())));
    bulkAction.setId(AbstractFormableEntityExport.REPORT_NAME);
    bulkAction.setName(AbstractFormableEntityExport.REPORT_NAME);
    bulkActionManager.processAction(bulkAction);
    RptReportFilter reportFilter = new RptReportFilter();
    reportFilter.setText(AbstractFormableEntityExport.REPORT_NAME);
    List<RptReportDto> content = reportService.find(reportFilter, null).getContent();
    Assert.assertFalse(content.isEmpty());
    Assert.assertEquals(1, content.size());
    RptReportDto reportDto = content.get(0);
    Assert.assertEquals(CoreResultCode.LONG_RUNNING_TASK_PARTITIAL_DOWNLOAD.getCode(), longRunningTaskManager.getLongRunningTask(reportDto.getLongRunningTask()).getResult().getCode());
    RptRenderedReportDto render = reportManager.render(reportDto, FormableEntityXlsxRenderer.NAME);
    Assert.assertNotNull(render);
    XSSFSheet sheetAt = null;
    try (XSSFWorkbook workbook = new XSSFWorkbook(render.getRenderedReport())) {
        sheetAt = workbook.getSheetAt(0);
    }
    Map<String, Map<String, String>> parsed = sheetToMap(sheetAt);
    Assert.assertEquals(2, parsed.size());
    Assert.assertNotNull(parsed.get(identityOne.getId().toString()));
    Assert.assertNotNull(parsed.get(identityDisabled.getId().toString()));
    Assert.assertEquals("TESTVAL", parsed.get(identityOne.getId().toString()).get("testAttrRpt"));
    Assert.assertEquals("[B, A]", parsed.get(identityOne.getId().toString()).get("testAttrRptMulti"));
}
Also used : IdmBulkActionDto(eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto) RptReportFilter(eu.bcvsolutions.idm.rpt.api.dto.filter.RptReportFilter) IdmIdentityFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter) RptReportDto(eu.bcvsolutions.idm.rpt.api.dto.RptReportDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) XSSFSheet(org.apache.poi.xssf.usermodel.XSSFSheet) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) RptRenderedReportDto(eu.bcvsolutions.idm.rpt.api.dto.RptRenderedReportDto) XSSFWorkbook(org.apache.poi.xssf.usermodel.XSSFWorkbook) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) UUID(java.util.UUID) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) HashMap(java.util.HashMap) Map(java.util.Map) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

RptReportFilter (eu.bcvsolutions.idm.rpt.api.dto.filter.RptReportFilter)6 RptReportDto (eu.bcvsolutions.idm.rpt.api.dto.RptReportDto)4 Test (org.junit.Test)4 IdmLongRunningTaskDto (eu.bcvsolutions.idm.core.scheduler.api.dto.IdmLongRunningTaskDto)3 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)3 IdmBulkActionDto (eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto)2 IdmFormInstanceDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto)2 UUID (java.util.UUID)2 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)1 IdmIdentityFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter)1 DefaultEventResult (eu.bcvsolutions.idm.core.api.event.DefaultEventResult)1 IdmFormAttributeDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto)1 IdmFormDefinitionDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto)1 IdmFormDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto)1 IdmFormValueDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto)1 IdmIdentity (eu.bcvsolutions.idm.core.model.entity.IdmIdentity)1 LongRunningFutureTask (eu.bcvsolutions.idm.core.scheduler.api.dto.LongRunningFutureTask)1 SimpleTaskTrigger (eu.bcvsolutions.idm.core.scheduler.api.dto.SimpleTaskTrigger)1 Task (eu.bcvsolutions.idm.core.scheduler.api.dto.Task)1 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)1