@Test public void downloadAndExtractDataFromStorage() throws Exception { EvidenceService evidenceService = new EvidenceService(metaDataClientFactory, logbookOperationsClientFactory, logbookLifeCyclesClientFactory, storageClientFactory); try (InputStream in = PropertiesUtils .getResourceAsStream("evidenceAudit/0_LogbookLifecycles_20180220_111512.zip")) { Response responseMock = mock(BuiltResponse.class); doReturn(in).when(responseMock).readEntity(eq(InputStream.class)); when(storageClient.getContainerAsync(eq(VitamConfiguration.getDefaultStrategy()), anyString(), eq(DataCategory.LOGBOOK), any())) .thenReturn(responseMock); assertThat(evidenceService.downloadAndExtractDataFromStorage("0_LogbookLifecycles_20180220_111512.zip", "data.txt", ".zip", true)) .isNotNull(); when(storageClient .getContainerAsync(VitamConfiguration.getDefaultStrategy(), "test", DataCategory.LOGBOOK, AccessLogUtils.getNoLogAccessLog())) .thenThrow(StorageNotFoundException.class); assertThatThrownBy(() -> evidenceService.downloadAndExtractDataFromStorage("test", "data.txt", ".zip", true)) .isInstanceOf(EvidenceAuditException.class) .hasMessage("Could not retrieve traceability zip file 'test'"); } }
public File downloadAndExtractDataFromStorage(String fileName, String fileToExtract, String extension,boolean delele) throws EvidenceAuditException { File traceabilityFile = downloadFileInTemporaryFolder(fileName, extension); return extractFileStreamFromZip(traceabilityFile, fileToExtract, extension, delele ); }
EvidenceService { public File downloadAndExtractDataFromStorage(String fileName, String fileToExtract, String extension,boolean delele) throws EvidenceAuditException { File traceabilityFile = downloadFileInTemporaryFolder(fileName, extension); return extractFileStreamFromZip(traceabilityFile, fileToExtract, extension, delele ); } }
EvidenceService { public File downloadAndExtractDataFromStorage(String fileName, String fileToExtract, String extension,boolean delele) throws EvidenceAuditException { File traceabilityFile = downloadFileInTemporaryFolder(fileName, extension); return extractFileStreamFromZip(traceabilityFile, fileToExtract, extension, delele ); } EvidenceService(); @VisibleForTesting  EvidenceService(MetaDataClientFactory metaDataClientFactory,
        LogbookOperationsClientFactory logbookOperationsClientFactory,
        LogbookLifeCyclesClientFactory logbookLifeCyclesClientFactory,
        StorageClientFactory storageClientFactory); }
EvidenceService { public File downloadAndExtractDataFromStorage(String fileName, String fileToExtract, String extension,boolean delele) throws EvidenceAuditException { File traceabilityFile = downloadFileInTemporaryFolder(fileName, extension); return extractFileStreamFromZip(traceabilityFile, fileToExtract, extension, delele ); } EvidenceService(); @VisibleForTesting  EvidenceService(MetaDataClientFactory metaDataClientFactory,
        LogbookOperationsClientFactory logbookOperationsClientFactory,
        LogbookLifeCyclesClientFactory logbookLifeCyclesClientFactory,
        StorageClientFactory storageClientFactory); EvidenceAuditReportLine auditAndGenerateReportIfKo(EvidenceAuditParameters parameters,
        List<String> securedLines,
        String id); File downloadAndExtractDataFromStorage(String fileName, String fileToExtract, String extension,boolean delele); static LifeCycleTraceabilitySecureFileObject loadInformationFromFile(List<String> securedLines,
        MetadataType metadataType,
        String id); File extractFileStreamFromZip(File file, String fileToExtract, String extension, boolean delete); EvidenceAuditParameters evidenceAuditsChecks(String id, MetadataType metadataType, List<StorageStrategy> storageStrategies); }
EvidenceService { public File downloadAndExtractDataFromStorage(String fileName, String fileToExtract, String extension,boolean delele) throws EvidenceAuditException { File traceabilityFile = downloadFileInTemporaryFolder(fileName, extension); return extractFileStreamFromZip(traceabilityFile, fileToExtract, extension, delele ); } EvidenceService(); @VisibleForTesting  EvidenceService(MetaDataClientFactory metaDataClientFactory,
        LogbookOperationsClientFactory logbookOperationsClientFactory,
        LogbookLifeCyclesClientFactory logbookLifeCyclesClientFactory,
        StorageClientFactory storageClientFactory); EvidenceAuditReportLine auditAndGenerateReportIfKo(EvidenceAuditParameters parameters,
        List<String> securedLines,
        String id); File downloadAndExtractDataFromStorage(String fileName, String fileToExtract, String extension,boolean delele); static LifeCycleTraceabilitySecureFileObject loadInformationFromFile(List<String> securedLines,
        MetadataType metadataType,
        String id); File extractFileStreamFromZip(File file, String fileToExtract, String extension, boolean delete); EvidenceAuditParameters evidenceAuditsChecks(String id, MetadataType metadataType, List<StorageStrategy> storageStrategies); static final String JSON; static final String OK; static final String WARNING; }