@Test public void testSelectObjectGroupBulk_notYetMigrated() throws Exception { String dataSetFile = "DataMigrationR6/15ObjectGroupDataSet/R6ObjectGroupDataSet.json"; importObjectGroupDataSetFile(dataSetFile); try (CloseableIterator<List<String>> listCloseableIterator = repository.selectObjectGroupBulk()) { Set<String> idSet = new HashSet<>(); listCloseableIterator.forEachRemaining(objectGroupBulk -> { assertThat(objectGroupBulk).size().isLessThanOrEqualTo(TEST_BULK_SIZE); for (String objectGroupId : objectGroupBulk) { assertThat(idSet.add(objectGroupId)).isTrue(); } }); assertThat(idSet).size().isEqualTo(NB_OBJECT_GROUPS); } }
public CloseableIterator<List<String>> selectObjectGroupBulk() { MongoCursor<ObjectGroup> ogMongoCursor = selectObjectGroups(); return new CloseableIterator<List<String>>() { @Override public void close() { ogMongoCursor.close(); } @Override public boolean hasNext() { return ogMongoCursor.hasNext(); } @Override public List<String> next() { if (!hasNext()) { throw new NoSuchElementException(); } List<String> bulkGotIds = new ArrayList<>(); while (ogMongoCursor.hasNext()) { ObjectGroup got = ogMongoCursor.next(); bulkGotIds.add(got.getId()); boolean shouldSplitByBulkSize = bulkGotIds.size() == bulkSize; if (shouldSplitByBulkSize) { break; } } return bulkGotIds; } }; }
DataMigrationRepository { public CloseableIterator<List<String>> selectObjectGroupBulk() { MongoCursor<ObjectGroup> ogMongoCursor = selectObjectGroups(); return new CloseableIterator<List<String>>() { @Override public void close() { ogMongoCursor.close(); } @Override public boolean hasNext() { return ogMongoCursor.hasNext(); } @Override public List<String> next() { if (!hasNext()) { throw new NoSuchElementException(); } List<String> bulkGotIds = new ArrayList<>(); while (ogMongoCursor.hasNext()) { ObjectGroup got = ogMongoCursor.next(); bulkGotIds.add(got.getId()); boolean shouldSplitByBulkSize = bulkGotIds.size() == bulkSize; if (shouldSplitByBulkSize) { break; } } return bulkGotIds; } }; } }
DataMigrationRepository { public CloseableIterator<List<String>> selectObjectGroupBulk() { MongoCursor<ObjectGroup> ogMongoCursor = selectObjectGroups(); return new CloseableIterator<List<String>>() { @Override public void close() { ogMongoCursor.close(); } @Override public boolean hasNext() { return ogMongoCursor.hasNext(); } @Override public List<String> next() { if (!hasNext()) { throw new NoSuchElementException(); } List<String> bulkGotIds = new ArrayList<>(); while (ogMongoCursor.hasNext()) { ObjectGroup got = ogMongoCursor.next(); bulkGotIds.add(got.getId()); boolean shouldSplitByBulkSize = bulkGotIds.size() == bulkSize; if (shouldSplitByBulkSize) { break; } } return bulkGotIds; } }; } DataMigrationRepository(); @VisibleForTesting  DataMigrationRepository(int bulkSize); }
DataMigrationRepository { public CloseableIterator<List<String>> selectObjectGroupBulk() { MongoCursor<ObjectGroup> ogMongoCursor = selectObjectGroups(); return new CloseableIterator<List<String>>() { @Override public void close() { ogMongoCursor.close(); } @Override public boolean hasNext() { return ogMongoCursor.hasNext(); } @Override public List<String> next() { if (!hasNext()) { throw new NoSuchElementException(); } List<String> bulkGotIds = new ArrayList<>(); while (ogMongoCursor.hasNext()) { ObjectGroup got = ogMongoCursor.next(); bulkGotIds.add(got.getId()); boolean shouldSplitByBulkSize = bulkGotIds.size() == bulkSize; if (shouldSplitByBulkSize) { break; } } return bulkGotIds; } }; } DataMigrationRepository(); @VisibleForTesting  DataMigrationRepository(int bulkSize); CloseableIterator<List<Unit>> selectUnitBulkInTopDownHierarchyLevel(); Map<String, Unit> getUnitGraphByIds(Collection<String> unitIds); void bulkReplaceUnits(List<Unit> updatedUnits); CloseableIterator<List<String>> selectObjectGroupBulk(); void bulkUpgradeObjectGroups(List<String> objectGroupIds); }
DataMigrationRepository { public CloseableIterator<List<String>> selectObjectGroupBulk() { MongoCursor<ObjectGroup> ogMongoCursor = selectObjectGroups(); return new CloseableIterator<List<String>>() { @Override public void close() { ogMongoCursor.close(); } @Override public boolean hasNext() { return ogMongoCursor.hasNext(); } @Override public List<String> next() { if (!hasNext()) { throw new NoSuchElementException(); } List<String> bulkGotIds = new ArrayList<>(); while (ogMongoCursor.hasNext()) { ObjectGroup got = ogMongoCursor.next(); bulkGotIds.add(got.getId()); boolean shouldSplitByBulkSize = bulkGotIds.size() == bulkSize; if (shouldSplitByBulkSize) { break; } } return bulkGotIds; } }; } DataMigrationRepository(); @VisibleForTesting  DataMigrationRepository(int bulkSize); CloseableIterator<List<Unit>> selectUnitBulkInTopDownHierarchyLevel(); Map<String, Unit> getUnitGraphByIds(Collection<String> unitIds); void bulkReplaceUnits(List<Unit> updatedUnits); CloseableIterator<List<String>> selectObjectGroupBulk(); void bulkUpgradeObjectGroups(List<String> objectGroupIds);  }