EpistemicAxiomRemover { void remove(AxiomDescriptor axiomDescriptor) throws SesameDriverException { final Resource individual = SesameUtils.toSesameIri(axiomDescriptor.getSubject().getIdentifier(), valueFactory); final Collection<Statement> toRemove = new HashSet<>(); for (Assertion a : axiomDescriptor.getAssertions()) { if (a.isInferred()) { continue; } final IRI contextUri = SesameUtils.toSesameIri(axiomDescriptor.getAssertionContext(a), valueFactory); toRemove.addAll(connector.findStatements(individual, SesameUtils.toSesameIri(a.getIdentifier(), valueFactory), null, a.isInferred(), contextUri)); } connector.removeStatements(toRemove); } EpistemicAxiomRemover(Connector connector, ValueFactory valueFactory);   }
@Test public void removeSkipsInferredAssertions() throws Exception { final Assertion ass = Assertion.createObjectPropertyAssertion(URI.create(PROPERTY), true); descriptor.addAssertion(ass); axiomRemover.remove(descriptor); verify(connectorMock, never()) .findStatements(eq(vf.createIRI(SUBJECT.toString())), eq(vf.createIRI(PROPERTY)), any(), anyBoolean(), any()); verify(connectorMock, never()) .findStatements(eq(vf.createIRI(SUBJECT.toString())), eq(vf.createIRI(PROPERTY)), any(), anyBoolean(), any()); }
@Test public void removeWithAssertionContextSearchesInContext() throws Exception { final String context = "http: final Assertion ass = Assertion.createObjectPropertyAssertion(URI.create(PROPERTY), false); descriptor.addAssertion(ass); descriptor.setAssertionContext(ass, URI.create(context)); axiomRemover.remove(descriptor); verify(connectorMock).findStatements(vf.createIRI(SUBJECT.toString()), vf.createIRI(PROPERTY), null, false, vf.createIRI(context)); verify(connectorMock).removeStatements(anyCollectionOf(Statement.class)); }
@Test public void removeCallsFindStatementsWithoutContextsWhenItIsNotSpecifiedForAssertion() throws Exception { final Assertion ass = Assertion.createObjectPropertyAssertion(URI.create(PROPERTY), false); descriptor.addAssertion(ass); axiomRemover.remove(descriptor); verify(connectorMock) .findStatements(vf.createIRI(SUBJECT.toString()), vf.createIRI(PROPERTY), null, false, null); verify(connectorMock).removeStatements(anyCollectionOf(Statement.class)); }