@Test @RunWithCustomExecutor public void givenMultipleBatchLfcAndMetadataWhenExecuteThenReturnResponseOK() throws Exception { VitamThreadUtils.getVitamSession().setTenantId(TENANT_ID); doReturn(PropertiesUtils.getResourceFile(LFC_WITH_METADATA_FILE)).when(handler).getInput(0); doReturn(new ProcessingUri(UriPrefix.MEMORY, "traceabilityData.jsonl")) .when(handler).getOutput(0); doReturn(new ProcessingUri(UriPrefix.MEMORY, "traceabilityStats.json")) .when(handler).getOutput(1); File traceabilityDataFile = folder.newFile(); File traceabilityStatsFile = folder.newFile(); doReturn(traceabilityDataFile).when(handler).getNewLocalFile("traceabilityData.jsonl"); doReturn(traceabilityStatsFile).when(handler).getNewLocalFile("traceabilityStats.json"); List<String> offerIds = Arrays.asList("vitam-iaas-app-02.int", "vitam-iaas-app-03.int"); doReturn(offerIds).when(storageClient).getOffers(anyString()); RequestResponseOK<BatchObjectInformationResponse> objectDigest1 = JsonHandler.getFromInputStream( PropertiesUtils.getResourceAsStream(BATCH_DIGESTS_PART1_FILE), RequestResponseOK.class, BatchObjectInformationResponse.class); doReturn(objectDigest1).when(storageClient) .getBatchObjectInformation(anyString(), eq(DataCategory.UNIT), eq(offerIds), eq(Arrays.asList( "aeaqaaaaaaesicexaasycalg6wczgmiaaaba.json", "aeaqaaaaaaesicexaasycalg6wczgwyaaaba.json", "aeaqaaaaaaesicexaasycalg6wczguqaaaba.json", "aeaqaaaaaaesicexaasycalg6wczgvqaaaba.json"))); RequestResponseOK<BatchObjectInformationResponse> objectDigest2 = JsonHandler.getFromInputStream( PropertiesUtils.getResourceAsStream(BATCH_DIGESTS_PART2_FILE), RequestResponseOK.class, BatchObjectInformationResponse.class); doReturn(objectDigest2).when(storageClient) .getBatchObjectInformation(anyString(), eq(DataCategory.UNIT), eq(offerIds), eq(Arrays.asList( "aeaqaaaaaaesicexaasycalg6wczgwaaaaba.json", "aeaqaaaaaaesicexaasycalg6wczgwqaaaaq.json"))); BuildUnitTraceabilityActionPlugin plugin = new BuildUnitTraceabilityActionPlugin(storageClientFactory, 4, alertService); ItemStatus statusCode = plugin.execute(params, handler); assertThat(statusCode.getGlobalStatus()).isEqualTo(StatusCode.OK); assertThat(traceabilityDataFile).hasSameContentAs(PropertiesUtils.getResourceFile(TRACEABILITY_DATA_FILE)); JsonAssert.assertJsonEquals(JsonHandler.getFromFile(traceabilityStatsFile), JsonHandler.getFromFile(PropertiesUtils.getResourceFile(TRACEABILITY_STATS_FILE))); verifyNoMoreInteractions(alertService); }
@Override public ItemStatus execute(WorkerParameters params, HandlerIO handler) throws ProcessingException { LOGGER.info("Building unit traceability data"); ItemStatus itemStatus = new ItemStatus(ACTION_HANDLER_ID); buildTraceabilityData(handler, LogbookLifeCycleUnit.class.getName(), itemStatus); LOGGER.info("Building unit traceability data finished with status " + itemStatus.getGlobalStatus()); return new ItemStatus(ACTION_HANDLER_ID).setItemsStatus(ACTION_HANDLER_ID, itemStatus); }
BuildUnitTraceabilityActionPlugin extends BuildTraceabilityActionPlugin { @Override public ItemStatus execute(WorkerParameters params, HandlerIO handler) throws ProcessingException { LOGGER.info("Building unit traceability data"); ItemStatus itemStatus = new ItemStatus(ACTION_HANDLER_ID); buildTraceabilityData(handler, LogbookLifeCycleUnit.class.getName(), itemStatus); LOGGER.info("Building unit traceability data finished with status " + itemStatus.getGlobalStatus()); return new ItemStatus(ACTION_HANDLER_ID).setItemsStatus(ACTION_HANDLER_ID, itemStatus); } }
BuildUnitTraceabilityActionPlugin extends BuildTraceabilityActionPlugin { @Override public ItemStatus execute(WorkerParameters params, HandlerIO handler) throws ProcessingException { LOGGER.info("Building unit traceability data"); ItemStatus itemStatus = new ItemStatus(ACTION_HANDLER_ID); buildTraceabilityData(handler, LogbookLifeCycleUnit.class.getName(), itemStatus); LOGGER.info("Building unit traceability data finished with status " + itemStatus.getGlobalStatus()); return new ItemStatus(ACTION_HANDLER_ID).setItemsStatus(ACTION_HANDLER_ID, itemStatus); } BuildUnitTraceabilityActionPlugin(); @VisibleForTesting  BuildUnitTraceabilityActionPlugin(StorageClientFactory storageClientFactory,
        int batchSize, AlertService alertService); }
BuildUnitTraceabilityActionPlugin extends BuildTraceabilityActionPlugin { @Override public ItemStatus execute(WorkerParameters params, HandlerIO handler) throws ProcessingException { LOGGER.info("Building unit traceability data"); ItemStatus itemStatus = new ItemStatus(ACTION_HANDLER_ID); buildTraceabilityData(handler, LogbookLifeCycleUnit.class.getName(), itemStatus); LOGGER.info("Building unit traceability data finished with status " + itemStatus.getGlobalStatus()); return new ItemStatus(ACTION_HANDLER_ID).setItemsStatus(ACTION_HANDLER_ID, itemStatus); } BuildUnitTraceabilityActionPlugin(); @VisibleForTesting  BuildUnitTraceabilityActionPlugin(StorageClientFactory storageClientFactory,
        int batchSize, AlertService alertService); @Override ItemStatus execute(WorkerParameters params, HandlerIO handler); static String getId(); }
BuildUnitTraceabilityActionPlugin extends BuildTraceabilityActionPlugin { @Override public ItemStatus execute(WorkerParameters params, HandlerIO handler) throws ProcessingException { LOGGER.info("Building unit traceability data"); ItemStatus itemStatus = new ItemStatus(ACTION_HANDLER_ID); buildTraceabilityData(handler, LogbookLifeCycleUnit.class.getName(), itemStatus); LOGGER.info("Building unit traceability data finished with status " + itemStatus.getGlobalStatus()); return new ItemStatus(ACTION_HANDLER_ID).setItemsStatus(ACTION_HANDLER_ID, itemStatus); } BuildUnitTraceabilityActionPlugin(); @VisibleForTesting  BuildUnitTraceabilityActionPlugin(StorageClientFactory storageClientFactory,
        int batchSize, AlertService alertService); @Override ItemStatus execute(WorkerParameters params, HandlerIO handler); static String getId();  }