HibernateProjectedResultMapper { public <T, R> R mapResult(Object o, Query<T, R> query, String[] returnFields) { return query.getEntityClass().equals(query.getReturnType()) ? query.getReturnType().cast(o) : mapper.mapTo(query.getReturnType(), o, 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 mapResult_projected() { when(mapper.mapTo(String.class, input, field)).thenReturn(string); assertEquals(string, hMapper.mapResult(input, projected)); verify(mapper).mapTo(String.class, input, field); }
@Test public void mapResult_projected2() { when(mapper.mapTo(TestClass.class, input, fields)).thenReturn(test); assertEquals(test, hMapper.mapResult(input, projected2)); verify(mapper).mapTo(TestClass.class, input, fields); }
@Test public void mapResult_unprojected() { assertEquals(string, hMapper.mapResult(string, unprojected)); }