@Test public void should_add_result_with_format() throws Exception { OutputPreservation output = new OutputPreservation(); output.setStatus(PreservationStatus.OK); output.setAction(ActionTypePreservation.GENERATE); output.setOutputName("outputName"); List<OutputExtra> outputExtras = Arrays.asList(OutputExtra.of(output)); List<WorkflowBatchResult> workflowBatchResults = Collections.singletonList(WorkflowBatchResult.of("", "", "", "", outputExtras, "", "")); Path batchDirectory = Paths.get("tmp"); WorkflowBatchResults batchResults = new WorkflowBatchResults(batchDirectory, workflowBatchResults); handler.addOutputResult(0, batchResults); FormatIdentifierResponse formatIdentifierResponse = new FormatIdentifierResponse("fmt/trololo", "application/trololo", "42", PRONOM_NAMESPACE); given(siegfried.analysePath(batchDirectory.resolve(OUTPUT_FILES).resolve(output.getOutputName()))) .willReturn(Collections.singletonList(formatIdentifierResponse)); siegriedPlugin.executeList(null, handler); assertThat(((WorkflowBatchResults) handler.getInput(0)).getWorkflowBatchResults()) .extracting(w -> w.getOutputExtras().get(0).getBinaryFormat()) .extracting(Optional::get) .extracting(FormatIdentifierResponse::getFormatLiteral) .containsOnly("fmt/trololo"); }
@Override public List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler) throws ProcessingException { FormatIdentifier siegfried = getFormatIdentifier(); logger.info("Starting PRESERVATION_SIEGFRIED_IDENTIFICATION."); handler.setCurrentObjectId(WorkflowBatchResults.NAME); WorkflowBatchResults results = (WorkflowBatchResults) handler.getInput(WORKFLOWBATCHRESULTS_IN_MEMORY); Path outputFiles = results.getBatchDirectory().resolve(OUTPUT_FILES); 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(outputFiles, a, results.getBatchDirectory(), siegfried)) .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; }
PreservationSiegfriedPlugin extends ActionHandler { @Override public List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler) throws ProcessingException { FormatIdentifier siegfried = getFormatIdentifier(); logger.info("Starting PRESERVATION_SIEGFRIED_IDENTIFICATION."); handler.setCurrentObjectId(WorkflowBatchResults.NAME); WorkflowBatchResults results = (WorkflowBatchResults) handler.getInput(WORKFLOWBATCHRESULTS_IN_MEMORY); Path outputFiles = results.getBatchDirectory().resolve(OUTPUT_FILES); 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(outputFiles, a, results.getBatchDirectory(), siegfried)) .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; } }
PreservationSiegfriedPlugin extends ActionHandler { @Override public List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler) throws ProcessingException { FormatIdentifier siegfried = getFormatIdentifier(); logger.info("Starting PRESERVATION_SIEGFRIED_IDENTIFICATION."); handler.setCurrentObjectId(WorkflowBatchResults.NAME); WorkflowBatchResults results = (WorkflowBatchResults) handler.getInput(WORKFLOWBATCHRESULTS_IN_MEMORY); Path outputFiles = results.getBatchDirectory().resolve(OUTPUT_FILES); 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(outputFiles, a, results.getBatchDirectory(), siegfried)) .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; } PreservationSiegfriedPlugin(); @VisibleForTesting private  PreservationSiegfriedPlugin(FormatIdentifierFactory siegfriedFactory); }
PreservationSiegfriedPlugin extends ActionHandler { @Override public List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler) throws ProcessingException { FormatIdentifier siegfried = getFormatIdentifier(); logger.info("Starting PRESERVATION_SIEGFRIED_IDENTIFICATION."); handler.setCurrentObjectId(WorkflowBatchResults.NAME); WorkflowBatchResults results = (WorkflowBatchResults) handler.getInput(WORKFLOWBATCHRESULTS_IN_MEMORY); Path outputFiles = results.getBatchDirectory().resolve(OUTPUT_FILES); 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(outputFiles, a, results.getBatchDirectory(), siegfried)) .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; } PreservationSiegfriedPlugin(); @VisibleForTesting private  PreservationSiegfriedPlugin(FormatIdentifierFactory siegfriedFactory); @Override List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler); }
PreservationSiegfriedPlugin extends ActionHandler { @Override public List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler) throws ProcessingException { FormatIdentifier siegfried = getFormatIdentifier(); logger.info("Starting PRESERVATION_SIEGFRIED_IDENTIFICATION."); handler.setCurrentObjectId(WorkflowBatchResults.NAME); WorkflowBatchResults results = (WorkflowBatchResults) handler.getInput(WORKFLOWBATCHRESULTS_IN_MEMORY); Path outputFiles = results.getBatchDirectory().resolve(OUTPUT_FILES); 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(outputFiles, a, results.getBatchDirectory(), siegfried)) .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; } PreservationSiegfriedPlugin(); @VisibleForTesting private  PreservationSiegfriedPlugin(FormatIdentifierFactory siegfriedFactory); @Override List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler);  }