DefaultIndexHandler implements IndexHandler<K, V> { protected List<Object> executeDiff(final DiffCriteria diffCriteria) { final List<Object> leftResult = execute(diffCriteria.getLeftCriteria()); final List<Object> rightResult = execute(diffCriteria.getRightCriteria()); for (final Object object : rightResult) { leftResult.remove(object); } return leftResult; } 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 executeDiff() { 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(criteria).when(diffCriteria).getLeftCriteria(); doReturn(criteria).when(diffCriteria).getRightCriteria(); doReturn(objectList1).doReturn(objectList2).when(handler).execute(criteria); List<Object> actualObjects = handler.executeDiff(diffCriteria); assertEquals(object1, actualObjects.get(0)); }