@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> gotDigest1 = JsonHandler.getFromInputStream( PropertiesUtils.getResourceAsStream(BATCH_DIGESTS_GOT_PART1_FILE), RequestResponseOK.class, BatchObjectInformationResponse.class); doReturn(gotDigest1).when(storageClient) .getBatchObjectInformation(anyString(), eq(DataCategory.OBJECTGROUP), eq(offerIds), eq(Arrays.asList( "aebaaaaaaaesicexaasycalg6xcwe6qaaaaq.json", "aebaaaaaaaesicexaasycalg6xcwe6aaaaaq.json"))); RequestResponseOK<BatchObjectInformationResponse> gotDigest2 = JsonHandler.getFromInputStream( PropertiesUtils.getResourceAsStream(BATCH_DIGESTS_GOT_PART2_FILE), RequestResponseOK.class, BatchObjectInformationResponse.class); doReturn(gotDigest2).when(storageClient) .getBatchObjectInformation(anyString(), eq(DataCategory.OBJECTGROUP), eq(offerIds), eq(Arrays.asList( "aebaaaaaaaesicexaasycalg6xcwe5aaaaaq.json"))); RequestResponseOK<BatchObjectInformationResponse> objectDigest1 = JsonHandler.getFromInputStream( PropertiesUtils.getResourceAsStream(BATCH_DIGESTS_OBJECTS_PART1_FILE), RequestResponseOK.class, BatchObjectInformationResponse.class); RequestResponseOK<BatchObjectInformationResponse> objectDigest2 = JsonHandler.getFromInputStream( PropertiesUtils.getResourceAsStream(BATCH_DIGESTS_OBJECTS_PART2_FILE), RequestResponseOK.class, BatchObjectInformationResponse.class); when(storageClient .getBatchObjectInformation(anyString(), eq(DataCategory.OBJECT), eq(offerIds), anyCollection())) .thenReturn(objectDigest1, objectDigest2); BuildObjectGroupTraceabilityActionPlugin plugin = new BuildObjectGroupTraceabilityActionPlugin(storageClientFactory, 2, 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))); ArgumentCaptor<Collection> objectIds = ArgumentCaptor.forClass(Collection.class); verify(storageClient, times(2)) .getBatchObjectInformation(anyString(), eq(DataCategory.OBJECT), eq(offerIds), objectIds.capture()); assertThat(objectIds.getAllValues().get(0)).containsExactlyInAnyOrder("aeaaaaaaaaesicexaasycalg6xcwe5yaaaba", "aeaaaaaaaaesicexaasycalg6xcwe6iaaaaq"); assertThat(objectIds.getAllValues().get(1)).containsExactlyInAnyOrder("aeaaaaaaaaesicexaasycalg6xcwe4yaaaaq"); verifyNoMoreInteractions(alertService); }
@Override public ItemStatus execute(WorkerParameters params, HandlerIO handler) throws ProcessingException { LOGGER.info("Building object group traceability data"); ItemStatus itemStatus = new ItemStatus(ACTION_HANDLER_ID); buildTraceabilityData(handler, LogbookLifeCycleObjectGroup.class.getName(), itemStatus); LOGGER.info("Building object group traceability data finished with status " + itemStatus.getGlobalStatus()); return new ItemStatus(ACTION_HANDLER_ID).setItemsStatus(ACTION_HANDLER_ID, itemStatus); }
BuildObjectGroupTraceabilityActionPlugin extends BuildTraceabilityActionPlugin { @Override public ItemStatus execute(WorkerParameters params, HandlerIO handler) throws ProcessingException { LOGGER.info("Building object group traceability data"); ItemStatus itemStatus = new ItemStatus(ACTION_HANDLER_ID); buildTraceabilityData(handler, LogbookLifeCycleObjectGroup.class.getName(), itemStatus); LOGGER.info("Building object group traceability data finished with status " + itemStatus.getGlobalStatus()); return new ItemStatus(ACTION_HANDLER_ID).setItemsStatus(ACTION_HANDLER_ID, itemStatus); } }
BuildObjectGroupTraceabilityActionPlugin extends BuildTraceabilityActionPlugin { @Override public ItemStatus execute(WorkerParameters params, HandlerIO handler) throws ProcessingException { LOGGER.info("Building object group traceability data"); ItemStatus itemStatus = new ItemStatus(ACTION_HANDLER_ID); buildTraceabilityData(handler, LogbookLifeCycleObjectGroup.class.getName(), itemStatus); LOGGER.info("Building object group traceability data finished with status " + itemStatus.getGlobalStatus()); return new ItemStatus(ACTION_HANDLER_ID).setItemsStatus(ACTION_HANDLER_ID, itemStatus); } BuildObjectGroupTraceabilityActionPlugin(); @VisibleForTesting  BuildObjectGroupTraceabilityActionPlugin(
        StorageClientFactory storageClientFactory,
        int batchSize, AlertService alertService); }
BuildObjectGroupTraceabilityActionPlugin extends BuildTraceabilityActionPlugin { @Override public ItemStatus execute(WorkerParameters params, HandlerIO handler) throws ProcessingException { LOGGER.info("Building object group traceability data"); ItemStatus itemStatus = new ItemStatus(ACTION_HANDLER_ID); buildTraceabilityData(handler, LogbookLifeCycleObjectGroup.class.getName(), itemStatus); LOGGER.info("Building object group traceability data finished with status " + itemStatus.getGlobalStatus()); return new ItemStatus(ACTION_HANDLER_ID).setItemsStatus(ACTION_HANDLER_ID, itemStatus); } BuildObjectGroupTraceabilityActionPlugin(); @VisibleForTesting  BuildObjectGroupTraceabilityActionPlugin(
        StorageClientFactory storageClientFactory,
        int batchSize, AlertService alertService); @Override ItemStatus execute(WorkerParameters params, HandlerIO handler); static String getId(); }
BuildObjectGroupTraceabilityActionPlugin extends BuildTraceabilityActionPlugin { @Override public ItemStatus execute(WorkerParameters params, HandlerIO handler) throws ProcessingException { LOGGER.info("Building object group traceability data"); ItemStatus itemStatus = new ItemStatus(ACTION_HANDLER_ID); buildTraceabilityData(handler, LogbookLifeCycleObjectGroup.class.getName(), itemStatus); LOGGER.info("Building object group traceability data finished with status " + itemStatus.getGlobalStatus()); return new ItemStatus(ACTION_HANDLER_ID).setItemsStatus(ACTION_HANDLER_ID, itemStatus); } BuildObjectGroupTraceabilityActionPlugin(); @VisibleForTesting  BuildObjectGroupTraceabilityActionPlugin(
        StorageClientFactory storageClientFactory,
        int batchSize, AlertService alertService); @Override ItemStatus execute(WorkerParameters params, HandlerIO handler); static String getId();  }