@Test @RunWithCustomExecutor public void givenWorkspaceInErrorWhenExecuteThenReturnResponseKO() throws Exception { VitamThreadUtils.getVitamSession().setTenantId(TENANT_ID); handlerIO.addOutIOParameters(out); final List<JsonNode> objectsLFC = IteratorUtils.toList(JsonHandler.getFromInputStream( PropertiesUtils.getResourceAsStream(LFC_OBJECTS_JSON)).elements()); final JsonNode lastTraceability = JsonHandler.getFromInputStream(PropertiesUtils.getResourceAsStream(LAST_TRACEABILITY_JSON)); reset(logbookLifeCyclesClient); when(logbookLifeCyclesClient.getRawObjectGroupLifecyclesByLastPersistedDate(any(), any(), anyInt())) .thenReturn(objectsLFC); reset(logbookOperationsClient); when(logbookOperationsClient.selectOperation(any())).thenReturn(lastTraceability); doThrow(new ContentAddressableStorageServerException("ContentAddressableStorageServerException")) .when(workspaceClient).putObject(anyString(), anyString(), any(InputStream.class)); WorkerParameters params = createExecParams(300, 100000); PrepareObjectGroupLfcTraceabilityActionPlugin handler = new PrepareObjectGroupLfcTraceabilityActionPlugin(); final ItemStatus response = handler.execute(params, handlerIO); assertEquals(StatusCode.FATAL, 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 { selectAndExportLifecyclesWithMetadata(temporizationDelayInSeconds, lifecycleTraceabilityMaxEntries, Contexts.OBJECTGROUP_LFC_TRACEABILITY.getEventType(), handler); itemStatus.increment(StatusCode.OK); } 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); }
PrepareObjectGroupLfcTraceabilityActionPlugin 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 { selectAndExportLifecyclesWithMetadata(temporizationDelayInSeconds, lifecycleTraceabilityMaxEntries, Contexts.OBJECTGROUP_LFC_TRACEABILITY.getEventType(), handler); itemStatus.increment(StatusCode.OK); } 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); } }
PrepareObjectGroupLfcTraceabilityActionPlugin 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 { selectAndExportLifecyclesWithMetadata(temporizationDelayInSeconds, lifecycleTraceabilityMaxEntries, Contexts.OBJECTGROUP_LFC_TRACEABILITY.getEventType(), handler); itemStatus.increment(StatusCode.OK); } 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); } PrepareObjectGroupLfcTraceabilityActionPlugin(); @VisibleForTesting  PrepareObjectGroupLfcTraceabilityActionPlugin(MetaDataClientFactory metaDataClientFactory,
        LogbookLifeCyclesClientFactory logbookLifeCyclesClientFactory,
        LogbookOperationsClientFactory logbookOperationsClientFactory,
        int batchSize); }
PrepareObjectGroupLfcTraceabilityActionPlugin 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 { selectAndExportLifecyclesWithMetadata(temporizationDelayInSeconds, lifecycleTraceabilityMaxEntries, Contexts.OBJECTGROUP_LFC_TRACEABILITY.getEventType(), handler); itemStatus.increment(StatusCode.OK); } 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); } PrepareObjectGroupLfcTraceabilityActionPlugin(); @VisibleForTesting  PrepareObjectGroupLfcTraceabilityActionPlugin(MetaDataClientFactory metaDataClientFactory,
        LogbookLifeCyclesClientFactory logbookLifeCyclesClientFactory,
        LogbookOperationsClientFactory logbookOperationsClientFactory,
        int batchSize); @Override ItemStatus execute(WorkerParameters params, HandlerIO handler); static String getId(); }
PrepareObjectGroupLfcTraceabilityActionPlugin 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 { selectAndExportLifecyclesWithMetadata(temporizationDelayInSeconds, lifecycleTraceabilityMaxEntries, Contexts.OBJECTGROUP_LFC_TRACEABILITY.getEventType(), handler); itemStatus.increment(StatusCode.OK); } 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); } PrepareObjectGroupLfcTraceabilityActionPlugin(); @VisibleForTesting  PrepareObjectGroupLfcTraceabilityActionPlugin(MetaDataClientFactory metaDataClientFactory,
        LogbookLifeCyclesClientFactory logbookLifeCyclesClientFactory,
        LogbookOperationsClientFactory logbookOperationsClientFactory,
        int batchSize); @Override ItemStatus execute(WorkerParameters params, HandlerIO handler); static String getId();  }