MatchableEntityHasher implements Serializable { public List<Tuple2<String, String>> hashEntity(MatchableEntity entity) { Preconditions.checkNotNull(entity); List<Tuple2<String, String>> hashIdPairs = new ArrayList<>(); Iterable<String> hashes = scalaIterableConverter.convertToJavaIterable(hashGenerator.generate(entity)); for (String hash : hashes) { hashIdPairs.add(new Tuple2<>(hash, entity.id())); } return hashIdPairs; }  List<Tuple2<String, String>> hashEntity(MatchableEntity entity); void setHashGenerator(HashGenerator hashGenerator);  }
@Test(expectedExceptions=NullPointerException.class) public void hashEntity_NULL() { matchableEntityHasher.hashEntity(null); }
@Test public void hashEntity() { MatchableEntity entity = mock(MatchableEntity.class); when(entity.id()).thenReturn("12"); @SuppressWarnings("unchecked") scala.collection.Iterable<String> iterable = mock(scala.collection.Iterable.class); Mockito.when(hashGenerator.generate(entity)).thenReturn(iterable); List<String> hashes = Lists.newArrayList("XXX", "ZZZ"); when(scalaIterableConverter.convertToJavaIterable(iterable)).thenReturn(hashes); List<Tuple2<String, String>> hashIdPairs = matchableEntityHasher.hashEntity(entity); assertEquals(2, hashIdPairs.size()); assertEquals(new Tuple2<>("XXX", "12"), hashIdPairs.get(0)); assertEquals(new Tuple2<>("ZZZ", "12"), hashIdPairs.get(1)); }