EpistemicAxiomRemover { void remove(AxiomDescriptor descriptor) { final Resource subject = ResourceFactory.createResource(descriptor.getSubject().getIdentifier().toString()); descriptor.getAssertions().stream().filter(a -> !a.isInferred()).forEach(assertion -> { final URI context = descriptor.getAssertionContext(assertion); final Property property = ResourceFactory.createProperty(assertion.getIdentifier().toString()); connector.remove(subject, property, null, context != null ? context.toString() : null); }); } EpistemicAxiomRemover(StorageConnector connector);   }
@Test public void removeRemovesStatementsByProperty() { final AxiomDescriptor descriptor = new AxiomDescriptor(SUBJECT); final Assertion dp = Assertion.createDataPropertyAssertion(Generator.generateUri(), false); descriptor.addAssertion(dp); final Assertion op = Assertion.createObjectPropertyAssertion(Generator.generateUri(), false); descriptor.addAssertion(op); remover.remove(descriptor); verify(connectorMock).remove(SUBJECT_RESOURCE, createProperty(dp.getIdentifier().toString()), null, null); verify(connectorMock).remove(SUBJECT_RESOURCE, createProperty(op.getIdentifier().toString()), null, null); }
@Test public void removeRemovesStatementsByPropertyFromCorrectContexts() { final URI mainContext = Generator.generateUri(); final AxiomDescriptor descriptor = new AxiomDescriptor(SUBJECT); descriptor.setSubjectContext(mainContext); final Assertion ca = Assertion.createClassAssertion(false); descriptor.addAssertion(ca); final Assertion ap = Assertion.createAnnotationPropertyAssertion(Generator.generateUri(), false); descriptor.addAssertion(ap); final URI assertionContext = Generator.generateUri(); descriptor.setAssertionContext(ap, assertionContext); remover.remove(descriptor); verify(connectorMock) .remove(SUBJECT_RESOURCE, createProperty(ca.getIdentifier().toString()), null, mainContext.toString()); verify(connectorMock).remove(SUBJECT_RESOURCE, createProperty(ap.getIdentifier().toString()), null, assertionContext.toString()); }