DefaultIndexHandler implements IndexHandler<K, V> { protected List<Object> executeAnd(final AndCriteria andCriteria) { List<Object> results = new ArrayList<Object>(); for (final Criteria innerCriteria : andCriteria.getCriterias()) { List<Object> result = execute(innerCriteria); results = getObjects(results, result); } return results; } DefaultIndexHandler(); void addIndex(final String attributeName, final IndexType type); void add(final K key, final V value); void remove(final K key, final V value); void clear(); @SuppressWarnings("unchecked") List<K> execute(final Query query);  }
@Test public void executeAnd() { Object object1 = new Object(); Object object2 = new Object(); Object object3 = new Object(); List<Object> objectList1 = new ArrayList<Object>(); List<Object> objectList2 = new ArrayList<Object>(); objectList1.add(object1); objectList1.add(object2); objectList2.add(object2); objectList2.add(object3); doReturn(new Criteria[]{criteria, criteria}).when(andCriteria).getCriterias(); doReturn(objectList1).doReturn(objectList2).when(handler).execute(criteria); List<Object> actualObjects = handler.executeAnd(andCriteria); assertEquals(object2, actualObjects.get(0)); }