SparqlQueryFactory implements QueryFactory { @Override public QueryImpl createNamedQuery(String name) { final String query = uow.getNamedQueryManager().getQuery(name); return createNativeQuery(query); } SparqlQueryFactory(UnitOfWorkImpl uow, ConnectionWrapper connection); @Override QueryImpl createNativeQuery(String sparql); @Override TypedQueryImpl<T> createNativeQuery(String sparql, Class<T> resultClass); @Override QueryImpl createNativeQuery(String sparql, String resultSetMapping); @Override QueryImpl createQuery(String query); @Override TypedQueryImpl<T> createQuery(String query, Class<T> resultClass); @Override QueryImpl createNamedQuery(String name); @Override TypedQueryImpl<T> createNamedQuery(String name, Class<T> resultClass);  }
@Test public void createNamedQueryRetrievesNamedQueryFromManagerAndReturnsCorrespondingNativeQuery() { final String queryName = "testQuery"; when(namedQueryManagerMock.getQuery(queryName)).thenReturn(QUERY); final Query q = factory.createNamedQuery(queryName); assertNotNull(q); verify(namedQueryManagerMock).getQuery(queryName); }
@Test public void createNamedTypedQueryRetrievesNamedQueryFromManagerAndReturnsCorrespondingNativeQuery() { final String queryName = "testQuery"; when(namedQueryManagerMock.getQuery(queryName)).thenReturn(QUERY); final TypedQuery<OWLClassA> q = factory.createNamedQuery(queryName, OWLClassA.class); assertNotNull(q); verify(namedQueryManagerMock).getQuery(queryName); }