@Test public void should_store_evidence_audit_report() throws Exception { String processId = "aeaaaaaaaafpuagsab43oallwisewyaaaaaq"; when(workspaceClientFactory.getClient()).thenReturn(workspaceClient); when(workspaceClient.isExistingContainer(processId)).thenReturn(true); String filename = String.format("report.jsonl", processId); Path report = initialisePathWithFileName(filename); when(storageClientFactory.getClient()).thenReturn(storageClient); when(storageClient.storeFileFromWorkspace(anyString(), any(), anyString(), any())).thenReturn(null); EvidenceAuditStatsModel auditStatus = new EvidenceAuditStatsModel(1, 0, 1, new EvidenceAuditFullStatusCount()); Document evidenceAuditData = getEvidenceAuditDocument(processId); FakeMongoCursor<Document> fakeMongoCursor = new FakeMongoCursor<>(Collections.singletonList(evidenceAuditData)); initialiseMockWhenPutAtomicObjectInWorkspace(report); when(evidenceAuditReportRepository.findCollectionByProcessIdTenantAndStatus(processId, TENANT_ID, EvidenceStatus.WARN.name(), EvidenceStatus.KO.name())) .thenReturn(fakeMongoCursor); when(evidenceAuditReportRepository.stats(processId, TENANT_ID)).thenReturn(auditStatus); OperationSummary operationSummary = new OperationSummary(TENANT_ID, processId, "", "", "", "", JsonHandler.createObjectNode(), JsonHandler.createObjectNode()); ReportResults reportResults = new ReportResults(1, 0, 0, 1); ReportSummary reportSummary = new ReportSummary(null, null, ReportType.EVIDENCE_AUDIT, reportResults, JsonHandler.createObjectNode()); JsonNode context = JsonHandler.createObjectNode(); Report reportInfo = new Report(operationSummary, reportSummary, context); batchReportServiceImpl.storeReportToWorkspace(reportInfo); reportSummary.setExtendedInfo(JsonHandler.toJsonNode(auditStatus)); String accumulatorExpected = JsonHandler.unprettyPrint(operationSummary) + "\n" + JsonHandler.unprettyPrint(reportSummary) + "\n" + JsonHandler.unprettyPrint(context) + "\n" + BsonHelper.stringify(evidenceAuditData); assertThat(new String(Files.readAllBytes(report))).isEqualTo(accumulatorExpected); }
private void storeReportToWorkspace(String processId, File report) throws IOException, ContentAddressableStorageServerException { try (WorkspaceClient workspaceClient = workspaceClientFactory.getClient(); InputStream inputStream = new FileInputStream(report)) { workspaceClient.putAtomicObject(processId, REPORT_JSONL, inputStream, report.length()); } }
BatchReportServiceImpl { private void storeReportToWorkspace(String processId, File report) throws IOException, ContentAddressableStorageServerException { try (WorkspaceClient workspaceClient = workspaceClientFactory.getClient(); InputStream inputStream = new FileInputStream(report)) { workspaceClient.putAtomicObject(processId, REPORT_JSONL, inputStream, report.length()); } } }
BatchReportServiceImpl { private void storeReportToWorkspace(String processId, File report) throws IOException, ContentAddressableStorageServerException { try (WorkspaceClient workspaceClient = workspaceClientFactory.getClient(); InputStream inputStream = new FileInputStream(report)) { workspaceClient.putAtomicObject(processId, REPORT_JSONL, inputStream, report.length()); } } 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 { private void storeReportToWorkspace(String processId, File report) throws IOException, ContentAddressableStorageServerException { try (WorkspaceClient workspaceClient = workspaceClientFactory.getClient(); InputStream inputStream = new FileInputStream(report)) { workspaceClient.putAtomicObject(processId, REPORT_JSONL, inputStream, report.length()); } } 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 { private void storeReportToWorkspace(String processId, File report) throws IOException, ContentAddressableStorageServerException { try (WorkspaceClient workspaceClient = workspaceClientFactory.getClient(); InputStream inputStream = new FileInputStream(report)) { workspaceClient.putAtomicObject(processId, REPORT_JSONL, inputStream, report.length()); } } 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);  }