OWL2JavaTransformer { public void setOntology(final String owlOntologyName, final String mappingFile) { this.ontology = getWholeOntology(owlOntologyName, mappingFile); LOG.debug("Parsing integrity constraints"); ontology.axioms().forEach(a -> { defaultContext.addAxiom(a); for (final String icContextName : getContexts(a)) { ContextDefinition ctx = getContextDefinition(icContextName); ctx.addAxiom(a); } }); registerEntitiesInContexts(); defaultContext.parse(); for (final ContextDefinition ctx : contexts.values()) { ctx.parse(); } LOG.debug("Integrity constraints successfully parsed."); }  Collection<String> listContexts(); void ignoreMissingImports(boolean ignore); void setOntology(final String owlOntologyName, final String mappingFile); void transform(TransformationConfiguration transformConfig); void generateVocabulary(TransformationConfiguration transformConfig);  }
@Test public void setUnknownOntologyIriThrowsOWL2JavaException() { final String unknownOntoIri = "http: final OWL2JavaException ex = assertThrows(OWL2JavaException.class, () -> transformer.setOntology(unknownOntoIri, mappingFilePath)); assertEquals("Unable to load ontology " + unknownOntoIri, ex.getMessage()); }
@Test public void setOntologyWithUnknownMappingFileThrowsMappingFileParserException() { final String unknownMappingFile = "/tmp/unknown-mapping-file"; assertThrows(MappingFileParserException.class, () -> transformer.setOntology(IC_ONTOLOGY_IRI, unknownMappingFile)); }
@Test public void setOntologyAddsDeclaredClassesIntoContextDefinition() throws Exception { this.targetDir = getTempDirectory(); transformer.setOntology("http: mappingFilePath); final ContextDefinition context = getContext("owl2java-ic"); assertTrue(context.classes .contains(dataFactory .getOWLClass("http: }
@Test public void setOntologyAddsDeclaredObjectPropertiesIntoContextDefinition() throws Exception { this.targetDir = getTempDirectory(); transformer.setOntology("http: mappingFilePath); final ContextDefinition context = getContext("owl2java-ic"); assertTrue(context.objectProperties.contains(dataFactory .getOWLObjectProperty("http: }
@Test public void setOntologyAddsDeclaredDataPropertiesIntoContextDefinition() throws Exception { this.targetDir = getTempDirectory(); transformer.setOntology("http: mappingFilePath); final ContextDefinition context = getContext("owl2java-ic"); assertTrue(context.dataProperties.contains(dataFactory .getOWLDataProperty("http: }
@Test public void setOntologyAddsDeclaredAnnotationPropertiesIntoContextDefinition() throws Exception { this.targetDir = getTempDirectory(); transformer.setOntology("http: mappingFilePath); final ContextDefinition context = getContext("owl2java-ic"); assertTrue(context.annotationProperties.contains(dataFactory.getOWLAnnotationProperty( "http: }