@Test @RunWithCustomExecutor public void givenLogbookNotFoundWhenExecuteThenReturnResponseFATAL() throws Exception { handlerIO.addOutIOParameters(in); handlerIO.addOutputResult(0, PropertiesUtils.getResourceFile(LAST_OPERATION), false); handlerIO.addOutputResult(1, PropertiesUtils.getResourceFile(TRACEABILITY_INFO), false); handlerIO.addOutputResult(2, PropertiesUtils.getResourceFile(TRACEABILITY_DATA), false); handlerIO.addOutputResult(3, PropertiesUtils.getResourceFile(TRACEABILITY_STATS), false); handlerIO.addInIOParameters(in); when(logbookOperationsClient.selectOperation(any())) .thenThrow(new LogbookClientException("LogbookClientException")); VitamThreadUtils.getVitamSession().setTenantId(TENANT_ID); GenerateUnitLifecycleTraceabilityActionPlugin plugin = new GenerateUnitLifecycleTraceabilityActionPlugin( logbookOperationsClientFactory, workspaceClientFactory); final ItemStatus response = plugin.execute(params, handlerIO); assertEquals(StatusCode.FATAL, response.getGlobalStatus()); }
@Override public ItemStatus execute(WorkerParameters params, HandlerIO handler) { final ItemStatus itemStatus = new ItemStatus(ACTION_HANDLER_ID); File traceabilityDataFile = (File) handler.getInput(TRACEABILITY_DATA_IN_RANK); try (final LogbookOperationsClient logbookOperationsClient = logbookOperationsClientFactory.getClient(); InputStream is = new FileInputStream(traceabilityDataFile); JsonLineGenericIterator<JsonLineModel> traceabilityDataIterator = new JsonLineGenericIterator<>(is, TYPE_REFERENCE)) { LogbookLifeCycleTraceabilityHelper helper = new LogbookUnitLifeCycleTraceabilityHelper(handler, logbookOperationsClient, itemStatus, params.getContainerName(), workspaceClientFactory, traceabilityDataIterator, TRACEABILITY_EVENT_FILE_NAME, TRACEABILITY_ZIP_FILE_NAME); generateLifecycleTraceabilityFile(helper); itemStatus.increment(StatusCode.OK); } catch (TraceabilityException | IOException e) { LOGGER.error("Exception while finalizing", e); itemStatus.increment(StatusCode.FATAL); } LOGGER.info("Unit lifecycle traceability finished with status " + itemStatus.getGlobalStatus()); return new ItemStatus(ACTION_HANDLER_ID).setItemsStatus(ACTION_HANDLER_ID, itemStatus); }
GenerateUnitLifecycleTraceabilityActionPlugin extends GenerateLifecycleTraceabilityActionPlugin { @Override public ItemStatus execute(WorkerParameters params, HandlerIO handler) { final ItemStatus itemStatus = new ItemStatus(ACTION_HANDLER_ID); File traceabilityDataFile = (File) handler.getInput(TRACEABILITY_DATA_IN_RANK); try (final LogbookOperationsClient logbookOperationsClient = logbookOperationsClientFactory.getClient(); InputStream is = new FileInputStream(traceabilityDataFile); JsonLineGenericIterator<JsonLineModel> traceabilityDataIterator = new JsonLineGenericIterator<>(is, TYPE_REFERENCE)) { LogbookLifeCycleTraceabilityHelper helper = new LogbookUnitLifeCycleTraceabilityHelper(handler, logbookOperationsClient, itemStatus, params.getContainerName(), workspaceClientFactory, traceabilityDataIterator, TRACEABILITY_EVENT_FILE_NAME, TRACEABILITY_ZIP_FILE_NAME); generateLifecycleTraceabilityFile(helper); itemStatus.increment(StatusCode.OK); } catch (TraceabilityException | IOException e) { LOGGER.error("Exception while finalizing", e); itemStatus.increment(StatusCode.FATAL); } LOGGER.info("Unit lifecycle traceability finished with status " + itemStatus.getGlobalStatus()); return new ItemStatus(ACTION_HANDLER_ID).setItemsStatus(ACTION_HANDLER_ID, itemStatus); } }
GenerateUnitLifecycleTraceabilityActionPlugin extends GenerateLifecycleTraceabilityActionPlugin { @Override public ItemStatus execute(WorkerParameters params, HandlerIO handler) { final ItemStatus itemStatus = new ItemStatus(ACTION_HANDLER_ID); File traceabilityDataFile = (File) handler.getInput(TRACEABILITY_DATA_IN_RANK); try (final LogbookOperationsClient logbookOperationsClient = logbookOperationsClientFactory.getClient(); InputStream is = new FileInputStream(traceabilityDataFile); JsonLineGenericIterator<JsonLineModel> traceabilityDataIterator = new JsonLineGenericIterator<>(is, TYPE_REFERENCE)) { LogbookLifeCycleTraceabilityHelper helper = new LogbookUnitLifeCycleTraceabilityHelper(handler, logbookOperationsClient, itemStatus, params.getContainerName(), workspaceClientFactory, traceabilityDataIterator, TRACEABILITY_EVENT_FILE_NAME, TRACEABILITY_ZIP_FILE_NAME); generateLifecycleTraceabilityFile(helper); itemStatus.increment(StatusCode.OK); } catch (TraceabilityException | IOException e) { LOGGER.error("Exception while finalizing", e); itemStatus.increment(StatusCode.FATAL); } LOGGER.info("Unit lifecycle traceability finished with status " + itemStatus.getGlobalStatus()); return new ItemStatus(ACTION_HANDLER_ID).setItemsStatus(ACTION_HANDLER_ID, itemStatus); } GenerateUnitLifecycleTraceabilityActionPlugin(); @VisibleForTesting  GenerateUnitLifecycleTraceabilityActionPlugin(LogbookOperationsClientFactory logbookOperationsClientFactory,
        WorkspaceClientFactory workspaceClientFactory); }
GenerateUnitLifecycleTraceabilityActionPlugin extends GenerateLifecycleTraceabilityActionPlugin { @Override public ItemStatus execute(WorkerParameters params, HandlerIO handler) { final ItemStatus itemStatus = new ItemStatus(ACTION_HANDLER_ID); File traceabilityDataFile = (File) handler.getInput(TRACEABILITY_DATA_IN_RANK); try (final LogbookOperationsClient logbookOperationsClient = logbookOperationsClientFactory.getClient(); InputStream is = new FileInputStream(traceabilityDataFile); JsonLineGenericIterator<JsonLineModel> traceabilityDataIterator = new JsonLineGenericIterator<>(is, TYPE_REFERENCE)) { LogbookLifeCycleTraceabilityHelper helper = new LogbookUnitLifeCycleTraceabilityHelper(handler, logbookOperationsClient, itemStatus, params.getContainerName(), workspaceClientFactory, traceabilityDataIterator, TRACEABILITY_EVENT_FILE_NAME, TRACEABILITY_ZIP_FILE_NAME); generateLifecycleTraceabilityFile(helper); itemStatus.increment(StatusCode.OK); } catch (TraceabilityException | IOException e) { LOGGER.error("Exception while finalizing", e); itemStatus.increment(StatusCode.FATAL); } LOGGER.info("Unit lifecycle traceability finished with status " + itemStatus.getGlobalStatus()); return new ItemStatus(ACTION_HANDLER_ID).setItemsStatus(ACTION_HANDLER_ID, itemStatus); } GenerateUnitLifecycleTraceabilityActionPlugin(); @VisibleForTesting  GenerateUnitLifecycleTraceabilityActionPlugin(LogbookOperationsClientFactory logbookOperationsClientFactory,
        WorkspaceClientFactory workspaceClientFactory); @Override ItemStatus execute(WorkerParameters params, HandlerIO handler); @Override void checkMandatoryIOParameter(HandlerIO handler); static String getId(); }
GenerateUnitLifecycleTraceabilityActionPlugin extends GenerateLifecycleTraceabilityActionPlugin { @Override public ItemStatus execute(WorkerParameters params, HandlerIO handler) { final ItemStatus itemStatus = new ItemStatus(ACTION_HANDLER_ID); File traceabilityDataFile = (File) handler.getInput(TRACEABILITY_DATA_IN_RANK); try (final LogbookOperationsClient logbookOperationsClient = logbookOperationsClientFactory.getClient(); InputStream is = new FileInputStream(traceabilityDataFile); JsonLineGenericIterator<JsonLineModel> traceabilityDataIterator = new JsonLineGenericIterator<>(is, TYPE_REFERENCE)) { LogbookLifeCycleTraceabilityHelper helper = new LogbookUnitLifeCycleTraceabilityHelper(handler, logbookOperationsClient, itemStatus, params.getContainerName(), workspaceClientFactory, traceabilityDataIterator, TRACEABILITY_EVENT_FILE_NAME, TRACEABILITY_ZIP_FILE_NAME); generateLifecycleTraceabilityFile(helper); itemStatus.increment(StatusCode.OK); } catch (TraceabilityException | IOException e) { LOGGER.error("Exception while finalizing", e); itemStatus.increment(StatusCode.FATAL); } LOGGER.info("Unit lifecycle traceability finished with status " + itemStatus.getGlobalStatus()); return new ItemStatus(ACTION_HANDLER_ID).setItemsStatus(ACTION_HANDLER_ID, itemStatus); } GenerateUnitLifecycleTraceabilityActionPlugin(); @VisibleForTesting  GenerateUnitLifecycleTraceabilityActionPlugin(LogbookOperationsClientFactory logbookOperationsClientFactory,
        WorkspaceClientFactory workspaceClientFactory); @Override ItemStatus execute(WorkerParameters params, HandlerIO handler); @Override void checkMandatoryIOParameter(HandlerIO handler); static String getId();  }