diff options
author | Federico Igne <git@federicoigne.com> | 2021-10-03 13:48:29 +0100 |
---|---|---|
committer | Federico Igne <git@federicoigne.com> | 2021-10-03 13:48:29 +0100 |
commit | 7a73dcd98f3a7824572d098889634662a47d6e7c (patch) | |
tree | 3c9c013697ac10f8680ba8f85ce8dc7379ac41aa /src/test | |
parent | 0cd63c26fdfafaf09734950add28f63d500ac330 (diff) | |
download | RSAComb-7a73dcd98f3a7824572d098889634662a47d6e7c.tar.gz RSAComb-7a73dcd98f3a7824572d098889634662a47d6e7c.zip |
Introduce functional tests
These tests will check correctness of the overall system across
versions. We should add more tests for know ontologies.
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/scala/uk/ac/ox/cs/rsacomb/functional/Functional.scala | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/test/scala/uk/ac/ox/cs/rsacomb/functional/Functional.scala b/src/test/scala/uk/ac/ox/cs/rsacomb/functional/Functional.scala new file mode 100644 index 0000000..6882997 --- /dev/null +++ b/src/test/scala/uk/ac/ox/cs/rsacomb/functional/Functional.scala | |||
@@ -0,0 +1,49 @@ | |||
1 | package uk.ac.ox.cs.rsacomb.functional | ||
2 | |||
3 | import org.scalatest.funspec.AnyFunSpec | ||
4 | import org.scalatest.matchers.should.Matchers | ||
5 | |||
6 | import uk.ac.ox.cs.rsacomb.ontology.Ontology | ||
7 | import uk.ac.ox.cs.rsacomb.approximation.Upperbound | ||
8 | import uk.ac.ox.cs.rsacomb.converter.Normalizer | ||
9 | import uk.ac.ox.cs.rsacomb.util.RDFoxUtil | ||
10 | |||
11 | class LUBM extends AnyFunSpec with Matchers { | ||
12 | |||
13 | private val test = os.pwd / "tests" / "lubm" | ||
14 | |||
15 | /* Approximation algorithms */ | ||
16 | //private val toLowerbound = new Lowerbound | ||
17 | private val toUpperbound = new Upperbound | ||
18 | |||
19 | /* Normalization algorithms */ | ||
20 | private val normalizer = new Normalizer | ||
21 | |||
22 | /* Ontology */ | ||
23 | private val ontology = Ontology( | ||
24 | test / "univ-bench.owl", | ||
25 | List(test / "data" / "lubm1.ttl") | ||
26 | ) normalize normalizer | ||
27 | private val rsa = ontology approximate toUpperbound | ||
28 | |||
29 | /* Queries and results */ | ||
30 | private val queries = | ||
31 | RDFoxUtil.loadQueriesFromFile(test / "queries.sparql") | ||
32 | private val results = ujson.read(os.read(test / "results.json")).arr | ||
33 | |||
34 | describe("Ontology size: 1)") { | ||
35 | |||
36 | queries foreach { query => | ||
37 | it(s"Tested Query${query.id}") { | ||
38 | val answers = rsa.ask(query).answers.map(_._2.mkString(" ")) | ||
39 | val reference = results | ||
40 | .find(_("queryID").num == query.id) | ||
41 | .get("answers") | ||
42 | .arr | ||
43 | .map(_.str) | ||
44 | answers should contain theSameElementsAs reference | ||
45 | } | ||
46 | } | ||
47 | |||
48 | } | ||
49 | } | ||