@Test public void should_update_identify_extract_and_generate() throws Exception { ArgumentCaptor<JsonNode> finalQueryCaptor = ArgumentCaptor.forClass(JsonNode.class); ArgumentCaptor<String> gotIdCaptor = ArgumentCaptor.forClass(String.class); WorkflowBatchResults batchResults = getWorkflowBatchResults(getOutputPreservation(EXTRACT), getOutputPreservation(GENERATE), getOutputPreservation(IDENTIFY)); TestHandlerIO testHandlerIO = new TestHandlerIO(); testHandlerIO.addOutputResult(0, batchResults); testHandlerIO.setInputs(batchResults); InputStream objectGroupStream = getClass().getResourceAsStream("/preservation/objectGroupDslResponse.json"); RequestResponse<JsonNode> responseOK = new RequestResponseOK<JsonNode>() .addResult(JsonHandler.getFromInputStream(objectGroupStream)) .setHttpCode(Response.Status.OK.getStatusCode()); given(metaDataClient.getObjectGroupByIdRaw(ArgumentMatchers.any())).willReturn(responseOK); doNothing().when(metaDataClient) .updateObjectGroupById(finalQueryCaptor.capture(), gotIdCaptor.capture()); List<ItemStatus> itemStatuses = plugin.executeList(parameter, testHandlerIO); assertThat(itemStatuses) .extracting(ItemStatus::getGlobalStatus) .containsOnly(OK); assertThat(finalQueryCaptor.getValue().at("/$action/2/$set/#qualifiers/0/_nbc").intValue()) .isEqualTo(2); assertThat(finalQueryCaptor.getValue().at("/$action/1/$set/#nbobjects").intValue()) .isEqualTo(2); assertThat(finalQueryCaptor.getValue() .at("/$action/2/$set/#qualifiers/0/versions/0/FormatIdentification/FormatLitteral").textValue()) .isEqualTo("Batman"); assertThat( finalQueryCaptor.getValue().at("/$action/2/$set/#qualifiers/0/versions/0/FormatIdentification/MimeType") .textValue()) .isEqualTo("text/winner"); assertThat( finalQueryCaptor.getValue().at("/$action/2/$set/#qualifiers/0/versions/0/OtherMetadata/GPS/0").textValue()) .isEqualTo("40.714, -74.006"); }
@Override public List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler) { LOGGER.info("Starting {}", PLUGIN_NAME); WorkflowBatchResults results = (WorkflowBatchResults) handler.getInput(0); List<WorkflowBatchResult> workflowBatchResults = results.getWorkflowBatchResults(); try (MetaDataClient metaDataClient = metaDataClientFactory.getClient()) { return workflowBatchResults.stream() .map(w -> updateObjectGroupModel(w, metaDataClient)) .collect(Collectors.toList()); } }
PreservationUpdateObjectGroupPlugin extends ActionHandler { @Override public List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler) { LOGGER.info("Starting {}", PLUGIN_NAME); WorkflowBatchResults results = (WorkflowBatchResults) handler.getInput(0); List<WorkflowBatchResult> workflowBatchResults = results.getWorkflowBatchResults(); try (MetaDataClient metaDataClient = metaDataClientFactory.getClient()) { return workflowBatchResults.stream() .map(w -> updateObjectGroupModel(w, metaDataClient)) .collect(Collectors.toList()); } } }
PreservationUpdateObjectGroupPlugin extends ActionHandler { @Override public List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler) { LOGGER.info("Starting {}", PLUGIN_NAME); WorkflowBatchResults results = (WorkflowBatchResults) handler.getInput(0); List<WorkflowBatchResult> workflowBatchResults = results.getWorkflowBatchResults(); try (MetaDataClient metaDataClient = metaDataClientFactory.getClient()) { return workflowBatchResults.stream() .map(w -> updateObjectGroupModel(w, metaDataClient)) .collect(Collectors.toList()); } } PreservationUpdateObjectGroupPlugin(); @VisibleForTesting  PreservationUpdateObjectGroupPlugin(MetaDataClientFactory metaDataClientFactory); }
PreservationUpdateObjectGroupPlugin extends ActionHandler { @Override public List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler) { LOGGER.info("Starting {}", PLUGIN_NAME); WorkflowBatchResults results = (WorkflowBatchResults) handler.getInput(0); List<WorkflowBatchResult> workflowBatchResults = results.getWorkflowBatchResults(); try (MetaDataClient metaDataClient = metaDataClientFactory.getClient()) { return workflowBatchResults.stream() .map(w -> updateObjectGroupModel(w, metaDataClient)) .collect(Collectors.toList()); } } PreservationUpdateObjectGroupPlugin(); @VisibleForTesting  PreservationUpdateObjectGroupPlugin(MetaDataClientFactory metaDataClientFactory); @Override List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler); }
PreservationUpdateObjectGroupPlugin extends ActionHandler { @Override public List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler) { LOGGER.info("Starting {}", PLUGIN_NAME); WorkflowBatchResults results = (WorkflowBatchResults) handler.getInput(0); List<WorkflowBatchResult> workflowBatchResults = results.getWorkflowBatchResults(); try (MetaDataClient metaDataClient = metaDataClientFactory.getClient()) { return workflowBatchResults.stream() .map(w -> updateObjectGroupModel(w, metaDataClient)) .collect(Collectors.toList()); } } PreservationUpdateObjectGroupPlugin(); @VisibleForTesting  PreservationUpdateObjectGroupPlugin(MetaDataClientFactory metaDataClientFactory); @Override List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler);  }