### Question:
DBUtil { public static Criterion getBoundedInCriterion(String propertyName, Collection idCollection) { Disjunction disjunction = Restrictions.disjunction(); List idList; int fromIndex = 0; if(CollectionUtils.isEmpty(idCollection)) { return Restrictions.conjunction(); } if (idCollection instanceof List) { idList = (List)idCollection; } else { idList = (List)idCollection.parallelStream().collect(Collectors.toList()); } while (maxInElements > 0 && fromIndex < idList.size()) { int toIndex = Math.min(fromIndex + maxInElements, idList.size()); List idSubList = idList.subList(fromIndex, toIndex); disjunction.add(Restrictions.in(propertyName, idSubList)); fromIndex += maxInElements; } return disjunction; }  static Criterion getBoundedInCriterion(String propertyName, Collection idCollection);  }### Answer:
@Test public void getBoundedInCriterion_withMoreRecords() { Disjunction expectedCriteria = Restrictions.disjunction(); Set<Integer> set = new HashSet<Integer>(); for(int i=0; i<2500; i++){ set.add(i); } expectedCriteria.add(Restrictions.in("fieldName", new ArrayList(set).subList(0,900))); expectedCriteria.add(Restrictions.in("fieldName", new ArrayList(set).subList(900,1800))); expectedCriteria.add(Restrictions.in("fieldName", new ArrayList(set).subList(1800,2500))); Disjunction actualCriteria = (Disjunction)DBUtil.getBoundedInCriterion("fieldName", set); assertEquals(expectedCriteria.toString(), actualCriteria.toString()); }
@Test public void getFixedInCriterion_withRecords_LessThan900() { Disjunction expectedCriteria = Restrictions.disjunction(); List<String> list = new ArrayList<String>(); for(int i=0; i<500; i++){ list.add(String.valueOf(i)); } expectedCriteria.add(Restrictions.in("fieldName", list)); Disjunction actualCriteria = (Disjunction)DBUtil.getBoundedInCriterion("fieldName", list); assertEquals(expectedCriteria.toString(), actualCriteria.toString()); }
@Test public void getFixedInCriterion_withEmptyRecords() { Conjunction expectedCriteria = Restrictions.conjunction(); List<Integer> list = new ArrayList<Integer>(); Criterion actualCriteria = DBUtil.getBoundedInCriterion("fieldName", list); assertEquals(expectedCriteria.toString(), actualCriteria.toString()); }