@Test public void should_include_binary_id_in_subtask() throws Exception { String outputName = "empty-file"; OutputPreservation output = new OutputPreservation(); output.setOutputName(outputName); output.setStatus(PreservationStatus.OK); output.setAction(ActionTypePreservation.GENERATE); List<OutputExtra> outputExtras = Arrays.asList(OutputExtra.of(output)); List<WorkflowBatchResult> workflowBatchResults = Collections.singletonList(WorkflowBatchResult.of("", "", "", "", outputExtras, "", "")); File file = tmpGriffinFolder.newFolder(OUTPUT_FILES); Files.createFile(file.toPath().resolve(outputName)); WorkflowBatchResults batchResults = new WorkflowBatchResults(tmpGriffinFolder.getRoot().toPath(), workflowBatchResults); handler.addOutputResult(0, batchResults); List<ItemStatus> itemStatuses = binaryHashPlugin.executeList(null, handler); String binaryGUID = ((WorkflowBatchResults) handler.getInput(0)).getWorkflowBatchResults().get(0).getOutputExtras().get(0).getBinaryGUID(); assertThat(itemStatuses).extracting(ItemStatus::getItemsStatus). extracting(itemStatus -> itemStatus.get(PRESERVATION_BINARY_HASH_SUBTASK)) .extracting(ItemStatus::getSubTaskStatus) .extracting(subItemStatus -> subItemStatus.get(binaryGUID)).isNotEmpty(); }
@Override public List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler) throws ProcessingException { logger.debug("Starting {}.", ITEM_ID); handler.setCurrentObjectId(WorkflowBatchResults.NAME); WorkflowBatchResults results = (WorkflowBatchResults) handler.getInput(0); List<ItemStatus> itemStatuses = new ArrayList<>(); List<WorkflowBatchResult> workflowBatchResults = new ArrayList<>(); for (WorkflowBatchResult workflowBatchResult : results.getWorkflowBatchResults()) { List<OutputExtra> outputExtras = workflowBatchResult.getOutputExtras() .stream() .filter(OutputExtra::isOkAndGenerated) .map(a -> getOutputExtra(results, a)) .collect(Collectors.toList()); if (outputExtras.isEmpty()) { workflowBatchResults.add(workflowBatchResult); ItemStatus itemStatus = new ItemStatus(ITEM_ID); itemStatus.disableLfc(); itemStatuses.add(itemStatus); continue; } itemStatuses.add(getItemStatus(outputExtras)); Stream<OutputExtra> otherActions = workflowBatchResult.getOutputExtras() .stream() .filter(o -> !o.isOkAndGenerated()); List<OutputExtra> previousAndNewExtras = Stream.concat(otherActions, outputExtras.stream().filter(outputExtra -> !outputExtra.isInError())) .collect(Collectors.toList()); workflowBatchResults.add(WorkflowBatchResult.of(workflowBatchResult, previousAndNewExtras)); } handler.addOutputResult(0, new WorkflowBatchResults(results.getBatchDirectory(), workflowBatchResults)); return itemStatuses; }
PreservationGenerateBinaryHash extends ActionHandler { @Override public List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler) throws ProcessingException { logger.debug("Starting {}.", ITEM_ID); handler.setCurrentObjectId(WorkflowBatchResults.NAME); WorkflowBatchResults results = (WorkflowBatchResults) handler.getInput(0); List<ItemStatus> itemStatuses = new ArrayList<>(); List<WorkflowBatchResult> workflowBatchResults = new ArrayList<>(); for (WorkflowBatchResult workflowBatchResult : results.getWorkflowBatchResults()) { List<OutputExtra> outputExtras = workflowBatchResult.getOutputExtras() .stream() .filter(OutputExtra::isOkAndGenerated) .map(a -> getOutputExtra(results, a)) .collect(Collectors.toList()); if (outputExtras.isEmpty()) { workflowBatchResults.add(workflowBatchResult); ItemStatus itemStatus = new ItemStatus(ITEM_ID); itemStatus.disableLfc(); itemStatuses.add(itemStatus); continue; } itemStatuses.add(getItemStatus(outputExtras)); Stream<OutputExtra> otherActions = workflowBatchResult.getOutputExtras() .stream() .filter(o -> !o.isOkAndGenerated()); List<OutputExtra> previousAndNewExtras = Stream.concat(otherActions, outputExtras.stream().filter(outputExtra -> !outputExtra.isInError())) .collect(Collectors.toList()); workflowBatchResults.add(WorkflowBatchResult.of(workflowBatchResult, previousAndNewExtras)); } handler.addOutputResult(0, new WorkflowBatchResults(results.getBatchDirectory(), workflowBatchResults)); return itemStatuses; } }
PreservationGenerateBinaryHash extends ActionHandler { @Override public List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler) throws ProcessingException { logger.debug("Starting {}.", ITEM_ID); handler.setCurrentObjectId(WorkflowBatchResults.NAME); WorkflowBatchResults results = (WorkflowBatchResults) handler.getInput(0); List<ItemStatus> itemStatuses = new ArrayList<>(); List<WorkflowBatchResult> workflowBatchResults = new ArrayList<>(); for (WorkflowBatchResult workflowBatchResult : results.getWorkflowBatchResults()) { List<OutputExtra> outputExtras = workflowBatchResult.getOutputExtras() .stream() .filter(OutputExtra::isOkAndGenerated) .map(a -> getOutputExtra(results, a)) .collect(Collectors.toList()); if (outputExtras.isEmpty()) { workflowBatchResults.add(workflowBatchResult); ItemStatus itemStatus = new ItemStatus(ITEM_ID); itemStatus.disableLfc(); itemStatuses.add(itemStatus); continue; } itemStatuses.add(getItemStatus(outputExtras)); Stream<OutputExtra> otherActions = workflowBatchResult.getOutputExtras() .stream() .filter(o -> !o.isOkAndGenerated()); List<OutputExtra> previousAndNewExtras = Stream.concat(otherActions, outputExtras.stream().filter(outputExtra -> !outputExtra.isInError())) .collect(Collectors.toList()); workflowBatchResults.add(WorkflowBatchResult.of(workflowBatchResult, previousAndNewExtras)); } handler.addOutputResult(0, new WorkflowBatchResults(results.getBatchDirectory(), workflowBatchResults)); return itemStatuses; }  }
PreservationGenerateBinaryHash extends ActionHandler { @Override public List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler) throws ProcessingException { logger.debug("Starting {}.", ITEM_ID); handler.setCurrentObjectId(WorkflowBatchResults.NAME); WorkflowBatchResults results = (WorkflowBatchResults) handler.getInput(0); List<ItemStatus> itemStatuses = new ArrayList<>(); List<WorkflowBatchResult> workflowBatchResults = new ArrayList<>(); for (WorkflowBatchResult workflowBatchResult : results.getWorkflowBatchResults()) { List<OutputExtra> outputExtras = workflowBatchResult.getOutputExtras() .stream() .filter(OutputExtra::isOkAndGenerated) .map(a -> getOutputExtra(results, a)) .collect(Collectors.toList()); if (outputExtras.isEmpty()) { workflowBatchResults.add(workflowBatchResult); ItemStatus itemStatus = new ItemStatus(ITEM_ID); itemStatus.disableLfc(); itemStatuses.add(itemStatus); continue; } itemStatuses.add(getItemStatus(outputExtras)); Stream<OutputExtra> otherActions = workflowBatchResult.getOutputExtras() .stream() .filter(o -> !o.isOkAndGenerated()); List<OutputExtra> previousAndNewExtras = Stream.concat(otherActions, outputExtras.stream().filter(outputExtra -> !outputExtra.isInError())) .collect(Collectors.toList()); workflowBatchResults.add(WorkflowBatchResult.of(workflowBatchResult, previousAndNewExtras)); } handler.addOutputResult(0, new WorkflowBatchResults(results.getBatchDirectory(), workflowBatchResults)); return itemStatuses; }  @Override List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler); }
PreservationGenerateBinaryHash extends ActionHandler { @Override public List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler) throws ProcessingException { logger.debug("Starting {}.", ITEM_ID); handler.setCurrentObjectId(WorkflowBatchResults.NAME); WorkflowBatchResults results = (WorkflowBatchResults) handler.getInput(0); List<ItemStatus> itemStatuses = new ArrayList<>(); List<WorkflowBatchResult> workflowBatchResults = new ArrayList<>(); for (WorkflowBatchResult workflowBatchResult : results.getWorkflowBatchResults()) { List<OutputExtra> outputExtras = workflowBatchResult.getOutputExtras() .stream() .filter(OutputExtra::isOkAndGenerated) .map(a -> getOutputExtra(results, a)) .collect(Collectors.toList()); if (outputExtras.isEmpty()) { workflowBatchResults.add(workflowBatchResult); ItemStatus itemStatus = new ItemStatus(ITEM_ID); itemStatus.disableLfc(); itemStatuses.add(itemStatus); continue; } itemStatuses.add(getItemStatus(outputExtras)); Stream<OutputExtra> otherActions = workflowBatchResult.getOutputExtras() .stream() .filter(o -> !o.isOkAndGenerated()); List<OutputExtra> previousAndNewExtras = Stream.concat(otherActions, outputExtras.stream().filter(outputExtra -> !outputExtra.isInError())) .collect(Collectors.toList()); workflowBatchResults.add(WorkflowBatchResult.of(workflowBatchResult, previousAndNewExtras)); } handler.addOutputResult(0, new WorkflowBatchResults(results.getBatchDirectory(), workflowBatchResults)); return itemStatuses; }  @Override List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler); static final DigestType digestPreservationGeneration; static final String ITEM_ID; }