@Test public void testPagingBreakup() { List<List<String>> brokenIds = delegate.extractBrokenListOfIds(generateIds(count)); assertEquals(brokenIds.size(), 1); brokenIds = delegate.extractBrokenListOfIds(generateIds(count + 1)); assertEquals(brokenIds.size(), 2); assertEquals(brokenIds.get(1).size(), 1); assertEquals((String) brokenIds.get(1).get(0), "" + count); brokenIds = delegate.extractBrokenListOfIds(generateIds(count - 1)); assertEquals(brokenIds.size(), 1); assertEquals(brokenIds.get(0).size(), count - 1); brokenIds = delegate.extractBrokenListOfIds(generateIds(count / 2)); assertEquals(brokenIds.size(), 1); assertEquals(brokenIds.get(0).size(), count / 2); brokenIds = delegate.extractBrokenListOfIds(generateIds(count * 3 + count / 2)); assertEquals(brokenIds.size(), 4); assertEquals(brokenIds.get(3).size(), count / 2); }
public List<List<String>> extractBrokenListOfIds(List<String> queriedIds) { List<List<String>> brokenList = new ArrayList<List<String>>(); int blocks = queriedIds.size() / count; if (queriedIds.size() % count > 0) { blocks++; } for (int i = 0; i < blocks; ++i) { List<String> part = new ArrayList<String>(); int offSet = queriedIds.size() - i * count; if (offSet > count) { offSet = count; } part.addAll(queriedIds.subList(i * count, i * count + offSet)); brokenList.add(part); } return brokenList; }
PagingRepositoryDelegate implements Repository<T> { public List<List<String>> extractBrokenListOfIds(List<String> queriedIds) { List<List<String>> brokenList = new ArrayList<List<String>>(); int blocks = queriedIds.size() / count; if (queriedIds.size() % count > 0) { blocks++; } for (int i = 0; i < blocks; ++i) { List<String> part = new ArrayList<String>(); int offSet = queriedIds.size() - i * count; if (offSet > count) { offSet = count; } part.addAll(queriedIds.subList(i * count, i * count + offSet)); brokenList.add(part); } return brokenList; } }
PagingRepositoryDelegate implements Repository<T> { public List<List<String>> extractBrokenListOfIds(List<String> queriedIds) { List<List<String>> brokenList = new ArrayList<List<String>>(); int blocks = queriedIds.size() / count; if (queriedIds.size() % count > 0) { blocks++; } for (int i = 0; i < blocks; ++i) { List<String> part = new ArrayList<String>(); int offSet = queriedIds.size() - i * count; if (offSet > count) { offSet = count; } part.addAll(queriedIds.subList(i * count, i * count + offSet)); brokenList.add(part); } return brokenList; }  }
PagingRepositoryDelegate implements Repository<T> { public List<List<String>> extractBrokenListOfIds(List<String> queriedIds) { List<List<String>> brokenList = new ArrayList<List<String>>(); int blocks = queriedIds.size() / count; if (queriedIds.size() % count > 0) { blocks++; } for (int i = 0; i < blocks; ++i) { List<String> part = new ArrayList<String>(); int offSet = queriedIds.size() - i * count; if (offSet > count) { offSet = count; } part.addAll(queriedIds.subList(i * count, i * count + offSet)); brokenList.add(part); } return brokenList; }  @Override T createWithRetries(String type, String id, Map<String, Object> body, Map<String, Object> metaData,
            String collectionName, int noOfRetries); @Override WriteResult updateMulti(NeutralQuery query, Map<String, Object> update, String entityReferenced); List<List<String>> extractBrokenListOfIds(List<String> queriedIds); @Override T create(String type, Map<String, Object> body); @Override T create(String type, Map<String, Object> body, String collectionName); @Override T create(String type, Map<String, Object> body, Map<String, Object> metaData, String collectionName); @Override List<T> insert(List<T> records, String collectionName); @Override T findById(String collectionName, String id); @Override T findById(String collectionName, String id, boolean allFields); @Override boolean exists(String collectionName, String id); @Override T findOne(String collectionName, NeutralQuery neutralQuery); @Override T findOne(String collectionName, NeutralQuery neutralQuery, boolean allFields); @Override Iterable<T> findAll(String collectionName, NeutralQuery neutralQuery); @Override Iterable<String> findAllIds(String collectionName, NeutralQuery neutralQuery); @Override long count(String collectionName, NeutralQuery neutralQuery); @Override boolean update(String collection, T object, boolean isSuperdoc); @Override boolean doUpdate(String collection, NeutralQuery query, Update update); @Override CascadeResult safeDelete(String entityType, String id, boolean cascade, boolean dryrun, boolean forced, boolean logViolations,
                                    Integer maxObjects, AccessibilityCheck access); @Override boolean delete(String collectionName, String id); @Override void deleteAll(String collectionName, NeutralQuery query); @Override DBCollection getCollection(String collectionName); @Override List<DBCollection> getCollections(boolean includeSystemCollections); @Override @Deprecated Iterable<T> findByQuery(String collectionName, Query query, int skip, int max); @Override boolean collectionExists(String collection); @Override void setWriteConcern(String writeConcern); @Override void setReferenceCheck(String referenceCheck); @Override long count(String collectionName, Query query); @Override boolean updateWithRetries(String collection, T object, int noOfRetries); @Override boolean patch(String type, String collectionName, String id, Map<String, Object> newValues); @Override T findAndUpdate(String collectionName, NeutralQuery neutralQuery, Update update); @Override Iterator<T> findEach(String collectionName, NeutralQuery query); @Override Iterator<T> findEach(String collectionName, Query query); @Override CascadeResult safeDelete(Entity entity, String id, boolean cascade, boolean dryrun, boolean force, boolean logViolations,
            Integer maxObjects, AccessibilityCheck access); }
PagingRepositoryDelegate implements Repository<T> { public List<List<String>> extractBrokenListOfIds(List<String> queriedIds) { List<List<String>> brokenList = new ArrayList<List<String>>(); int blocks = queriedIds.size() / count; if (queriedIds.size() % count > 0) { blocks++; } for (int i = 0; i < blocks; ++i) { List<String> part = new ArrayList<String>(); int offSet = queriedIds.size() - i * count; if (offSet > count) { offSet = count; } part.addAll(queriedIds.subList(i * count, i * count + offSet)); brokenList.add(part); } return brokenList; }  @Override T createWithRetries(String type, String id, Map<String, Object> body, Map<String, Object> metaData,
            String collectionName, int noOfRetries); @Override WriteResult updateMulti(NeutralQuery query, Map<String, Object> update, String entityReferenced); List<List<String>> extractBrokenListOfIds(List<String> queriedIds); @Override T create(String type, Map<String, Object> body); @Override T create(String type, Map<String, Object> body, String collectionName); @Override T create(String type, Map<String, Object> body, Map<String, Object> metaData, String collectionName); @Override List<T> insert(List<T> records, String collectionName); @Override T findById(String collectionName, String id); @Override T findById(String collectionName, String id, boolean allFields); @Override boolean exists(String collectionName, String id); @Override T findOne(String collectionName, NeutralQuery neutralQuery); @Override T findOne(String collectionName, NeutralQuery neutralQuery, boolean allFields); @Override Iterable<T> findAll(String collectionName, NeutralQuery neutralQuery); @Override Iterable<String> findAllIds(String collectionName, NeutralQuery neutralQuery); @Override long count(String collectionName, NeutralQuery neutralQuery); @Override boolean update(String collection, T object, boolean isSuperdoc); @Override boolean doUpdate(String collection, NeutralQuery query, Update update); @Override CascadeResult safeDelete(String entityType, String id, boolean cascade, boolean dryrun, boolean forced, boolean logViolations,
                                    Integer maxObjects, AccessibilityCheck access); @Override boolean delete(String collectionName, String id); @Override void deleteAll(String collectionName, NeutralQuery query); @Override DBCollection getCollection(String collectionName); @Override List<DBCollection> getCollections(boolean includeSystemCollections); @Override @Deprecated Iterable<T> findByQuery(String collectionName, Query query, int skip, int max); @Override boolean collectionExists(String collection); @Override void setWriteConcern(String writeConcern); @Override void setReferenceCheck(String referenceCheck); @Override long count(String collectionName, Query query); @Override boolean updateWithRetries(String collection, T object, int noOfRetries); @Override boolean patch(String type, String collectionName, String id, Map<String, Object> newValues); @Override T findAndUpdate(String collectionName, NeutralQuery neutralQuery, Update update); @Override Iterator<T> findEach(String collectionName, NeutralQuery query); @Override Iterator<T> findEach(String collectionName, Query query); @Override CascadeResult safeDelete(Entity entity, String id, boolean cascade, boolean dryrun, boolean force, boolean logViolations,
            Integer maxObjects, AccessibilityCheck access);  }