Search in sources :

Example 1 with AxiomType

use of org.semanticweb.owlapi.model.AxiomType in project stanbol by apache.

the class HermitReasoningServiceTest method testEnrichResultTypes.

/**
     * 
     * @param testID
     *            // The ontology to run
     * @param types
     *            // The type of axioms we expect in the result
     */
private void testEnrichResultTypes(String testID, AxiomType<?>[] types) {
    List<AxiomType<?>> typelist = new ArrayList<AxiomType<?>>();
    typelist.addAll(Arrays.asList(types));
    log.info("Testing the enrich() method (result axioms types)");
    OWLOntologyManager manager = TestData.manager;
    // We prepare the input ontology
    try {
        OWLOntology testOntology = manager.createOntology();
        OWLOntologyID testOntologyID = testOntology.getOntologyID();
        log.debug("Created test ontology with ID: {}", testOntologyID);
        OWLImportsDeclaration importTest = TestData.factory.getOWLImportsDeclaration(IRI.create(testID));
        manager.applyChange(new AddImport(testOntology, importTest));
        // Maybe we want to see what is in before
        if (log.isDebugEnabled())
            TestUtils.debug(manager.getOntology(testOntologyID), log);
        // Now we test the method
        log.debug("Running HermiT");
        Set<OWLAxiom> inferred = this.theinstance.runTask(ReasoningService.Tasks.ENRICH, manager.getOntology(testOntologyID));
        // Maybe we want to see the inferred axiom list
        if (log.isDebugEnabled()) {
            TestUtils.debug(inferred, log);
        }
        for (OWLAxiom a : inferred) {
            typelist.remove(a.getAxiomType());
        }
        if (!typelist.isEmpty()) {
            for (AxiomType<?> t : typelist) log.error("Missing axiom type: {}", t);
        }
        assertTrue(typelist.isEmpty());
        // We want to remove the ontology from the manager
        manager.removeOntology(testOntology);
    } catch (OWLOntologyCreationException e) {
        log.error("An {} have been thrown while creating the input ontology for test", e.getClass());
        assertTrue(false);
    } catch (ReasoningServiceException e) {
        log.error("An {} have been thrown while executing the reasoning", e.getClass());
        assertTrue(false);
    } catch (InconsistentInputException e) {
        log.error("An {} have been thrown while executing the reasoning", e.getClass());
        assertTrue(false);
    } catch (UnsupportedTaskException e) {
        log.error("An {} have been thrown while executing the reasoning", e.getClass());
        assertTrue(false);
    }
}
Also used : AxiomType(org.semanticweb.owlapi.model.AxiomType) ArrayList(java.util.ArrayList) OWLImportsDeclaration(org.semanticweb.owlapi.model.OWLImportsDeclaration) InconsistentInputException(org.apache.stanbol.reasoners.servicesapi.InconsistentInputException) AddImport(org.semanticweb.owlapi.model.AddImport) UnsupportedTaskException(org.apache.stanbol.reasoners.servicesapi.UnsupportedTaskException) ReasoningServiceException(org.apache.stanbol.reasoners.servicesapi.ReasoningServiceException) OWLOntologyCreationException(org.semanticweb.owlapi.model.OWLOntologyCreationException) OWLOntology(org.semanticweb.owlapi.model.OWLOntology) OWLOntologyID(org.semanticweb.owlapi.model.OWLOntologyID) OWLOntologyManager(org.semanticweb.owlapi.model.OWLOntologyManager) OWLAxiom(org.semanticweb.owlapi.model.OWLAxiom)

Aggregations

ArrayList (java.util.ArrayList)1 InconsistentInputException (org.apache.stanbol.reasoners.servicesapi.InconsistentInputException)1 ReasoningServiceException (org.apache.stanbol.reasoners.servicesapi.ReasoningServiceException)1 UnsupportedTaskException (org.apache.stanbol.reasoners.servicesapi.UnsupportedTaskException)1 AddImport (org.semanticweb.owlapi.model.AddImport)1 AxiomType (org.semanticweb.owlapi.model.AxiomType)1 OWLAxiom (org.semanticweb.owlapi.model.OWLAxiom)1 OWLImportsDeclaration (org.semanticweb.owlapi.model.OWLImportsDeclaration)1 OWLOntology (org.semanticweb.owlapi.model.OWLOntology)1 OWLOntologyCreationException (org.semanticweb.owlapi.model.OWLOntologyCreationException)1 OWLOntologyID (org.semanticweb.owlapi.model.OWLOntologyID)1 OWLOntologyManager (org.semanticweb.owlapi.model.OWLOntologyManager)1