diff options
| author | Federico Igne <federico.igne@cs.ox.ac.uk> | 2020-11-18 19:13:25 +0000 |
|---|---|---|
| committer | Federico Igne <federico.igne@cs.ox.ac.uk> | 2020-11-18 19:13:25 +0000 |
| commit | 1efc189e90240c162b54cbc50362b46786643dad (patch) | |
| tree | 9beabe0a2af7ba1674aea0060787782aa72e8a83 /src/test/scala/rsacomb | |
| parent | a45aeff72b82bbc9a52f10929bf15b414c868525 (diff) | |
| download | RSAComb-1efc189e90240c162b54cbc50362b46786643dad.tar.gz RSAComb-1efc189e90240c162b54cbc50362b46786643dad.zip | |
Reorganize project with Java-like folder structure
Diffstat (limited to 'src/test/scala/rsacomb')
| -rw-r--r-- | src/test/scala/rsacomb/CanonicalModelSpec.scala | 369 | ||||
| -rw-r--r-- | src/test/scala/rsacomb/FilteringProgramSpecs.scala | 397 | ||||
| -rw-r--r-- | src/test/scala/rsacomb/OWLAxiomSpec.scala | 335 | ||||
| -rw-r--r-- | src/test/scala/rsacomb/OWLClassSpec.scala | 273 |
4 files changed, 0 insertions, 1374 deletions
diff --git a/src/test/scala/rsacomb/CanonicalModelSpec.scala b/src/test/scala/rsacomb/CanonicalModelSpec.scala deleted file mode 100644 index 06602e3..0000000 --- a/src/test/scala/rsacomb/CanonicalModelSpec.scala +++ /dev/null | |||
| @@ -1,369 +0,0 @@ | |||
| 1 | package rsacomb | ||
| 2 | |||
| 3 | import java.io.File | ||
| 4 | import org.scalatest.LoneElement | ||
| 5 | import org.scalatest.flatspec.AnyFlatSpec | ||
| 6 | import org.scalatest.matchers.should.Matchers | ||
| 7 | |||
| 8 | import org.semanticweb.owlapi.model._ | ||
| 9 | import uk.ac.manchester.cs.owl.owlapi._ | ||
| 10 | import org.semanticweb.owlapi.dlsyntax.renderer.DLSyntaxObjectRenderer | ||
| 11 | |||
| 12 | import tech.oxfordsemantic.jrdfox.logic.datalog.Rule | ||
| 13 | import tech.oxfordsemantic.jrdfox.logic.expression.Variable | ||
| 14 | |||
| 15 | import scala.collection.JavaConverters._ | ||
| 16 | |||
| 17 | import rsacomb.util.{RDFoxHelpers, RSA} | ||
| 18 | |||
| 19 | object Ontology1_CanonicalModelSpec { | ||
| 20 | |||
| 21 | /* Renderer to display OWL Axioms with DL syntax*/ | ||
| 22 | val renderer = new DLSyntaxObjectRenderer() | ||
| 23 | |||
| 24 | def base(str: String): IRI = | ||
| 25 | IRI.create("http://example.com/rsa_example.owl#" + str) | ||
| 26 | |||
| 27 | val ontology_path: File = new File("examples/example1.ttl") | ||
| 28 | val ontology = RSAOntology(ontology_path) | ||
| 29 | val program = ontology.canonicalModel | ||
| 30 | |||
| 31 | val roleR = new OWLObjectPropertyImpl(base("R")) | ||
| 32 | val roleS = new OWLObjectPropertyImpl(base("S")) | ||
| 33 | val roleT = new OWLObjectPropertyImpl(base("T")) | ||
| 34 | val roleR_inv = roleR.getInverseProperty() | ||
| 35 | val roleS_inv = roleS.getInverseProperty() | ||
| 36 | val roleT_inv = roleT.getInverseProperty() | ||
| 37 | |||
| 38 | val AsubClassOfD = new OWLSubClassOfAxiomImpl( | ||
| 39 | new OWLClassImpl(base("A")), | ||
| 40 | new OWLClassImpl(base("D")), | ||
| 41 | Seq().asJava | ||
| 42 | ) | ||
| 43 | |||
| 44 | val DsomeValuesFromRB = new OWLSubClassOfAxiomImpl( | ||
| 45 | new OWLClassImpl(base("D")), | ||
| 46 | new OWLObjectSomeValuesFromImpl( | ||
| 47 | roleR, | ||
| 48 | new OWLClassImpl(base("B")) | ||
| 49 | ), | ||
| 50 | Seq().asJava | ||
| 51 | ) | ||
| 52 | |||
| 53 | val BsomeValuesFromSD = new OWLSubClassOfAxiomImpl( | ||
| 54 | new OWLClassImpl(base("B")), | ||
| 55 | new OWLObjectSomeValuesFromImpl( | ||
| 56 | roleS, | ||
| 57 | new OWLClassImpl(base("D")) | ||
| 58 | ), | ||
| 59 | Seq().asJava | ||
| 60 | ) | ||
| 61 | |||
| 62 | val AsomeValuesFromSiC = new OWLSubClassOfAxiomImpl( | ||
| 63 | new OWLClassImpl(base("A")), | ||
| 64 | new OWLObjectSomeValuesFromImpl( | ||
| 65 | roleS_inv, | ||
| 66 | new OWLClassImpl(base("C")) | ||
| 67 | ), | ||
| 68 | Seq().asJava | ||
| 69 | ) | ||
| 70 | |||
| 71 | val SsubPropertyOfT = new OWLSubObjectPropertyOfAxiomImpl( | ||
| 72 | new OWLObjectPropertyImpl(base("S")), | ||
| 73 | new OWLObjectPropertyImpl(base("T")), | ||
| 74 | Seq().asJava | ||
| 75 | ) | ||
| 76 | |||
| 77 | } | ||
| 78 | |||
| 79 | class Ontology1_CanonicalModelSpec | ||
| 80 | extends AnyFlatSpec | ||
| 81 | with Matchers | ||
| 82 | with LoneElement { | ||
| 83 | |||
| 84 | import Ontology1_CanonicalModelSpec._ | ||
| 85 | |||
| 86 | "The program generated from Example #1" should "not be empty" in { | ||
| 87 | program.rules should not be empty | ||
| 88 | } | ||
| 89 | |||
| 90 | renderer.render(AsubClassOfD) should "be converted into a single Rule" in { | ||
| 91 | val varX = Variable.create("X") | ||
| 92 | val visitor = program.RuleGenerator | ||
| 93 | val rules = AsubClassOfD.accept(visitor) | ||
| 94 | rules.loneElement shouldBe a[Rule] | ||
| 95 | } | ||
| 96 | |||
| 97 | // Role R // | ||
| 98 | |||
| 99 | renderer.render(roleR) should "be safe" in { | ||
| 100 | ontology.unsafeRoles should not contain roleR | ||
| 101 | } | ||
| 102 | |||
| 103 | it should "have 3 elements in its conflict set" in { | ||
| 104 | ontology.confl(roleR) should have size 3 | ||
| 105 | } | ||
| 106 | |||
| 107 | it should "contain S in its conflict set" in { | ||
| 108 | ontology.confl(roleR) should contain(roleS) | ||
| 109 | } | ||
| 110 | |||
| 111 | it should "contain T in its conflict set" in { | ||
| 112 | ontology.confl(roleR) should contain(roleT) | ||
| 113 | } | ||
| 114 | |||
| 115 | it should ("contain " + renderer.render( | ||
| 116 | roleR_inv | ||
| 117 | ) + " in its conflict set") in { | ||
| 118 | ontology.confl(roleR) should contain(roleR_inv) | ||
| 119 | } | ||
| 120 | |||
| 121 | // Role S // | ||
| 122 | |||
| 123 | renderer.render(roleS) should "be safe" in { | ||
| 124 | ontology.unsafeRoles should not contain roleS | ||
| 125 | } | ||
| 126 | |||
| 127 | it should "have 3 elements in its conflict set" in { | ||
| 128 | ontology.confl(roleS) should have size 3 | ||
| 129 | } | ||
| 130 | |||
| 131 | it should "contain R in its conflict set" in { | ||
| 132 | ontology.confl(roleS) should contain(roleR) | ||
| 133 | } | ||
| 134 | |||
| 135 | it should ("contain " + renderer.render( | ||
| 136 | roleS_inv | ||
| 137 | ) + " in its conflict set") in { | ||
| 138 | ontology.confl(roleS) should contain(roleS_inv) | ||
| 139 | } | ||
| 140 | |||
| 141 | it should ("contain " + renderer.render( | ||
| 142 | roleT_inv | ||
| 143 | ) + " in its conflict set") in { | ||
| 144 | ontology.confl(roleS) should contain(roleT_inv) | ||
| 145 | } | ||
| 146 | |||
| 147 | // S⁻ | ||
| 148 | |||
| 149 | renderer.render(roleS_inv) should "be unsafe" in { | ||
| 150 | ontology.unsafeRoles should contain(roleS_inv) | ||
| 151 | } | ||
| 152 | |||
| 153 | renderer.render( | ||
| 154 | AsomeValuesFromSiC | ||
| 155 | ) should "produce 1 rule" in { | ||
| 156 | val varX = Variable.create("X") | ||
| 157 | val visitor = program.RuleGenerator | ||
| 158 | val rules = AsomeValuesFromSiC.accept(visitor) | ||
| 159 | rules should have length 1 | ||
| 160 | } | ||
| 161 | |||
| 162 | renderer.render( | ||
| 163 | DsomeValuesFromRB | ||
| 164 | ) should "have a 'cycle' set of 48 elements" in { | ||
| 165 | // Cycle introduces a new constant for each possible triple (the | ||
| 166 | // order among triples is total). In this example there are 4 | ||
| 167 | // concept names and R has 3 safe roles in its conflict set (S, T, | ||
| 168 | // Inv(R)). Triples are | ||
| 169 | // (concept, role, concept) | ||
| 170 | // and hence we have 4*3*4=48 new constants introduced. | ||
| 171 | ontology.cycle(DsomeValuesFromRB) should have size 48 | ||
| 172 | } | ||
| 173 | |||
| 174 | it should "produce 5 rules" in { | ||
| 175 | // Rule 1 provides 1 rule (split in 2) + 48 fact | ||
| 176 | // Rule 2 provides 0 rules | ||
| 177 | // Rule 3 provides 48 rule (split in 2) | ||
| 178 | // Then (1*2 + 48) + (0) + (48*2) = 146 | ||
| 179 | val varX = Variable.create("X") | ||
| 180 | val visitor = program.RuleGenerator | ||
| 181 | val rules = DsomeValuesFromRB.accept(visitor) | ||
| 182 | rules should have length 146 | ||
| 183 | } | ||
| 184 | |||
| 185 | renderer.render( | ||
| 186 | BsomeValuesFromSD | ||
| 187 | ) should "have a 'cycle' set of 32 elements" in { | ||
| 188 | // Cycle introduces a new constant for each possible triple (the | ||
| 189 | // order among triples is total). In this example there are 4 | ||
| 190 | // concept names and S has 2 safe roles in its conflict set (R, | ||
| 191 | // Inv(T)). Triples are | ||
| 192 | // (concept, role, concept) | ||
| 193 | // and hence we have 4*2*4=32 new constants introduced. | ||
| 194 | ontology.cycle(BsomeValuesFromSD) should have size 32 | ||
| 195 | } | ||
| 196 | |||
| 197 | it should "produce 5 rules" in { | ||
| 198 | // Rule 1 provides 1 rule (split in 2) + 32 fact | ||
| 199 | // Rule 2 provides 0 rules | ||
| 200 | // Rule 3 provides 32 rule (split in 2) | ||
| 201 | // Then (1*2 + 32) + (0) + (32*2) = 98 | ||
| 202 | val varX = Variable.create("X") | ||
| 203 | val visitor = program.RuleGenerator | ||
| 204 | val rules = DsomeValuesFromRB.accept(visitor) | ||
| 205 | rules should have length 146 | ||
| 206 | } | ||
| 207 | |||
| 208 | renderer.render( | ||
| 209 | SsubPropertyOfT | ||
| 210 | ) should "produce 2 rules" in { | ||
| 211 | val varX = Variable.create("X") | ||
| 212 | val visitor = program.RuleGenerator | ||
| 213 | val rules = SsubPropertyOfT.accept(visitor) | ||
| 214 | rules should have length 2 | ||
| 215 | } | ||
| 216 | |||
| 217 | } | ||
| 218 | |||
| 219 | object Ontology2_CanonicalModelSpec { | ||
| 220 | |||
| 221 | /* Renderer to display OWL Axioms with DL syntax*/ | ||
| 222 | val renderer = new DLSyntaxObjectRenderer() | ||
| 223 | |||
| 224 | def base(str: String): IRI = | ||
| 225 | IRI.create("http://example.com/rsa_example.owl#" + str) | ||
| 226 | |||
| 227 | val ontology_path: File = new File("examples/example2.owl") | ||
| 228 | val ontology = RSAOntology(ontology_path) | ||
| 229 | val program = ontology.canonicalModel | ||
| 230 | |||
| 231 | val roleR = new OWLObjectPropertyImpl(base("R")) | ||
| 232 | val roleS = new OWLObjectPropertyImpl(base("S")) | ||
| 233 | val roleT = new OWLObjectPropertyImpl(base("T")) | ||
| 234 | val roleP = new OWLObjectPropertyImpl(base("P")) | ||
| 235 | val roleR_inv = roleR.getInverseProperty() | ||
| 236 | val roleS_inv = roleS.getInverseProperty() | ||
| 237 | val roleT_inv = roleT.getInverseProperty() | ||
| 238 | val roleP_inv = roleP.getInverseProperty() | ||
| 239 | |||
| 240 | val AsomeValuesFromRB = new OWLSubClassOfAxiomImpl( | ||
| 241 | new OWLClassImpl(base("A")), | ||
| 242 | new OWLObjectSomeValuesFromImpl( | ||
| 243 | roleR, | ||
| 244 | new OWLClassImpl(base("B")) | ||
| 245 | ), | ||
| 246 | Seq().asJava | ||
| 247 | ) | ||
| 248 | |||
| 249 | val BsomeValuesFromSC = new OWLSubClassOfAxiomImpl( | ||
| 250 | new OWLClassImpl(base("B")), | ||
| 251 | new OWLObjectSomeValuesFromImpl( | ||
| 252 | roleS, | ||
| 253 | new OWLClassImpl(base("C")) | ||
| 254 | ), | ||
| 255 | Seq().asJava | ||
| 256 | ) | ||
| 257 | |||
| 258 | val CsomeValuesFromTD = new OWLSubClassOfAxiomImpl( | ||
| 259 | new OWLClassImpl(base("C")), | ||
| 260 | new OWLObjectSomeValuesFromImpl( | ||
| 261 | roleT, | ||
| 262 | new OWLClassImpl(base("D")) | ||
| 263 | ), | ||
| 264 | Seq().asJava | ||
| 265 | ) | ||
| 266 | |||
| 267 | val DsomeValuesFromPA = new OWLSubClassOfAxiomImpl( | ||
| 268 | new OWLClassImpl(base("D")), | ||
| 269 | new OWLObjectSomeValuesFromImpl( | ||
| 270 | roleP, | ||
| 271 | new OWLClassImpl(base("A")) | ||
| 272 | ), | ||
| 273 | Seq().asJava | ||
| 274 | ) | ||
| 275 | |||
| 276 | } | ||
| 277 | |||
| 278 | class Ontology2_CanonicalModelSpec | ||
| 279 | extends AnyFlatSpec | ||
| 280 | with Matchers | ||
| 281 | with LoneElement { | ||
| 282 | |||
| 283 | import Ontology2_CanonicalModelSpec._ | ||
| 284 | |||
| 285 | "The program generated from Example #1" should "not be empty" in { | ||
| 286 | program.rules should not be empty | ||
| 287 | } | ||
| 288 | |||
| 289 | // Role R // | ||
| 290 | |||
| 291 | renderer.render(roleR) should "be unsafe" in { | ||
| 292 | ontology.unsafeRoles should contain(roleR) | ||
| 293 | } | ||
| 294 | |||
| 295 | it should "have only its inverse in its conflict set" in { | ||
| 296 | ontology.confl(roleR).loneElement shouldBe roleR_inv | ||
| 297 | } | ||
| 298 | |||
| 299 | // Role S // | ||
| 300 | |||
| 301 | renderer.render(roleS) should "be unsafe" in { | ||
| 302 | ontology.unsafeRoles should contain(roleS) | ||
| 303 | } | ||
| 304 | |||
| 305 | it should "have only its inverse in its conflict set" in { | ||
| 306 | ontology.confl(roleS).loneElement shouldBe roleS_inv | ||
| 307 | } | ||
| 308 | |||
| 309 | // Role T // | ||
| 310 | |||
| 311 | renderer.render(roleT) should "be unsafe" in { | ||
| 312 | ontology.unsafeRoles should contain(roleT) | ||
| 313 | } | ||
| 314 | |||
| 315 | it should "have only its inverse in its conflict set" in { | ||
| 316 | ontology.confl(roleT).loneElement shouldBe roleT_inv | ||
| 317 | } | ||
| 318 | |||
| 319 | // Role P // | ||
| 320 | |||
| 321 | renderer.render(roleP) should "be unsafe" in { | ||
| 322 | ontology.unsafeRoles should contain(roleP) | ||
| 323 | } | ||
| 324 | |||
| 325 | it should "have only its inverse in its conflict set" in { | ||
| 326 | ontology.confl(roleP).loneElement shouldBe roleP_inv | ||
| 327 | } | ||
| 328 | |||
| 329 | // A ⊑ ∃ R.B | ||
| 330 | |||
| 331 | renderer.render( | ||
| 332 | AsomeValuesFromRB | ||
| 333 | ) should "produce 1 rule" in { | ||
| 334 | val visitor = program.RuleGenerator | ||
| 335 | val rules = AsomeValuesFromRB.accept(visitor) | ||
| 336 | rules should have length 1 | ||
| 337 | } | ||
| 338 | |||
| 339 | // B ⊑ ∃ S.C | ||
| 340 | |||
| 341 | renderer.render( | ||
| 342 | BsomeValuesFromSC | ||
| 343 | ) should "produce 1 rule" in { | ||
| 344 | val visitor = program.RuleGenerator | ||
| 345 | val rules = BsomeValuesFromSC.accept(visitor) | ||
| 346 | rules should have length 1 | ||
| 347 | } | ||
| 348 | |||
| 349 | // C ⊑ ∃ T.D | ||
| 350 | |||
| 351 | renderer.render( | ||
| 352 | CsomeValuesFromTD | ||
| 353 | ) should "produce 1 rule" in { | ||
| 354 | val visitor = program.RuleGenerator | ||
| 355 | val rules = CsomeValuesFromTD.accept(visitor) | ||
| 356 | rules should have length 1 | ||
| 357 | } | ||
| 358 | |||
| 359 | // D ⊑ ∃ P.A | ||
| 360 | |||
| 361 | renderer.render( | ||
| 362 | DsomeValuesFromPA | ||
| 363 | ) should "produce 1 rule" in { | ||
| 364 | val visitor = program.RuleGenerator | ||
| 365 | val rules = DsomeValuesFromPA.accept(visitor) | ||
| 366 | rules should have length 1 | ||
| 367 | } | ||
| 368 | |||
| 369 | } | ||
diff --git a/src/test/scala/rsacomb/FilteringProgramSpecs.scala b/src/test/scala/rsacomb/FilteringProgramSpecs.scala deleted file mode 100644 index 66c1cae..0000000 --- a/src/test/scala/rsacomb/FilteringProgramSpecs.scala +++ /dev/null | |||
| @@ -1,397 +0,0 @@ | |||
| 1 | package rsacomb | ||
| 2 | |||
| 3 | import java.io.File | ||
| 4 | import java.util.{ArrayList => JList} | ||
| 5 | import org.scalatest.LoneElement | ||
| 6 | import org.scalatest.Inspectors | ||
| 7 | import org.scalatest.flatspec.AnyFlatSpec | ||
| 8 | import org.scalatest.matchers.should.Matchers | ||
| 9 | |||
| 10 | import tech.oxfordsemantic.jrdfox.logic.datalog.TupleTableAtom | ||
| 11 | import tech.oxfordsemantic.jrdfox.logic.expression.{Variable, IRI} | ||
| 12 | import tech.oxfordsemantic.jrdfox.logic.sparql.statement.{Query, SelectQuery} | ||
| 13 | import tech.oxfordsemantic.jrdfox.Prefixes | ||
| 14 | |||
| 15 | import scala.collection.JavaConverters._ | ||
| 16 | |||
| 17 | import rsacomb.util.RDFoxHelpers | ||
| 18 | |||
| 19 | object FilteringProgramSpec { | ||
| 20 | |||
| 21 | val prefixes = new Prefixes() | ||
| 22 | prefixes.declarePrefix( | ||
| 23 | ":", | ||
| 24 | "http://slegger.gitlab.io/slegge-obda/ontology/subsurface-exploration#" | ||
| 25 | ) | ||
| 26 | prefixes.declarePrefix("rdf:", "http://www.w3.org/1999/02/22-rdf-syntax-ns#") | ||
| 27 | prefixes.declarePrefix("rdfs:", "http://www.w3.org/2000/01/rdf-schema#") | ||
| 28 | prefixes.declarePrefix("owl:", "http://www.w3.org/2002/07/owl#") | ||
| 29 | |||
| 30 | // DEBUG: Quick helper functions | ||
| 31 | def v(v: String): Variable = Variable.create(v) | ||
| 32 | def c(c: String): IRI = IRI.create(":" + c) | ||
| 33 | |||
| 34 | // QUERY 0 | ||
| 35 | |||
| 36 | val query0 = RDFoxHelpers | ||
| 37 | .parseSelectQuery(""" | ||
| 38 | SELECT ?subj | ||
| 39 | WHERE { | ||
| 40 | ?subj ?pred ?obj | ||
| 41 | } | ||
| 42 | """, prefixes) | ||
| 43 | .get | ||
| 44 | |||
| 45 | // val query0 = Query.create( | ||
| 46 | // QueryType.SELECT, | ||
| 47 | // false, | ||
| 48 | // List(v("subj")).asJava, | ||
| 49 | // Atom.rdf(v("subj"), v("pred"), v("obj")) | ||
| 50 | // ) | ||
| 51 | |||
| 52 | // QUERY 1 | ||
| 53 | |||
| 54 | val query1 = RDFoxHelpers | ||
| 55 | .parseSelectQuery(""" | ||
| 56 | SELECT * | ||
| 57 | WHERE { | ||
| 58 | ?w a :Wellbore | ||
| 59 | } | ||
| 60 | """, prefixes) | ||
| 61 | .get | ||
| 62 | |||
| 63 | // val query1 = Query.create( | ||
| 64 | // QueryType.SELECT, | ||
| 65 | // false, | ||
| 66 | // List(v("w")).asJava, | ||
| 67 | // Atom.rdf(v("w"), IRI.RDF_TYPE, c("Wellbore")) | ||
| 68 | // ) | ||
| 69 | |||
| 70 | // QUERY 2 | ||
| 71 | |||
| 72 | val query2 = RDFoxHelpers | ||
| 73 | .parseSelectQuery( | ||
| 74 | """ | ||
| 75 | SELECT * | ||
| 76 | WHERE { | ||
| 77 | ?w a :Wellbore ; | ||
| 78 | :wellboreDocument ?doc . | ||
| 79 | ?doc :hasURL ?document_hyperlink | ||
| 80 | } | ||
| 81 | """, | ||
| 82 | prefixes | ||
| 83 | ) | ||
| 84 | .get | ||
| 85 | |||
| 86 | // val query2 = Query.create( | ||
| 87 | // QueryType.SELECT, | ||
| 88 | // false, | ||
| 89 | // List(v("w"), v("doc"), v("document_hyperlink")).asJava, | ||
| 90 | // Conjunction.create( | ||
| 91 | // Atom.rdf(v("w"), IRI.RDF_TYPE, c("Wellbore")), | ||
| 92 | // Atom.rdf(v("w"), c("wellboreDocument"), v("doc")), | ||
| 93 | // Atom.rdf(v("doc"), c("hasURL"), v("document_hyperlink")) | ||
| 94 | // ) | ||
| 95 | // ) | ||
| 96 | |||
| 97 | // QUERY 3 | ||
| 98 | |||
| 99 | val query3 = RDFoxHelpers | ||
| 100 | .parseSelectQuery( | ||
| 101 | """ | ||
| 102 | SELECT ?wellbore ?formation_pressure | ||
| 103 | WHERE { | ||
| 104 | ?w a :Wellbore ; | ||
| 105 | :name ?wellbore ; | ||
| 106 | :hasFormationPressure ?fp . | ||
| 107 | ?fp :valueInStandardUnit ?formation_pressure | ||
| 108 | } | ||
| 109 | """, | ||
| 110 | prefixes | ||
| 111 | ) | ||
| 112 | .get | ||
| 113 | |||
| 114 | // val query3 = Query.create( | ||
| 115 | // QueryType.SELECT, | ||
| 116 | // false, | ||
| 117 | // List(v("wellbore"), v("formation_pressure")).asJava, | ||
| 118 | // Conjunction.create( | ||
| 119 | // Atom.rdf(v("w"), IRI.RDF_TYPE, c("Wellbore")), | ||
| 120 | // Atom.rdf(v("w"), c("name"), v("wellbore")), | ||
| 121 | // Atom.rdf(v("w"), c("hasFormationPressure"), v("fp")), | ||
| 122 | // Atom.rdf(v("fp"), c("valueInStandardUnit"), v("formation_pressure")) | ||
| 123 | // ) | ||
| 124 | // ) | ||
| 125 | |||
| 126 | // QUERY 4 | ||
| 127 | |||
| 128 | val query4 = RDFoxHelpers | ||
| 129 | .parseSelectQuery( | ||
| 130 | """ | ||
| 131 | SELECT * | ||
| 132 | WHERE { | ||
| 133 | ?w a :Wellbore ; | ||
| 134 | :hasGeochemicalMeasurement ?measurement . | ||
| 135 | ?measurement :cgType ?cgtype ; | ||
| 136 | :peakName ?peakType ; | ||
| 137 | :peakHeight ?peak_height ; | ||
| 138 | :peakAmount ?peak_amount | ||
| 139 | } | ||
| 140 | """, | ||
| 141 | prefixes | ||
| 142 | ) | ||
| 143 | .get | ||
| 144 | |||
| 145 | // val query4 = Query.create( | ||
| 146 | // QueryType.SELECT, | ||
| 147 | // false, | ||
| 148 | // List( | ||
| 149 | // v("w"), | ||
| 150 | // v("measurement"), | ||
| 151 | // v("cgtype"), | ||
| 152 | // v("peakType"), | ||
| 153 | // v("peak_height"), | ||
| 154 | // v("peak_amount") | ||
| 155 | // ).asJava, | ||
| 156 | // Conjunction.create( | ||
| 157 | // Atom.rdf(v("w"), IRI.RDF_TYPE, c("Wellbore")), | ||
| 158 | // Atom.rdf(v("w"), c("hasGeochemicalMeasurement"), v("measurement")), | ||
| 159 | // Atom.rdf(v("measurement"), c("cgType"), v("cgtype")), | ||
| 160 | // Atom.rdf(v("measurement"), c("peakName"), v("peakType")), | ||
| 161 | // Atom.rdf(v("measurement"), c("peakHeight"), v("peak_height")), | ||
| 162 | // Atom.rdf(v("measurement"), c("peakAmount"), v("peak_amount")) | ||
| 163 | // ) | ||
| 164 | // ) | ||
| 165 | |||
| 166 | // QUERY 5 | ||
| 167 | |||
| 168 | val query5 = RDFoxHelpers | ||
| 169 | .parseSelectQuery( | ||
| 170 | """ | ||
| 171 | SELECT ?wellbore ?unit_name ?discovery | ||
| 172 | WHERE { | ||
| 173 | ?w a :Wellbore ; | ||
| 174 | :name ?wellbore ; | ||
| 175 | :hasWellboreInterval ?c_int ; | ||
| 176 | :hasWellboreInterval ?f_int . | ||
| 177 | ?c_int :hasUnit ?c_unit . | ||
| 178 | ?c_unit :name ?unit_name . | ||
| 179 | ?f_int a :FluidZone ; | ||
| 180 | :name ?discovery ; | ||
| 181 | :overlapsWellboreInterval ?c_int | ||
| 182 | } | ||
| 183 | """, | ||
| 184 | prefixes | ||
| 185 | ) | ||
| 186 | .get | ||
| 187 | |||
| 188 | // val query5 = Query.create( | ||
| 189 | // QueryType.SELECT, | ||
| 190 | // false, | ||
| 191 | // List(v("wellbore"), v("unit_name"), v("discovery")).asJava, | ||
| 192 | // Conjunction.create( | ||
| 193 | // Atom.rdf(v("w"), IRI.RDF_TYPE, c("Wellbore")), | ||
| 194 | // Atom.rdf(v("w"), c("name"), v("wellbore")), | ||
| 195 | // Atom.rdf(v("w"), c("hasWellboreInterval"), v("c_int")), | ||
| 196 | // Atom.rdf(v("w"), c("hasWellboreInterval"), v("f_int")), | ||
| 197 | // Atom.rdf(v("c_int"), c("hasUnit"), v("c_unit")), | ||
| 198 | // Atom.rdf(v("c_unit"), c("name"), v("unit_name")), | ||
| 199 | // Atom.rdf(v("f_int"), IRI.RDF_TYPE, c("FluidZone")), | ||
| 200 | // Atom.rdf(v("f_int"), c("name"), v("discovery")), | ||
| 201 | // Atom.rdf(v("f_int"), c("overlapsWellboreInterval"), v("c_int")) | ||
| 202 | // ) | ||
| 203 | // ) | ||
| 204 | |||
| 205 | // QUERY 6 | ||
| 206 | |||
| 207 | val query6 = RDFoxHelpers | ||
| 208 | .parseSelectQuery( | ||
| 209 | """ | ||
| 210 | SELECT DISTINCT ?wellbore ?content | ||
| 211 | WHERE { | ||
| 212 | ?w a :Wellbore ; | ||
| 213 | :name ?wellbore ; | ||
| 214 | :hasWellboreInterval ?int . | ||
| 215 | ?int a :FluidZone ; | ||
| 216 | :fluidZoneContent ?content | ||
| 217 | } | ||
| 218 | """, | ||
| 219 | prefixes | ||
| 220 | ) | ||
| 221 | .get | ||
| 222 | |||
| 223 | // val query6 = Query.create( | ||
| 224 | // QueryType.SELECT, | ||
| 225 | // true, | ||
| 226 | // List(v("wellbore"), v("content")).asJava, | ||
| 227 | // Conjunction.create( | ||
| 228 | // Atom.rdf(v("w"), IRI.RDF_TYPE, c("Wellbore")), | ||
| 229 | // Atom.rdf(v("w"), c("name"), v("wellbore")), | ||
| 230 | // Atom.rdf(v("w"), c("hasWellboreInterval"), v("int")), | ||
| 231 | // Atom.rdf(v("int"), IRI.RDF_TYPE, c("FluidZone")), | ||
| 232 | // Atom.rdf(v("int"), c("fluidZoneContent"), v("content")) | ||
| 233 | // ) | ||
| 234 | // ) | ||
| 235 | |||
| 236 | // QUERY 7 | ||
| 237 | |||
| 238 | val query7 = RDFoxHelpers | ||
| 239 | .parseSelectQuery( | ||
| 240 | """ | ||
| 241 | SELECT ?wName ?sample ?porosity ?top_depth_md ?bot_depth_md | ||
| 242 | WHERE { | ||
| 243 | ?w a :Wellbore ; | ||
| 244 | :name ?wName ; | ||
| 245 | :hasWellboreInterval ?z . | ||
| 246 | ?z :hasUnit ?u . | ||
| 247 | ?u :name ?strat_unit_name . | ||
| 248 | ?wellbore :hasWellboreInterval ?cored_int . | ||
| 249 | ?c :extractedFrom ?cored_int ; | ||
| 250 | :hasCoreSample ?sample . | ||
| 251 | ?sample :hasDepth ?sample_depth . | ||
| 252 | ?sample_depth | ||
| 253 | :inWellboreInterval ?z . | ||
| 254 | ?sample :hasPorosity ?p . | ||
| 255 | ?p :valueInStandardUnit ?porosity . | ||
| 256 | ?z :hasTopDepth ?top . | ||
| 257 | ?top a :MeasuredDepth ; | ||
| 258 | :valueInStandardUnit ?top_depth_md . | ||
| 259 | ?z :hasBottomDepth ?bot . | ||
| 260 | ?bot a :MeasuredDepth ; | ||
| 261 | :valueInStandardUnit ?bot_depth_md | ||
| 262 | } | ||
| 263 | """, | ||
| 264 | prefixes | ||
| 265 | ) | ||
| 266 | .get | ||
| 267 | |||
| 268 | // val query7 = Query.create( | ||
| 269 | // QueryType.SELECT, | ||
| 270 | // false, | ||
| 271 | // List( | ||
| 272 | // v("wName"), | ||
| 273 | // v("sample"), | ||
| 274 | // v("porosity"), | ||
| 275 | // v("top_depth_md"), | ||
| 276 | // v("bot_depth_md") | ||
| 277 | // ).asJava, | ||
| 278 | // Conjunction.create( | ||
| 279 | // Atom.rdf(v("w"), IRI.RDF_TYPE, c("Wellbore")), | ||
| 280 | // Atom.rdf(v("w"), c("name"), v("wName")), | ||
| 281 | // Atom.rdf(v("w"), c("hasWellboreInterval"), v("z")), | ||
| 282 | // Atom.rdf(v("z"), c("hasUnit"), v("u")), | ||
| 283 | // Atom.rdf(v("u"), c("name"), v("strat_unit_name")), | ||
| 284 | // Atom.rdf(v("wellbore"), c("hasWellboreInterval"), v("cored_int")), | ||
| 285 | // Atom.rdf(v("c"), c("extractedFrom"), v("cored_int")), | ||
| 286 | // Atom.rdf(v("c"), c("hasCoreSample"), v("sample")), | ||
| 287 | // Atom.rdf(v("sample"), c("hasDepth"), v("sample_depth")), | ||
| 288 | // Atom.rdf(v("sample_depth"), c("inWellboreInterval"), v("z")), | ||
| 289 | // Atom.rdf(v("sample"), c("hasPorosity"), v("p")), | ||
| 290 | // Atom.rdf(v("p"), c("valueInStandardUnit"), v("porosity")), | ||
| 291 | // Atom.rdf(v("z"), c("hasTopDepth"), v("top")), | ||
| 292 | // Atom.rdf(v("top"), IRI.RDF_TYPE, c("MeasuredDepth")), | ||
| 293 | // Atom.rdf(v("top"), c("valueInStandardUnit"), v("top_depth_md")), | ||
| 294 | // Atom.rdf(v("z"), c("hasBottomDepth"), v("bot")), | ||
| 295 | // Atom.rdf(v("bot"), IRI.RDF_TYPE, c("MeasuredDepth")), | ||
| 296 | // Atom.rdf(v("bot"), c("valueInStandardUnit"), v("bot_depth_md")) | ||
| 297 | // ) | ||
| 298 | // ) | ||
| 299 | |||
| 300 | val queries = | ||
| 301 | List(query0, query1, query2, query3, query4, query5, query6, query7) | ||
| 302 | } | ||
| 303 | |||
| 304 | class FilteringProgramSpec | ||
| 305 | extends AnyFlatSpec | ||
| 306 | with Matchers | ||
| 307 | with LoneElement | ||
| 308 | with Inspectors { | ||
| 309 | |||
| 310 | import FilteringProgramSpec._ | ||
| 311 | |||
| 312 | "Queries" should "have distinct answer and bounded variables" in { | ||
| 313 | for (query <- queries) { | ||
| 314 | val program = new FilteringProgram(query, List()) | ||
| 315 | forAll(program.answer) { v => program.bounded should not contain v } | ||
| 316 | forAll(program.bounded) { v => program.answer should not contain v } | ||
| 317 | } | ||
| 318 | } | ||
| 319 | |||
| 320 | "Query 0" should "have {?obj, ?pred} as bounded variables" in { | ||
| 321 | val pred = Variable.create("obj") | ||
| 322 | val obj = Variable.create("pred") | ||
| 323 | val program = new FilteringProgram(query0, List()) | ||
| 324 | program.bounded should contain theSameElementsAs List(pred, obj) | ||
| 325 | } | ||
| 326 | |||
| 327 | "Query 1" should "have no bounded variable" in { | ||
| 328 | val program = new FilteringProgram(query1, List()) | ||
| 329 | program.bounded shouldBe empty | ||
| 330 | } | ||
| 331 | |||
| 332 | "Query 2" should "have no bounded variable" in { | ||
| 333 | val program = new FilteringProgram(query2, List()) | ||
| 334 | program.bounded shouldBe empty | ||
| 335 | } | ||
| 336 | |||
| 337 | "Query 3" should "have {?w, ?fp} as bounded variables" in { | ||
| 338 | val w = Variable.create("w") | ||
| 339 | val fp = Variable.create("fp") | ||
| 340 | val program = new FilteringProgram(query3, List()) | ||
| 341 | program.bounded should contain theSameElementsAs List(w, fp) | ||
| 342 | } | ||
| 343 | |||
| 344 | "Query 4" should "have no bounded variable" in { | ||
| 345 | val program = new FilteringProgram(query4, List()) | ||
| 346 | program.bounded shouldBe empty | ||
| 347 | } | ||
| 348 | |||
| 349 | "Query 5" should "have a non-empty bounded set" in { | ||
| 350 | val w = Variable.create("w") | ||
| 351 | val c_int = Variable.create("c_int") | ||
| 352 | val f_int = Variable.create("f_int") | ||
| 353 | val c_unit = Variable.create("c_unit") | ||
| 354 | val program = new FilteringProgram(query5, List()) | ||
| 355 | program.bounded should contain theSameElementsAs List( | ||
| 356 | w, | ||
| 357 | c_int, | ||
| 358 | f_int, | ||
| 359 | c_unit | ||
| 360 | ) | ||
| 361 | } | ||
| 362 | |||
| 363 | "Query 6" should "have a non-empty bounded set" in { | ||
| 364 | val w = Variable.create("w") | ||
| 365 | val int = Variable.create("int") | ||
| 366 | val program = new FilteringProgram(query6, List()) | ||
| 367 | program.bounded should contain theSameElementsAs List(w, int) | ||
| 368 | } | ||
| 369 | |||
| 370 | "Query 7" should "have a non-empty bounded set" in { | ||
| 371 | val w = Variable.create("w") | ||
| 372 | val z = Variable.create("z") | ||
| 373 | val u = Variable.create("u") | ||
| 374 | val strat_unit_name = Variable.create("strat_unit_name") | ||
| 375 | val wellbore = Variable.create("wellbore") | ||
| 376 | val cored_int = Variable.create("cored_int") | ||
| 377 | val c = Variable.create("c") | ||
| 378 | val sample_depth = Variable.create("sample_depth") | ||
| 379 | val p = Variable.create("p") | ||
| 380 | val top = Variable.create("top") | ||
| 381 | val bot = Variable.create("bot") | ||
| 382 | val program = new FilteringProgram(query7, List()) | ||
| 383 | program.bounded should contain theSameElementsAs List( | ||
| 384 | w, | ||
| 385 | z, | ||
| 386 | u, | ||
| 387 | strat_unit_name, | ||
| 388 | wellbore, | ||
| 389 | cored_int, | ||
| 390 | c, | ||
| 391 | sample_depth, | ||
| 392 | p, | ||
| 393 | top, | ||
| 394 | bot | ||
| 395 | ) | ||
| 396 | } | ||
| 397 | } | ||
diff --git a/src/test/scala/rsacomb/OWLAxiomSpec.scala b/src/test/scala/rsacomb/OWLAxiomSpec.scala deleted file mode 100644 index 65333f5..0000000 --- a/src/test/scala/rsacomb/OWLAxiomSpec.scala +++ /dev/null | |||
| @@ -1,335 +0,0 @@ | |||
| 1 | package rsacomb | ||
| 2 | |||
| 3 | import java.util.{ArrayList => JList} | ||
| 4 | import org.scalatest.LoneElement | ||
| 5 | import org.scalatest.flatspec.AnyFlatSpec | ||
| 6 | import org.scalatest.matchers.should.Matchers | ||
| 7 | |||
| 8 | import org.semanticweb.owlapi.model.OWLClassExpression | ||
| 9 | import uk.ac.manchester.cs.owl.owlapi.{OWLSubClassOfAxiomImpl} | ||
| 10 | import uk.ac.manchester.cs.owl.owlapi.{ | ||
| 11 | OWLClassImpl, | ||
| 12 | OWLObjectSomeValuesFromImpl, | ||
| 13 | OWLObjectIntersectionOfImpl, | ||
| 14 | OWLObjectOneOfImpl, | ||
| 15 | OWLObjectAllValuesFromImpl, | ||
| 16 | OWLObjectMaxCardinalityImpl, | ||
| 17 | OWLNamedIndividualImpl | ||
| 18 | } | ||
| 19 | import uk.ac.manchester.cs.owl.owlapi.{OWLObjectPropertyImpl} | ||
| 20 | import org.semanticweb.owlapi.model.{OWLAxiom} | ||
| 21 | |||
| 22 | import tech.oxfordsemantic.jrdfox.logic.Datatype | ||
| 23 | import tech.oxfordsemantic.jrdfox.logic.datalog.{ | ||
| 24 | Rule, | ||
| 25 | BindAtom, | ||
| 26 | TupleTableAtom, | ||
| 27 | TupleTableName | ||
| 28 | } | ||
| 29 | import tech.oxfordsemantic.jrdfox.logic.expression.{ | ||
| 30 | FunctionCall, | ||
| 31 | Term, | ||
| 32 | Variable, | ||
| 33 | Literal | ||
| 34 | } | ||
| 35 | |||
| 36 | import org.semanticweb.owlapi.model.{IRI => OWLIRI} | ||
| 37 | import tech.oxfordsemantic.jrdfox.logic.expression.{IRI => RDFIRI} | ||
| 38 | |||
| 39 | import rsacomb.util.RSA | ||
| 40 | |||
| 41 | object OWLAxiomSpec { | ||
| 42 | |||
| 43 | // IRI | ||
| 44 | val iri_Professor = OWLIRI.create("univ:Professor") | ||
| 45 | val iri_Female = OWLIRI.create("std:Female") | ||
| 46 | val iri_Student = OWLIRI.create("univ:Student") | ||
| 47 | val iri_PartTimeStudent = OWLIRI.create("univ:PartTimeStudent") | ||
| 48 | val iri_Worker = OWLIRI.create("univ:Worker") | ||
| 49 | val iri_alice = OWLIRI.create("univ:alice") | ||
| 50 | val iri_supervises = OWLIRI.create("univ:supervises") | ||
| 51 | val iri_hasSupervisor = OWLIRI.create("univ:hasSupervisor") | ||
| 52 | val iri_sameAs = OWLIRI.create("owl:sameAs") | ||
| 53 | |||
| 54 | // RDFox Terms | ||
| 55 | val term_x = Variable.create("x") | ||
| 56 | val term_y = Variable.create("y") | ||
| 57 | val term_z = Variable.create("z") | ||
| 58 | val term_c1 = RSA("c_1") | ||
| 59 | val term_c2 = RSA("c_2") | ||
| 60 | val term_alice = RDFIRI.create("univ:alice") | ||
| 61 | |||
| 62 | // RDFox Predicates | ||
| 63 | val pred_sameAs = TupleTableName.create("owl:sameAs") | ||
| 64 | val pred_Professor = TupleTableName.create(iri_Professor.getIRIString) | ||
| 65 | val pred_hasSupervisor = TupleTableName.create(iri_hasSupervisor.getIRIString) | ||
| 66 | |||
| 67 | // OWL Classes | ||
| 68 | // Name Class corresponding to | ||
| 69 | // | ||
| 70 | // Professor | ||
| 71 | // | ||
| 72 | val class_Professor = new OWLClassImpl(iri_Professor) | ||
| 73 | val class_Female = new OWLClassImpl(iri_Female) | ||
| 74 | val class_Student = new OWLClassImpl(iri_Student) | ||
| 75 | val class_PartTimeStudent = new OWLClassImpl(iri_PartTimeStudent) | ||
| 76 | val class_Worker = new OWLClassImpl(iri_Worker) | ||
| 77 | val class_OWLClass = class_Professor | ||
| 78 | // Class Conjunction corresponding to | ||
| 79 | // | ||
| 80 | // Student ∧ Worker | ||
| 81 | // | ||
| 82 | val class_OWLObjectIntersectionOf = { | ||
| 83 | val conjuncts = new JList[OWLClassExpression]() | ||
| 84 | conjuncts.add(class_Student) | ||
| 85 | conjuncts.add(class_Worker) | ||
| 86 | new OWLObjectIntersectionOfImpl(conjuncts) | ||
| 87 | } | ||
| 88 | // Singleton Class corresponding to | ||
| 89 | // | ||
| 90 | // { alice } | ||
| 91 | // | ||
| 92 | val class_OWLObjectOneOf = | ||
| 93 | new OWLObjectOneOfImpl( | ||
| 94 | new OWLNamedIndividualImpl(iri_alice) | ||
| 95 | ) | ||
| 96 | // Object Existential Restiction corresponding to | ||
| 97 | // | ||
| 98 | // ∃ hasSupervisor.Professor | ||
| 99 | // | ||
| 100 | val class_OWLObjectSomeValuesFrom = | ||
| 101 | new OWLObjectSomeValuesFromImpl( | ||
| 102 | new OWLObjectPropertyImpl(iri_hasSupervisor), | ||
| 103 | class_Professor | ||
| 104 | ) | ||
| 105 | // Object Max Cardinality Restriction corresponding to | ||
| 106 | // | ||
| 107 | // ≤ 1 hasSupervisor . Professor | ||
| 108 | val class_OWLObjectMaxCardinality = | ||
| 109 | new OWLObjectMaxCardinalityImpl( | ||
| 110 | new OWLObjectPropertyImpl(iri_hasSupervisor), | ||
| 111 | 1, | ||
| 112 | class_Professor | ||
| 113 | ) | ||
| 114 | |||
| 115 | // OWL Axioms | ||
| 116 | // Axiom SubClassOf corresponding to | ||
| 117 | // | ||
| 118 | // Student ∧ Worker -> PartTimeStudent | ||
| 119 | // | ||
| 120 | val axiom_OWLSubClassOf1 = | ||
| 121 | new OWLSubClassOfAxiomImpl( | ||
| 122 | class_OWLObjectIntersectionOf, | ||
| 123 | class_PartTimeStudent, | ||
| 124 | new JList() | ||
| 125 | ) | ||
| 126 | |||
| 127 | // Axiom SubClassOf corresponding to | ||
| 128 | // | ||
| 129 | // Student -> ∃ hasSupervisor.Professor | ||
| 130 | // | ||
| 131 | val axiom_OWLSubClassOf2 = | ||
| 132 | new OWLSubClassOfAxiomImpl( | ||
| 133 | class_Student, | ||
| 134 | class_OWLObjectSomeValuesFrom, | ||
| 135 | new JList() | ||
| 136 | ) | ||
| 137 | |||
| 138 | // Axiom SubClassOf corresponding to | ||
| 139 | // | ||
| 140 | // ∃ hasSupervisor.Professor -> Student | ||
| 141 | // | ||
| 142 | val axiom_OWLSubClassOf3 = | ||
| 143 | new OWLSubClassOfAxiomImpl( | ||
| 144 | class_OWLObjectSomeValuesFrom, | ||
| 145 | class_Student, | ||
| 146 | new JList() | ||
| 147 | ) | ||
| 148 | |||
| 149 | // Axiom SubClassOf corresponding to | ||
| 150 | // | ||
| 151 | // Student -> { alice } | ||
| 152 | // | ||
| 153 | val axiom_OWLSubClassOf4 = | ||
| 154 | new OWLSubClassOfAxiomImpl( | ||
| 155 | class_Student, | ||
| 156 | class_OWLObjectOneOf, | ||
| 157 | new JList() | ||
| 158 | ) | ||
| 159 | |||
| 160 | // Axiom SubClassOf corresponding to | ||
| 161 | // | ||
| 162 | // Student -> ≤1 hasSupervisor.Professor | ||
| 163 | // | ||
| 164 | val axiom_OWLSubClassOf5 = | ||
| 165 | new OWLSubClassOfAxiomImpl( | ||
| 166 | class_Student, | ||
| 167 | class_OWLObjectMaxCardinality, | ||
| 168 | new JList() | ||
| 169 | ) | ||
| 170 | |||
| 171 | def convertAxiom( | ||
| 172 | axiom: OWLAxiom, | ||
| 173 | term: Term, | ||
| 174 | skolem: SkolemStrategy = SkolemStrategy.None | ||
| 175 | ): List[Rule] = { | ||
| 176 | axiom.accept(RDFoxAxiomConverter(term, List())) | ||
| 177 | } | ||
| 178 | |||
| 179 | } // object OWLAxiomSpec | ||
| 180 | |||
| 181 | class OWLAxiomSpec extends AnyFlatSpec with Matchers with LoneElement { | ||
| 182 | |||
| 183 | // Import required data | ||
| 184 | import OWLAxiomSpec._ | ||
| 185 | // Implicit convertion from IRI in OWLAPI to IRI in JRDFox | ||
| 186 | import rsacomb.implicits.RDFox._ | ||
| 187 | |||
| 188 | // OWLSubClassOfAxiom #1 | ||
| 189 | axiom_OWLSubClassOf1.toString should "be converted into a singleton List[Rule]" in { | ||
| 190 | val result = convertAxiom(axiom_OWLSubClassOf1, term_x) | ||
| 191 | result.loneElement shouldBe a[Rule] | ||
| 192 | } | ||
| 193 | |||
| 194 | it should "contain a conjuction of atoms (Student[?x],Worker[?x]) in the body of the rule" in { | ||
| 195 | val result = convertAxiom(axiom_OWLSubClassOf1, term_x) | ||
| 196 | val body = List( | ||
| 197 | TupleTableAtom.rdf(term_x, RDFIRI.RDF_TYPE, iri_Student), | ||
| 198 | TupleTableAtom.rdf(term_x, RDFIRI.RDF_TYPE, iri_Worker) | ||
| 199 | ) | ||
| 200 | result.loneElement.getBody should contain theSameElementsAs body | ||
| 201 | } | ||
| 202 | |||
| 203 | it should "contain a single atom (PartTimeStudent[?x]) in the head of the rule" in { | ||
| 204 | val result = convertAxiom(axiom_OWLSubClassOf1, term_x) | ||
| 205 | val head = TupleTableAtom.rdf(term_x, RDFIRI.RDF_TYPE, iri_PartTimeStudent) | ||
| 206 | result.loneElement.getHead.loneElement should be(head) | ||
| 207 | } | ||
| 208 | |||
| 209 | // OWLSubClassOfAxiom #2 (w/ constant skolemization) | ||
| 210 | (axiom_OWLSubClassOf2.toString + "\n(w/ constant skolemization)") should | ||
| 211 | "be converted into a singleton List[Rule]" in { | ||
| 212 | val skolem = SkolemStrategy.Constant(axiom_OWLSubClassOf2.toString) | ||
| 213 | val result = convertAxiom(axiom_OWLSubClassOf2, term_x, skolem) | ||
| 214 | result.loneElement shouldBe a[Rule] | ||
| 215 | } | ||
| 216 | |||
| 217 | it should "contain a single atom (Student[?x]) in the body of the rule" in { | ||
| 218 | val skolem = SkolemStrategy.Constant(axiom_OWLSubClassOf2.toString) | ||
| 219 | val result = convertAxiom(axiom_OWLSubClassOf2, term_x, skolem) | ||
| 220 | val body = | ||
| 221 | TupleTableAtom.rdf(term_x, RDFIRI.RDF_TYPE, iri_Student.getIRIString) | ||
| 222 | result.loneElement.getBody.loneElement should equal(body) | ||
| 223 | } | ||
| 224 | |||
| 225 | // it should "contain a conjuction of atoms (hasSupervisor[?x,?c],Professor[?c]) in the head of the rule" in { | ||
| 226 | // val skolem = SkolemStrategy.Constant(axiom_OWLSubClassOf2.toString) | ||
| 227 | // val result = convertAxiom(axiom_OWLSubClassOf2, term_x, skolem) | ||
| 228 | // val term_c = RSA.rsa(skolem.const.getIRI) | ||
| 229 | // val head = List( | ||
| 230 | // TupleTableAtom.rdf(term_x, iri_hasSupervisor, term_c), | ||
| 231 | // TupleTableAtom.rdf(term_c, RDFIRI.RDF_TYPE, iri_Professor) | ||
| 232 | // ) | ||
| 233 | // result.loneElement.getHead should contain theSameElementsAs (head) | ||
| 234 | // } | ||
| 235 | |||
| 236 | // OWLSubClassOfAxiom #2 (w/ skolemization) | ||
| 237 | (axiom_OWLSubClassOf2.toString + "\n(w/ skolemization)") should | ||
| 238 | "be converted into a singleton List[Rule]" in { | ||
| 239 | val skolem = SkolemStrategy.Standard(axiom_OWLSubClassOf2.toString) | ||
| 240 | val result = convertAxiom(axiom_OWLSubClassOf2, term_x, skolem) | ||
| 241 | result.loneElement shouldBe a[Rule] | ||
| 242 | } | ||
| 243 | |||
| 244 | it should "contain an atom (Student[?x]) in the body of the rule" in { | ||
| 245 | val skolem = SkolemStrategy.Standard(axiom_OWLSubClassOf2.toString) | ||
| 246 | val result = convertAxiom(axiom_OWLSubClassOf2, term_x, skolem) | ||
| 247 | val body = | ||
| 248 | TupleTableAtom.rdf(term_x, RDFIRI.RDF_TYPE, iri_Student) | ||
| 249 | result.loneElement.getBody should contain(body) | ||
| 250 | } | ||
| 251 | |||
| 252 | // it should "contain a built-in function call (BIND(?y,SKOLEM(?f,?x))) in the body of the rule" in { | ||
| 253 | // val skolem = SkolemStrategy.Standard(axiom_OWLSubClassOf2.toString) | ||
| 254 | // val result = convertAxiom(axiom_OWLSubClassOf2, term_x, skolem) | ||
| 255 | // val call = | ||
| 256 | // BindAtom.create(BuiltinFunctionCall.create("SKOLEM", term_x), term_y) | ||
| 257 | // result.loneElement.getBody should contain(call) | ||
| 258 | // } | ||
| 259 | |||
| 260 | // it should "contain a conjuction of atom (hasSupervisor[?x,?y],Professor[?y]) in the head of the rule" in { | ||
| 261 | // val skolem = SkolemStrategy.Standard(axiom_OWLSubClassOf2.toString) | ||
| 262 | // val result = convertAxiom(axiom_OWLSubClassOf2, term_x, skolem) | ||
| 263 | // val head = List( | ||
| 264 | // TupleTableAtom.rdf(term_x, iri_hasSupervisor, term_y), | ||
| 265 | // TupleTableAtom.rdf(term_y, RDFIRI.RDF_TYPE, iri_Professor) | ||
| 266 | // ) | ||
| 267 | // result.loneElement.getHead should contain theSameElementsAs head | ||
| 268 | // } | ||
| 269 | |||
| 270 | // OWLSubClassOfAxiom #3 | ||
| 271 | axiom_OWLSubClassOf3.toString should "be converted into a singleton List[Rule]" in { | ||
| 272 | val result = convertAxiom(axiom_OWLSubClassOf3, term_x) | ||
| 273 | result.loneElement shouldBe a[Rule] | ||
| 274 | } | ||
| 275 | |||
| 276 | // it should "contain a conjunction of atoms (hasSupervisor[?x,?y],Professor[?y]) in the body of the rule" in { | ||
| 277 | // val result = convertAxiom(axiom_OWLSubClassOf3, term_x) | ||
| 278 | // val body = List( | ||
| 279 | // TupleTableAtom.rdf(term_x, iri_hasSupervisor, term_y), | ||
| 280 | // TupleTableAtom.rdf(term_y, RDFIRI.RDF_TYPE, iri_Professor) | ||
| 281 | // ) | ||
| 282 | // result.loneElement.getBody should contain theSameElementsAs body | ||
| 283 | // } | ||
| 284 | |||
| 285 | it should "contain a single atom (Student[?x]) in the head of the rule" in { | ||
| 286 | val result = convertAxiom(axiom_OWLSubClassOf3, term_x) | ||
| 287 | val head = | ||
| 288 | TupleTableAtom.rdf(term_x, RDFIRI.RDF_TYPE, iri_Student) | ||
| 289 | result.loneElement.getHead.loneElement should be(head) | ||
| 290 | } | ||
| 291 | |||
| 292 | // OWLSubClassOfAxiom #4 | ||
| 293 | axiom_OWLSubClassOf4.toString should "be converted into a singleton List[Rule]" in { | ||
| 294 | val result = convertAxiom(axiom_OWLSubClassOf4, term_x) | ||
| 295 | result.loneElement shouldBe a[Rule] | ||
| 296 | } | ||
| 297 | |||
| 298 | it should "contain a single atoms (Student[?x]) in the body of the rule" in { | ||
| 299 | val result = convertAxiom(axiom_OWLSubClassOf4, term_x) | ||
| 300 | val body = | ||
| 301 | TupleTableAtom.rdf(term_x, RDFIRI.RDF_TYPE, iri_Student) | ||
| 302 | result.loneElement.getBody.loneElement should be(body) | ||
| 303 | } | ||
| 304 | |||
| 305 | it should "contain a single atom (sameAs[?x,alice])) in the head of the rule" in { | ||
| 306 | val result = convertAxiom(axiom_OWLSubClassOf4, term_x) | ||
| 307 | val head = TupleTableAtom.rdf(term_x, RDFIRI.SAME_AS, term_alice) | ||
| 308 | result.loneElement.getHead.loneElement should be(head) | ||
| 309 | } | ||
| 310 | |||
| 311 | // OWLSubClassOfAxiom #5 | ||
| 312 | axiom_OWLSubClassOf5.toString should "be converted into a singleton List[Rule]" in { | ||
| 313 | val result = convertAxiom(axiom_OWLSubClassOf5, term_x) | ||
| 314 | result.loneElement shouldBe a[Rule] | ||
| 315 | } | ||
| 316 | |||
| 317 | // it should "contain a conjunction of atoms (...) in the body of the rule" in { | ||
| 318 | // val result = convertAxiom(axiom_OWLSubClassOf5, term_x) | ||
| 319 | // val body = List( | ||
| 320 | // TupleTableAtom.rdf(term_x, RDFIRI.RDF_TYPE, iri_Student), | ||
| 321 | // TupleTableAtom.rdf(term_x, iri_hasSupervisor, term_y), | ||
| 322 | // TupleTableAtom.rdf(term_y, RDFIRI.RDF_TYPE, iri_Professor), | ||
| 323 | // TupleTableAtom.rdf(term_x, iri_hasSupervisor, term_z), | ||
| 324 | // TupleTableAtom.rdf(term_z, RDFIRI.RDF_TYPE, iri_Professor) | ||
| 325 | // ) | ||
| 326 | // result.loneElement.getBody should contain theSameElementsAs body | ||
| 327 | // } | ||
| 328 | |||
| 329 | // it should "contain a single atom (sameAs[?x,?z])) in the head of the rule" in { | ||
| 330 | // val result = convertAxiom(axiom_OWLSubClassOf5, term_x) | ||
| 331 | // val head = TupleTableAtom.rdf(term_y, RDFIRI.SAME_AS, term_z) | ||
| 332 | // result.loneElement.getHead.loneElement should be(head) | ||
| 333 | // } | ||
| 334 | |||
| 335 | } // class OWLAxiomSpec | ||
diff --git a/src/test/scala/rsacomb/OWLClassSpec.scala b/src/test/scala/rsacomb/OWLClassSpec.scala deleted file mode 100644 index 27e0872..0000000 --- a/src/test/scala/rsacomb/OWLClassSpec.scala +++ /dev/null | |||
| @@ -1,273 +0,0 @@ | |||
| 1 | package rsacomb | ||
| 2 | |||
| 3 | import java.util.{ArrayList => JList} | ||
| 4 | |||
| 5 | import org.scalatest.LoneElement | ||
| 6 | import org.scalatest.flatspec.AnyFlatSpec | ||
| 7 | import org.scalatest.matchers.should.Matchers | ||
| 8 | |||
| 9 | import org.semanticweb.owlapi.model.OWLClassExpression | ||
| 10 | import uk.ac.manchester.cs.owl.owlapi.{ | ||
| 11 | OWLClassImpl, | ||
| 12 | OWLObjectSomeValuesFromImpl, | ||
| 13 | OWLObjectIntersectionOfImpl, | ||
| 14 | OWLObjectOneOfImpl, | ||
| 15 | OWLObjectAllValuesFromImpl, | ||
| 16 | OWLObjectMaxCardinalityImpl, | ||
| 17 | OWLNamedIndividualImpl | ||
| 18 | } | ||
| 19 | import uk.ac.manchester.cs.owl.owlapi.{OWLObjectPropertyImpl} | ||
| 20 | import org.semanticweb.owlapi.model.IRI | ||
| 21 | import tech.oxfordsemantic.jrdfox.logic.expression.{IRI => RDFIRI} | ||
| 22 | |||
| 23 | import tech.oxfordsemantic.jrdfox.logic.Datatype | ||
| 24 | import tech.oxfordsemantic.jrdfox.logic.datalog.{ | ||
| 25 | TupleTableAtom, | ||
| 26 | TupleTableName, | ||
| 27 | BindAtom | ||
| 28 | } | ||
| 29 | import tech.oxfordsemantic.jrdfox.logic.expression.{ | ||
| 30 | FunctionCall, | ||
| 31 | Term, | ||
| 32 | Variable, | ||
| 33 | Literal | ||
| 34 | } | ||
| 35 | |||
| 36 | import rsacomb.RDFoxRuleShards | ||
| 37 | import rsacomb.util.RSA | ||
| 38 | |||
| 39 | object OWLClassSpec { | ||
| 40 | |||
| 41 | // IRI | ||
| 42 | val iri_Professor = IRI.create("univ:Professor") | ||
| 43 | val iri_Female = IRI.create("std:Female") | ||
| 44 | val iri_Student = IRI.create("univ:Student") | ||
| 45 | val iri_Worker = IRI.create("univ:Worker") | ||
| 46 | val iri_alice = IRI.create("univ:alice") | ||
| 47 | val iri_supervises = IRI.create("univ:supervises") | ||
| 48 | val iri_hasSupervisor = IRI.create("univ:hasSupervisor") | ||
| 49 | |||
| 50 | // RDFox Terms | ||
| 51 | val term_x = Variable.create("x") | ||
| 52 | val term_y = Variable.create("y") | ||
| 53 | val term_c1 = RSA("c_1") | ||
| 54 | val term_c2 = RSA("c_2") | ||
| 55 | val term_alice = RDFIRI.create("univ:alice") | ||
| 56 | |||
| 57 | // RDFox Predicates | ||
| 58 | val pred_sameAs = TupleTableName.create("owl:sameAs") | ||
| 59 | val pred_Professor = TupleTableName.create(iri_Professor.getIRIString) | ||
| 60 | val pred_hasSupervisor = TupleTableName.create(iri_hasSupervisor.getIRIString) | ||
| 61 | |||
| 62 | // OWL Classes | ||
| 63 | // Name Class corresponding to | ||
| 64 | // | ||
| 65 | // Professor | ||
| 66 | // | ||
| 67 | val class_Professor = new OWLClassImpl(iri_Professor) | ||
| 68 | val class_Female = new OWLClassImpl(iri_Female) | ||
| 69 | val class_Student = new OWLClassImpl(iri_Student) | ||
| 70 | val class_Worker = new OWLClassImpl(iri_Worker) | ||
| 71 | val class_OWLClass = class_Professor | ||
| 72 | |||
| 73 | // Class Conjunction corresponding to | ||
| 74 | // | ||
| 75 | // Female ∧ Student ∧ Worker | ||
| 76 | // | ||
| 77 | val class_OWLObjectIntersectionOf = { | ||
| 78 | val conjuncts = new JList[OWLClassExpression]() | ||
| 79 | conjuncts.add(class_Female) | ||
| 80 | conjuncts.add(class_Student) | ||
| 81 | conjuncts.add(class_Worker) | ||
| 82 | new OWLObjectIntersectionOfImpl(conjuncts) | ||
| 83 | } | ||
| 84 | // Singleton Class corresponding to | ||
| 85 | // | ||
| 86 | // { alice } | ||
| 87 | // | ||
| 88 | val class_OWLObjectOneOf = | ||
| 89 | new OWLObjectOneOfImpl( | ||
| 90 | new OWLNamedIndividualImpl(iri_alice) | ||
| 91 | ) | ||
| 92 | // Object Existential Restiction corresponding to | ||
| 93 | // | ||
| 94 | // ∃ hasSupervisor.Professor | ||
| 95 | // | ||
| 96 | val class_OWLObjectSomeValuesFrom = | ||
| 97 | new OWLObjectSomeValuesFromImpl( | ||
| 98 | new OWLObjectPropertyImpl(iri_hasSupervisor), | ||
| 99 | class_Professor | ||
| 100 | ) | ||
| 101 | // Object Max Cardinality Restriction corresponding to | ||
| 102 | // | ||
| 103 | // ≤1 hasSupervisor.Professor | ||
| 104 | val class_OWLObjectMaxCardinality = | ||
| 105 | new OWLObjectMaxCardinalityImpl( | ||
| 106 | new OWLObjectPropertyImpl(iri_hasSupervisor), | ||
| 107 | 1, | ||
| 108 | class_Professor | ||
| 109 | ) | ||
| 110 | } // object OWLClassSpec | ||
| 111 | |||
| 112 | class OWLClassSpec extends AnyFlatSpec with Matchers with LoneElement { | ||
| 113 | // Import required data | ||
| 114 | import OWLClassSpec._ | ||
| 115 | |||
| 116 | // OWLClass | ||
| 117 | class_OWLClass.toString should "be converted into a RDFoxRuleShards" in { | ||
| 118 | val visitor = RDFoxClassExprConverter(term_x) | ||
| 119 | val result = class_OWLClass.accept(visitor) | ||
| 120 | result shouldBe a[RDFoxRuleShards] | ||
| 121 | } | ||
| 122 | |||
| 123 | it should "have a single TupleTableAtom in its result list" in { | ||
| 124 | val visitor = RDFoxClassExprConverter(term_x) | ||
| 125 | val result = class_OWLClass.accept(visitor) | ||
| 126 | result.res.loneElement shouldBe an[TupleTableAtom] | ||
| 127 | } | ||
| 128 | |||
| 129 | it should "have an empty extension list" in { | ||
| 130 | val visitor = RDFoxClassExprConverter(term_x) | ||
| 131 | val result = class_OWLClass.accept(visitor) | ||
| 132 | result.ext shouldBe empty | ||
| 133 | } | ||
| 134 | |||
| 135 | // OWLObjectIntersectionOf | ||
| 136 | class_OWLObjectIntersectionOf.toString should "be converted into a RDFoxRuleShards" in { | ||
| 137 | val visitor = RDFoxClassExprConverter(term_x) | ||
| 138 | val result = class_OWLObjectIntersectionOf.accept(visitor) | ||
| 139 | result shouldBe a[RDFoxRuleShards] | ||
| 140 | } | ||
| 141 | |||
| 142 | it should "be converted in the union of its converted conjuncts" in { | ||
| 143 | val visitor = RDFoxClassExprConverter(term_x) | ||
| 144 | val result1 = class_OWLObjectIntersectionOf.accept(visitor) | ||
| 145 | val result2 = RDFoxClassExprConverter.merge( | ||
| 146 | List( | ||
| 147 | class_Female.accept(visitor), | ||
| 148 | class_Student.accept(visitor), | ||
| 149 | class_Worker.accept(visitor) | ||
| 150 | ) | ||
| 151 | ) | ||
| 152 | result1.res should contain theSameElementsAs result2.res | ||
| 153 | result1.ext should contain theSameElementsAs result2.ext | ||
| 154 | } | ||
| 155 | |||
| 156 | // OWLObjectOneOf | ||
| 157 | class_OWLObjectOneOf.toString should "be converted into a RDFoxRuleShards" in { | ||
| 158 | val visitor = RDFoxClassExprConverter(term_x) | ||
| 159 | val result = class_OWLObjectOneOf.accept(visitor) | ||
| 160 | result shouldBe a[RDFoxRuleShards] | ||
| 161 | } | ||
| 162 | |||
| 163 | // it should "be converted into a single <owl:sameAs> TupleTableAtom" in { | ||
| 164 | // val visitor = RDFoxClassExprConverter(term_x) | ||
| 165 | // val result = class_OWLObjectOneOf.accept(visitor) | ||
| 166 | // result.res.loneElement should (be (a [TupleTableAtom]) and have ('tupleTableName (pred_sameAs))) | ||
| 167 | // } | ||
| 168 | |||
| 169 | it should "have an empty extension list" in { | ||
| 170 | val visitor = RDFoxClassExprConverter(term_x) | ||
| 171 | val result = class_OWLObjectOneOf.accept(visitor) | ||
| 172 | result.ext shouldBe empty | ||
| 173 | } | ||
| 174 | |||
| 175 | // OWLObjectSomeValuesFrom | ||
| 176 | (class_OWLObjectSomeValuesFrom.toString ++ " w/o skolemization") should | ||
| 177 | "be converted into a RDFoxRuleShards" in { | ||
| 178 | val visitor = RDFoxClassExprConverter(term_x) | ||
| 179 | val result = class_OWLObjectSomeValuesFrom.accept(visitor) | ||
| 180 | result shouldBe a[RDFoxRuleShards] | ||
| 181 | } | ||
| 182 | |||
| 183 | it should "have two TupleTableAtoms in its result list" in { | ||
| 184 | val visitor = RDFoxClassExprConverter(term_x) | ||
| 185 | val result = class_OWLObjectSomeValuesFrom.accept(visitor) | ||
| 186 | exactly(2, result.res) should (be(an[TupleTableAtom]) | ||
| 187 | //and have('numberOfArguments (3)) | ||
| 188 | ) | ||
| 189 | } | ||
| 190 | |||
| 191 | it should "have an empty extension list" in { | ||
| 192 | val visitor = RDFoxClassExprConverter(term_x) | ||
| 193 | val result = class_OWLObjectSomeValuesFrom.accept(visitor) | ||
| 194 | result.ext shouldBe empty | ||
| 195 | } | ||
| 196 | |||
| 197 | (class_OWLObjectSomeValuesFrom.toString ++ " w/ skolemization") should | ||
| 198 | "be converted into a RDFoxRuleShards" in { | ||
| 199 | val skolem = SkolemStrategy.Standard(class_OWLObjectSomeValuesFrom.toString) | ||
| 200 | val visitor = RDFoxClassExprConverter(term_x, List(), skolem) | ||
| 201 | val result = class_OWLObjectSomeValuesFrom.accept(visitor) | ||
| 202 | result shouldBe a[RDFoxRuleShards] | ||
| 203 | } | ||
| 204 | |||
| 205 | it should "have exactly two TupleTableAtoms in its result list" in { | ||
| 206 | val skolem = SkolemStrategy.Standard(class_OWLObjectSomeValuesFrom.toString) | ||
| 207 | val visitor = RDFoxClassExprConverter(term_x, List(), skolem) | ||
| 208 | val result = class_OWLObjectSomeValuesFrom.accept(visitor) | ||
| 209 | exactly(2, result.res) should (be(an[TupleTableAtom]) | ||
| 210 | //and have('numberOfArguments (3)) | ||
| 211 | ) | ||
| 212 | } | ||
| 213 | |||
| 214 | it should "should have a single SKOLEM call in the extension list" in { | ||
| 215 | val skolem = SkolemStrategy.Standard(class_OWLObjectSomeValuesFrom.toString) | ||
| 216 | val visitor = RDFoxClassExprConverter(term_x, List(), skolem) | ||
| 217 | val result = class_OWLObjectSomeValuesFrom.accept(visitor) | ||
| 218 | result.ext.loneElement shouldBe a[BindAtom] | ||
| 219 | val builtin = result.ext.head.asInstanceOf[BindAtom].getExpression | ||
| 220 | builtin should (be(a[FunctionCall]) and have( | ||
| 221 | 'functionName ("SKOLEM") | ||
| 222 | )) | ||
| 223 | } | ||
| 224 | |||
| 225 | (class_OWLObjectSomeValuesFrom.toString ++ " w/ constant skolemization") should | ||
| 226 | "be converted into a RDFoxRuleShards" in { | ||
| 227 | val skolem = SkolemStrategy.Constant(class_OWLObjectSomeValuesFrom.toString) | ||
| 228 | val visitor = RDFoxClassExprConverter(term_x, List(), skolem) | ||
| 229 | val result = class_OWLObjectSomeValuesFrom.accept(visitor) | ||
| 230 | result shouldBe a[RDFoxRuleShards] | ||
| 231 | } | ||
| 232 | |||
| 233 | it should "have exactly two TupleTableAtoms in its result list" in { | ||
| 234 | val skolem = SkolemStrategy.Constant(class_OWLObjectSomeValuesFrom.toString) | ||
| 235 | val visitor = RDFoxClassExprConverter(term_x, List(), skolem) | ||
| 236 | val result = class_OWLObjectSomeValuesFrom.accept(visitor) | ||
| 237 | exactly(2, result.res) should (be(an[TupleTableAtom]) | ||
| 238 | //and have('numberOfArguments (3)) | ||
| 239 | ) | ||
| 240 | } | ||
| 241 | |||
| 242 | it should "have an empty extension list" in { | ||
| 243 | val skolem = SkolemStrategy.Constant(class_OWLObjectSomeValuesFrom.toString) | ||
| 244 | val visitor = RDFoxClassExprConverter(term_x, List(), skolem) | ||
| 245 | val result = class_OWLObjectSomeValuesFrom.accept(visitor) | ||
| 246 | result.ext shouldBe empty | ||
| 247 | } | ||
| 248 | |||
| 249 | // OWLObjectMaxCardinalityImpl | ||
| 250 | class_OWLObjectMaxCardinality.toString should | ||
| 251 | "be converted into a RDFoxRuleShards" in { | ||
| 252 | val visitor = RDFoxClassExprConverter(term_x) | ||
| 253 | val result = class_OWLObjectMaxCardinality.accept(visitor) | ||
| 254 | result shouldBe a[RDFoxRuleShards] | ||
| 255 | } | ||
| 256 | |||
| 257 | // it should "have a single <owl:sameAs> TupleTableAtom in the result list" in { | ||
| 258 | // val visitor = RDFoxClassExprConverter(term_x) | ||
| 259 | // val result = class_OWLObjectMaxCardinality.accept(visitor) | ||
| 260 | // result.res.loneElement should (be(an[TupleTableAtom]) and have( | ||
| 261 | // 'tupleTableName (pred_sameAs) | ||
| 262 | // )) | ||
| 263 | // } | ||
| 264 | |||
| 265 | it should "have 4 TupleTableAtoms in its extension list" in { | ||
| 266 | val visitor = RDFoxClassExprConverter(term_x) | ||
| 267 | val result = class_OWLObjectMaxCardinality.accept(visitor) | ||
| 268 | exactly(4, result.ext) should (be(an[TupleTableAtom]) | ||
| 269 | //and have('numberOfArguments (3)) | ||
| 270 | ) | ||
| 271 | } | ||
| 272 | |||
| 273 | } // class OWLClassSpec | ||
