Skip to content

Commit

Permalink
Support Scala 2.13.0-M4.
Browse files Browse the repository at this point in the history
  • Loading branch information
balhoff committed Jun 19, 2018
1 parent b5c76cf commit fe657b6
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 22 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
language: scala
scala:
- "2.12.1"
- "2.13.0-M4"
- "2.12.6"
- "2.11.8"
- "2.10.6"
jdk:
Expand Down
6 changes: 3 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ licenses := Seq("MIT license" -> url("https://opensource.org/licenses/MIT"))

homepage := Some(url("https://github.com/phenoscape/scowl"))

crossScalaVersions := Seq("2.10.6", "2.11.8", "2.12.1")
crossScalaVersions := Seq("2.10.6", "2.11.8", "2.12.6", "2.13.0-M4")

scalacOptions := Seq("-unchecked", "-deprecation", "-feature", "-encoding", "utf8")

Expand All @@ -30,8 +30,8 @@ javaOptions += "-Xmx8G"
libraryDependencies ++= {
Seq(
"net.sourceforge.owlapi" % "owlapi-distribution" % "4.2.7",
"org.scalatest" %% "scalatest" % "3.0.1" % Test,
"org.scalaz" %% "scalaz-core" % "7.2.10" % Test
"org.scalatest" %% "scalatest" % "3.0.6-SNAP1" % Test,
"org.scalaz" %% "scalaz-core" % "7.2.24" % Test
)
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/org/phenoscape/scowl/ofn/SWRL.scala
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ trait SWRL {
}

def unapply(atom: SWRLBuiltInAtom): Option[(IRI, Seq[SWRLDArgument])] = {
Option(atom.getPredicate, atom.getArguments.asScala)
Option((atom.getPredicate, atom.getArguments.asScala.toSeq))
}

}
Expand Down
12 changes: 6 additions & 6 deletions src/test/scala/org/phenoscape/scowl/example/DataChecks.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Scalaz._
import org.semanticweb.owlapi.model.OWLOntology
import org.phenoscape.scowl._
import org.phenoscape.scowl.^^
import scala.collection.JavaConversions._
import scala.collection.JavaConverters._
import org.semanticweb.owlapi.model.AxiomType
import org.semanticweb.owlapi.model.parameters.Imports
import org.semanticweb.owlapi.apibinding.OWLManager
Expand All @@ -25,22 +25,22 @@ class DataChecks extends UnitSpec {
val synonymProperties = Set(HasExactSynonym, HasNarrowSynonym, HasBroadSynonym, HasRelatedSynonym)

"rdfs:label values" should "be used only once per ontology" ignore {
ont.getAxioms(Imports.EXCLUDED)
ont.getAxioms(Imports.EXCLUDED).asScala
.collect { case axiom @ AnnotationAssertion(_, RDFSLabel, _, value ^^ _) => Map(value -> Set(axiom)) }
.reduce(_ |+| _)
.filter { case (label, annotations) => annotations.size > 1 } shouldBe empty
}

"hasExactSynonym values" should "be used only once per ontology" ignore {
ont.getAxioms(Imports.EXCLUDED)
ont.getAxioms(Imports.EXCLUDED).asScala
.collect { case axiom @ AnnotationAssertion(_, HasExactSynonym, _, value ^^ _) => Map(value -> Set(axiom)) }
.reduce(_ |+| _)
.filter { case (label, annotations) => annotations.size > 1 } shouldBe empty
}

// This test is very slow; SPARQL would probably be better (perhaps for many other such tests as well).
"No class" should "have a synonym that matches the label" ignore { //FIXME ignored
val annotations = ont.getAxioms(AxiomType.ANNOTATION_ASSERTION, Imports.EXCLUDED).toSet
val annotations = ont.getAxioms(AxiomType.ANNOTATION_ASSERTION, Imports.EXCLUDED).asScala.toSet
(for {
AnnotationAssertion(_, RDFSLabel, termIRI, label ^^ _) <- annotations
AnnotationAssertion(_, synonymProperty, `termIRI`, `label` ^^ _) <- annotations
Expand All @@ -49,13 +49,13 @@ class DataChecks extends UnitSpec {
}

"Annotation values" should "not contain double spaces" ignore {
ont.getAxioms(Imports.EXCLUDED)
ont.getAxioms(Imports.EXCLUDED).asScala
.collect { case axiom @ AnnotationAssertion(_, _, _, value ^^ _) if value.contains(" ") => axiom } shouldBe empty

}

"Trim" should "not have an effect on annotation values" ignore {
ont.getAxioms(Imports.EXCLUDED)
ont.getAxioms(Imports.EXCLUDED).asScala
.collect { case axiom @ AnnotationAssertion(_, _, _, value ^^ _) if value.trim != value => axiom } shouldBe empty
}

Expand Down
23 changes: 12 additions & 11 deletions src/test/scala/org/phenoscape/scowltest/ScowlTest.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.phenoscape.scowltest

import scala.collection.JavaConversions._
import scala.collection.JavaConverters._
import scala.language.postfixOps

import org.phenoscape.scowl._
Expand All @@ -12,6 +12,7 @@ import org.semanticweb.owlapi.vocab.OWLFacet
import org.semanticweb.owlapi.vocab.SWRLBuiltInsVocabulary
import org.semanticweb.owlapi.vocab.XSDVocabulary
import org.semanticweb.owlapi.search.EntitySearcher
import org.semanticweb.owlapi.model.SWRLDArgument

class ScowlTest extends UnitSpec {

Expand Down Expand Up @@ -43,16 +44,16 @@ class ScowlTest extends UnitSpec {
val Narcissist = Class("http://example.org/Narcissist")
val loves = ObjectProperty("http://example.org/loves")
(Narcissist EquivalentTo (loves Self)) should equal(factory.getOWLEquivalentClassesAxiom(Narcissist, factory.getOWLObjectHasSelf(loves)))
((ind1 Fact (prop1, ind2)) Annotation (RDFSLabel, AnonymousIndividual("urn:anon:1"))) should equal(factory.getOWLObjectPropertyAssertionAxiom(prop1, ind1, ind2, Set(factory.getOWLAnnotation(factory.getRDFSLabel, factory.getOWLAnonymousIndividual("urn:anon:1")))))
((ind1 Fact (prop1, ind2)) Annotation (RDFSLabel, AnonymousIndividual("urn:anon:1"))) should equal(factory.getOWLObjectPropertyAssertionAxiom(prop1, ind1, ind2, Set(factory.getOWLAnnotation(factory.getRDFSLabel, factory.getOWLAnonymousIndividual("urn:anon:1"))).asJava))
(ind1 SameAs ind2) should equal(factory.getOWLSameIndividualAxiom(ind1, ind2))
(ind1 SameAs (ind2, ind3)) should equal(factory.getOWLSameIndividualAxiom(ind1, ind2, ind3))
(ind1 DifferentFrom ind2) should equal(factory.getOWLDifferentIndividualsAxiom(ind1, ind2))
ind1 DifferentFrom (ind2, ind3) should equal(factory.getOWLDifferentIndividualsAxiom(ind1, ind2, ind3))
}

"Scowl property chains" should "equal standard API" in {
(prop4 SubPropertyChain (prop1 o prop2)) should equal(factory.getOWLSubPropertyChainOfAxiom(List(prop1, prop2), prop4))
(prop4 SubPropertyChain (prop1 o prop2 o prop3)) should equal(factory.getOWLSubPropertyChainOfAxiom(List(prop1, prop2, prop3), prop4))
(prop4 SubPropertyChain (prop1 o prop2)) should equal(factory.getOWLSubPropertyChainOfAxiom(List(prop1, prop2).asJava, prop4))
(prop4 SubPropertyChain (prop1 o prop2 o prop3)) should equal(factory.getOWLSubPropertyChainOfAxiom(List(prop1, prop2, prop3).asJava, prop4))
}

"Scowl data properties and literals" should "equal standard API" in {
Expand Down Expand Up @@ -89,9 +90,9 @@ class ScowlTest extends UnitSpec {
} yield lang -> value
langValuePairs should equal(Set("en" -> "cat", "fr" -> "chat"))

val ont = OWLManager.createOWLOntologyManager().createOntology(Set[OWLAxiom](class1 Annotation (RDFSLabel, "cat" @@ "en")))
val ont = OWLManager.createOWLOntologyManager().createOntology(Set[OWLAxiom](class1 Annotation (RDFSLabel, "cat" @@ "en")).asJava)
val values = for {
Annotation(_, _, value @@ _) <- EntitySearcher.getAnnotations(class1, ont)
Annotation(_, _, value @@ _) <- EntitySearcher.getAnnotations(class1, ont).asScala
} yield value
values.toSet should equal(Set("cat"))
}
Expand All @@ -101,11 +102,11 @@ class ScowlTest extends UnitSpec {
factory.getSWRLRule(
Set(
factory.getSWRLClassAtom(class1, factory.getSWRLVariable(IRI.create("urn:swrl#x"))),
factory.getSWRLClassAtom(class1, factory.getSWRLVariable(IRI.create("urn:swrl#y")))),
factory.getSWRLClassAtom(class1, factory.getSWRLVariable(IRI.create("urn:swrl#y")))).asJava,
Set(
factory.getSWRLClassAtom(class2, factory.getSWRLVariable(IRI.create("urn:swrl#x")))),
factory.getSWRLClassAtom(class2, factory.getSWRLVariable(IRI.create("urn:swrl#x")))).asJava,
Set(
factory.getOWLAnnotation(factory.getRDFSLabel, factory.getOWLLiteral("X and Y rule")))))
factory.getOWLAnnotation(factory.getRDFSLabel, factory.getOWLLiteral("X and Y rule"))).asJava))
(prop1(ind1, 'x) ^ class1('x) ^ class2(ind1) ^ class1('y)) --> prop2('x, 'y)
((prop5(ind1, 42) ^ class1(ind1) ^ sameAs(ind1, ind2) ^ differentFrom(ind1, 'x) ^ swrlbAbs('x)) --> prop5(ind1, "text")) should equal(
factory.getSWRLRule(
Expand All @@ -114,9 +115,9 @@ class ScowlTest extends UnitSpec {
factory.getSWRLClassAtom(class1, factory.getSWRLIndividualArgument(ind1)),
factory.getSWRLSameIndividualAtom(factory.getSWRLIndividualArgument(ind1), factory.getSWRLIndividualArgument(ind2)),
factory.getSWRLDifferentIndividualsAtom(factory.getSWRLIndividualArgument(ind1), factory.getSWRLVariable(IRI.create("urn:swrl#x"))),
factory.getSWRLBuiltInAtom(SWRLBuiltInsVocabulary.ABS.getIRI, List(factory.getSWRLVariable(IRI.create("urn:swrl#x"))))),
factory.getSWRLBuiltInAtom(SWRLBuiltInsVocabulary.ABS.getIRI, List[SWRLDArgument](factory.getSWRLVariable(IRI.create("urn:swrl#x"))).toSeq.asJava)).asJava,
Set(
factory.getSWRLDataPropertyAtom(prop5, factory.getSWRLIndividualArgument(ind1), factory.getSWRLLiteralArgument(factory.getOWLLiteral("text"))))))
factory.getSWRLDataPropertyAtom(prop5, factory.getSWRLIndividualArgument(ind1), factory.getSWRLLiteralArgument(factory.getOWLLiteral("text")))).asJava))
}

}

0 comments on commit fe657b6

Please sign in to comment.