SesameConnection implements Connection { @Override public Collection<Axiom<?>> find(AxiomDescriptor descriptor) throws OntoDriverException { ensureOpen(); Objects.requireNonNull(descriptor); try { return adapter.find(descriptor); } catch (RuntimeException e) { throw new SesameDriverException(e); } } SesameConnection(SesameAdapter adapter); void setProperties(Properties properties); @Override void close(); @Override boolean isOpen(); @Override void commit(); @Override void rollback(); @Override void setAutoCommit(boolean autoCommit); @Override boolean isAutoCommit(); @Override Statement createStatement(); @Override PreparedStatement prepareStatement(String sparql); @Override boolean isConsistent(URI context); @Override List<URI> getContexts(); @Override URI generateIdentifier(URI classUri); @Override boolean contains(Axiom<?> axiom, URI context); @Override Collection<Axiom<?>> find(AxiomDescriptor descriptor); @Override void persist(AxiomValueDescriptor descriptor); @Override void update(AxiomValueDescriptor descriptor); @Override void remove(AxiomDescriptor descriptor); @Override Lists lists(); @Override Types types(); @Override Properties properties(); @Override T unwrap(Class<T> cls);  }
@Test public void testFind() throws Exception { final AxiomDescriptor axDesc = mock(AxiomDescriptor.class); final List<Axiom<?>> axioms = new ArrayList<>(); axioms.add(mock(Axiom.class)); axioms.add(mock(Axiom.class)); when(adapterMock.find(axDesc)).thenReturn(axioms); final Collection<Axiom<?>> res = connection.find(axDesc); assertEquals(axioms, res); }
@Test(expected = NullPointerException.class) public void testFindNull() throws Exception { try { final Collection<Axiom<?>> res = connection.find(null); fail("This line should not have been reached."); assert res == null; } finally { verify(adapterMock, never()).find(any(AxiomDescriptor.class)); } }