@Test @RunWithCustomExecutor public void givenSelectLFCErrorWhenExecuteThenReturnResponseKO() throws Exception { VitamThreadUtils.getVitamSession().setTenantId(TENANT_ID); handlerIO.addOutIOParameters(out); reset(logbookOperationsClient); final JsonNode lastTraceability = JsonHandler.getFromInputStream(PropertiesUtils.getResourceAsStream(LAST_TRACEABILITY_JSON)); when(logbookOperationsClient.selectOperation(any())).thenReturn(lastTraceability); reset(logbookLifeCyclesClient); when(logbookLifeCyclesClient.getRawUnitLifecyclesByLastPersistedDate(any(), any(), anyInt())) .thenThrow(new InvalidParseOperationException("InvalidParseOperationException")); WorkerParameters params = createExecParams(300, 100000); PrepareUnitLfcTraceabilityActionPlugin handler = new PrepareUnitLfcTraceabilityActionPlugin( metadataClientFactory, logbookLifeCyclesClientFactory, logbookOperationsClientFactory, 10); final ItemStatus response = handler.execute(params, handlerIO); assertEquals(StatusCode.KO, response.getGlobalStatus()); }
@Override public ItemStatus execute(WorkerParameters params, HandlerIO handler) throws ProcessingException { String temporizationDelayInSecondsStr = params.getMapParameters().get(WorkerParameterName.lifecycleTraceabilityTemporizationDelayInSeconds); String lifecycleTraceabilityMaxEntriesStr = params.getMapParameters().get(WorkerParameterName.lifecycleTraceabilityMaxEntries); int temporizationDelayInSeconds = Integer.parseInt(temporizationDelayInSecondsStr); int lifecycleTraceabilityMaxEntries = Integer.parseInt(lifecycleTraceabilityMaxEntriesStr); final ItemStatus itemStatus = new ItemStatus(ACTION_HANDLER_ID); try { StatusCode statusCode = selectAndExportLifecyclesWithMetadata(temporizationDelayInSeconds, lifecycleTraceabilityMaxEntries, Contexts.UNIT_LFC_TRACEABILITY.getEventType(), handler); itemStatus.increment(statusCode); } catch (ProcessingException | LogbookClientException | VitamFatalRuntimeException e) { LOGGER.error("Logbook exception", e); itemStatus.increment(StatusCode.FATAL); } catch (InvalidParseOperationException | InvalidCreateOperationException | VitamKoRuntimeException e) { LOGGER.error("Processing exception", e); itemStatus.increment(StatusCode.KO); } return new ItemStatus(ACTION_HANDLER_ID).setItemsStatus(ACTION_HANDLER_ID, itemStatus); }
PrepareUnitLfcTraceabilityActionPlugin extends PrepareLfcTraceabilityActionPlugin { @Override public ItemStatus execute(WorkerParameters params, HandlerIO handler) throws ProcessingException { String temporizationDelayInSecondsStr = params.getMapParameters().get(WorkerParameterName.lifecycleTraceabilityTemporizationDelayInSeconds); String lifecycleTraceabilityMaxEntriesStr = params.getMapParameters().get(WorkerParameterName.lifecycleTraceabilityMaxEntries); int temporizationDelayInSeconds = Integer.parseInt(temporizationDelayInSecondsStr); int lifecycleTraceabilityMaxEntries = Integer.parseInt(lifecycleTraceabilityMaxEntriesStr); final ItemStatus itemStatus = new ItemStatus(ACTION_HANDLER_ID); try { StatusCode statusCode = selectAndExportLifecyclesWithMetadata(temporizationDelayInSeconds, lifecycleTraceabilityMaxEntries, Contexts.UNIT_LFC_TRACEABILITY.getEventType(), handler); itemStatus.increment(statusCode); } catch (ProcessingException | LogbookClientException | VitamFatalRuntimeException e) { LOGGER.error("Logbook exception", e); itemStatus.increment(StatusCode.FATAL); } catch (InvalidParseOperationException | InvalidCreateOperationException | VitamKoRuntimeException e) { LOGGER.error("Processing exception", e); itemStatus.increment(StatusCode.KO); } return new ItemStatus(ACTION_HANDLER_ID).setItemsStatus(ACTION_HANDLER_ID, itemStatus); } }
PrepareUnitLfcTraceabilityActionPlugin extends PrepareLfcTraceabilityActionPlugin { @Override public ItemStatus execute(WorkerParameters params, HandlerIO handler) throws ProcessingException { String temporizationDelayInSecondsStr = params.getMapParameters().get(WorkerParameterName.lifecycleTraceabilityTemporizationDelayInSeconds); String lifecycleTraceabilityMaxEntriesStr = params.getMapParameters().get(WorkerParameterName.lifecycleTraceabilityMaxEntries); int temporizationDelayInSeconds = Integer.parseInt(temporizationDelayInSecondsStr); int lifecycleTraceabilityMaxEntries = Integer.parseInt(lifecycleTraceabilityMaxEntriesStr); final ItemStatus itemStatus = new ItemStatus(ACTION_HANDLER_ID); try { StatusCode statusCode = selectAndExportLifecyclesWithMetadata(temporizationDelayInSeconds, lifecycleTraceabilityMaxEntries, Contexts.UNIT_LFC_TRACEABILITY.getEventType(), handler); itemStatus.increment(statusCode); } catch (ProcessingException | LogbookClientException | VitamFatalRuntimeException e) { LOGGER.error("Logbook exception", e); itemStatus.increment(StatusCode.FATAL); } catch (InvalidParseOperationException | InvalidCreateOperationException | VitamKoRuntimeException e) { LOGGER.error("Processing exception", e); itemStatus.increment(StatusCode.KO); } return new ItemStatus(ACTION_HANDLER_ID).setItemsStatus(ACTION_HANDLER_ID, itemStatus); } PrepareUnitLfcTraceabilityActionPlugin(); @VisibleForTesting  PrepareUnitLfcTraceabilityActionPlugin(MetaDataClientFactory metaDataClientFactory,
        LogbookLifeCyclesClientFactory logbookLifeCyclesClientFactory,
        LogbookOperationsClientFactory logbookOperationsClientFactory,
        int batchSize); }
PrepareUnitLfcTraceabilityActionPlugin extends PrepareLfcTraceabilityActionPlugin { @Override public ItemStatus execute(WorkerParameters params, HandlerIO handler) throws ProcessingException { String temporizationDelayInSecondsStr = params.getMapParameters().get(WorkerParameterName.lifecycleTraceabilityTemporizationDelayInSeconds); String lifecycleTraceabilityMaxEntriesStr = params.getMapParameters().get(WorkerParameterName.lifecycleTraceabilityMaxEntries); int temporizationDelayInSeconds = Integer.parseInt(temporizationDelayInSecondsStr); int lifecycleTraceabilityMaxEntries = Integer.parseInt(lifecycleTraceabilityMaxEntriesStr); final ItemStatus itemStatus = new ItemStatus(ACTION_HANDLER_ID); try { StatusCode statusCode = selectAndExportLifecyclesWithMetadata(temporizationDelayInSeconds, lifecycleTraceabilityMaxEntries, Contexts.UNIT_LFC_TRACEABILITY.getEventType(), handler); itemStatus.increment(statusCode); } catch (ProcessingException | LogbookClientException | VitamFatalRuntimeException e) { LOGGER.error("Logbook exception", e); itemStatus.increment(StatusCode.FATAL); } catch (InvalidParseOperationException | InvalidCreateOperationException | VitamKoRuntimeException e) { LOGGER.error("Processing exception", e); itemStatus.increment(StatusCode.KO); } return new ItemStatus(ACTION_HANDLER_ID).setItemsStatus(ACTION_HANDLER_ID, itemStatus); } PrepareUnitLfcTraceabilityActionPlugin(); @VisibleForTesting  PrepareUnitLfcTraceabilityActionPlugin(MetaDataClientFactory metaDataClientFactory,
        LogbookLifeCyclesClientFactory logbookLifeCyclesClientFactory,
        LogbookOperationsClientFactory logbookOperationsClientFactory,
        int batchSize); @Override ItemStatus execute(WorkerParameters params, HandlerIO handler); static String getId(); }
PrepareUnitLfcTraceabilityActionPlugin extends PrepareLfcTraceabilityActionPlugin { @Override public ItemStatus execute(WorkerParameters params, HandlerIO handler) throws ProcessingException { String temporizationDelayInSecondsStr = params.getMapParameters().get(WorkerParameterName.lifecycleTraceabilityTemporizationDelayInSeconds); String lifecycleTraceabilityMaxEntriesStr = params.getMapParameters().get(WorkerParameterName.lifecycleTraceabilityMaxEntries); int temporizationDelayInSeconds = Integer.parseInt(temporizationDelayInSecondsStr); int lifecycleTraceabilityMaxEntries = Integer.parseInt(lifecycleTraceabilityMaxEntriesStr); final ItemStatus itemStatus = new ItemStatus(ACTION_HANDLER_ID); try { StatusCode statusCode = selectAndExportLifecyclesWithMetadata(temporizationDelayInSeconds, lifecycleTraceabilityMaxEntries, Contexts.UNIT_LFC_TRACEABILITY.getEventType(), handler); itemStatus.increment(statusCode); } catch (ProcessingException | LogbookClientException | VitamFatalRuntimeException e) { LOGGER.error("Logbook exception", e); itemStatus.increment(StatusCode.FATAL); } catch (InvalidParseOperationException | InvalidCreateOperationException | VitamKoRuntimeException e) { LOGGER.error("Processing exception", e); itemStatus.increment(StatusCode.KO); } return new ItemStatus(ACTION_HANDLER_ID).setItemsStatus(ACTION_HANDLER_ID, itemStatus); } PrepareUnitLfcTraceabilityActionPlugin(); @VisibleForTesting  PrepareUnitLfcTraceabilityActionPlugin(MetaDataClientFactory metaDataClientFactory,
        LogbookLifeCyclesClientFactory logbookLifeCyclesClientFactory,
        LogbookOperationsClientFactory logbookOperationsClientFactory,
        int batchSize); @Override ItemStatus execute(WorkerParameters params, HandlerIO handler); static String getId();  }