JenaOntologyService implements OntologyService { @Override public Set<URI> inferClasses(final URI uri, final WebResource resource, final Ontology ontology) { final OntModel model = resolveImports(ont(ontology)); model.add(parse(resource)); final Individual individual = model.getIndividual(uri.toString()); if (individual != null) { return individual .listRDFTypes(false) .filterKeep(Resource::isURIResource) .mapWith(Resource::getURI) .mapWith(URI::create) .toSet(); } else { LOG.info("<{}> does not make any statements about itself, " + "so we can't infer anything about it nor bind extensions to it", uri); return Collections.emptySet(); } } JenaOntologyService(); void setOntModelSpec(final OntModelSpec spec); @Reference void setRegistryDelegate(final OntologyRegistry registry); @Override Ont getOntology(final URI uri); @Override Ont parseOntology(final WebResource ont); @Override Ont merge(final Ontology ontology1, final Ontology ontology2); @Override Set<URI> inferClasses(final URI uri, final WebResource resource, final Ontology ontology);  }
@Test public void inferClassesTest() { final Ontology ontology = toTest.getOntology(URI.create(ONT1)); final String individualURI = "test:/individual"; final WebResource individual = mock(WebResource.class); when(individual.contentType()).thenReturn("application/n-triples"); when(individual.representation()).thenReturn(IOUtils.toInputStream(triple(individualURI, RDF_TYPE, CLASS_B), Charset.defaultCharset())); assertTrue(toTest.inferClasses(URI.create(individualURI), individual, ontology).contains(URI.create( CLASS_A))); }