From 37e908b71354f76b9108aeb52182bad7f2f704e2 Mon Sep 17 00:00:00 2001 From: Federico Igne Date: Fri, 23 Oct 2020 12:35:00 +0200 Subject: Add additional tests for T5 axiom rule generation --- src/test/scala/rsacomb/CanonicalModelSpec.scala | 59 ++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) (limited to 'src/test/scala') diff --git a/src/test/scala/rsacomb/CanonicalModelSpec.scala b/src/test/scala/rsacomb/CanonicalModelSpec.scala index c5f040d..783c149 100644 --- a/src/test/scala/rsacomb/CanonicalModelSpec.scala +++ b/src/test/scala/rsacomb/CanonicalModelSpec.scala @@ -47,6 +47,15 @@ object Ontology1_CanonicalModelSpec { Seq().asJava ) + val BsomeValuesFromSD = new OWLSubClassOfAxiomImpl( + new OWLClassImpl(RSA.base("B")), + new OWLObjectSomeValuesFromImpl( + roleS, + new OWLClassImpl(RSA.base("D")) + ), + Seq().asJava + ) + } // object OWLAxiomSpec class Ontology1_CanonicalModelSpec @@ -67,6 +76,8 @@ class Ontology1_CanonicalModelSpec rules.loneElement shouldBe a[Rule] } + // Role R // + renderer.render(roleR) should "be safe" in { ontology.unsafeRoles should not contain roleR } @@ -89,14 +100,32 @@ class Ontology1_CanonicalModelSpec ontology.confl(roleR) should contain(roleR_inv) } + // Role S // + renderer.render(roleS) should "be safe" in { ontology.unsafeRoles should not contain roleS } + it should "have 3 elements in its conflict set" in { + ontology.confl(roleS) should have size 3 + } + it should "contain R in its conflict set" in { ontology.confl(roleS) should contain(roleR) } + it should ("contain " + renderer.render( + roleS_inv + ) + " in its conflict set") in { + ontology.confl(roleS) should contain(roleS_inv) + } + + it should ("contain " + renderer.render( + roleT_inv + ) + " in its conflict set") in { + ontology.confl(roleS) should contain(roleT_inv) + } + renderer.render(roleS_inv) should "be unsafe" in { ontology.unsafeRoles should contain(roleS_inv) } @@ -109,10 +138,38 @@ class Ontology1_CanonicalModelSpec renderer.render( DsomeValuesFromRB - ) should "produce 5 rules" ignore { + ) should "have a sigleton 'cycle' set" in { + // Using `hashCode` we are assuming (B,S,D) < (D,R,B) + val ind = RSA.internal("v1_" ++ BsomeValuesFromSD.hashCode.toString()) + ontology.cycle(DsomeValuesFromRB).loneElement shouldBe ind + } + + it should "produce 5 rules" in { + // Rule 1 provides 1 rule (split in 2) + 1 fact + // Rule 2 provides 0 rules + // Rule 3 provides 1 rule (split in 2) val varX = Variable.create("X") val visitor = ProgramGenerator(ontology, varX) val rules = DsomeValuesFromRB.accept(visitor) rules should have length 5 } + + renderer.render( + BsomeValuesFromSD + ) should "have a sigleton 'cycle' set" in { + // Using `hashCode` we are assuming (B,S,D) < (D,R,B) + val ind = RSA.internal("v0_" ++ DsomeValuesFromRB.hashCode.toString()) + ontology.cycle(BsomeValuesFromSD).loneElement shouldBe ind + } + + it should "produce 5 rules" ignore { + // Rule 1 provides 1 rule (split in 2) + 1 fact + // Rule 2 provides 0 rules + // Rule 3 provides 1 rule (split in 2) + val varX = Variable.create("X") + val visitor = ProgramGenerator(ontology, varX) + val rules = BsomeValuesFromSD.accept(visitor) + rules should have length 5 + } + } // class OWLAxiomSpec -- cgit v1.2.3