@Test public void should_export_unit_inherited_rules_invalidation_report() throws Exception { String filename = "filename.jsonl"; when(workspaceClientFactory.getClient()).thenReturn(workspaceClient); Path report = initialisePathWithFileName(filename); initialiseMockWhenPutObjectInWorkspace(report); doReturn( CloseableIteratorUtils.toCloseableIterator(Arrays.asList( new Document("id", "unit1"), new Document("id", "unit2") ).iterator())) .when(unitComputedInheritedRulesInvalidationRepository) .findCollectionByProcessIdTenant("procId", 1); batchReportServiceImpl.exportUnitsToInvalidate("procId", 1, new ReportExportRequest(filename)); try (InputStream is = Files.newInputStream(report); JsonLineGenericIterator<JsonLineModel> reader = new JsonLineGenericIterator<>(is, TYPE_REFERENCE)) { assertThat(reader).extracting(JsonLineModel::getId).containsExactly( "unit1", "unit2" ); } }
public void exportUnitsToInvalidate(String processId, int tenantId, ReportExportRequest reportExportRequest) throws IOException, ContentAddressableStorageServerException { File file = Files.createFile(Paths.get(VitamConfiguration.getVitamTmpFolder(), reportExportRequest.getFilename())) .toFile(); try { try ( OutputStream outputStream = new FileOutputStream(file); JsonLineWriter jsonLineWriter = new JsonLineWriter(outputStream); CloseableIterator<Document> units = unitComputedInheritedRulesInvalidationRepository .findCollectionByProcessIdTenant(processId, tenantId)) { while (units.hasNext()) { Document unit = units.next(); jsonLineWriter.addEntry(new JsonLineModel((String) unit.get("id"))); } } transferDocumentToWorkspace(processId, reportExportRequest.getFilename(), file); } finally { deleteQuietly(file); } }
BatchReportServiceImpl { public void exportUnitsToInvalidate(String processId, int tenantId, ReportExportRequest reportExportRequest) throws IOException, ContentAddressableStorageServerException { File file = Files.createFile(Paths.get(VitamConfiguration.getVitamTmpFolder(), reportExportRequest.getFilename())) .toFile(); try { try ( OutputStream outputStream = new FileOutputStream(file); JsonLineWriter jsonLineWriter = new JsonLineWriter(outputStream); CloseableIterator<Document> units = unitComputedInheritedRulesInvalidationRepository .findCollectionByProcessIdTenant(processId, tenantId)) { while (units.hasNext()) { Document unit = units.next(); jsonLineWriter.addEntry(new JsonLineModel((String) unit.get("id"))); } } transferDocumentToWorkspace(processId, reportExportRequest.getFilename(), file); } finally { deleteQuietly(file); } } }
BatchReportServiceImpl { public void exportUnitsToInvalidate(String processId, int tenantId, ReportExportRequest reportExportRequest) throws IOException, ContentAddressableStorageServerException { File file = Files.createFile(Paths.get(VitamConfiguration.getVitamTmpFolder(), reportExportRequest.getFilename())) .toFile(); try { try ( OutputStream outputStream = new FileOutputStream(file); JsonLineWriter jsonLineWriter = new JsonLineWriter(outputStream); CloseableIterator<Document> units = unitComputedInheritedRulesInvalidationRepository .findCollectionByProcessIdTenant(processId, tenantId)) { while (units.hasNext()) { Document unit = units.next(); jsonLineWriter.addEntry(new JsonLineModel((String) unit.get("id"))); } } transferDocumentToWorkspace(processId, reportExportRequest.getFilename(), file); } finally { deleteQuietly(file); } } BatchReportServiceImpl(EliminationActionUnitRepository eliminationActionUnitRepository,
        PurgeUnitRepository purgeUnitRepository, PurgeObjectGroupRepository purgeObjectGroupRepository,
        TransferReplyUnitRepository transferReplyUnitRepository, WorkspaceClientFactory workspaceClientFactory,
        PreservationReportRepository preservationReportRepository,
        AuditReportRepository auditReportRepository,
        UpdateUnitReportRepository updateUnitReportRepository,
        UnitComputedInheritedRulesInvalidationRepository unitComputedInheritedRulesInvalidationRepository,
        EvidenceAuditReportRepository evidenceAuditReportRepository); @VisibleForTesting  BatchReportServiceImpl(
        EliminationActionUnitRepository eliminationActionUnitRepository,
        PurgeUnitRepository purgeUnitRepository,
        PurgeObjectGroupRepository purgeObjectGroupRepository,
        TransferReplyUnitRepository transferReplyUnitRepository,
        UpdateUnitReportRepository updateUnitReportRepository,
        WorkspaceClientFactory workspaceClientFactory,
        PreservationReportRepository preservationReportRepository,
        AuditReportRepository auditReportRepository,
        UnitComputedInheritedRulesInvalidationRepository unitComputedInheritedRulesInvalidationRepository,
        EvidenceAuditReportRepository evidenceAuditReportRepository); }
BatchReportServiceImpl { public void exportUnitsToInvalidate(String processId, int tenantId, ReportExportRequest reportExportRequest) throws IOException, ContentAddressableStorageServerException { File file = Files.createFile(Paths.get(VitamConfiguration.getVitamTmpFolder(), reportExportRequest.getFilename())) .toFile(); try { try ( OutputStream outputStream = new FileOutputStream(file); JsonLineWriter jsonLineWriter = new JsonLineWriter(outputStream); CloseableIterator<Document> units = unitComputedInheritedRulesInvalidationRepository .findCollectionByProcessIdTenant(processId, tenantId)) { while (units.hasNext()) { Document unit = units.next(); jsonLineWriter.addEntry(new JsonLineModel((String) unit.get("id"))); } } transferDocumentToWorkspace(processId, reportExportRequest.getFilename(), file); } finally { deleteQuietly(file); } } BatchReportServiceImpl(EliminationActionUnitRepository eliminationActionUnitRepository,
        PurgeUnitRepository purgeUnitRepository, PurgeObjectGroupRepository purgeObjectGroupRepository,
        TransferReplyUnitRepository transferReplyUnitRepository, WorkspaceClientFactory workspaceClientFactory,
        PreservationReportRepository preservationReportRepository,
        AuditReportRepository auditReportRepository,
        UpdateUnitReportRepository updateUnitReportRepository,
        UnitComputedInheritedRulesInvalidationRepository unitComputedInheritedRulesInvalidationRepository,
        EvidenceAuditReportRepository evidenceAuditReportRepository); @VisibleForTesting  BatchReportServiceImpl(
        EliminationActionUnitRepository eliminationActionUnitRepository,
        PurgeUnitRepository purgeUnitRepository,
        PurgeObjectGroupRepository purgeObjectGroupRepository,
        TransferReplyUnitRepository transferReplyUnitRepository,
        UpdateUnitReportRepository updateUnitReportRepository,
        WorkspaceClientFactory workspaceClientFactory,
        PreservationReportRepository preservationReportRepository,
        AuditReportRepository auditReportRepository,
        UnitComputedInheritedRulesInvalidationRepository unitComputedInheritedRulesInvalidationRepository,
        EvidenceAuditReportRepository evidenceAuditReportRepository); void appendEliminationActionUnitReport(String processId, List<EliminationActionUnitReportEntry> entries,
        int tenantId); void appendPurgeUnitReport(String processId, List<PurgeUnitReportEntry> entries,
        int tenantId); void appendPurgeObjectGroupReport(String processId,
        List<PurgeObjectGroupReportEntry> entries, int tenantId); void appendTransferReplyUnitReport(String processId, List<TransferReplyUnitReportEntry> entries,
        int tenantId); void appendPreservationReport(String processId, List<PreservationReportEntry> preservationEntries,
        int tenantId); void appendUnitReport(List<UpdateUnitMetadataReportEntry> unitEntries); void appendUnitComputedInheritedRulesInvalidationReport(String processId,
        List<UnitComputedInheritedRulesInvalidationReportEntry> unitEntries, int tenantId); void deleteUnitComputedInheritedRulesInvalidationReport(String processId, int tenantId); void exportUnitsToInvalidate(String processId, int tenantId, ReportExportRequest reportExportRequest); void appendAuditReport(String processId, List<AuditObjectGroupReportEntry> auditEntries, int tenantId); void appendEvidenceAuditReport(String processId, List<EvidenceAuditReportEntry> auditEntries, int tenantId); void storeReportToWorkspace(Report reportInfo); void exportPurgeDistinctObjectGroupOfDeletedUnits(String processId, String filename,
        int tenantId); void exportPurgeAccessionRegister(String processId, String filename, int tenantId); void deleteEliminationUnitByProcessId(String processId, int tenantId); void deletePurgeUnitByProcessId(String processId, int tenantId); void deletePurgeObjectGroupByIdAndTenant(String processId, int tenantId); void deleteTransferReplyUnitByProcessId(String processId, int tenantId); void deletePreservationByIdAndTenant(String processId, int tenantId); void deleteAuditByIdAndTenant(String processId, int tenantId); void deleteUpdateUnitByIdAndTenant(String processId, int tenantId); void deleteEvidenceAuditByIdAndTenant(String processId, int tenantId); }
BatchReportServiceImpl { public void exportUnitsToInvalidate(String processId, int tenantId, ReportExportRequest reportExportRequest) throws IOException, ContentAddressableStorageServerException { File file = Files.createFile(Paths.get(VitamConfiguration.getVitamTmpFolder(), reportExportRequest.getFilename())) .toFile(); try { try ( OutputStream outputStream = new FileOutputStream(file); JsonLineWriter jsonLineWriter = new JsonLineWriter(outputStream); CloseableIterator<Document> units = unitComputedInheritedRulesInvalidationRepository .findCollectionByProcessIdTenant(processId, tenantId)) { while (units.hasNext()) { Document unit = units.next(); jsonLineWriter.addEntry(new JsonLineModel((String) unit.get("id"))); } } transferDocumentToWorkspace(processId, reportExportRequest.getFilename(), file); } finally { deleteQuietly(file); } } BatchReportServiceImpl(EliminationActionUnitRepository eliminationActionUnitRepository,
        PurgeUnitRepository purgeUnitRepository, PurgeObjectGroupRepository purgeObjectGroupRepository,
        TransferReplyUnitRepository transferReplyUnitRepository, WorkspaceClientFactory workspaceClientFactory,
        PreservationReportRepository preservationReportRepository,
        AuditReportRepository auditReportRepository,
        UpdateUnitReportRepository updateUnitReportRepository,
        UnitComputedInheritedRulesInvalidationRepository unitComputedInheritedRulesInvalidationRepository,
        EvidenceAuditReportRepository evidenceAuditReportRepository); @VisibleForTesting  BatchReportServiceImpl(
        EliminationActionUnitRepository eliminationActionUnitRepository,
        PurgeUnitRepository purgeUnitRepository,
        PurgeObjectGroupRepository purgeObjectGroupRepository,
        TransferReplyUnitRepository transferReplyUnitRepository,
        UpdateUnitReportRepository updateUnitReportRepository,
        WorkspaceClientFactory workspaceClientFactory,
        PreservationReportRepository preservationReportRepository,
        AuditReportRepository auditReportRepository,
        UnitComputedInheritedRulesInvalidationRepository unitComputedInheritedRulesInvalidationRepository,
        EvidenceAuditReportRepository evidenceAuditReportRepository); void appendEliminationActionUnitReport(String processId, List<EliminationActionUnitReportEntry> entries,
        int tenantId); void appendPurgeUnitReport(String processId, List<PurgeUnitReportEntry> entries,
        int tenantId); void appendPurgeObjectGroupReport(String processId,
        List<PurgeObjectGroupReportEntry> entries, int tenantId); void appendTransferReplyUnitReport(String processId, List<TransferReplyUnitReportEntry> entries,
        int tenantId); void appendPreservationReport(String processId, List<PreservationReportEntry> preservationEntries,
        int tenantId); void appendUnitReport(List<UpdateUnitMetadataReportEntry> unitEntries); void appendUnitComputedInheritedRulesInvalidationReport(String processId,
        List<UnitComputedInheritedRulesInvalidationReportEntry> unitEntries, int tenantId); void deleteUnitComputedInheritedRulesInvalidationReport(String processId, int tenantId); void exportUnitsToInvalidate(String processId, int tenantId, ReportExportRequest reportExportRequest); void appendAuditReport(String processId, List<AuditObjectGroupReportEntry> auditEntries, int tenantId); void appendEvidenceAuditReport(String processId, List<EvidenceAuditReportEntry> auditEntries, int tenantId); void storeReportToWorkspace(Report reportInfo); void exportPurgeDistinctObjectGroupOfDeletedUnits(String processId, String filename,
        int tenantId); void exportPurgeAccessionRegister(String processId, String filename, int tenantId); void deleteEliminationUnitByProcessId(String processId, int tenantId); void deletePurgeUnitByProcessId(String processId, int tenantId); void deletePurgeObjectGroupByIdAndTenant(String processId, int tenantId); void deleteTransferReplyUnitByProcessId(String processId, int tenantId); void deletePreservationByIdAndTenant(String processId, int tenantId); void deleteAuditByIdAndTenant(String processId, int tenantId); void deleteUpdateUnitByIdAndTenant(String processId, int tenantId); void deleteEvidenceAuditByIdAndTenant(String processId, int tenantId);  }