EntityResultMapper implements SparqlResultMapper { @Override public T map(ResultRow resultRow, UnitOfWorkImpl uow) { try { final T instance = et.getJavaType().newInstance(); fieldMappers.forEach(m -> m.map(resultRow, instance, uow)); return (T) uow.registerExistingObject(instance, new EntityDescriptor(), Collections.singletonList(new PostLoadInvoker(uow.getMetamodel()))); } catch (InstantiationException | IllegalAccessException e) { throw new SparqlResultMappingException(e); } } EntityResultMapper(EntityType<T> et); @Override T map(ResultRow resultRow, UnitOfWorkImpl uow);  }
@Test void mapCreatesNewInstanceOfTargetTypeAndRegistersItInUOW() { final OWLClassA clone = new OWLClassA(); when(uowMock.registerExistingObject(any(), any(), any())).thenReturn(clone); final OWLClassA result = mapper.map(resultRow, uowMock); assertNotNull(result); verify(uowMock).registerExistingObject(any(), any(), any()); }