@Test public void should_prepare_Linked_got_files() throws Exception { given(metaDataClient.selectObjectGroups(any(JsonNode.class))).willReturn( JsonHandler.getFromInputStream(getClass().getResourceAsStream("/migration/resultObjectGroup.json"))); File jsonLineFile = tempFolder.newFile(); given(handlerIO.getNewLocalFile("ObjectGroups.jsonl")).willReturn(jsonLineFile); File reportFile = tempFolder.newFile(); given(handlerIO.getNewLocalFile(("report.json"))).willReturn(reportFile); MigrationObjectGroupPrepare migrationGotPrepare = new MigrationObjectGroupPrepare(metaDataClientFactory, 2); File file = tempFolder.newFile(); when(handlerIO.getNewLocalFile("migrationObjectsListIds")).thenReturn(file); ItemStatus execute = migrationGotPrepare.execute(defaultWorkerParameters, handlerIO); assertThat(execute.getGlobalStatus()).isEqualTo(StatusCode.OK); try (InputStream is = new FileInputStream(jsonLineFile)) { JsonLineGenericIterator<JsonLineModel> lineGenericIterator = new JsonLineGenericIterator<>(is, TYPE_REFERENCE); List<String> unitIds = IteratorUtils.toList(lineGenericIterator) .stream() .map(JsonLineModel::getId) .collect(Collectors.toList()); assertThat(unitIds).containsExactly( "aebaaaaaaadf6mc4aathcak7tmtgc7yaaaaq", "aebaaaaaaadf6mc4aathcak7tmtgc7qaaaaq", "aebaaaaaaadf6mc4aathcak7tmtgc6yaaaaq" ); } }
@Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) { ItemStatus itemStatus = new ItemStatus(MIGRATION_OBJECT_GROUPS_LIST); try (MetaDataClient client = metaDataClientFactory.getClient()) { SelectMultiQuery selectMultiQuery = getSelectMultiQuery(); ScrollSpliterator<JsonNode> scrollRequest = ScrollSpliteratorHelper .createObjectGroupScrollSplitIterator(client, selectMultiQuery, bachSize); exportToReportAndDistributionFile(scrollRequest, handler, "ObjectGroups.jsonl", REPORTS + "/" + MIGRATION_OBJECT_LIST_IDS + ".json"); } catch (InvalidParseOperationException | InvalidCreateOperationException | ProcessingException e) { LOGGER.error(e); return itemStatus.increment(StatusCode.FATAL); } itemStatus.increment(StatusCode.OK); return new ItemStatus(MIGRATION_OBJECT_GROUPS_LIST).setItemsStatus(MIGRATION_OBJECT_GROUPS_LIST, itemStatus); }
MigrationObjectGroupPrepare extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) { ItemStatus itemStatus = new ItemStatus(MIGRATION_OBJECT_GROUPS_LIST); try (MetaDataClient client = metaDataClientFactory.getClient()) { SelectMultiQuery selectMultiQuery = getSelectMultiQuery(); ScrollSpliterator<JsonNode> scrollRequest = ScrollSpliteratorHelper .createObjectGroupScrollSplitIterator(client, selectMultiQuery, bachSize); exportToReportAndDistributionFile(scrollRequest, handler, "ObjectGroups.jsonl", REPORTS + "/" + MIGRATION_OBJECT_LIST_IDS + ".json"); } catch (InvalidParseOperationException | InvalidCreateOperationException | ProcessingException e) { LOGGER.error(e); return itemStatus.increment(StatusCode.FATAL); } itemStatus.increment(StatusCode.OK); return new ItemStatus(MIGRATION_OBJECT_GROUPS_LIST).setItemsStatus(MIGRATION_OBJECT_GROUPS_LIST, itemStatus); } }
MigrationObjectGroupPrepare extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) { ItemStatus itemStatus = new ItemStatus(MIGRATION_OBJECT_GROUPS_LIST); try (MetaDataClient client = metaDataClientFactory.getClient()) { SelectMultiQuery selectMultiQuery = getSelectMultiQuery(); ScrollSpliterator<JsonNode> scrollRequest = ScrollSpliteratorHelper .createObjectGroupScrollSplitIterator(client, selectMultiQuery, bachSize); exportToReportAndDistributionFile(scrollRequest, handler, "ObjectGroups.jsonl", REPORTS + "/" + MIGRATION_OBJECT_LIST_IDS + ".json"); } catch (InvalidParseOperationException | InvalidCreateOperationException | ProcessingException e) { LOGGER.error(e); return itemStatus.increment(StatusCode.FATAL); } itemStatus.increment(StatusCode.OK); return new ItemStatus(MIGRATION_OBJECT_GROUPS_LIST).setItemsStatus(MIGRATION_OBJECT_GROUPS_LIST, itemStatus); } @VisibleForTesting  MigrationObjectGroupPrepare(MetaDataClientFactory metaDataClientFactory, int bachSize);  MigrationObjectGroupPrepare(); }
MigrationObjectGroupPrepare extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) { ItemStatus itemStatus = new ItemStatus(MIGRATION_OBJECT_GROUPS_LIST); try (MetaDataClient client = metaDataClientFactory.getClient()) { SelectMultiQuery selectMultiQuery = getSelectMultiQuery(); ScrollSpliterator<JsonNode> scrollRequest = ScrollSpliteratorHelper .createObjectGroupScrollSplitIterator(client, selectMultiQuery, bachSize); exportToReportAndDistributionFile(scrollRequest, handler, "ObjectGroups.jsonl", REPORTS + "/" + MIGRATION_OBJECT_LIST_IDS + ".json"); } catch (InvalidParseOperationException | InvalidCreateOperationException | ProcessingException e) { LOGGER.error(e); return itemStatus.increment(StatusCode.FATAL); } itemStatus.increment(StatusCode.OK); return new ItemStatus(MIGRATION_OBJECT_GROUPS_LIST).setItemsStatus(MIGRATION_OBJECT_GROUPS_LIST, itemStatus); } @VisibleForTesting  MigrationObjectGroupPrepare(MetaDataClientFactory metaDataClientFactory, int bachSize);  MigrationObjectGroupPrepare(); @Override ItemStatus execute(WorkerParameters param, HandlerIO handler); @Override void checkMandatoryIOParameter(final HandlerIO handler); }
MigrationObjectGroupPrepare extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) { ItemStatus itemStatus = new ItemStatus(MIGRATION_OBJECT_GROUPS_LIST); try (MetaDataClient client = metaDataClientFactory.getClient()) { SelectMultiQuery selectMultiQuery = getSelectMultiQuery(); ScrollSpliterator<JsonNode> scrollRequest = ScrollSpliteratorHelper .createObjectGroupScrollSplitIterator(client, selectMultiQuery, bachSize); exportToReportAndDistributionFile(scrollRequest, handler, "ObjectGroups.jsonl", REPORTS + "/" + MIGRATION_OBJECT_LIST_IDS + ".json"); } catch (InvalidParseOperationException | InvalidCreateOperationException | ProcessingException e) { LOGGER.error(e); return itemStatus.increment(StatusCode.FATAL); } itemStatus.increment(StatusCode.OK); return new ItemStatus(MIGRATION_OBJECT_GROUPS_LIST).setItemsStatus(MIGRATION_OBJECT_GROUPS_LIST, itemStatus); } @VisibleForTesting  MigrationObjectGroupPrepare(MetaDataClientFactory metaDataClientFactory, int bachSize);  MigrationObjectGroupPrepare(); @Override ItemStatus execute(WorkerParameters param, HandlerIO handler); @Override void checkMandatoryIOParameter(final HandlerIO handler);  }