@Test public void should_return_status_ok_when_ATR_OK_or_WARNING() throws Exception { TestHandlerIO handler = new TestHandlerIO(); handler.addOutputResult(0, createATR(WARNING.name())); File file = tempFolder.newFile(); handler.setNewLocalFile(file); handler.setOutputWithPath(file.toPath().toString()); ItemStatus execute = checkAtrAndAddItToWorkspacePlugin.execute(null, handler); assertThat(execute.getGlobalStatus()).isEqualTo(OK); }
@Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { ArchiveTransferReplyType atr = (ArchiveTransferReplyType) handler.getInput(0); try { String messageIdentifier = atr.getMessageIdentifier().getValue(); if (!isValidStatus(atr)) { return buildItemStatus(PLUGIN_NAME, KO, EventDetails.of(String.format("ATR '%s' is KO, workflow will stop here.", messageIdentifier))); } File tempFile = handler.getNewLocalFile(handler.getOutput(TRANSFER_REPLY_CONTEXT_OUT_RANK).getPath()); FileUtils.copyInputStreamToFile(streamFromIds(atr), tempFile); handler.addOutputResult(TRANSFER_REPLY_CONTEXT_OUT_RANK, tempFile, true, false); return buildItemStatus(PLUGIN_NAME, OK, EventDetails.of(String.format("ATR '%s' is OK.", messageIdentifier))); } catch (IOException | InvalidParseOperationException e) { LOGGER.error(e); return buildItemStatus(PLUGIN_NAME, FATAL, EventDetails.of(e.getMessage())); } }
CheckAtrAndAddItToWorkspacePlugin extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { ArchiveTransferReplyType atr = (ArchiveTransferReplyType) handler.getInput(0); try { String messageIdentifier = atr.getMessageIdentifier().getValue(); if (!isValidStatus(atr)) { return buildItemStatus(PLUGIN_NAME, KO, EventDetails.of(String.format("ATR '%s' is KO, workflow will stop here.", messageIdentifier))); } File tempFile = handler.getNewLocalFile(handler.getOutput(TRANSFER_REPLY_CONTEXT_OUT_RANK).getPath()); FileUtils.copyInputStreamToFile(streamFromIds(atr), tempFile); handler.addOutputResult(TRANSFER_REPLY_CONTEXT_OUT_RANK, tempFile, true, false); return buildItemStatus(PLUGIN_NAME, OK, EventDetails.of(String.format("ATR '%s' is OK.", messageIdentifier))); } catch (IOException | InvalidParseOperationException e) { LOGGER.error(e); return buildItemStatus(PLUGIN_NAME, FATAL, EventDetails.of(e.getMessage())); } } }
CheckAtrAndAddItToWorkspacePlugin extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { ArchiveTransferReplyType atr = (ArchiveTransferReplyType) handler.getInput(0); try { String messageIdentifier = atr.getMessageIdentifier().getValue(); if (!isValidStatus(atr)) { return buildItemStatus(PLUGIN_NAME, KO, EventDetails.of(String.format("ATR '%s' is KO, workflow will stop here.", messageIdentifier))); } File tempFile = handler.getNewLocalFile(handler.getOutput(TRANSFER_REPLY_CONTEXT_OUT_RANK).getPath()); FileUtils.copyInputStreamToFile(streamFromIds(atr), tempFile); handler.addOutputResult(TRANSFER_REPLY_CONTEXT_OUT_RANK, tempFile, true, false); return buildItemStatus(PLUGIN_NAME, OK, EventDetails.of(String.format("ATR '%s' is OK.", messageIdentifier))); } catch (IOException | InvalidParseOperationException e) { LOGGER.error(e); return buildItemStatus(PLUGIN_NAME, FATAL, EventDetails.of(e.getMessage())); } }  }
CheckAtrAndAddItToWorkspacePlugin extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { ArchiveTransferReplyType atr = (ArchiveTransferReplyType) handler.getInput(0); try { String messageIdentifier = atr.getMessageIdentifier().getValue(); if (!isValidStatus(atr)) { return buildItemStatus(PLUGIN_NAME, KO, EventDetails.of(String.format("ATR '%s' is KO, workflow will stop here.", messageIdentifier))); } File tempFile = handler.getNewLocalFile(handler.getOutput(TRANSFER_REPLY_CONTEXT_OUT_RANK).getPath()); FileUtils.copyInputStreamToFile(streamFromIds(atr), tempFile); handler.addOutputResult(TRANSFER_REPLY_CONTEXT_OUT_RANK, tempFile, true, false); return buildItemStatus(PLUGIN_NAME, OK, EventDetails.of(String.format("ATR '%s' is OK.", messageIdentifier))); } catch (IOException | InvalidParseOperationException e) { LOGGER.error(e); return buildItemStatus(PLUGIN_NAME, FATAL, EventDetails.of(e.getMessage())); } }  @Override ItemStatus execute(WorkerParameters param, HandlerIO handler); }
CheckAtrAndAddItToWorkspacePlugin extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { ArchiveTransferReplyType atr = (ArchiveTransferReplyType) handler.getInput(0); try { String messageIdentifier = atr.getMessageIdentifier().getValue(); if (!isValidStatus(atr)) { return buildItemStatus(PLUGIN_NAME, KO, EventDetails.of(String.format("ATR '%s' is KO, workflow will stop here.", messageIdentifier))); } File tempFile = handler.getNewLocalFile(handler.getOutput(TRANSFER_REPLY_CONTEXT_OUT_RANK).getPath()); FileUtils.copyInputStreamToFile(streamFromIds(atr), tempFile); handler.addOutputResult(TRANSFER_REPLY_CONTEXT_OUT_RANK, tempFile, true, false); return buildItemStatus(PLUGIN_NAME, OK, EventDetails.of(String.format("ATR '%s' is OK.", messageIdentifier))); } catch (IOException | InvalidParseOperationException e) { LOGGER.error(e); return buildItemStatus(PLUGIN_NAME, FATAL, EventDetails.of(e.getMessage())); } }  @Override ItemStatus execute(WorkerParameters param, HandlerIO handler); static final String PLUGIN_NAME; }