aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/scala/uk/ac/ox/cs/rsacomb/sparql/ConjunctiveQueryAnswers.scala9
-rw-r--r--src/test/scala/uk/ac/ox/cs/rsacomb/sparql/ConjunctiveQueryAnswerSpecs.scala4
2 files changed, 9 insertions, 4 deletions
diff --git a/src/main/scala/uk/ac/ox/cs/rsacomb/sparql/ConjunctiveQueryAnswers.scala b/src/main/scala/uk/ac/ox/cs/rsacomb/sparql/ConjunctiveQueryAnswers.scala
index 0f830eb..327ae8e 100644
--- a/src/main/scala/uk/ac/ox/cs/rsacomb/sparql/ConjunctiveQueryAnswers.scala
+++ b/src/main/scala/uk/ac/ox/cs/rsacomb/sparql/ConjunctiveQueryAnswers.scala
@@ -1,6 +1,6 @@
1package uk.ac.ox.cs.rsacomb.sparql 1package uk.ac.ox.cs.rsacomb.sparql
2 2
3import tech.oxfordsemantic.jrdfox.logic.expression.{Resource, Variable} 3import tech.oxfordsemantic.jrdfox.logic.expression.{IRI, Resource, Variable}
4 4
5/** A collections of answers to a query. 5/** A collections of answers to a query.
6 * 6 *
@@ -25,7 +25,12 @@ class ConjunctiveQueryAnswers(
25 "NO ANSWER." 25 "NO ANSWER."
26 else { 26 else {
27 val header = variables map (_.getName) mkString "\t" 27 val header = variables map (_.getName) mkString "\t"
28 val body = answers.map(_.mkString("\t")).mkString("\n") 28 val body = answers
29 .map(_.map {
30 case x: IRI => x.getIRI
31 case x => x.toString
32 }.mkString("\t"))
33 .mkString("\n")
29 s"$header\n$body" 34 s"$header\n$body"
30 } 35 }
31 } 36 }
diff --git a/src/test/scala/uk/ac/ox/cs/rsacomb/sparql/ConjunctiveQueryAnswerSpecs.scala b/src/test/scala/uk/ac/ox/cs/rsacomb/sparql/ConjunctiveQueryAnswerSpecs.scala
index ddc6377..b2319bc 100644
--- a/src/test/scala/uk/ac/ox/cs/rsacomb/sparql/ConjunctiveQueryAnswerSpecs.scala
+++ b/src/test/scala/uk/ac/ox/cs/rsacomb/sparql/ConjunctiveQueryAnswerSpecs.scala
@@ -43,11 +43,11 @@ class ConjunctiveQueryAnswerSpec extends AnyFlatSpec with Matchers {
43 import ConjunctiveQueryAnswerSpec._ 43 import ConjunctiveQueryAnswerSpec._
44 44
45 "A conjunctive query" should "print an header and a single line if it has a single answer" in { 45 "A conjunctive query" should "print an header and a single line if it has a single answer" in {
46 oneAnswer.toString shouldBe s"X\tY\tZ\n$iri1\t$iri2\t$iri3" 46 oneAnswer.toString shouldBe s"X\tY\tZ\n${iri1.getIRI}\t${iri2.getIRI}\t${iri3.getIRI}"
47 } 47 }
48 48
49 it should "print a header and multiple answers on multiple lines" in { 49 it should "print a header and multiple answers on multiple lines" in {
50 multipleAnswers.toString shouldBe s"Y\tZ\n$iri1\t$iri1\n$iri1\t$iri2\n$iri1\t$iri3" 50 multipleAnswers.toString shouldBe s"Y\tZ\n${iri1.getIRI}\t${iri1.getIRI}\n${iri1.getIRI}\t${iri2.getIRI}\n${iri1.getIRI}\t${iri3.getIRI}"
51 } 51 }
52 52
53 it should "print a special \"NO ANSWER.\" string when it has no answer" in { 53 it should "print a special \"NO ANSWER.\" string when it has no answer" in {