DiffFilter extends LogicalFilter { public List<Object> filter(List<Object> objects) { final List<Object> leftResult = leftFilter.filter(objects); final List<Object> rightResult = rightFilter.filter(objects); for (final Object object : rightResult) { leftResult.remove(object); } return leftResult; } DiffFilter(Filter leftFilter, Filter rightFilter); Filter getLeftFilter(); Filter getRightFilter(); List<Object> filter(List<Object> objects);  }
@Test public void filter() { Object object1 = new Object(); Object object2 = new Object(); Object object3 = new Object(); List<Object> list1 = new ArrayList<Object>(); list1.add(object1); list1.add(object2); List<Object> list2 = new ArrayList<Object>(); list2.add(object2); list2.add(object3); doReturn(list1).doReturn(list2).when(filter).filter(anyList()); List<Object> actualObjects = diffFilter.filter(list1); assertEquals(object1, actualObjects.get(0)); }