SnapshotStorageConnectorWithInference extends SnapshotStorageConnector implements InferredStorageConnector { @Override public boolean containsWithInference(Resource subject, Property property, RDFNode value, String context) { ensureTransactionalState(); if (context != null) { return storage.getNamedGraph(context).contains(subject, property, value); } else { return storage.getDefaultGraph().contains(subject, property, value); } } SnapshotStorageConnectorWithInference(AbstractStorageConnector centralConnector,
                                          Map<String, String> reasonerConfig); @Override List<Statement> find(Resource subject, Property property, RDFNode value, String context); @Override boolean contains(Resource subject, Property property, RDFNode value, String context); @Override List<Statement> findWithInference(Resource subject, Property property, RDFNode value, String context); @Override boolean containsWithInference(Resource subject, Property property, RDFNode value, String context); @Override boolean isConsistent(String context);  }
@Test public void containsWithInferenceUsesInferredKnowledgeInDefaultGraph() throws Exception { generateTestData(null); connector.begin(); assertTrue(connector.containsWithInference(createResource(SUBJECT), RDF.type, createResource(TYPE_TWO), null)); assertTrue(connector.containsWithInference(createResource(SUBJECT), RDF.type, createResource(TYPE_ONE), null)); }
@Test public void containsWithInferenceInContextUsesInferredKnowledgeInNamedGraph() throws Exception { generateTestData(NAMED_GRAPH); connector.begin(); assertTrue(connector .containsWithInference(createResource(SUBJECT), RDF.type, createResource(TYPE_TWO), NAMED_GRAPH)); assertTrue(connector .containsWithInference(createResource(SUBJECT), RDF.type, createResource(TYPE_ONE), NAMED_GRAPH)); }
@Test public void addStatementsInfluencesInferenceResults() throws Exception { generateTestData(null); connector.begin(); final Resource another = createResource(Generator.generateUri().toString()); connector.add(Collections.singletonList(statement(another.getURI(), RDF.type.getURI(), TYPE_ONE)), null); assertTrue(connector.containsWithInference(another, RDF.type, createResource(TYPE_TWO), null)); }
@Test public void removeStatementsInfluencesInferenceResults() throws Exception { generateTestData(null); connector.begin(); connector.remove(null, RDF.type, createResource(TYPE_ONE), null); assertFalse(connector.containsWithInference(createResource(SUBJECT), RDF.type, createResource(TYPE_TWO), null)); }