@Test @RunWithCustomExecutor public void exportDistinctObjectGroups() throws Exception { InputStream is = PropertiesUtils .getResourceAsStream("EliminationAction/EliminationActionUnitReportService/unitObjectGroups.jsonl"); Response response = mock(Response.class); doReturn(is).when(response).readEntity(InputStream.class); doReturn(response).when(workspaceClient).getObject(PROC_ID, DISTINCT_REPORT_JSONL); CloseableIterator<String> entries = instance.exportDistinctObjectGroups(PROC_ID); ArgumentCaptor<ReportExportRequest> reportExportRequestArgumentCaptor = ArgumentCaptor.forClass(ReportExportRequest.class); verify(batchReportClient).generatePurgeDistinctObjectGroupInUnitReport(eq(PROC_ID), reportExportRequestArgumentCaptor.capture()); assertThat(reportExportRequestArgumentCaptor.getValue().getFilename()) .isEqualTo(DISTINCT_REPORT_JSONL); assertThat(IteratorUtils.toList(entries)).containsExactly("got1", "got2"); }
public CloseableIterator<String> exportDistinctObjectGroups(String processId) throws ProcessingStatusException { try (BatchReportClient batchReportClient = batchReportClientFactory.getClient()) { batchReportClient.generatePurgeDistinctObjectGroupInUnitReport(processId, new ReportExportRequest(DISTINCT_REPORT_JSONL)); } catch (VitamClientInternalException e) { throw new ProcessingStatusException(StatusCode.FATAL, "Could not generate distinct object group report for deleted units to workspace", e); } try (WorkspaceClient workspaceClient = workspaceClientFactory.getClient()) { Response reportResponse = workspaceClient.getObject(processId, DISTINCT_REPORT_JSONL); JsonLineIterator jsonLineIterator = new JsonLineIterator(new VitamAsyncInputStream(reportResponse)); return CloseableIteratorUtils.map(jsonLineIterator, JsonLineModel::getId); } catch (ContentAddressableStorageServerException | ContentAddressableStorageNotFoundException e) { throw new ProcessingStatusException(StatusCode.FATAL, "Could not load report from workspace", e); } }
PurgeReportService { public CloseableIterator<String> exportDistinctObjectGroups(String processId) throws ProcessingStatusException { try (BatchReportClient batchReportClient = batchReportClientFactory.getClient()) { batchReportClient.generatePurgeDistinctObjectGroupInUnitReport(processId, new ReportExportRequest(DISTINCT_REPORT_JSONL)); } catch (VitamClientInternalException e) { throw new ProcessingStatusException(StatusCode.FATAL, "Could not generate distinct object group report for deleted units to workspace", e); } try (WorkspaceClient workspaceClient = workspaceClientFactory.getClient()) { Response reportResponse = workspaceClient.getObject(processId, DISTINCT_REPORT_JSONL); JsonLineIterator jsonLineIterator = new JsonLineIterator(new VitamAsyncInputStream(reportResponse)); return CloseableIteratorUtils.map(jsonLineIterator, JsonLineModel::getId); } catch (ContentAddressableStorageServerException | ContentAddressableStorageNotFoundException e) { throw new ProcessingStatusException(StatusCode.FATAL, "Could not load report from workspace", e); } } }
PurgeReportService { public CloseableIterator<String> exportDistinctObjectGroups(String processId) throws ProcessingStatusException { try (BatchReportClient batchReportClient = batchReportClientFactory.getClient()) { batchReportClient.generatePurgeDistinctObjectGroupInUnitReport(processId, new ReportExportRequest(DISTINCT_REPORT_JSONL)); } catch (VitamClientInternalException e) { throw new ProcessingStatusException(StatusCode.FATAL, "Could not generate distinct object group report for deleted units to workspace", e); } try (WorkspaceClient workspaceClient = workspaceClientFactory.getClient()) { Response reportResponse = workspaceClient.getObject(processId, DISTINCT_REPORT_JSONL); JsonLineIterator jsonLineIterator = new JsonLineIterator(new VitamAsyncInputStream(reportResponse)); return CloseableIteratorUtils.map(jsonLineIterator, JsonLineModel::getId); } catch (ContentAddressableStorageServerException | ContentAddressableStorageNotFoundException e) { throw new ProcessingStatusException(StatusCode.FATAL, "Could not load report from workspace", e); } } PurgeReportService(); @VisibleForTesting  PurgeReportService(
        BatchReportClientFactory batchReportClientFactory,
        WorkspaceClientFactory workspaceClientFactory); }
PurgeReportService { public CloseableIterator<String> exportDistinctObjectGroups(String processId) throws ProcessingStatusException { try (BatchReportClient batchReportClient = batchReportClientFactory.getClient()) { batchReportClient.generatePurgeDistinctObjectGroupInUnitReport(processId, new ReportExportRequest(DISTINCT_REPORT_JSONL)); } catch (VitamClientInternalException e) { throw new ProcessingStatusException(StatusCode.FATAL, "Could not generate distinct object group report for deleted units to workspace", e); } try (WorkspaceClient workspaceClient = workspaceClientFactory.getClient()) { Response reportResponse = workspaceClient.getObject(processId, DISTINCT_REPORT_JSONL); JsonLineIterator jsonLineIterator = new JsonLineIterator(new VitamAsyncInputStream(reportResponse)); return CloseableIteratorUtils.map(jsonLineIterator, JsonLineModel::getId); } catch (ContentAddressableStorageServerException | ContentAddressableStorageNotFoundException e) { throw new ProcessingStatusException(StatusCode.FATAL, "Could not load report from workspace", e); } } PurgeReportService(); @VisibleForTesting  PurgeReportService(
        BatchReportClientFactory batchReportClientFactory,
        WorkspaceClientFactory workspaceClientFactory); void appendUnitEntries(String processId, List<PurgeUnitReportEntry> entries); void appendObjectGroupEntries(String processId, List<PurgeObjectGroupReportEntry> entries); CloseableIterator<String> exportDistinctObjectGroups(String processId); void exportAccessionRegisters(String processId); void cleanupReport(String processId); }
PurgeReportService { public CloseableIterator<String> exportDistinctObjectGroups(String processId) throws ProcessingStatusException { try (BatchReportClient batchReportClient = batchReportClientFactory.getClient()) { batchReportClient.generatePurgeDistinctObjectGroupInUnitReport(processId, new ReportExportRequest(DISTINCT_REPORT_JSONL)); } catch (VitamClientInternalException e) { throw new ProcessingStatusException(StatusCode.FATAL, "Could not generate distinct object group report for deleted units to workspace", e); } try (WorkspaceClient workspaceClient = workspaceClientFactory.getClient()) { Response reportResponse = workspaceClient.getObject(processId, DISTINCT_REPORT_JSONL); JsonLineIterator jsonLineIterator = new JsonLineIterator(new VitamAsyncInputStream(reportResponse)); return CloseableIteratorUtils.map(jsonLineIterator, JsonLineModel::getId); } catch (ContentAddressableStorageServerException | ContentAddressableStorageNotFoundException e) { throw new ProcessingStatusException(StatusCode.FATAL, "Could not load report from workspace", e); } } PurgeReportService(); @VisibleForTesting  PurgeReportService(
        BatchReportClientFactory batchReportClientFactory,
        WorkspaceClientFactory workspaceClientFactory); void appendUnitEntries(String processId, List<PurgeUnitReportEntry> entries); void appendObjectGroupEntries(String processId, List<PurgeObjectGroupReportEntry> entries); CloseableIterator<String> exportDistinctObjectGroups(String processId); void exportAccessionRegisters(String processId); void cleanupReport(String processId);  }