@Test public void executeOr() { 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(orCriteria).getCriterias(); doReturn(objectList1).doReturn(objectList2).when(handler).execute(criteria); List<Object> actualObjects = handler.executeOr(orCriteria); assertTrue(actualObjects.contains(object1)); assertTrue(actualObjects.contains(object2)); assertTrue(actualObjects.contains(object3)); }
protected List<Object> executeOr(final OrCriteria orCriteria) { final Set<Object> results = new HashSet<>(); for (Criteria innerCriteria : orCriteria.getCriterias()) { final List<Object> result = execute(innerCriteria); results.addAll(result); } return new ArrayList<>(results); }
DefaultIndexHandler implements IndexHandler<K, V> { protected List<Object> executeOr(final OrCriteria orCriteria) { final Set<Object> results = new HashSet<>(); for (Criteria innerCriteria : orCriteria.getCriterias()) { final List<Object> result = execute(innerCriteria); results.addAll(result); } return new ArrayList<>(results); } }
DefaultIndexHandler implements IndexHandler<K, V> { protected List<Object> executeOr(final OrCriteria orCriteria) { final Set<Object> results = new HashSet<>(); for (Criteria innerCriteria : orCriteria.getCriterias()) { final List<Object> result = execute(innerCriteria); results.addAll(result); } return new ArrayList<>(results); } DefaultIndexHandler(); }
DefaultIndexHandler implements IndexHandler<K, V> { protected List<Object> executeOr(final OrCriteria orCriteria) { final Set<Object> results = new HashSet<>(); for (Criteria innerCriteria : orCriteria.getCriterias()) { final List<Object> result = execute(innerCriteria); results.addAll(result); } return new ArrayList<>(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); }
DefaultIndexHandler implements IndexHandler<K, V> { protected List<Object> executeOr(final OrCriteria orCriteria) { final Set<Object> results = new HashSet<>(); for (Criteria innerCriteria : orCriteria.getCriterias()) { final List<Object> result = execute(innerCriteria); results.addAll(result); } return new ArrayList<>(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);  }