Mapper implements Func1<From, To> { public Collection<To> map(@Nonnull Collection<From> entities) { requireNotNull(entities); final Collection<To> result = new ArrayList<>(entities.size()); for (From from : entities) { result.add(map(from)); } return result; }  @Override final To call(@Nonnull From from); Collection<To> map(@Nonnull Collection<From> entities); abstract To map(From entity);  }
@Test public void shouldCallOverloadedMethod() { mapper.map(asList(1, 2, 3)); verify(mapper).map(1); verify(mapper).map(2); verify(mapper).map(3); }
@Test public void shouldNotRespectNullCollections() { checkIllegalArgumentException(() -> mapper.map((Collection<Integer>) null)); }