TypedQueryImpl extends AbstractQuery implements TypedQuery<X> { @Override public List<X> getResultList() { ensureOpen(); try { return getResultListImpl(); } catch (OntoDriverException e) { markTransactionForRollback(); throw queryEvaluationException(e); } catch (RuntimeException e) { markTransactionForRollback(); throw e; } } TypedQueryImpl(final QueryHolder query, final Class<X> resultType,
                          final ConnectionWrapper connection, MetamodelProvider metamodelProvider); void setUnitOfWork(UnitOfWork uow); @Override List<X> getResultList(); @Override X getSingleResult(); @Override Stream<X> getResultStream(); @Override TypedQuery<X> setMaxResults(int maxResults); @Override TypedQuery<X> setFirstResult(int startPosition); @Override TypedQuery<X> setParameter(int position, Object value); @Override TypedQuery<X> setParameter(int position, String value, String language); @Override TypedQuery<X> setParameter(String name, Object value); @Override TypedQuery<X> setParameter(String name, String value, String language); @Override TypedQuery<X> setParameter(Parameter<T> parameter, T value); @Override TypedQuery<X> setParameter(Parameter<String> parameter, String value, String language); @Override TypedQuery<X> setUntypedParameter(int position, Object value); @Override TypedQuery<X> setUntypedParameter(String name, Object value); @Override TypedQuery<X> setUntypedParameter(Parameter<T> parameter, T value); @Override TypedQuery<X> setDescriptor(Descriptor descriptor);  }
@Test void getResultListWithEntityTypeReturnsEntities() throws Exception { final TypedQuery<OWLClassA> query = create(SELECT_QUERY, OWLClassA.class); final List<String> uris = initDataForQuery(5); final List<OWLClassA> res = query.getResultList(); verifyResults(uris, res, 5); }
@Test void getResultListSkipsValuesWhichCannotBeLoadedAsEntities() throws Exception { when(resultSetIterator.hasNext()).thenReturn(true, true, false); final List<String> uris = Arrays.asList(Generators.createIndividualIdentifier().toString(), Generators.createIndividualIdentifier().toString()); when(resultRow.isBound(0)).thenReturn(true); when(resultRow.getString(0)).thenReturn(uris.get(0), uris.get(1)); when(uowMock.readObject(eq(OWLClassA.class), eq(URI.create(uris.get(0))), any(Descriptor.class))) .thenReturn(new OWLClassA(URI.create(uris.get(0)))); final TypedQuery<OWLClassA> q = create(SELECT_QUERY, OWLClassA.class); final List<OWLClassA> result = q.getResultList(); assertEquals(1, result.size()); }