AxiomSaver { void persist(AxiomValueDescriptor descriptor) { for (Assertion assertion : descriptor.getAssertions()) { switch (assertion.getType()) { case CLASS: persistTypes(descriptor.getSubject(), descriptor.getAssertionValues(assertion)); break; case DATA_PROPERTY: persistDataPropertyValues(descriptor.getSubject(), assertion, descriptor.getAssertionValues(assertion)); break; case ANNOTATION_PROPERTY: persistAnnotationPropertyValues(descriptor.getSubject(), assertion, descriptor.getAssertionValues(assertion)); break; case OBJECT_PROPERTY: persistObjectPropertyValues(descriptor.getSubject(), assertion, descriptor.getAssertionValues(assertion)); break; case PROPERTY: persistPropertyValues(descriptor.getSubject(), assertion, descriptor.getAssertionValues(assertion)); break; default: break; } } } AxiomSaver(OwlapiAdapter adapter, OntologySnapshot snapshot);   }
@Test public void persistValueWithNullDoesNothing() { final Assertion dpAssertion = Assertion.createDataPropertyAssertion(ASSERTION_URI, false); final Assertion opAssertion = Assertion.createObjectPropertyAssertion(ASSERTION_URI, false); final Assertion apAssertion = Assertion.createAnnotationPropertyAssertion(ASSERTION_URI, false); descriptor.addAssertionValue(dpAssertion, Value.nullValue()); descriptor.addAssertionValue(opAssertion, Value.nullValue()); descriptor.addAssertionValue(apAssertion, Value.nullValue()); axiomSaver.persist(descriptor); verify(manager, never()).applyChanges(anyList()); }
@Test public void testPersistIndividualWithDataProperty() { final Assertion dpAssertion = Assertion.createDataPropertyAssertion( URI.create("http: final Set<Object> values = new HashSet<>(); values.add("StringValue"); values.add(1111); values.add(3.14159D); descriptor.addAssertion(dpAssertion); values.forEach(value -> descriptor.addAssertionValue(dpAssertion, new Value<>(value))); axiomSaver.persist(descriptor); verifyDataPropertyValuesInOntology(dpAssertion, values); verifyTransactionalChangesRecorded(); }
@Test public void testPersistIndividualWithAnnotationProperty() { final Assertion apAssertion = Assertion.createAnnotationPropertyAssertion( URI.create("http: final Set<Object> values = new HashSet<>(); values.add("StringLabel"); values.add(1111); values.add(URI.create("http: descriptor.addAssertion(apAssertion); values.forEach(value -> descriptor.addAssertionValue(apAssertion, new Value<>(value))); axiomSaver.persist(descriptor); verifyAnnotationPropertyValuesInOntology(apAssertion, values); verifyTransactionalChangesRecorded(); }
@Test public void testPersistIndividualWithObjectProperty() { final Assertion assertion = Assertion.createObjectPropertyAssertion( URI.create("http: descriptor.addAssertion(assertion); final Set<NamedResource> values = new HashSet<>(); values.add(NamedResource.create("http: values.add(NamedResource.create("http: values.add(NamedResource.create("http: values.forEach(value -> descriptor.addAssertionValue(assertion, new Value<>(value))); axiomSaver.persist(descriptor); verifyObjectPropertyValuesInOntology(assertion, values); verifyTransactionalChangesRecorded(); }
@Test public void testPersistIndividualWithUnspecifiedPropertyTypePropertiesExist() { final Assertion opAssertion = Assertion.createPropertyAssertion( URI.create("http: descriptor.addAssertion(opAssertion); final Set<NamedResource> opValues = new HashSet<>(); opValues.add(NamedResource.create("http: opValues.add(NamedResource.create("http: opValues.add(NamedResource.create("http: opValues.forEach(value -> descriptor.addAssertionValue(opAssertion, new Value<>(value))); final Assertion dpAssertion = Assertion.createPropertyAssertion( URI.create("http: final Set<Object> dpValues = new HashSet<>(); dpValues.add("StringValue"); descriptor.addAssertion(dpAssertion); dpValues.forEach(value -> descriptor.addAssertionValue(dpAssertion, new Value<>(value))); addDataPropertyAssertion(dpAssertion.getIdentifier()); addObjectPropertyAssertion(opAssertion.getIdentifier()); axiomSaver.persist(descriptor); verifyDataPropertyValuesInOntology(dpAssertion, dpValues); verifyObjectPropertyValuesInOntology(opAssertion, opValues); verifyTransactionalChangesRecorded(); }
@Test public void testPersistIndividualWithUnspecifiedPropertyTypePropertiesUnknown() { final Assertion opAssertion = Assertion.createPropertyAssertion( URI.create("http: descriptor.addAssertion(opAssertion); final Set<NamedResource> opValues = new HashSet<>(); opValues.add(NamedResource.create("http: opValues.add(NamedResource.create("http: opValues.add(NamedResource.create("http: opValues.add(NamedResource.create("non-uri-value")); opValues.forEach(value -> descriptor.addAssertionValue(opAssertion, new Value<>(value))); axiomSaver.persist(descriptor); verifyObjectPropertyValuesInOntology(opAssertion, opValues); verifyTransactionalChangesRecorded(); }