SesameAdapter implements Closeable, Wrapper { List<URI> getContexts() throws SesameDriverException { final List<Resource> contextIds = connector.getContexts(); final List<URI> contexts = new ArrayList<>(contextIds.size()); for (Resource res : contextIds) { final URI context = SesameUtils.toJavaUri(res); if (context != null) { contexts.add(context); } } return contexts; } SesameAdapter(Connector connector, DriverConfiguration configuration); @Override void close(); @Override boolean isOpen(); @Override T unwrap(Class<T> cls);  }
@Test void testGetContexts() throws Exception { final List<Resource> contexts = new ArrayList<>(); for (int i = 0; i < 5; i++) { contexts.add(vf.createIRI("http: } when(connectorMock.getContexts()).thenReturn(contexts); final List<URI> res = adapter.getContexts(); assertEquals(contexts.size(), res.size()); for (int i = 0; i < contexts.size(); i++) { assertEquals(contexts.get(i).stringValue(), res.get(i).toString()); } }
@Test void testGetContextsWithBNodes() throws Exception { final List<Resource> contexts = new ArrayList<>(); int bnodes = 0; for (int i = 0; i < 5; i++) { if (i % 2 == 1) { contexts.add(vf.createBNode()); bnodes++; } else { contexts.add(vf.createIRI("http: } } when(connectorMock.getContexts()).thenReturn(contexts); final List<URI> res = adapter.getContexts(); assertEquals(contexts.size() - bnodes, res.size()); }