diff options
| author | Federico Igne <federico.igne@cs.ox.ac.uk> | 2020-12-02 17:13:29 +0000 |
|---|---|---|
| committer | Federico Igne <federico.igne@cs.ox.ac.uk> | 2020-12-02 17:13:29 +0000 |
| commit | 42ba69cc2ad2ccc6ba0208a58e874eba5c911baf (patch) | |
| tree | 16e77fd9a3f011ec0ecaf5490de18bc69262c274 /src/test/scala/uk | |
| parent | a72e44139897052eb83fe464fca94489e8f80092 (diff) | |
| download | RSAComb-42ba69cc2ad2ccc6ba0208a58e874eba5c911baf.tar.gz RSAComb-42ba69cc2ad2ccc6ba0208a58e874eba5c911baf.zip | |
Fix tests failing due to recent changes
Diffstat (limited to 'src/test/scala/uk')
| -rw-r--r-- | src/test/scala/uk/ac/ox/cs/rsacomb/CanonicalModelSpec.scala | 99 | ||||
| -rw-r--r-- | src/test/scala/uk/ac/ox/cs/rsacomb/RDFoxConverterSpec.scala | 26 |
2 files changed, 86 insertions, 39 deletions
diff --git a/src/test/scala/uk/ac/ox/cs/rsacomb/CanonicalModelSpec.scala b/src/test/scala/uk/ac/ox/cs/rsacomb/CanonicalModelSpec.scala index 3070ce3..0d07923 100644 --- a/src/test/scala/uk/ac/ox/cs/rsacomb/CanonicalModelSpec.scala +++ b/src/test/scala/uk/ac/ox/cs/rsacomb/CanonicalModelSpec.scala | |||
| @@ -15,6 +15,8 @@ import tech.oxfordsemantic.jrdfox.logic.expression.Variable | |||
| 15 | import scala.collection.JavaConverters._ | 15 | import scala.collection.JavaConverters._ |
| 16 | 16 | ||
| 17 | import uk.ac.ox.cs.rsacomb.RSAOntology | 17 | import uk.ac.ox.cs.rsacomb.RSAOntology |
| 18 | import uk.ac.ox.cs.rsacomb.converter.SkolemStrategy | ||
| 19 | import uk.ac.ox.cs.rsacomb.suffix.Empty | ||
| 18 | import uk.ac.ox.cs.rsacomb.util.{RDFoxUtil, RSA} | 20 | import uk.ac.ox.cs.rsacomb.util.{RDFoxUtil, RSA} |
| 19 | 21 | ||
| 20 | object Ontology1_CanonicalModelSpec { | 22 | object Ontology1_CanonicalModelSpec { |
| @@ -28,6 +30,7 @@ object Ontology1_CanonicalModelSpec { | |||
| 28 | val ontology_path: File = new File("examples/example1.ttl") | 30 | val ontology_path: File = new File("examples/example1.ttl") |
| 29 | val ontology = RSAOntology(ontology_path) | 31 | val ontology = RSAOntology(ontology_path) |
| 30 | val program = ontology.canonicalModel | 32 | val program = ontology.canonicalModel |
| 33 | val converter = program.CanonicalModelConverter | ||
| 31 | 34 | ||
| 32 | val roleR = new OWLObjectPropertyImpl(base("R")) | 35 | val roleR = new OWLObjectPropertyImpl(base("R")) |
| 33 | val roleS = new OWLObjectPropertyImpl(base("S")) | 36 | val roleS = new OWLObjectPropertyImpl(base("S")) |
| @@ -89,9 +92,13 @@ class Ontology1_CanonicalModelSpec | |||
| 89 | } | 92 | } |
| 90 | 93 | ||
| 91 | renderer.render(AsubClassOfD) should "be converted into a single Rule" in { | 94 | renderer.render(AsubClassOfD) should "be converted into a single Rule" in { |
| 92 | val varX = Variable.create("X") | 95 | val term = Variable.create("X") |
| 93 | val visitor = program.RuleGenerator | 96 | val unsafe = ontology.unsafeRoles |
| 94 | val rules = AsubClassOfD.accept(visitor) | 97 | val skolem = SkolemStrategy.None |
| 98 | val suffix = Empty | ||
| 99 | val (facts, rules) = | ||
| 100 | converter.convert(AsubClassOfD, term, unsafe, skolem, suffix) | ||
| 101 | facts shouldBe empty | ||
| 95 | rules.loneElement shouldBe a[Rule] | 102 | rules.loneElement shouldBe a[Rule] |
| 96 | } | 103 | } |
| 97 | 104 | ||
| @@ -154,10 +161,14 @@ class Ontology1_CanonicalModelSpec | |||
| 154 | renderer.render( | 161 | renderer.render( |
| 155 | AsomeValuesFromSiC | 162 | AsomeValuesFromSiC |
| 156 | ) should "produce 1 rule" in { | 163 | ) should "produce 1 rule" in { |
| 157 | val varX = Variable.create("X") | 164 | val term = Variable.create("X") |
| 158 | val visitor = program.RuleGenerator | 165 | val unsafe = ontology.unsafeRoles |
| 159 | val rules = AsomeValuesFromSiC.accept(visitor) | 166 | val skolem = SkolemStrategy.None |
| 160 | rules should have length 1 | 167 | val suffix = Empty |
| 168 | val (facts, rules) = | ||
| 169 | converter.convert(AsomeValuesFromSiC, term, unsafe, skolem, suffix) | ||
| 170 | facts shouldBe empty | ||
| 171 | rules.loneElement shouldBe a[Rule] | ||
| 161 | } | 172 | } |
| 162 | 173 | ||
| 163 | renderer.render( | 174 | renderer.render( |
| @@ -172,15 +183,18 @@ class Ontology1_CanonicalModelSpec | |||
| 172 | ontology.cycle(DsomeValuesFromRB) should have size 48 | 183 | ontology.cycle(DsomeValuesFromRB) should have size 48 |
| 173 | } | 184 | } |
| 174 | 185 | ||
| 175 | it should "produce 5 rules" in { | 186 | it should "produce 48 facts and 98 rules" in { |
| 176 | // Rule 1 provides 1 rule (split in 2) + 48 fact | 187 | // Rule 1 provides 1 rule (split in 2) + 48 fact |
| 177 | // Rule 2 provides 0 rules | 188 | // Rule 2 provides 0 rules |
| 178 | // Rule 3 provides 48 rule (split in 2) | 189 | // Rule 3 provides 48 rule (split in 2) |
| 179 | // Then (1*2 + 48) + (0) + (48*2) = 146 | 190 | val term = Variable.create("X") |
| 180 | val varX = Variable.create("X") | 191 | val unsafe = ontology.unsafeRoles |
| 181 | val visitor = program.RuleGenerator | 192 | val skolem = SkolemStrategy.None |
| 182 | val rules = DsomeValuesFromRB.accept(visitor) | 193 | val suffix = Empty |
| 183 | rules should have length 146 | 194 | val (facts, rules) = |
| 195 | converter.convert(DsomeValuesFromRB, term, unsafe, skolem, suffix) | ||
| 196 | facts should have length 48 | ||
| 197 | rules should have length 98 | ||
| 184 | } | 198 | } |
| 185 | 199 | ||
| 186 | renderer.render( | 200 | renderer.render( |
| @@ -200,18 +214,26 @@ class Ontology1_CanonicalModelSpec | |||
| 200 | // Rule 2 provides 0 rules | 214 | // Rule 2 provides 0 rules |
| 201 | // Rule 3 provides 32 rule (split in 2) | 215 | // Rule 3 provides 32 rule (split in 2) |
| 202 | // Then (1*2 + 32) + (0) + (32*2) = 98 | 216 | // Then (1*2 + 32) + (0) + (32*2) = 98 |
| 203 | val varX = Variable.create("X") | 217 | val term = Variable.create("X") |
| 204 | val visitor = program.RuleGenerator | 218 | val unsafe = ontology.unsafeRoles |
| 205 | val rules = DsomeValuesFromRB.accept(visitor) | 219 | val skolem = SkolemStrategy.None |
| 206 | rules should have length 146 | 220 | val suffix = Empty |
| 221 | val (facts, rules) = | ||
| 222 | converter.convert(BsomeValuesFromSD, term, unsafe, skolem, suffix) | ||
| 223 | facts should have length 32 | ||
| 224 | rules should have length 66 | ||
| 207 | } | 225 | } |
| 208 | 226 | ||
| 209 | renderer.render( | 227 | renderer.render( |
| 210 | SsubPropertyOfT | 228 | SsubPropertyOfT |
| 211 | ) should "produce 2 rules" in { | 229 | ) should "produce 2 rules" in { |
| 212 | val varX = Variable.create("X") | 230 | val term = Variable.create("X") |
| 213 | val visitor = program.RuleGenerator | 231 | val unsafe = ontology.unsafeRoles |
| 214 | val rules = SsubPropertyOfT.accept(visitor) | 232 | val skolem = SkolemStrategy.None |
| 233 | val suffix = Empty | ||
| 234 | val (facts, rules) = | ||
| 235 | converter.convert(SsubPropertyOfT, term, unsafe, skolem, suffix) | ||
| 236 | facts shouldBe empty | ||
| 215 | rules should have length 2 | 237 | rules should have length 2 |
| 216 | } | 238 | } |
| 217 | 239 | ||
| @@ -228,6 +250,7 @@ object Ontology2_CanonicalModelSpec { | |||
| 228 | val ontology_path: File = new File("examples/example2.owl") | 250 | val ontology_path: File = new File("examples/example2.owl") |
| 229 | val ontology = RSAOntology(ontology_path) | 251 | val ontology = RSAOntology(ontology_path) |
| 230 | val program = ontology.canonicalModel | 252 | val program = ontology.canonicalModel |
| 253 | val converter = program.CanonicalModelConverter | ||
| 231 | 254 | ||
| 232 | val roleR = new OWLObjectPropertyImpl(base("R")) | 255 | val roleR = new OWLObjectPropertyImpl(base("R")) |
| 233 | val roleS = new OWLObjectPropertyImpl(base("S")) | 256 | val roleS = new OWLObjectPropertyImpl(base("S")) |
| @@ -332,8 +355,13 @@ class Ontology2_CanonicalModelSpec | |||
| 332 | renderer.render( | 355 | renderer.render( |
| 333 | AsomeValuesFromRB | 356 | AsomeValuesFromRB |
| 334 | ) should "produce 1 rule" in { | 357 | ) should "produce 1 rule" in { |
| 335 | val visitor = program.RuleGenerator | 358 | val term = Variable.create("X") |
| 336 | val rules = AsomeValuesFromRB.accept(visitor) | 359 | val unsafe = ontology.unsafeRoles |
| 360 | val skolem = SkolemStrategy.None | ||
| 361 | val suffix = Empty | ||
| 362 | val (facts, rules) = | ||
| 363 | converter.convert(AsomeValuesFromRB, term, unsafe, skolem, suffix) | ||
| 364 | facts shouldBe empty | ||
| 337 | rules should have length 1 | 365 | rules should have length 1 |
| 338 | } | 366 | } |
| 339 | 367 | ||
| @@ -342,8 +370,13 @@ class Ontology2_CanonicalModelSpec | |||
| 342 | renderer.render( | 370 | renderer.render( |
| 343 | BsomeValuesFromSC | 371 | BsomeValuesFromSC |
| 344 | ) should "produce 1 rule" in { | 372 | ) should "produce 1 rule" in { |
| 345 | val visitor = program.RuleGenerator | 373 | val term = Variable.create("X") |
| 346 | val rules = BsomeValuesFromSC.accept(visitor) | 374 | val unsafe = ontology.unsafeRoles |
| 375 | val skolem = SkolemStrategy.None | ||
| 376 | val suffix = Empty | ||
| 377 | val (facts, rules) = | ||
| 378 | converter.convert(BsomeValuesFromSC, term, unsafe, skolem, suffix) | ||
| 379 | facts shouldBe empty | ||
| 347 | rules should have length 1 | 380 | rules should have length 1 |
| 348 | } | 381 | } |
| 349 | 382 | ||
| @@ -352,8 +385,13 @@ class Ontology2_CanonicalModelSpec | |||
| 352 | renderer.render( | 385 | renderer.render( |
| 353 | CsomeValuesFromTD | 386 | CsomeValuesFromTD |
| 354 | ) should "produce 1 rule" in { | 387 | ) should "produce 1 rule" in { |
| 355 | val visitor = program.RuleGenerator | 388 | val term = Variable.create("X") |
| 356 | val rules = CsomeValuesFromTD.accept(visitor) | 389 | val unsafe = ontology.unsafeRoles |
| 390 | val skolem = SkolemStrategy.None | ||
| 391 | val suffix = Empty | ||
| 392 | val (facts, rules) = | ||
| 393 | converter.convert(CsomeValuesFromTD, term, unsafe, skolem, suffix) | ||
| 394 | facts shouldBe empty | ||
| 357 | rules should have length 1 | 395 | rules should have length 1 |
| 358 | } | 396 | } |
| 359 | 397 | ||
| @@ -362,8 +400,13 @@ class Ontology2_CanonicalModelSpec | |||
| 362 | renderer.render( | 400 | renderer.render( |
| 363 | DsomeValuesFromPA | 401 | DsomeValuesFromPA |
| 364 | ) should "produce 1 rule" in { | 402 | ) should "produce 1 rule" in { |
| 365 | val visitor = program.RuleGenerator | 403 | val term = Variable.create("X") |
| 366 | val rules = DsomeValuesFromPA.accept(visitor) | 404 | val unsafe = ontology.unsafeRoles |
| 405 | val skolem = SkolemStrategy.None | ||
| 406 | val suffix = Empty | ||
| 407 | val (facts, rules) = | ||
| 408 | converter.convert(DsomeValuesFromPA, term, unsafe, skolem, suffix) | ||
| 409 | facts shouldBe empty | ||
| 367 | rules should have length 1 | 410 | rules should have length 1 |
| 368 | } | 411 | } |
| 369 | 412 | ||
diff --git a/src/test/scala/uk/ac/ox/cs/rsacomb/RDFoxConverterSpec.scala b/src/test/scala/uk/ac/ox/cs/rsacomb/RDFoxConverterSpec.scala index 35af464..e2da6e4 100644 --- a/src/test/scala/uk/ac/ox/cs/rsacomb/RDFoxConverterSpec.scala +++ b/src/test/scala/uk/ac/ox/cs/rsacomb/RDFoxConverterSpec.scala | |||
| @@ -32,7 +32,11 @@ object RDFoxConverterSpec { | |||
| 32 | ) | 32 | ) |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | class RDFoxConverterSpec extends AnyFlatSpec with Matchers with LoneElement { | 35 | class RDFoxConverterSpec |
| 36 | extends AnyFlatSpec | ||
| 37 | with Matchers | ||
| 38 | with LoneElement | ||
| 39 | with RDFoxConverter { | ||
| 36 | 40 | ||
| 37 | import RDFoxConverterSpec._ | 41 | import RDFoxConverterSpec._ |
| 38 | 42 | ||
| @@ -40,7 +44,7 @@ class RDFoxConverterSpec extends AnyFlatSpec with Matchers with LoneElement { | |||
| 40 | val cls = factory.getOWLClass(iriString0) | 44 | val cls = factory.getOWLClass(iriString0) |
| 41 | val atom = TupleTableAtom.rdf(term0, IRI.RDF_TYPE, IRI.create(iriString0)) | 45 | val atom = TupleTableAtom.rdf(term0, IRI.RDF_TYPE, IRI.create(iriString0)) |
| 42 | val (res, ext) = | 46 | val (res, ext) = |
| 43 | RDFoxConverter.convert(cls, term0, List(), SkolemStrategy.None, Empty) | 47 | convert(cls, term0, List(), SkolemStrategy.None, Empty) |
| 44 | res.loneElement shouldEqual atom | 48 | res.loneElement shouldEqual atom |
| 45 | ext shouldBe empty | 49 | ext shouldBe empty |
| 46 | } | 50 | } |
| @@ -51,13 +55,13 @@ class RDFoxConverterSpec extends AnyFlatSpec with Matchers with LoneElement { | |||
| 51 | val cls2 = factory.getOWLClass(iriString2) | 55 | val cls2 = factory.getOWLClass(iriString2) |
| 52 | val conj = factory.getOWLObjectIntersectionOf(cls0, cls1, cls2) | 56 | val conj = factory.getOWLObjectIntersectionOf(cls0, cls1, cls2) |
| 53 | val (res0, ext0) = | 57 | val (res0, ext0) = |
| 54 | RDFoxConverter.convert(cls0, term0, List(), SkolemStrategy.None, Empty) | 58 | convert(cls0, term0, List(), SkolemStrategy.None, Empty) |
| 55 | val (res1, ext1) = | 59 | val (res1, ext1) = |
| 56 | RDFoxConverter.convert(cls1, term0, List(), SkolemStrategy.None, Empty) | 60 | convert(cls1, term0, List(), SkolemStrategy.None, Empty) |
| 57 | val (res2, ext2) = | 61 | val (res2, ext2) = |
| 58 | RDFoxConverter.convert(cls2, term0, List(), SkolemStrategy.None, Empty) | 62 | convert(cls2, term0, List(), SkolemStrategy.None, Empty) |
| 59 | val (res, ext) = | 63 | val (res, ext) = |
| 60 | RDFoxConverter.convert(conj, term0, List(), SkolemStrategy.None, Empty) | 64 | convert(conj, term0, List(), SkolemStrategy.None, Empty) |
| 61 | res should contain theSameElementsAs (res0 ::: res1 ::: res2) | 65 | res should contain theSameElementsAs (res0 ::: res1 ::: res2) |
| 62 | ext should contain theSameElementsAs (ext0 ::: ext1 ::: ext2) | 66 | ext should contain theSameElementsAs (ext0 ::: ext1 ::: ext2) |
| 63 | } | 67 | } |
| @@ -66,9 +70,9 @@ class RDFoxConverterSpec extends AnyFlatSpec with Matchers with LoneElement { | |||
| 66 | val cls0 = factory.getOWLClass(iriString0) | 70 | val cls0 = factory.getOWLClass(iriString0) |
| 67 | val conj = factory.getOWLObjectIntersectionOf(cls0) | 71 | val conj = factory.getOWLObjectIntersectionOf(cls0) |
| 68 | val (res0, ext0) = | 72 | val (res0, ext0) = |
| 69 | RDFoxConverter.convert(cls0, term0, List(), SkolemStrategy.None, Empty) | 73 | convert(cls0, term0, List(), SkolemStrategy.None, Empty) |
| 70 | val (res, ext) = | 74 | val (res, ext) = |
| 71 | RDFoxConverter.convert(conj, term0, List(), SkolemStrategy.None, Empty) | 75 | convert(conj, term0, List(), SkolemStrategy.None, Empty) |
| 72 | res should contain theSameElementsAs res0 | 76 | res should contain theSameElementsAs res0 |
| 73 | ext should contain theSameElementsAs ext0 | 77 | ext should contain theSameElementsAs ext0 |
| 74 | } | 78 | } |
| @@ -78,7 +82,7 @@ class RDFoxConverterSpec extends AnyFlatSpec with Matchers with LoneElement { | |||
| 78 | for (sx <- suffixes) { | 82 | for (sx <- suffixes) { |
| 79 | val atom = | 83 | val atom = |
| 80 | TupleTableAtom.rdf(term0, IRI.create(iriString0 :: sx), term1) | 84 | TupleTableAtom.rdf(term0, IRI.create(iriString0 :: sx), term1) |
| 81 | RDFoxConverter.convert(prop, term0, term1, sx) shouldEqual atom | 85 | convert(prop, term0, term1, sx) shouldEqual atom |
| 82 | } | 86 | } |
| 83 | } | 87 | } |
| 84 | 88 | ||
| @@ -88,7 +92,7 @@ class RDFoxConverterSpec extends AnyFlatSpec with Matchers with LoneElement { | |||
| 88 | for (sx <- Seq(Empty, Forward, Backward)) { | 92 | for (sx <- Seq(Empty, Forward, Backward)) { |
| 89 | val atom = | 93 | val atom = |
| 90 | TupleTableAtom.rdf(term0, IRI.create(iriString0 :: sx + Inverse), term1) | 94 | TupleTableAtom.rdf(term0, IRI.create(iriString0 :: sx + Inverse), term1) |
| 91 | RDFoxConverter.convert(inv, term0, term1, sx) shouldEqual atom | 95 | convert(inv, term0, term1, sx) shouldEqual atom |
| 92 | } | 96 | } |
| 93 | } | 97 | } |
| 94 | 98 | ||
| @@ -97,7 +101,7 @@ class RDFoxConverterSpec extends AnyFlatSpec with Matchers with LoneElement { | |||
| 97 | for (suffix <- suffixes) { | 101 | for (suffix <- suffixes) { |
| 98 | val atom = | 102 | val atom = |
| 99 | TupleTableAtom.rdf(term0, IRI.create(iriString0 :: suffix), term1) | 103 | TupleTableAtom.rdf(term0, IRI.create(iriString0 :: suffix), term1) |
| 100 | RDFoxConverter.convert(prop, term0, term1, suffix) shouldEqual atom | 104 | convert(prop, term0, term1, suffix) shouldEqual atom |
| 101 | } | 105 | } |
| 102 | } | 106 | } |
| 103 | 107 | ||
