@Test public void should_export_distinct_object_group_of_deleted_units() throws Exception { when(workspaceClientFactory.getClient()).thenReturn(workspaceClient); String objectGroupId = "aeaaaaaaaafr5hk6abgeualfvd6jsniaaaaq"; File folder = this.folder.newFolder(); Path report = Paths.get(folder.getAbsolutePath(), "distinct_objectgroup.json"); initialiseMockWhenPutObjectInWorkspace(report); when(emptyMongoCursor.next()).thenReturn(objectGroupId); when(emptyMongoCursor.hasNext()).thenReturn(true).thenReturn(false); when(purgeUnitRepository.distinctObjectGroupOfDeletedUnits(PROCESS_ID, TENANT_ID)) .thenReturn(emptyMongoCursor); when(workspaceClient.isExistingContainer(PROCESS_ID)).thenReturn(true); batchReportServiceImpl .exportPurgeDistinctObjectGroupOfDeletedUnits(PROCESS_ID, "distinct_objectgroup_report", TENANT_ID); try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(report.toFile())))) { while (reader.ready()) { String line = reader.readLine(); assertThat(line).isNotNull(); } } }
public void exportPurgeDistinctObjectGroupOfDeletedUnits(String processId, String filename, int tenantId) throws IOException, ContentAddressableStorageServerException { File tempFile = File.createTempFile(filename, JSONL_EXTENSION, new File(VitamConfiguration.getVitamTmpFolder())); try (MongoCursor<String> iterator = purgeUnitRepository .distinctObjectGroupOfDeletedUnits(processId, tenantId)) { createFileFromMongoCursorWithString(tempFile, iterator); transferDocumentToWorkspace(processId, filename, tempFile); } finally { deleteQuietly(tempFile); } }
BatchReportServiceImpl { public void exportPurgeDistinctObjectGroupOfDeletedUnits(String processId, String filename, int tenantId) throws IOException, ContentAddressableStorageServerException { File tempFile = File.createTempFile(filename, JSONL_EXTENSION, new File(VitamConfiguration.getVitamTmpFolder())); try (MongoCursor<String> iterator = purgeUnitRepository .distinctObjectGroupOfDeletedUnits(processId, tenantId)) { createFileFromMongoCursorWithString(tempFile, iterator); transferDocumentToWorkspace(processId, filename, tempFile); } finally { deleteQuietly(tempFile); } } }
BatchReportServiceImpl { public void exportPurgeDistinctObjectGroupOfDeletedUnits(String processId, String filename, int tenantId) throws IOException, ContentAddressableStorageServerException { File tempFile = File.createTempFile(filename, JSONL_EXTENSION, new File(VitamConfiguration.getVitamTmpFolder())); try (MongoCursor<String> iterator = purgeUnitRepository .distinctObjectGroupOfDeletedUnits(processId, tenantId)) { createFileFromMongoCursorWithString(tempFile, iterator); transferDocumentToWorkspace(processId, filename, tempFile); } finally { deleteQuietly(tempFile); } } 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 exportPurgeDistinctObjectGroupOfDeletedUnits(String processId, String filename, int tenantId) throws IOException, ContentAddressableStorageServerException { File tempFile = File.createTempFile(filename, JSONL_EXTENSION, new File(VitamConfiguration.getVitamTmpFolder())); try (MongoCursor<String> iterator = purgeUnitRepository .distinctObjectGroupOfDeletedUnits(processId, tenantId)) { createFileFromMongoCursorWithString(tempFile, iterator); transferDocumentToWorkspace(processId, filename, tempFile); } finally { deleteQuietly(tempFile); } } 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 exportPurgeDistinctObjectGroupOfDeletedUnits(String processId, String filename, int tenantId) throws IOException, ContentAddressableStorageServerException { File tempFile = File.createTempFile(filename, JSONL_EXTENSION, new File(VitamConfiguration.getVitamTmpFolder())); try (MongoCursor<String> iterator = purgeUnitRepository .distinctObjectGroupOfDeletedUnits(processId, tenantId)) { createFileFromMongoCursorWithString(tempFile, iterator); transferDocumentToWorkspace(processId, filename, tempFile); } finally { deleteQuietly(tempFile); } } 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);  }