SesameAdapter implements Closeable, Wrapper { boolean contains(Axiom<?> axiom, URI context) throws SesameDriverException { startTransactionIfNotActive(); Value value; if (SesameUtils.isResourceIdentifier(axiom.getValue().getValue())) { value = valueFactory.createIRI(axiom.getValue().stringValue()); } else { final String lang = axiom.getAssertion().hasLanguage() ? axiom.getAssertion().getLanguage() : Constants.DEFAULT_LANG; value = SesameUtils.createDataPropertyLiteral(axiom.getValue().getValue(), lang, valueFactory); } final org.eclipse.rdf4j.model.IRI sesameContext = SesameUtils.toSesameIri(context, valueFactory); return connector.containsStatement( SesameUtils.toSesameIri(axiom.getSubject().getIdentifier(), valueFactory), SesameUtils.toSesameIri(axiom.getAssertion().getIdentifier(), valueFactory), value, axiom.getAssertion().isInferred(), sesameContext); } SesameAdapter(Connector connector, DriverConfiguration configuration); @Override void close(); @Override boolean isOpen(); @Override T unwrap(Class<T> cls);  }
@Test void testContainsClassAssertion() throws Exception { final Axiom<URI> ax = new AxiomImpl<>(SUBJECT, Assertion.createClassAssertion(false), new Value<>(URI.create("http: when(connectorMock .containsStatement(eq(subjectIri), eq(RDF.TYPE), eq(vf.createIRI(ax.getValue().stringValue())), anyBoolean(), eq(null))).thenReturn(true); assertTrue(adapter.contains(ax, null)); verify(connectorMock).containsStatement(subjectIri, RDF.TYPE, vf.createIRI(ax.getValue().stringValue()), ax.getAssertion().isInferred(), null); }
@Test void testContainsClassAssertionInContext() throws Exception { final URI context = URI.create("http: final Axiom<URI> ax = new AxiomImpl<>(SUBJECT, Assertion.createClassAssertion(false), new Value<>(URI .create("http: when( connectorMock.containsStatement(eq(subjectIri), eq(RDF.TYPE), eq(vf.createIRI(ax.getValue().stringValue())), anyBoolean(), any(org.eclipse.rdf4j.model.IRI.class))).thenReturn(true); assertTrue(adapter.contains(ax, context)); verify(connectorMock).containsStatement(subjectIri, RDF.TYPE, vf.createIRI(ax.getValue().stringValue()), ax.getAssertion().isInferred(), vf.createIRI(context.toString())); }
@Test void testContainsDataPropertyValue() throws Exception { final URI context = URI.create("http: final int val = 10; final Axiom<Integer> ax = new AxiomImpl<>(SUBJECT, Assertion.createClassAssertion(false), new Value<>(val)); when( connectorMock.containsStatement(eq(subjectIri), eq(RDF.TYPE), eq(vf.createLiteral(val)), anyBoolean(), any(org.eclipse.rdf4j.model.IRI.class))) .thenReturn(false); assertFalse(adapter.contains(ax, context)); verify(connectorMock) .containsStatement(subjectIri, RDF.TYPE, vf.createLiteral(val), ax.getAssertion().isInferred(), vf.createIRI(context.toString())); }