@Test public void should_save_metadata_and_lfc_in_storage() throws Exception { InputStream stream = getClass().getResourceAsStream("/preservation/objectGroup.json"); JsonNode document = JsonHandler.getFromInputStream(stream); RequestResponse<JsonNode> responseOK = new RequestResponseOK<JsonNode>().addResult(document) .setHttpCode(Response.Status.OK.getStatusCode()); given(metaDataClient.getObjectGroupByIdRaw(GOT_ID)).willReturn(responseOK); given(logbookClient.getRawObjectGroupLifeCycleById(GOT_ID)).willReturn(document); List<ItemStatus> itemStatus = plugin.executeList(parameter, handlerIO); assertThat(itemStatus).extracting(ItemStatus::getGlobalStatus).containsOnly(StatusCode.OK); verify(storageClient).storeFileFromWorkspace(eq("other_got_strategy"), eq(DataCategory.OBJECTGROUP), eq(GOT_ID + ".json"), any()); }
@Override public List<ItemStatus> executeList(WorkerParameters param, HandlerIO handler) throws ProcessingException { final ItemStatus itemStatus = new ItemStatus(PRESERVATION_STORAGE_METADATA_LFC); WorkflowBatchResults results = (WorkflowBatchResults) handler.getInput(WORKFLOWBATCHRESULTS_IN_MEMORY); List<ItemStatus> itemStatuses = new ArrayList<>(); List<WorkflowBatchResult> workflowBatchResults = results.getWorkflowBatchResults(); for (WorkflowBatchResult result : workflowBatchResults) { List<WorkflowBatchResult.OutputExtra> outputExtras = result.getOutputExtras().stream() .filter(WorkflowBatchResult.OutputExtra::isOkAndGenerated) .collect(Collectors.toList()); if (outputExtras.isEmpty()) { itemStatuses.add(new ItemStatus(PRESERVATION_STORAGE_METADATA_LFC)); continue; } itemStatuses.add(saveDocumentWithLfcInStorage(result.getGotId(), handler, param.getContainerName(), itemStatus)); } return itemStatuses; }
PreservationStorageMetadataAndLfc extends StoreMetadataObjectActionHandler { @Override public List<ItemStatus> executeList(WorkerParameters param, HandlerIO handler) throws ProcessingException { final ItemStatus itemStatus = new ItemStatus(PRESERVATION_STORAGE_METADATA_LFC); WorkflowBatchResults results = (WorkflowBatchResults) handler.getInput(WORKFLOWBATCHRESULTS_IN_MEMORY); List<ItemStatus> itemStatuses = new ArrayList<>(); List<WorkflowBatchResult> workflowBatchResults = results.getWorkflowBatchResults(); for (WorkflowBatchResult result : workflowBatchResults) { List<WorkflowBatchResult.OutputExtra> outputExtras = result.getOutputExtras().stream() .filter(WorkflowBatchResult.OutputExtra::isOkAndGenerated) .collect(Collectors.toList()); if (outputExtras.isEmpty()) { itemStatuses.add(new ItemStatus(PRESERVATION_STORAGE_METADATA_LFC)); continue; } itemStatuses.add(saveDocumentWithLfcInStorage(result.getGotId(), handler, param.getContainerName(), itemStatus)); } return itemStatuses; } }
PreservationStorageMetadataAndLfc extends StoreMetadataObjectActionHandler { @Override public List<ItemStatus> executeList(WorkerParameters param, HandlerIO handler) throws ProcessingException { final ItemStatus itemStatus = new ItemStatus(PRESERVATION_STORAGE_METADATA_LFC); WorkflowBatchResults results = (WorkflowBatchResults) handler.getInput(WORKFLOWBATCHRESULTS_IN_MEMORY); List<ItemStatus> itemStatuses = new ArrayList<>(); List<WorkflowBatchResult> workflowBatchResults = results.getWorkflowBatchResults(); for (WorkflowBatchResult result : workflowBatchResults) { List<WorkflowBatchResult.OutputExtra> outputExtras = result.getOutputExtras().stream() .filter(WorkflowBatchResult.OutputExtra::isOkAndGenerated) .collect(Collectors.toList()); if (outputExtras.isEmpty()) { itemStatuses.add(new ItemStatus(PRESERVATION_STORAGE_METADATA_LFC)); continue; } itemStatuses.add(saveDocumentWithLfcInStorage(result.getGotId(), handler, param.getContainerName(), itemStatus)); } return itemStatuses; } PreservationStorageMetadataAndLfc(); @VisibleForTesting  PreservationStorageMetadataAndLfc(MetaDataClientFactory metaDataClientFactory,
        LogbookLifeCyclesClientFactory logbookLifeCyclesClientFactory, StorageClientFactory storageClientFactory); }
PreservationStorageMetadataAndLfc extends StoreMetadataObjectActionHandler { @Override public List<ItemStatus> executeList(WorkerParameters param, HandlerIO handler) throws ProcessingException { final ItemStatus itemStatus = new ItemStatus(PRESERVATION_STORAGE_METADATA_LFC); WorkflowBatchResults results = (WorkflowBatchResults) handler.getInput(WORKFLOWBATCHRESULTS_IN_MEMORY); List<ItemStatus> itemStatuses = new ArrayList<>(); List<WorkflowBatchResult> workflowBatchResults = results.getWorkflowBatchResults(); for (WorkflowBatchResult result : workflowBatchResults) { List<WorkflowBatchResult.OutputExtra> outputExtras = result.getOutputExtras().stream() .filter(WorkflowBatchResult.OutputExtra::isOkAndGenerated) .collect(Collectors.toList()); if (outputExtras.isEmpty()) { itemStatuses.add(new ItemStatus(PRESERVATION_STORAGE_METADATA_LFC)); continue; } itemStatuses.add(saveDocumentWithLfcInStorage(result.getGotId(), handler, param.getContainerName(), itemStatus)); } return itemStatuses; } PreservationStorageMetadataAndLfc(); @VisibleForTesting  PreservationStorageMetadataAndLfc(MetaDataClientFactory metaDataClientFactory,
        LogbookLifeCyclesClientFactory logbookLifeCyclesClientFactory, StorageClientFactory storageClientFactory); @Override List<ItemStatus> executeList(WorkerParameters param, HandlerIO handler); }
PreservationStorageMetadataAndLfc extends StoreMetadataObjectActionHandler { @Override public List<ItemStatus> executeList(WorkerParameters param, HandlerIO handler) throws ProcessingException { final ItemStatus itemStatus = new ItemStatus(PRESERVATION_STORAGE_METADATA_LFC); WorkflowBatchResults results = (WorkflowBatchResults) handler.getInput(WORKFLOWBATCHRESULTS_IN_MEMORY); List<ItemStatus> itemStatuses = new ArrayList<>(); List<WorkflowBatchResult> workflowBatchResults = results.getWorkflowBatchResults(); for (WorkflowBatchResult result : workflowBatchResults) { List<WorkflowBatchResult.OutputExtra> outputExtras = result.getOutputExtras().stream() .filter(WorkflowBatchResult.OutputExtra::isOkAndGenerated) .collect(Collectors.toList()); if (outputExtras.isEmpty()) { itemStatuses.add(new ItemStatus(PRESERVATION_STORAGE_METADATA_LFC)); continue; } itemStatuses.add(saveDocumentWithLfcInStorage(result.getGotId(), handler, param.getContainerName(), itemStatus)); } return itemStatuses; } PreservationStorageMetadataAndLfc(); @VisibleForTesting  PreservationStorageMetadataAndLfc(MetaDataClientFactory metaDataClientFactory,
        LogbookLifeCyclesClientFactory logbookLifeCyclesClientFactory, StorageClientFactory storageClientFactory); @Override List<ItemStatus> executeList(WorkerParameters param, HandlerIO handler);  }