@RunWithCustomExecutor @Test public void WhenTransferWorkflowthenStoreOnTransfersContainer() throws Exception { VitamThreadUtils.getVitamSession().setTenantId(2); String requestId = GUIDFactory.newRequestIdGUID(2).toString(); VitamThreadUtils.getVitamSession().setRequestId(requestId); HandlerIO handlerIO = mock(HandlerIO.class); WorkspaceClientFactory workspaceClientFactory = mock(WorkspaceClientFactory.class); WorkspaceClient workspaceClient = mock(WorkspaceClient.class); doReturn(workspaceClientFactory).when(handlerIO).getWorkspaceClientFactory(); doReturn(workspaceClient).when(workspaceClientFactory).getClient(); WorkerParameters params = mock(WorkerParameters.class); doReturn(requestId).when(params).getContainerName(); doReturn(requestId).when(handlerIO).getContainerName(); doReturn(ARCHIVE_TRANSFER).when(params).getWorkflowIdentifier(); StorageClientFactory storageClientFactory = mock(StorageClientFactory.class); StorageClient storageClient = mock(StorageClient.class); doReturn(storageClient).when(storageClientFactory).getClient(); StoreExports storeExports = new StoreExports(storageClientFactory); storeExports.execute(params, handlerIO); verify(workspaceClient).createContainer(TRANSFER_CONTAINER); verify(workspaceClient).createFolder(TRANSFER_CONTAINER, "2"); ArgumentCaptor<CompressInformation> compressInformationArgumentCaptor = ArgumentCaptor.forClass(CompressInformation.class); verify(workspaceClient).compress(eq(requestId), compressInformationArgumentCaptor.capture()); assertThat(compressInformationArgumentCaptor.getValue().getFiles()) .isEqualTo(Arrays.asList(SEDA_FILE, StoreExports.CONTENT)); assertThat(compressInformationArgumentCaptor.getValue().getOutputFile()).isEqualTo("2/" + requestId); assertThat(compressInformationArgumentCaptor.getValue().getOutputContainer()).isEqualTo(TRANSFER_CONTAINER); ArgumentCaptor<ObjectDescription> objectDescriptionArgumentCaptor = ArgumentCaptor.forClass(ObjectDescription.class); String reportName = VitamThreadUtils.getVitamSession().getRequestId() + ".jsonl"; verify(storageClient).storeFileFromWorkspace(eq(VitamConfiguration.getDefaultStrategy()), eq(REPORT), eq(reportName), objectDescriptionArgumentCaptor.capture()); ObjectDescription description = objectDescriptionArgumentCaptor.getValue(); assertThat(description.getWorkspaceContainerGUID()).isEqualTo( VitamThreadUtils.getVitamSession().getRequestId()); assertThat(description.getWorkspaceObjectURI()).isEqualTo(reportName); }
@Override public ItemStatus execute(WorkerParameters params, HandlerIO handler) throws ProcessingException { String container; String statusAction; if (isTransferWorkflow(params)) { container = TRANSFER_CONTAINER; statusAction = TRANSFER_DIP; } else { container = DIP_CONTAINER; statusAction = STORE_DIP; } final ItemStatus itemStatus = new ItemStatus(statusAction); try { String tenantFolder = Integer.toString(VitamThreadUtils.getVitamSession().getTenantId()); String zipFileName = params.getContainerName(); if (isTransferWorkflow(params)) { storeReportToOffers(params.getContainerName()); } zipWorkspace(handler, tenantFolder, zipFileName, container); itemStatus.increment(StatusCode.OK); } catch (ContentAddressableStorageException | StorageAlreadyExistsClientException | StorageNotFoundClientException | StorageServerClientException e) { throw new ProcessingException(e); } return new ItemStatus(statusAction).setItemsStatus(statusAction, itemStatus); }
StoreExports extends ActionHandler { @Override public ItemStatus execute(WorkerParameters params, HandlerIO handler) throws ProcessingException { String container; String statusAction; if (isTransferWorkflow(params)) { container = TRANSFER_CONTAINER; statusAction = TRANSFER_DIP; } else { container = DIP_CONTAINER; statusAction = STORE_DIP; } final ItemStatus itemStatus = new ItemStatus(statusAction); try { String tenantFolder = Integer.toString(VitamThreadUtils.getVitamSession().getTenantId()); String zipFileName = params.getContainerName(); if (isTransferWorkflow(params)) { storeReportToOffers(params.getContainerName()); } zipWorkspace(handler, tenantFolder, zipFileName, container); itemStatus.increment(StatusCode.OK); } catch (ContentAddressableStorageException | StorageAlreadyExistsClientException | StorageNotFoundClientException | StorageServerClientException e) { throw new ProcessingException(e); } return new ItemStatus(statusAction).setItemsStatus(statusAction, itemStatus); } }
StoreExports extends ActionHandler { @Override public ItemStatus execute(WorkerParameters params, HandlerIO handler) throws ProcessingException { String container; String statusAction; if (isTransferWorkflow(params)) { container = TRANSFER_CONTAINER; statusAction = TRANSFER_DIP; } else { container = DIP_CONTAINER; statusAction = STORE_DIP; } final ItemStatus itemStatus = new ItemStatus(statusAction); try { String tenantFolder = Integer.toString(VitamThreadUtils.getVitamSession().getTenantId()); String zipFileName = params.getContainerName(); if (isTransferWorkflow(params)) { storeReportToOffers(params.getContainerName()); } zipWorkspace(handler, tenantFolder, zipFileName, container); itemStatus.increment(StatusCode.OK); } catch (ContentAddressableStorageException | StorageAlreadyExistsClientException | StorageNotFoundClientException | StorageServerClientException e) { throw new ProcessingException(e); } return new ItemStatus(statusAction).setItemsStatus(statusAction, itemStatus); } StoreExports(); @VisibleForTesting  StoreExports(StorageClientFactory storageClientFactory); }
StoreExports extends ActionHandler { @Override public ItemStatus execute(WorkerParameters params, HandlerIO handler) throws ProcessingException { String container; String statusAction; if (isTransferWorkflow(params)) { container = TRANSFER_CONTAINER; statusAction = TRANSFER_DIP; } else { container = DIP_CONTAINER; statusAction = STORE_DIP; } final ItemStatus itemStatus = new ItemStatus(statusAction); try { String tenantFolder = Integer.toString(VitamThreadUtils.getVitamSession().getTenantId()); String zipFileName = params.getContainerName(); if (isTransferWorkflow(params)) { storeReportToOffers(params.getContainerName()); } zipWorkspace(handler, tenantFolder, zipFileName, container); itemStatus.increment(StatusCode.OK); } catch (ContentAddressableStorageException | StorageAlreadyExistsClientException | StorageNotFoundClientException | StorageServerClientException e) { throw new ProcessingException(e); } return new ItemStatus(statusAction).setItemsStatus(statusAction, itemStatus); } StoreExports(); @VisibleForTesting  StoreExports(StorageClientFactory storageClientFactory); @Override ItemStatus execute(WorkerParameters params, HandlerIO handler); @Override void checkMandatoryIOParameter(HandlerIO handler); }
StoreExports extends ActionHandler { @Override public ItemStatus execute(WorkerParameters params, HandlerIO handler) throws ProcessingException { String container; String statusAction; if (isTransferWorkflow(params)) { container = TRANSFER_CONTAINER; statusAction = TRANSFER_DIP; } else { container = DIP_CONTAINER; statusAction = STORE_DIP; } final ItemStatus itemStatus = new ItemStatus(statusAction); try { String tenantFolder = Integer.toString(VitamThreadUtils.getVitamSession().getTenantId()); String zipFileName = params.getContainerName(); if (isTransferWorkflow(params)) { storeReportToOffers(params.getContainerName()); } zipWorkspace(handler, tenantFolder, zipFileName, container); itemStatus.increment(StatusCode.OK); } catch (ContentAddressableStorageException | StorageAlreadyExistsClientException | StorageNotFoundClientException | StorageServerClientException e) { throw new ProcessingException(e); } return new ItemStatus(statusAction).setItemsStatus(statusAction, itemStatus); } StoreExports(); @VisibleForTesting  StoreExports(StorageClientFactory storageClientFactory); @Override ItemStatus execute(WorkerParameters params, HandlerIO handler); @Override void checkMandatoryIOParameter(HandlerIO handler); static final String TRANSFER_CONTAINER; }