HibernateProjectedResultMapper { @SuppressWarnings("unchecked") public <T, R> List<R> mapResults(List<?> objects, final Query<T, R> query) { final String[] returnFields = returnFields(query); return query.getEntityClass().equals(query.getReturnType()) ? (List<R>) objects : Lists.transform(objects, new Function<Object,R>() { @Override public R apply(Object arg0) { return mapResult(arg0, query, returnFields); } }); } HibernateProjectedResultMapper(ProjectedResultMapper mapper); R mapResult(Object o, Query<T, R> query, String[] returnFields); R mapResult(Object o, Query<T, R> query); @SuppressWarnings("unchecked") List<R> mapResults(List<?> objects, final Query<T, R> query); @SuppressWarnings("unchecked") Iterable<R> mapResults(ScrollableResults objects, final Query<T, R> query);  }
@Test public void mapResults_projected() { List<String> results = hMapper.mapResults(inputs, projected); for (String result : results) { assertNull(result); } verify(mapper, times(inputs.size())).mapTo(eq(String.class), any(Object.class), eq(field)); }
@Test public void mapResults_projected2() { List<TestClass> results = hMapper.mapResults(inputs, projected2); for (TestClass result : results) { assertNull(result); } verify(mapper, times(inputs.size())).mapTo(eq(TestClass.class), any(Object.class), eq(fields)); }
@Test public void mapResults_unprojected() { assertEquals(strings, hMapper.mapResults(strings, unprojected)); }