ElementMatch implements Match { @Override public List matching(final Object testObject) { if (matchCandidates == null) { throw new IllegalArgumentException(NULL_MATCH_CANDIDATES_ERROR_MESSAGE); } List matches = new ArrayList<>(); for (final Object entry : matchCandidates) { if (elementJoinComparator.test((Element) entry, (Element) testObject)) { matches.add(((Element) entry).shallowClone()); } } return matches; } ElementMatch();  ElementMatch(final String... groupByProperties);  ElementMatch(final Set<String> groupByProperties); void setElementGroupByProperties(final Set<String> groupByProperties); @Override void init(final Iterable matchCandidates); @Override List matching(final Object testObject);  }
@Test public void shouldThrowExceptionIfNotInitialised() { ElementMatch elementMatch = new ElementMatch(); try { elementMatch.matching(new Entity("testGroup", "test")); fail("Exception expected"); } catch (final IllegalArgumentException e) { assertEquals("ElementMatch must be initialised with non-null match candidates", e.getMessage()); } }