diff --git a/webapp/test/edu/cornell/mannlib/vitro/webapp/reasoner/SimpleReasonerTest.java b/webapp/test/edu/cornell/mannlib/vitro/webapp/reasoner/SimpleReasonerTest.java index 17694f558..a858320ca 100644 --- a/webapp/test/edu/cornell/mannlib/vitro/webapp/reasoner/SimpleReasonerTest.java +++ b/webapp/test/edu/cornell/mannlib/vitro/webapp/reasoner/SimpleReasonerTest.java @@ -29,6 +29,42 @@ public class SimpleReasonerTest extends AbstractTestClass { suppressSyserr(); } + @Test + public void addType(){ + + // Test that when a new instance is asserted, its asserted type is not added to the + // inference graph + + // Create a Tbox with a simple class hierarchy. B is a subclass of A. + // Pellet will compute TBox inferences + OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC); + + OntClass classA = tBox.createClass("http://test.vivo/A"); + classA.setLabel("class A", "en-US"); + + OntClass classB = tBox.createClass("http://test.vivo/B"); + classB.setLabel("class B", "en-US"); + + classA.addSubClass(classB); + + // this is the model to receive inferences + Model inf = ModelFactory.createDefaultModel(); + + // create an Abox and register the SimpleReasoner listener with it + OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); + aBox.register(new SimpleReasoner(tBox, aBox, inf)); + + // Individual x + Resource ind_x = aBox.createResource("http://test.vivo/x"); + + // add a statement to the ABox that individual x is of type (i.e. is an instance of) B. + Statement xisb = ResourceFactory.createStatement(ind_x, RDF.type, classB); + aBox.add(xisb); + + // Verify that "x is of type B" was not inferred + Assert.assertFalse(inf.contains(xisb)); + } + @Test public void addTypes(){