EqualsTypeComparator extends AbstractMovieComparator { @Override public boolean areEqual(@NonNull Movie movie1, @NonNull Movie movie2) { boolean result = movie1.getType().equals(movie2.getType()); LOG.debug( "Comparing type '{}' with type '{}', matches = '{}'", movie1.getType(), movie2.getType(), result ); return result; }  @Override boolean areEqual(@NonNull Movie movie1, @NonNull Movie movie2);  }
@Test public void areEqualEqual() throws Exception { for (Movie.Type type : Movie.Type.values()) { assertTrue(comparator.areEqual( new Movie("Inception", 2010).setType(type), new Movie("Inception", 2010).setType(type) )); } }
@Test public void areEqualNotEqual() throws Exception { assertFalse(comparator.areEqual( new Movie("Inception", 2010), new Movie("Inception", 2010).setType(Movie.Type.DOCUMENTARY) )); assertFalse(comparator.areEqual( new Movie("Inception", 2010), new Movie("Inception", 2010).setType(Movie.Type.SHORT) )); assertFalse(comparator.areEqual( new Movie("Inception", 2010), new Movie("Inception", 2010).setType(Movie.Type.SERIES) )); assertFalse(comparator.areEqual( new Movie("Inception", 2010), new Movie("Inception", 2010).setType(Movie.Type.VIDEO_GAME) )); }