AxiomAdapter { OWLAxiom toOwlAnnotationPropertyAssertionAxiom(Axiom<?> axiom) { final OWLAnnotationProperty annotationProperty = dataFactory.getOWLAnnotationProperty(IRI.create( axiom.getAssertion().getIdentifier())); final Object value = axiom.getValue().getValue(); final OWLAnnotationValue annotationValue; if (OwlapiUtils.isIndividualIri(value)) { annotationValue = IRI.create(value.toString()); } else { annotationValue = OwlapiUtils.createOWLLiteralFromValue( axiom.getValue().getValue(), OwlapiUtils.getAssertionLanguage(axiom.getAssertion())); } return dataFactory .getOWLAnnotationAssertionAxiom(annotationProperty, toOWLIndividual(axiom.getSubject()).getIRI(), annotationValue); } AxiomAdapter(OWLDataFactory dataFactory); OWLAxiom toOwlObjectPropertyAssertionAxiom(Axiom<?> axiom); Axiom<V> createAxiom(NamedResource subject, Assertion assertion, V value);  }
@Test void toOwlAnnotationPropertyAxiomUsesLanguageTagSpecifiedInAssertion() { final Axiom<String> ax = new AxiomImpl<>(NamedResource.create(INDIVIDUAL), Assertion.createAnnotationPropertyAssertion(PROPERTY, "cs", false), new Value<>("cestina")); final OWLAxiom axiom = adapter.toOwlAnnotationPropertyAssertionAxiom(ax); final OWLAnnotationAssertionAxiom apAxiom = (OWLAnnotationAssertionAxiom) axiom; final Optional<OWLLiteral> literal = apAxiom.getValue().asLiteral(); assertTrue(literal.isPresent()); assertEquals(ax.getValue().getValue(), literal.get().getLiteral()); assertEquals("cs", literal.get().getLang()); }
@Test void toOwlAnnotationPropertyAxiomCreatesSimpleLiteralWhenLanguageIsNotSpecifiedInAssertion() { final Axiom<String> ax = new AxiomImpl<>(NamedResource.create(INDIVIDUAL), Assertion.createAnnotationPropertyAssertion(PROPERTY, false), new Value<>("english")); final OWLAxiom axiom = adapter.toOwlAnnotationPropertyAssertionAxiom(ax); final OWLAnnotationAssertionAxiom apAxiom = (OWLAnnotationAssertionAxiom) axiom; final Optional<OWLLiteral> literal = apAxiom.getValue().asLiteral(); assertTrue(literal.isPresent()); assertEquals(ax.getValue().getValue(), literal.get().getLiteral()); assertFalse(literal.get().hasLang()); }