@Test @RunWithCustomExecutor public void should_finalize_preservation_report() throws Exception { File newLocalFile = tempFolder.newFile(); TestHandlerIO handlerIO = new TestHandlerIO(); handlerIO.setNewLocalFile(newLocalFile); try (InputStream resourceAsStream = getClass().getResourceAsStream("/preservation/preservationRequest"); InputStream scenarioInputStream = getClass().getResourceAsStream("/preservation/preservationDocument")) { populateTestHandlerIo(handlerIO, resourceAsStream, scenarioInputStream); JsonNode logbookOperationJson = JsonHandler.getFromInputStream(getClass().getResourceAsStream("/preservation/logbookOperationOk.json")); given(logbookOperationsClient.selectOperationById(anyString())).willReturn(logbookOperationJson); when(preservationReportService.isReportWrittenInWorkspace(anyString())).thenReturn(false); ItemStatus itemStatus = plugin.execute(parameter, handlerIO); assertThat(itemStatus.getGlobalStatus()).isEqualTo(StatusCode.OK); assertThat(itemStatus.getItemId()).isEqualTo("PRESERVATION_FINALIZATION"); } }
@Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { try { storeReportToWorkspace(param, handler); storeReportToOffers(param.getContainerName()); cleanupReport(param.getRequestId()); } catch (Exception e) { LOGGER.error("Error on finalization", e); ObjectNode eventDetails = JsonHandler.createObjectNode(); eventDetails.put("error", e.getMessage()); return buildItemStatus(PLUGIN_NAME, FATAL, eventDetails); } return buildItemStatus(PLUGIN_NAME, OK, EventDetails.of("Finalization ok.")); }
PreservationFinalizationPlugin extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { try { storeReportToWorkspace(param, handler); storeReportToOffers(param.getContainerName()); cleanupReport(param.getRequestId()); } catch (Exception e) { LOGGER.error("Error on finalization", e); ObjectNode eventDetails = JsonHandler.createObjectNode(); eventDetails.put("error", e.getMessage()); return buildItemStatus(PLUGIN_NAME, FATAL, eventDetails); } return buildItemStatus(PLUGIN_NAME, OK, EventDetails.of("Finalization ok.")); } }
PreservationFinalizationPlugin extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { try { storeReportToWorkspace(param, handler); storeReportToOffers(param.getContainerName()); cleanupReport(param.getRequestId()); } catch (Exception e) { LOGGER.error("Error on finalization", e); ObjectNode eventDetails = JsonHandler.createObjectNode(); eventDetails.put("error", e.getMessage()); return buildItemStatus(PLUGIN_NAME, FATAL, eventDetails); } return buildItemStatus(PLUGIN_NAME, OK, EventDetails.of("Finalization ok.")); } PreservationFinalizationPlugin(); @VisibleForTesting  PreservationFinalizationPlugin(PreservationReportService preservationReportService,
        LogbookOperationsClient logbookOperationsClient); }
PreservationFinalizationPlugin extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { try { storeReportToWorkspace(param, handler); storeReportToOffers(param.getContainerName()); cleanupReport(param.getRequestId()); } catch (Exception e) { LOGGER.error("Error on finalization", e); ObjectNode eventDetails = JsonHandler.createObjectNode(); eventDetails.put("error", e.getMessage()); return buildItemStatus(PLUGIN_NAME, FATAL, eventDetails); } return buildItemStatus(PLUGIN_NAME, OK, EventDetails.of("Finalization ok.")); } PreservationFinalizationPlugin(); @VisibleForTesting  PreservationFinalizationPlugin(PreservationReportService preservationReportService,
        LogbookOperationsClient logbookOperationsClient); @Override ItemStatus execute(WorkerParameters param, HandlerIO handler); }
PreservationFinalizationPlugin extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { try { storeReportToWorkspace(param, handler); storeReportToOffers(param.getContainerName()); cleanupReport(param.getRequestId()); } catch (Exception e) { LOGGER.error("Error on finalization", e); ObjectNode eventDetails = JsonHandler.createObjectNode(); eventDetails.put("error", e.getMessage()); return buildItemStatus(PLUGIN_NAME, FATAL, eventDetails); } return buildItemStatus(PLUGIN_NAME, OK, EventDetails.of("Finalization ok.")); } PreservationFinalizationPlugin(); @VisibleForTesting  PreservationFinalizationPlugin(PreservationReportService preservationReportService,
        LogbookOperationsClient logbookOperationsClient); @Override ItemStatus execute(WorkerParameters param, HandlerIO handler);  }