OrFilter extends LogicalFilter { public List<Object> filter(final List<Object> objects) { final Set<Object> results = new HashSet<Object>(); for (final Filter filter : filters) { results.addAll(filter.filter(objects)); } return new ArrayList<>(results); } OrFilter(Filter... filters); Filter[] getFilters(); List<Object> filter(final 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 = orFilter.filter(list1); assertTrue(actualObjects.contains(object1)); assertTrue(actualObjects.contains(object2)); assertTrue(actualObjects.contains(object3)); }