SharedStorageConnector extends AbstractStorageConnector { @Override public Collection<Statement> find(Resource subject, Property property, RDFNode value, String context) { ensureOpen(); return Txn.calculateRead(storage.getDataset(), () -> { final Model target = context != null ? storage.getNamedGraph(context) : storage.getDefaultGraph(); final StmtIterator it = target.listStatements(subject, property, value); return it.toList(); }); } SharedStorageConnector(DriverConfiguration configuration); @Override synchronized void begin(); @Override synchronized void commit(); @Override void rollback(); @Override Collection<Statement> find(Resource subject, Property property, RDFNode value, String context); @Override boolean contains(Resource subject, Property property, RDFNode value, String context); @Override List<String> getContexts(); @Override void add(List<Statement> statements, String context); @Override void remove(List<Statement> statements, String context); @Override void remove(Resource subject, Property property, RDFNode object, String context); @Override AbstractResultSet executeSelectQuery(Query query, StatementOntology target); @Override AbstractResultSet executeAskQuery(Query query, StatementOntology target); @Override void executeUpdate(String query, StatementOntology target); @Override synchronized void close(); synchronized void reloadStorage(); synchronized void setDataset(Dataset dataset);  }
@Test public void findFiltersStatementsFromDatasetDefaultModel() { final SharedStorageConnector connector = initConnector(); final Dataset ds = connector.storage.getDataset(); generateTestData(ds); final Collection<Statement> result = connector.find(RESOURCE, null, null, null); assertFalse(result.isEmpty()); }
@Test public void findInContextFiltersStatementsInTargetContext() { final SharedStorageConnector connector = initConnector(); final Dataset ds = connector.storage.getDataset(); generateTestData(ds); final Collection<Statement> result = connector.find(RESOURCE, null, null, NAMED_GRAPH); assertFalse(result.isEmpty()); }
@Test public void findInContextReturnsEmptyCollectionForUnknownContext() { final SharedStorageConnector connector = initConnector(); final Dataset ds = connector.storage.getDataset(); generateTestData(ds); final Collection<Statement> result = connector.find(RESOURCE, null, null, "http: assertNotNull(result); assertTrue(result.isEmpty()); }