diff --git a/build.gradle b/build.gradle index 5acc042817..f298117089 100644 --- a/build.gradle +++ b/build.gradle @@ -36,6 +36,10 @@ subprojects { apply plugin: 'scala' apply plugin: 'java-library' + configurations { + mockitoAgent + } + dependencies { api libs.scala.library @@ -49,15 +53,28 @@ subprojects { testImplementation libs.log4j.core testImplementation libs.testing.scala.scalatest testImplementation libs.testing.scala.scalacheck - testImplementation libs.testing.junit - testImplementation libs.testing.mockito.all - testRuntimeOnly libs.testing.junit.platform.runner + testImplementation libs.testing.mockito.core + mockitoAgent(libs.testing.mockito.core) { + transitive = false + } + testImplementation libs.testing.scalatest.scalacheck + testImplementation libs.testing.scalatest.mockito + testImplementation libs.testing.junit.platform.launcher + + testRuntimeOnly libs.testing.junit.platform.engine + testRuntimeOnly libs.testing.scalatest.junit } test { maxHeapSize = "2g" maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1 - useJUnit() + + useJUnitPlatform { + includeEngines 'scalatest' + testLogging { + events("failed", "standard_error") + } + } // JVM args required by spark (see org.apache.spark.launcher.JavaModuleOptions) jvmArgs( @@ -81,6 +98,7 @@ subprojects { '--add-opens=java.security.jgss/sun.security.krb5=ALL-UNNAMED', '-Djdk.reflect.useDirectMethodHandle=false' ) + jvmArgs += "-javaagent:${configurations.mockitoAgent.asPath}" def testTempDir = layout.buildDirectory.get().dir("tmp/test").asFile testTempDir.mkdirs() diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 0aaf8b68ad..b11bb2a6e0 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -2,28 +2,31 @@ apache-commons-text = "1.14.0" bctls = "1.59" cats = "2.13.0" -claimant = "0.0.2" +claimant = "0.2.0" cypher-frontend = "9.0.20190305" cypher-tck = "1.0.0-M14" -discipline = "0.11.0" +discipline-core = "1.7.0" +discipline-scalatest = "2.3.0" eff = "7.0.6" fastparse = "2.1.0" h2 = "2.4.240" # Note: has shared transitive dependencies with spark hadoop = "3.3.4" -junit-main = "4.12" -junit-runner = "1.0.2" +junit-platform = "1.13.1" log4j-main = "2.25.2" log4j-scala = "13.1.0" -mockito = "1.10.19" +mockito = "5.18.0" neo4j-driver = "1.7.2" netty = "4.2.7.Final" # @pin - let's prevent automatic updates for the moment scala-full = "2.12.20" # @pin - let's prevent automatic updates for the moment scala-major = "2.12" -scalacheck = "1.14.0" -scalatest = "3.0.6" +scalacheck = "1.19.0" +scalatest = "3.2.19" +scalatest-mockito = "3.2.19.0" # Note, connected to scalatest version +scalatest-scalacheck = "3.2.19.0" # Note, connected to scalatest version +scalatest-junit = "3.2.19.0" # Note, connected to scalatest version spark = "3.5.7" testcontainers = "2.0.2" upickle = "4.4.1" @@ -47,7 +50,7 @@ opencypher-rewriting = { module = "org.opencypher:rewriting-9.0", version.ref = opencypher-tck = { module = "org.opencypher:tck", version.ref = "cypher-tck" } opencypher-tck-api = { module = "org.opencypher:tck-api_2.12", version.ref = "cypher-tck" } opencypher-util = { module = "org.opencypher:util-9.0", version.ref = "cypher-frontend" } -scala-claimant = { module = "org.spire-math:claimant_2.12", version.ref = "claimant" } +scala-claimant = { module = "org.typelevel:claimant_2.12", version.ref = "claimant" } scala-eff = { module = "org.atnos:eff_2.12", version.ref = "eff" } scala-fastparse = { module = "com.lihaoyi:fastparse_2.12", version.ref = "fastparse" } # Seems we need to lock this down, otherwise we get runtime errors on reflection @@ -63,14 +66,18 @@ scala-spark-hive = { module = "org.apache.spark:spark-hive_2.12", version.ref = scala-spark-sql = { module = "org.apache.spark:spark-sql_2.12", version.ref = "spark" } scala-typelevel-cats-core = { module = "org.typelevel:cats-core_2.12", version.ref = "cats" } scala-typelevel-cats-laws = { module = "org.typelevel:cats-laws_2.12", version.ref = "cats" } -scala-typelevel-discipline = { module = "org.typelevel:discipline_2.12", version.ref = "discipline" } +scala-typelevel-discipline-core = { module = "org.typelevel:discipline-core_2.12", version.ref = "discipline-core" } +scala-typelevel-discipline-scalatest = { module = "org.typelevel:discipline-scalatest_2.12", version.ref = "discipline-scalatest" } scala-upickle = { module = "com.lihaoyi:upickle_2.12", version.ref = "upickle" } testcontainers-neo4j = { module = "org.testcontainers:testcontainers-neo4j", version.ref = "testcontainers" } -testing-junit = { module = "junit:junit", version.ref = "junit-main" } -testing-junit-platform-runner = { module = "org.junit.platform:junit-platform-runner", version.ref = "junit-runner" } -testing-mockito-all = { module = "org.mockito:mockito-all", version.ref = "mockito" } +testing-junit-platform-engine = { module = "org.junit.platform:junit-platform-engine", version.ref = "junit-platform" } +testing-junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher", version.ref = "junit-platform" } +testing-mockito-core = { module = "org.mockito:mockito-core", version.ref = "mockito" } testing-scala-scalacheck = { module = "org.scalacheck:scalacheck_2.12", version.ref = "scalacheck" } testing-scala-scalatest = { module = "org.scalatest:scalatest_2.12", version.ref = "scalatest" } +testing-scalatest-mockito = { module = "org.scalatestplus:mockito-5-18_2.12", version.ref = "scalatest-mockito" } +testing-scalatest-scalacheck = { module = "org.scalatestplus:scalacheck-1-18_2.12", version.ref = "scalatest-scalacheck" } +testing-scalatest-junit = { module = "org.scalatestplus:junit-5-13_2.12", version.ref = "scalatest-junit" } [plugins] champeau-jmh = "me.champeau.jmh:0.7.3" diff --git a/graph-ddl/src/test/scala/org/opencypher/graphddl/GraphDdlTest.scala b/graph-ddl/src/test/scala/org/opencypher/graphddl/GraphDdlTest.scala index 06e83bad35..dc52530594 100644 --- a/graph-ddl/src/test/scala/org/opencypher/graphddl/GraphDdlTest.scala +++ b/graph-ddl/src/test/scala/org/opencypher/graphddl/GraphDdlTest.scala @@ -26,16 +26,14 @@ */ package org.opencypher.graphddl -import org.junit.runner.RunWith import org.opencypher.graphddl.GraphDdlParser.parseDdl import org.opencypher.okapi.api.graph.GraphName import org.opencypher.okapi.api.types.{CTBoolean, CTFloat, CTInteger, CTString} import org.opencypher.okapi.testing.MatchHelper.equalWithTracing -import org.scalatestplus.junit.JUnitRunner -import org.scalatest.{FunSpec, Matchers} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers -@RunWith(classOf[JUnitRunner]) -class GraphDdlTest extends FunSpec with Matchers { +class GraphDdlTest extends AnyFunSpec with Matchers { val ddlString: String = s""" diff --git a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/CaseClassExampleTest.scala b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/CaseClassExampleTest.scala index 4cf885c7ad..f4f497a440 100644 --- a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/CaseClassExampleTest.scala +++ b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/CaseClassExampleTest.scala @@ -26,7 +26,7 @@ */ package org.opencypher.morpheus.examples -class CaseClassExampleTest extends ExampleTest { +class CaseClassExampleTest extends ExampleTestBase { it("should produce the correct output") { validate( CaseClassExample.main(Array.empty), diff --git a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/CatalogExampleTest.scala b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/CatalogExampleTest.scala index e36a969d60..5823f00dea 100644 --- a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/CatalogExampleTest.scala +++ b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/CatalogExampleTest.scala @@ -26,7 +26,7 @@ */ package org.opencypher.morpheus.examples -class CatalogExampleTest extends ExampleTest { +class CatalogExampleTest extends ExampleTestBase { it("should produce the correct output") { validate( CatalogExample.main(Array.empty), diff --git a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/CensusHiveExampleTest.scala b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/CensusHiveExampleTest.scala index d994e3c922..ce43ec45f4 100644 --- a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/CensusHiveExampleTest.scala +++ b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/CensusHiveExampleTest.scala @@ -26,7 +26,7 @@ */ package org.opencypher.morpheus.examples -class CensusHiveExampleTest extends ExampleTest { +class CensusHiveExampleTest extends ExampleTestBase { it("runs CensusHiveExampleTest") { validate( CensusHiveExample.main(Array.empty), diff --git a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/CensusJdbcExampleTest.scala b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/CensusJdbcExampleTest.scala index 342624f57a..a4e5b4d04b 100644 --- a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/CensusJdbcExampleTest.scala +++ b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/CensusJdbcExampleTest.scala @@ -26,7 +26,7 @@ */ package org.opencypher.morpheus.examples -class CensusJdbcExampleTest extends ExampleTest { +class CensusJdbcExampleTest extends ExampleTestBase { it("runs CensusJdbcExample") { validate( CensusJdbcExample.main(Array.empty), diff --git a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/CustomDataFrameInputExampleTest.scala b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/CustomDataFrameInputExampleTest.scala index 7cd760332e..4993b6e460 100644 --- a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/CustomDataFrameInputExampleTest.scala +++ b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/CustomDataFrameInputExampleTest.scala @@ -26,7 +26,7 @@ */ package org.opencypher.morpheus.examples -class CustomDataFrameInputExampleTest extends ExampleTest { +class CustomDataFrameInputExampleTest extends ExampleTestBase { it("should produce the correct output") { validate( CustomDataFrameInputExample.main(Array.empty), diff --git a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/Customer360ExampleTest.scala b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/Customer360ExampleTest.scala index 9d557cc60d..9e4e7804f3 100644 --- a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/Customer360ExampleTest.scala +++ b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/Customer360ExampleTest.scala @@ -28,7 +28,7 @@ package org.opencypher.morpheus.examples import org.opencypher.okapi.neo4j.io.testing.Neo4jServerFixture -class Customer360ExampleTest extends ExampleTest with Neo4jServerFixture { +class Customer360ExampleTest extends ExampleTestBase with Neo4jServerFixture { override def dataFixture: String = "" it("should produce the correct output") { diff --git a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/CypherSQLRoundtripExampleTest.scala b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/CypherSQLRoundtripExampleTest.scala index a5fd06361c..adeb46e1a9 100644 --- a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/CypherSQLRoundtripExampleTest.scala +++ b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/CypherSQLRoundtripExampleTest.scala @@ -26,7 +26,7 @@ */ package org.opencypher.morpheus.examples -class CypherSQLRoundtripExampleTest extends ExampleTest { +class CypherSQLRoundtripExampleTest extends ExampleTestBase { it("should produce the correct output") { validate( CypherSQLRoundtripExample.main(Array.empty), diff --git a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/DataFrameInputExampleTest.scala b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/DataFrameInputExampleTest.scala index 9e230f2c77..1d7931468c 100644 --- a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/DataFrameInputExampleTest.scala +++ b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/DataFrameInputExampleTest.scala @@ -26,7 +26,7 @@ */ package org.opencypher.morpheus.examples -class DataFrameInputExampleTest extends ExampleTest { +class DataFrameInputExampleTest extends ExampleTestBase { it("should produce the correct output") { validate(DataFrameInputExample.main(Array.empty), getClass.getResource("/example_outputs/DataFrameInputExample.out").toURI) diff --git a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/DataFrameOutputExampleTest.scala b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/DataFrameOutputExampleTest.scala index 1b61ce7214..35f6348dc6 100644 --- a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/DataFrameOutputExampleTest.scala +++ b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/DataFrameOutputExampleTest.scala @@ -26,7 +26,7 @@ */ package org.opencypher.morpheus.examples -class DataFrameOutputExampleTest extends ExampleTest { +class DataFrameOutputExampleTest extends ExampleTestBase { it("should produce the correct output") { validate(DataFrameOutputExample.main(Array.empty), getClass.getResource("/example_outputs/DataFrameOutputExample.out").toURI) diff --git a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/DataSourceExampleTest.scala b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/DataSourceExampleTest.scala index bc377c66d9..e71b2f789f 100644 --- a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/DataSourceExampleTest.scala +++ b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/DataSourceExampleTest.scala @@ -26,7 +26,7 @@ */ package org.opencypher.morpheus.examples -class DataSourceExampleTest extends ExampleTest { +class DataSourceExampleTest extends ExampleTestBase { it("should produce the correct output") { validate(DataSourceExample.main(Array.empty), getClass.getResource("/example_outputs/DataSourceExample.out").toURI) diff --git a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/ExampleTest.scala b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/ExampleTestBase.scala similarity index 91% rename from morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/ExampleTest.scala rename to morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/ExampleTestBase.scala index f71f93934c..b5766354bd 100644 --- a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/ExampleTest.scala +++ b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/ExampleTestBase.scala @@ -28,16 +28,14 @@ package org.opencypher.morpheus.examples import java.io.{ByteArrayOutputStream, PrintStream} import java.net.URI - -import org.junit.runner.RunWith import org.opencypher.okapi.testing.Bag._ -import org.scalatest.{BeforeAndAfterAll, FunSpec, Matchers} -import org.scalatestplus.junit.JUnitRunner +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.BeforeAndAfterAll +import org.scalatest.matchers.should.Matchers import scala.io.Source -@RunWith(classOf[JUnitRunner]) -abstract class ExampleTest extends FunSpec with Matchers with BeforeAndAfterAll { +abstract class ExampleTestBase extends AnyFunSpec with Matchers with BeforeAndAfterAll { private val oldStdOut = System.out diff --git a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/GraphXPageRankExampleTest.scala b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/GraphXPageRankExampleTest.scala index f999d30d22..fe0e9d0490 100644 --- a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/GraphXPageRankExampleTest.scala +++ b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/GraphXPageRankExampleTest.scala @@ -26,7 +26,7 @@ */ package org.opencypher.morpheus.examples -class GraphXPageRankExampleTest extends ExampleTest { +class GraphXPageRankExampleTest extends ExampleTestBase { it("should produce the correct output") { validate(GraphXPageRankExample.main(Array.empty), getClass.getResource("/example_outputs/GraphXPageRankExample.out").toURI) diff --git a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/HiveSupportExampleTest.scala b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/HiveSupportExampleTest.scala index 9d499607be..0eaf2cfebc 100644 --- a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/HiveSupportExampleTest.scala +++ b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/HiveSupportExampleTest.scala @@ -26,7 +26,7 @@ */ package org.opencypher.morpheus.examples -class HiveSupportExampleTest extends ExampleTest { +class HiveSupportExampleTest extends ExampleTestBase { it("should produce the correct output") { validate(HiveSupportExample.main(Array.empty), diff --git a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/LdbcHiveExampleTest.scala b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/LdbcHiveExampleTest.scala index 49bf92f63c..66ef653107 100644 --- a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/LdbcHiveExampleTest.scala +++ b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/LdbcHiveExampleTest.scala @@ -26,7 +26,7 @@ */ package org.opencypher.morpheus.examples -class LdbcHiveExampleTest extends ExampleTest { +class LdbcHiveExampleTest extends ExampleTestBase { it("runs LdbcHiveExampleTest") { validate( LdbcHiveExample.main(Array.empty), diff --git a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/MultipleGraphExampleTest.scala b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/MultipleGraphExampleTest.scala index b3db42c6d9..b54624b57b 100644 --- a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/MultipleGraphExampleTest.scala +++ b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/MultipleGraphExampleTest.scala @@ -26,7 +26,7 @@ */ package org.opencypher.morpheus.examples -class MultipleGraphExampleTest extends ExampleTest { +class MultipleGraphExampleTest extends ExampleTestBase { it("should produce the correct output") { validate(MultipleGraphExample.main(Array.empty), diff --git a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/Neo4jCustomSchemaExampleTest.scala b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/Neo4jCustomSchemaExampleTest.scala index 9cc6eef6de..268b434ec4 100644 --- a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/Neo4jCustomSchemaExampleTest.scala +++ b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/Neo4jCustomSchemaExampleTest.scala @@ -28,7 +28,7 @@ package org.opencypher.morpheus.examples import org.opencypher.okapi.neo4j.io.testing.Neo4jServerFixture -class Neo4jCustomSchemaExampleTest extends ExampleTest with Neo4jServerFixture { +class Neo4jCustomSchemaExampleTest extends ExampleTestBase with Neo4jServerFixture { override def dataFixture: String = "" diff --git a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/Neo4jMergeExampleTest.scala b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/Neo4jMergeExampleTest.scala index 71249e0533..ea343bf819 100644 --- a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/Neo4jMergeExampleTest.scala +++ b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/Neo4jMergeExampleTest.scala @@ -28,7 +28,7 @@ package org.opencypher.morpheus.examples import org.opencypher.okapi.neo4j.io.testing.Neo4jServerFixture -class Neo4jMergeExampleTest extends ExampleTest with Neo4jServerFixture { +class Neo4jMergeExampleTest extends ExampleTestBase with Neo4jServerFixture { override def dataFixture: String = "" diff --git a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/Neo4jReadWriteExampleTest.scala b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/Neo4jReadWriteExampleTest.scala index 23d7f00b64..df40dbaf9b 100644 --- a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/Neo4jReadWriteExampleTest.scala +++ b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/Neo4jReadWriteExampleTest.scala @@ -28,7 +28,7 @@ package org.opencypher.morpheus.examples import org.opencypher.okapi.neo4j.io.testing.Neo4jServerFixture -class Neo4jReadWriteExampleTest extends ExampleTest with Neo4jServerFixture { +class Neo4jReadWriteExampleTest extends ExampleTestBase with Neo4jServerFixture { override def dataFixture: String = "" diff --git a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/Neo4jWorkflowExampleTest.scala b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/Neo4jWorkflowExampleTest.scala index 698888647e..bc1df782cf 100644 --- a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/Neo4jWorkflowExampleTest.scala +++ b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/Neo4jWorkflowExampleTest.scala @@ -28,7 +28,7 @@ package org.opencypher.morpheus.examples import org.opencypher.okapi.neo4j.io.testing.Neo4jServerFixture -class Neo4jWorkflowExampleTest extends ExampleTest with Neo4jServerFixture { +class Neo4jWorkflowExampleTest extends ExampleTestBase with Neo4jServerFixture { override def dataFixture: String = "" diff --git a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/NorthwindJdbcExampleTest.scala b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/NorthwindJdbcExampleTest.scala index 701ab38c41..60c682521d 100644 --- a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/NorthwindJdbcExampleTest.scala +++ b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/NorthwindJdbcExampleTest.scala @@ -36,7 +36,7 @@ import org.opencypher.okapi.impl.util.TablePrinter.toTable import scala.io.Source -class NorthwindJdbcExampleTest extends ExampleTest { +class NorthwindJdbcExampleTest extends ExampleTestBase { it("runs JdbcSqlGraphSourceExample") { validate( NorthwindJdbcExample.main(Array.empty), diff --git a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/RecommendationExampleTest.scala b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/RecommendationExampleTest.scala index 94506d31f7..e53e3af085 100644 --- a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/RecommendationExampleTest.scala +++ b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/RecommendationExampleTest.scala @@ -26,7 +26,7 @@ */ package org.opencypher.morpheus.examples -class RecommendationExampleTest extends ExampleTest { +class RecommendationExampleTest extends ExampleTestBase { // TODO: enable when spark planning bug is fixed ignore("should produce the correct output") { validate(RecommendationExample.main(Array.empty), diff --git a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/UpdateExampleTest.scala b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/UpdateExampleTest.scala index 91604cbde0..3ae43260b0 100644 --- a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/UpdateExampleTest.scala +++ b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/UpdateExampleTest.scala @@ -26,7 +26,7 @@ */ package org.opencypher.morpheus.examples -class UpdateExampleTest extends ExampleTest { +class UpdateExampleTest extends ExampleTestBase { it("should produce the correct output") { validate(UpdateExample.main(Array.empty), getClass.getResource("/example_outputs/UpdateExample.out").toURI) diff --git a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/ViewsExampleTest.scala b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/ViewsExampleTest.scala index 4b1b8d0e1d..42fd2df5d0 100644 --- a/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/ViewsExampleTest.scala +++ b/morpheus-examples/src/test/scala/org/opencypher/morpheus/examples/ViewsExampleTest.scala @@ -26,7 +26,7 @@ */ package org.opencypher.morpheus.examples -class ViewsExampleTest extends ExampleTest { +class ViewsExampleTest extends ExampleTestBase { it("should produce the correct output") { validate(ViewsExample.main(Array.empty), getClass.getResource("/example_outputs/ViewsExample.out").toURI) diff --git a/morpheus-examples/src/test/scala/org/opencypher/morpheus/snippets/SqlPGDSTest.scala b/morpheus-examples/src/test/scala/org/opencypher/morpheus/snippets/SqlPGDSTest.scala index 470ac9978f..158cf35c16 100644 --- a/morpheus-examples/src/test/scala/org/opencypher/morpheus/snippets/SqlPGDSTest.scala +++ b/morpheus-examples/src/test/scala/org/opencypher/morpheus/snippets/SqlPGDSTest.scala @@ -26,9 +26,9 @@ */ package org.opencypher.morpheus.snippets -import org.opencypher.morpheus.examples.ExampleTest +import org.opencypher.morpheus.examples.ExampleTestBase -class SqlPGDSTest extends ExampleTest { +class SqlPGDSTest extends ExampleTestBase { it("should produce the correct output") { validate( diff --git a/morpheus-spark-cypher/src/main/scala/org/opencypher/morpheus/api/io/sql/SqlDataSourceConfig.scala b/morpheus-spark-cypher/src/main/scala/org/opencypher/morpheus/api/io/sql/SqlDataSourceConfig.scala index d41a479e8b..b387bb52cd 100644 --- a/morpheus-spark-cypher/src/main/scala/org/opencypher/morpheus/api/io/sql/SqlDataSourceConfig.scala +++ b/morpheus-spark-cypher/src/main/scala/org/opencypher/morpheus/api/io/sql/SqlDataSourceConfig.scala @@ -27,6 +27,7 @@ package org.opencypher.morpheus.api.io.sql import org.opencypher.morpheus.api.io.{FileFormat, HiveFormat, JdbcFormat, StorageFormat} +import ujson.Obj import ujson.Value import scala.util.{Failure, Success, Try} @@ -36,10 +37,10 @@ case class SqlDataSourceConfigException(msg: String, cause: Throwable = null) ex import org.opencypher.okapi.impl.util.JsonUtils.FlatOption._ -sealed abstract class SqlDataSourceConfig( - val format: StorageFormat, - val options: Map[String, String] -) +sealed trait SqlDataSourceConfig { + def format: StorageFormat + def options: Map[String, String] +} object SqlDataSourceConfig { private implicit val jdbc: ReadWriter[Jdbc] = macroRW @@ -52,14 +53,20 @@ object SqlDataSourceConfig { implicit val rw: ReadWriter[SqlDataSourceConfig] = readwriter[Value].bimap[SqlDataSourceConfig]( // Rename discriminator key from ujson default, to a more friendly version - cfg => writeJs(cfg)(defaultMacroRW).obj.collect { - case (UJSON_TYPE_KEY, value) => MORPHEUS_TYPE_KEY -> value - case other => other + cfg => writeJs(cfg)(defaultMacroRW) match { + case Obj(obj) => obj.collect { + case (UJSON_TYPE_KEY, value) => MORPHEUS_TYPE_KEY -> value + case other => other + } + case other => other // Note, case objects are serialised as strings }, // Revert name change so we can use the ujson reader - js => read[SqlDataSourceConfig](js.obj.map { - case (MORPHEUS_TYPE_KEY, value) => UJSON_TYPE_KEY -> value - case other => other + js => read[SqlDataSourceConfig](js match { + case Obj(obj) => obj.map { + case (MORPHEUS_TYPE_KEY, value) => UJSON_TYPE_KEY -> value + case other => other + } + case _ => js // Note, case objects are serialised as strings })(defaultMacroRW) ) @@ -87,13 +94,18 @@ object SqlDataSourceConfig { url: String, driver: String, override val options: Map[String, String] = Map.empty - ) extends SqlDataSourceConfig(JdbcFormat, options) + ) extends SqlDataSourceConfig { + override def format: StorageFormat = JdbcFormat + } /** Configures a data source that reads tables from Hive * @note The Spark session needs to be configured with `.enableHiveSupport()` */ @upickle.implicits.key("hive") - case object Hive extends SqlDataSourceConfig(HiveFormat, Map.empty) + case object Hive extends SqlDataSourceConfig { + override def format: StorageFormat = HiveFormat + override def options: Map[String, String] = Map.empty + } /** Configures a data source that reads tables from files * @@ -106,6 +118,5 @@ object SqlDataSourceConfig { override val format: FileFormat, basePath: Option[String] = None, override val options: Map[String, String] = Map.empty - ) extends SqlDataSourceConfig(format, options) - + ) extends SqlDataSourceConfig } diff --git a/morpheus-spark-cypher/src/main/scala/org/opencypher/morpheus/api/io/sql/SqlPropertyGraphDataSource.scala b/morpheus-spark-cypher/src/main/scala/org/opencypher/morpheus/api/io/sql/SqlPropertyGraphDataSource.scala index 613b73e254..eb4ab95775 100644 --- a/morpheus-spark-cypher/src/main/scala/org/opencypher/morpheus/api/io/sql/SqlPropertyGraphDataSource.scala +++ b/morpheus-spark-cypher/src/main/scala/org/opencypher/morpheus/api/io/sql/SqlPropertyGraphDataSource.scala @@ -243,7 +243,7 @@ case class SqlPropertyGraphDataSource( } val inputTable = sqlDataSourceConfig match { - case hive@Hive => readSqlTable(viewId, hive) + case Hive => readSqlTable(viewId, Hive) case jdbc: Jdbc => readSqlTable(viewId, jdbc) case file: File => readFile(viewId, file) } diff --git a/morpheus-testing/build.gradle b/morpheus-testing/build.gradle index fce50c9b11..5d9d42b1d2 100644 --- a/morpheus-testing/build.gradle +++ b/morpheus-testing/build.gradle @@ -11,7 +11,8 @@ dependencies { api libs.hadoop.client.minicluster api libs.testing.scala.scalatest - api libs.testing.mockito.all + api libs.testing.mockito.core + testImplementation libs.testing.scalatest.mockito testImplementation project(':okapi-api').sourceSets.test.output diff --git a/morpheus-testing/src/test/scala/org/opencypher/morpheus/api/io/FullPGDSAcceptanceTest.scala b/morpheus-testing/src/test/scala/org/opencypher/morpheus/api/io/FullPGDSAcceptanceTest.scala index 6959cbcbda..ff6eeee873 100644 --- a/morpheus-testing/src/test/scala/org/opencypher/morpheus/api/io/FullPGDSAcceptanceTest.scala +++ b/morpheus-testing/src/test/scala/org/opencypher/morpheus/api/io/FullPGDSAcceptanceTest.scala @@ -26,11 +26,11 @@ */ package org.opencypher.morpheus.api.io -import java.nio.file.Paths +import org.apache.commons.io.FileUtils +import java.nio.file.{Files, Paths} import org.apache.hadoop.fs.Path import org.apache.spark.sql.{DataFrame, SaveMode, functions} -import org.junit.rules.TemporaryFolder import org.opencypher.graphddl import org.opencypher.graphddl.{Graph, GraphType, NodeToViewMapping, NodeViewKey} import org.opencypher.morpheus.api.FSGraphSources.FSGraphSourceFactory @@ -317,21 +317,20 @@ class FullPGDSAcceptanceTest extends MorpheusTestSuite override def toString: String = s"LocalFS-PGDS-${fileFormat.name.toUpperCase}-FORMAT-$filesPerTable-FILE(S)-PER-TABLE" - protected var tempDir: TemporaryFolder = _ + protected var tempDir: java.nio.file.Path = _ - def basePath: String = s"file://${Paths.get(tempDir.getRoot.getAbsolutePath)}" + def basePath: String = s"file://${tempDir.toAbsolutePath}" def graphSourceFactory: FSGraphSourceFactory = GraphSources.fs(basePath, filesPerTable = Some(filesPerTable)) override def initializeContext(graphNames: List[GraphName]): TestContext = { - tempDir = new TemporaryFolder() - tempDir.create() + tempDir = Files.createTempDirectory(getClass.getSimpleName) super.initializeContext(graphNames) } override def releaseContext(implicit ctx: TestContext): Unit = { super.releaseContext - tempDir.delete() + FileUtils.deleteDirectory(tempDir.toFile) } } diff --git a/morpheus-testing/src/test/scala/org/opencypher/morpheus/api/io/fs/DefaultFileSystemTest.scala b/morpheus-testing/src/test/scala/org/opencypher/morpheus/api/io/fs/DefaultFileSystemTest.scala index 754809b5a6..363d7a53c9 100644 --- a/morpheus-testing/src/test/scala/org/opencypher/morpheus/api/io/fs/DefaultFileSystemTest.scala +++ b/morpheus-testing/src/test/scala/org/opencypher/morpheus/api/io/fs/DefaultFileSystemTest.scala @@ -26,24 +26,26 @@ */ package org.opencypher.morpheus.api.io.fs -import org.junit.rules.TemporaryFolder +import org.apache.commons.io.FileUtils import org.opencypher.morpheus.api.FSGraphSources import org.opencypher.morpheus.api.io.fs.DefaultGraphDirectoryStructure.pathSeparator import org.opencypher.morpheus.testing.MorpheusTestSuite import org.opencypher.okapi.api.graph.GraphName +import java.nio.file.{Files, Path} + class DefaultFileSystemTest extends MorpheusTestSuite { - protected var tempDir = new TemporaryFolder() + protected var tempDir: Path = _ override protected def beforeEach(): Unit = { - tempDir.create() + tempDir = Files.createTempDirectory(getClass.getSimpleName) super.beforeEach() } override protected def afterEach(): Unit = { - tempDir.delete() - tempDir = new TemporaryFolder() + FileUtils.deleteDirectory(tempDir.toFile) + tempDir = null super.afterEach() } @@ -54,7 +56,7 @@ class DefaultFileSystemTest extends MorpheusTestSuite { | CREATE () |RETURN GRAPH """.stripMargin).graph - val ds = FSGraphSources(s"${tempDir.getRoot.getAbsolutePath}${pathSeparator}someNewFolder1${pathSeparator}someNewFolder2").csv + val ds = FSGraphSources(tempDir.toAbsolutePath.resolve("someNewFolder1/someNewFolder2").toString).csv ds.store(GraphName("foo"), graph) } diff --git a/morpheus-testing/src/test/scala/org/opencypher/morpheus/api/io/fs/FSGraphSourceTest.scala b/morpheus-testing/src/test/scala/org/opencypher/morpheus/api/io/fs/FSGraphSourceTest.scala index 57fa55cf0b..da7e510be0 100644 --- a/morpheus-testing/src/test/scala/org/opencypher/morpheus/api/io/fs/FSGraphSourceTest.scala +++ b/morpheus-testing/src/test/scala/org/opencypher/morpheus/api/io/fs/FSGraphSourceTest.scala @@ -26,8 +26,8 @@ */ package org.opencypher.morpheus.api.io.fs +import org.apache.commons.io.FileUtils import org.apache.spark.sql.{AnalysisException, Row} -import org.junit.rules.TemporaryFolder import org.opencypher.morpheus.api.GraphSources import org.opencypher.morpheus.api.io.FileFormat import org.opencypher.morpheus.api.io.util.HiveTableName @@ -39,22 +39,23 @@ import org.opencypher.okapi.api.graph.{GraphName, Node, Relationship} import org.opencypher.okapi.api.value.CypherValue.CypherMap import org.opencypher.okapi.testing.Bag +import java.nio.file.{Files, Path} + class FSGraphSourceTest extends MorpheusTestSuite with ScanGraphInit { - private var tempDir = new TemporaryFolder() + private var tempDir: Path = _ private val testDatabaseName = "test" override protected def beforeEach(): Unit = { morpheus.sparkSession.sql(s"CREATE DATABASE IF NOT EXISTS $testDatabaseName") - tempDir.create() + tempDir = Files.createTempDirectory(getClass.getSimpleName) super.beforeEach() } override protected def afterEach(): Unit = { morpheus.sparkSession.sql(s"DROP DATABASE IF EXISTS $testDatabaseName CASCADE") - tempDir.delete() - tempDir = new TemporaryFolder() + FileUtils.deleteDirectory(tempDir.toFile) super.afterEach() } @@ -68,7 +69,7 @@ class FSGraphSourceTest extends MorpheusTestSuite with ScanGraphInit { it("writes nodes and relationships to hive tables") { val given = testGraph - val fs = new FSGraphSource("file:///" + tempDir.getRoot.getAbsolutePath.replace("\\", "/"), + val fs = new FSGraphSource("file:///" + tempDir.toAbsolutePath.toString.replace("\\", "/"), FileFormat.parquet, Some(testDatabaseName), None) fs.store(graphName, given) @@ -91,7 +92,7 @@ class FSGraphSourceTest extends MorpheusTestSuite with ScanGraphInit { it("deletes the hive database if the graph is deleted") { val given = testGraph - val fs = new FSGraphSource("file:///" + tempDir.getRoot.getAbsolutePath.replace("\\", "/"), + val fs = new FSGraphSource("file:///" + tempDir.toAbsolutePath.toString.replace("\\", "/"), FileFormat.parquet, Some(testDatabaseName), None) fs.store(graphName, given) @@ -118,7 +119,7 @@ class FSGraphSourceTest extends MorpheusTestSuite with ScanGraphInit { |CREATE (:A {`foo@bar`: 42}) """.stripMargin) - val fs = GraphSources.fs("file:///" + tempDir.getRoot.getAbsolutePath.replace("\\", "/")).orc + val fs = GraphSources.fs("file:///" + tempDir.toAbsolutePath.toString.replace("\\", "/")).orc fs.store(graphName, given) val graph = fs.graph(graphName) diff --git a/morpheus-testing/src/test/scala/org/opencypher/morpheus/api/io/neo4j/Neo4jBulkCSVDataSinkTest.scala b/morpheus-testing/src/test/scala/org/opencypher/morpheus/api/io/neo4j/Neo4jBulkCSVDataSinkTest.scala index a9c6de6027..656b6cd532 100644 --- a/morpheus-testing/src/test/scala/org/opencypher/morpheus/api/io/neo4j/Neo4jBulkCSVDataSinkTest.scala +++ b/morpheus-testing/src/test/scala/org/opencypher/morpheus/api/io/neo4j/Neo4jBulkCSVDataSinkTest.scala @@ -26,7 +26,7 @@ */ package org.opencypher.morpheus.api.io.neo4j -import org.junit.rules.TemporaryFolder +import org.apache.commons.io.FileUtils import org.opencypher.morpheus.api.io.neo4j.Neo4jBulkCSVDataSink._ import org.opencypher.morpheus.impl.acceptance.ScanGraphInit import org.opencypher.morpheus.impl.table.SparkTable @@ -36,25 +36,26 @@ import org.opencypher.okapi.api.graph.{GraphName, Namespace} import org.opencypher.okapi.relational.api.graph.RelationalCypherGraph import org.scalatest.BeforeAndAfterAll +import java.nio.file.{Files, Path} import scala.io.Source class Neo4jBulkCSVDataSinkTest extends MorpheusTestSuite with TeamDataFixture with ScanGraphInit with BeforeAndAfterAll { - protected val tempDir = new TemporaryFolder() + protected var tempDir: Path = _ private val graphName = GraphName("teamdata") private val namespace = Namespace("teamDatasource") override protected def beforeAll(): Unit = { super.beforeAll() - tempDir.create() + tempDir = Files.createTempDirectory(getClass.getSimpleName) val graph: RelationalCypherGraph[SparkTable.DataFrameTable] = initGraph(dataFixture) - val dataSource = new Neo4jBulkCSVDataSink(tempDir.getRoot.getAbsolutePath) + val dataSource = new Neo4jBulkCSVDataSink(tempDir.toAbsolutePath.toString) dataSource.store(graphName, graph) morpheus.catalog.register(namespace, dataSource) } protected override def afterAll(): Unit = { - tempDir.delete() + FileUtils.deleteDirectory(tempDir.toFile) super.afterAll() } diff --git a/morpheus-testing/src/test/scala/org/opencypher/morpheus/api/io/neo4j/Neo4jPropertyGraphDataSourceTest.scala b/morpheus-testing/src/test/scala/org/opencypher/morpheus/api/io/neo4j/Neo4jPropertyGraphDataSourceTest.scala index b5b56e3b0d..18c1751568 100644 --- a/morpheus-testing/src/test/scala/org/opencypher/morpheus/api/io/neo4j/Neo4jPropertyGraphDataSourceTest.scala +++ b/morpheus-testing/src/test/scala/org/opencypher/morpheus/api/io/neo4j/Neo4jPropertyGraphDataSourceTest.scala @@ -55,7 +55,7 @@ class Neo4jPropertyGraphDataSourceTest with TeamDataFixture { it("should cache the schema during and between queries") { - val spiedPGDS = spy(CypherGraphSources.neo4j(neo4jConfig)) + val spiedPGDS = spy[Neo4jPropertyGraphDataSource](CypherGraphSources.neo4j(neo4jConfig)) morpheus.registerSource(Namespace("pgds"), spiedPGDS) diff --git a/morpheus-testing/src/test/scala/org/opencypher/morpheus/api/io/sql/SqlDataSourceConfigTest.scala b/morpheus-testing/src/test/scala/org/opencypher/morpheus/api/io/sql/SqlDataSourceConfigTest.scala index ca08886710..1874f26e94 100644 --- a/morpheus-testing/src/test/scala/org/opencypher/morpheus/api/io/sql/SqlDataSourceConfigTest.scala +++ b/morpheus-testing/src/test/scala/org/opencypher/morpheus/api/io/sql/SqlDataSourceConfigTest.scala @@ -28,11 +28,12 @@ package org.opencypher.morpheus.api.io.sql import org.opencypher.morpheus.api.io.FileFormat import org.opencypher.morpheus.api.io.sql.SqlDataSourceConfig.{File, Hive, Jdbc} -import org.scalatest.Matchers +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import scala.io.Source -class SqlDataSourceConfigTest extends org.scalatest.FunSpec with Matchers { +class SqlDataSourceConfigTest extends AnyFunSpec with Matchers { private def roundTrip(cfg: SqlDataSourceConfig): SqlDataSourceConfig = SqlDataSourceConfig.fromJson(SqlDataSourceConfig.toJson(cfg)) diff --git a/morpheus-testing/src/test/scala/org/opencypher/morpheus/impl/SparkTableTest.scala b/morpheus-testing/src/test/scala/org/opencypher/morpheus/impl/SparkTableTest.scala index b9ff5c0eca..dbbb7c3a3e 100644 --- a/morpheus-testing/src/test/scala/org/opencypher/morpheus/impl/SparkTableTest.scala +++ b/morpheus-testing/src/test/scala/org/opencypher/morpheus/impl/SparkTableTest.scala @@ -32,7 +32,7 @@ import org.opencypher.morpheus.impl.table.SparkTable.{DataFrameTable, _} import org.opencypher.morpheus.testing.MorpheusTestSuite import org.opencypher.okapi.testing.Bag import org.opencypher.okapi.testing.Bag._ -import org.scalatest.Matchers +import org.scalatest.matchers.should.Matchers import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks import scala.collection.mutable.WrappedArray.ofLong diff --git a/morpheus-testing/src/test/scala/org/opencypher/morpheus/impl/acceptance/ExpressionTests.scala b/morpheus-testing/src/test/scala/org/opencypher/morpheus/impl/acceptance/ExpressionTests.scala index eab6153867..ef696be662 100644 --- a/morpheus-testing/src/test/scala/org/opencypher/morpheus/impl/acceptance/ExpressionTests.scala +++ b/morpheus-testing/src/test/scala/org/opencypher/morpheus/impl/acceptance/ExpressionTests.scala @@ -26,7 +26,6 @@ */ package org.opencypher.morpheus.impl.acceptance -import claimant.Claim import org.opencypher.morpheus.impl.SparkSQLMappingException import org.opencypher.morpheus.testing.MorpheusTestSuite import org.opencypher.morpheus.testing.support.creation.graphs.ScanGraphFactory @@ -42,6 +41,7 @@ import org.opencypher.okapi.testing.Bag._ import org.scalacheck.Prop import org.scalatestplus.scalacheck.Checkers import org.opencypher.morpheus.impl.MorpheusConverters._ +import org.typelevel.claimant.Claim class ExpressionTests extends MorpheusTestSuite with ScanGraphInit with Checkers { diff --git a/morpheus-testing/src/test/scala/org/opencypher/morpheus/impl/io/neo4j/external/Neo4jTest.scala b/morpheus-testing/src/test/scala/org/opencypher/morpheus/impl/io/neo4j/external/Neo4jTest.scala index 817892976e..3770cda28f 100644 --- a/morpheus-testing/src/test/scala/org/opencypher/morpheus/impl/io/neo4j/external/Neo4jTest.scala +++ b/morpheus-testing/src/test/scala/org/opencypher/morpheus/impl/io/neo4j/external/Neo4jTest.scala @@ -26,7 +26,6 @@ */ package org.opencypher.morpheus.impl.io.neo4j.external -import org.junit.Assert.assertEquals import org.opencypher.morpheus.testing.fixture.SparkSessionFixture import org.opencypher.okapi.neo4j.io.testing.Neo4jServerFixture import org.opencypher.okapi.testing.BaseTestSuite @@ -49,26 +48,26 @@ class Neo4jTest extends BaseTestSuite test("run Cypher Query With Params") { val result = neo4j.cypher("MATCH (n:Person) WHERE n.id <= {maxId} RETURN id(n)").param("maxId", 10) - assertEquals(10, result.loadRowRdd.count()) + assertResult(10)(result.loadRowRdd.count()) } test("run Cypher Node Query") { val result = neo4j.cypher("MATCH (n:Person) RETURN id(n)") - assertEquals(100, result.loadRowRdd.count()) + assertResult(100)(result.loadRowRdd.count()) } test("run Cypher Rel Query") { val result = neo4j.cypher("MATCH ()-[r:KNOWS]->() RETURN id(r)") - assertEquals(1000, result.loadRowRdd.count()) + assertResult(1000)(result.loadRowRdd.count()) } test("run Cypher Query With Partition") { val result = neo4j.cypher("MATCH (n:Person) RETURN id(n) SKIP {_skip} LIMIT {_limit}").partitions(4).batch(25) - assertEquals(100, result.loadRowRdd.count()) + assertResult(100)(result.loadRowRdd.count()) } test("run Cypher Rel Query WithPartition") { val result = neo4j.cypher("MATCH (n:Person)-[r:KNOWS]->(m:Person) RETURN id(n) as src,id(m) as dst,type(r) as value SKIP {_skip} LIMIT {_limit}").partitions(7).batch(200) - assertEquals(1000, result.loadRowRdd.count()) + assertResult(1000)(result.loadRowRdd.count()) } } diff --git a/morpheus-testing/src/test/scala/org/opencypher/morpheus/impl/values/MorpheusLiteralTests.scala b/morpheus-testing/src/test/scala/org/opencypher/morpheus/impl/values/MorpheusLiteralTests.scala index 8ab5f322d8..c47402c642 100644 --- a/morpheus-testing/src/test/scala/org/opencypher/morpheus/impl/values/MorpheusLiteralTests.scala +++ b/morpheus-testing/src/test/scala/org/opencypher/morpheus/impl/values/MorpheusLiteralTests.scala @@ -26,7 +26,6 @@ */ package org.opencypher.morpheus.impl.values -import claimant.Claim import org.opencypher.morpheus.impl.acceptance.ScanGraphInit import org.opencypher.morpheus.testing.MorpheusTestSuite import org.opencypher.okapi.api.value.CypherValue.Format._ @@ -35,6 +34,7 @@ import org.opencypher.okapi.api.value.GenCypherValue._ import org.scalacheck.Gen.const import org.scalacheck.{Gen, Prop} import org.scalatestplus.scalacheck.Checkers +import org.typelevel.claimant.Claim class MorpheusLiteralTests extends MorpheusTestSuite with Checkers with ScanGraphInit { diff --git a/okapi-api/build.gradle b/okapi-api/build.gradle index 66c209e85c..4fdc9267e8 100644 --- a/okapi-api/build.gradle +++ b/okapi-api/build.gradle @@ -15,7 +15,7 @@ dependencies { api libs.scala.fastparse - testImplementation libs.scala.typelevel.discipline + testImplementation libs.scala.typelevel.discipline.core + testImplementation libs.scala.typelevel.discipline.scalatest testImplementation libs.scala.typelevel.cats.laws - testImplementation libs.testing.junit } diff --git a/okapi-api/src/test/scala/org/opencypher/okapi/ApiBaseTest.scala b/okapi-api/src/test/scala/org/opencypher/okapi/ApiBaseTest.scala index e24814014f..361b1f9610 100644 --- a/okapi-api/src/test/scala/org/opencypher/okapi/ApiBaseTest.scala +++ b/okapi-api/src/test/scala/org/opencypher/okapi/ApiBaseTest.scala @@ -26,10 +26,8 @@ */ package org.opencypher.okapi -import org.junit.runner.RunWith -import org.scalatestplus.junit.JUnitRunner +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{FunSpec, Matchers} -@RunWith(classOf[JUnitRunner]) -abstract class ApiBaseTest extends FunSpec with MockitoSugar with Matchers +abstract class ApiBaseTest extends AnyFunSpec with MockitoSugar with Matchers diff --git a/okapi-api/src/test/scala/org/opencypher/okapi/api/schema/PropertyGraphSchemaTest.scala b/okapi-api/src/test/scala/org/opencypher/okapi/api/schema/PropertyGraphSchemaTest.scala index 3e0863f5a7..c5ec783cf8 100644 --- a/okapi-api/src/test/scala/org/opencypher/okapi/api/schema/PropertyGraphSchemaTest.scala +++ b/okapi-api/src/test/scala/org/opencypher/okapi/api/schema/PropertyGraphSchemaTest.scala @@ -31,7 +31,6 @@ import org.opencypher.okapi.api.schema.PropertyKeys.PropertyKeys import org.opencypher.okapi.api.types._ import org.opencypher.okapi.impl.exception.SchemaException import org.opencypher.okapi.impl.util.Version -import org.scalatest.{FunSpec, Matchers} class PropertyGraphSchemaTest extends ApiBaseTest { diff --git a/okapi-api/src/test/scala/org/opencypher/okapi/api/types/TypeLawsTest.scala b/okapi-api/src/test/scala/org/opencypher/okapi/api/types/TypeLawsTest.scala index c957120eb4..02d0f3c33b 100644 --- a/okapi-api/src/test/scala/org/opencypher/okapi/api/types/TypeLawsTest.scala +++ b/okapi-api/src/test/scala/org/opencypher/okapi/api/types/TypeLawsTest.scala @@ -30,11 +30,12 @@ import cats.Monoid import cats.kernel.Eq import org.opencypher.okapi.api.graph.QualifiedGraphName import org.scalacheck.{Arbitrary, Gen} +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks -import org.scalatest.{FunSuite, Matchers} -import org.typelevel.discipline.scalatest.Discipline +import org.typelevel.discipline.scalatest.FunSpecDiscipline -class TypeLawsTest extends FunSuite with Matchers with ScalaCheckDrivenPropertyChecks with Discipline { +class TypeLawsTest extends AnyFunSpec with Matchers with ScalaCheckDrivenPropertyChecks with FunSpecDiscipline { def pickOne[T](gens: List[Gen[T]]): Gen[T] = for { i <- Gen.choose(0, gens.size - 1) diff --git a/okapi-neo4j-io-testing/build.gradle b/okapi-neo4j-io-testing/build.gradle index d1beb241df..eb6a523fcb 100644 --- a/okapi-neo4j-io-testing/build.gradle +++ b/okapi-neo4j-io-testing/build.gradle @@ -6,7 +6,9 @@ dependencies { api libs.neo4j.java.driver api libs.bouncycastle + api libs.testing.mockito.core api libs.testing.scala.scalatest + api libs.testing.scalatest.mockito api libs.testcontainers.neo4j } diff --git a/okapi-tck/src/main/scala/org/opencypher/okapi/tck/test/TCKFixture.scala b/okapi-tck/src/main/scala/org/opencypher/okapi/tck/test/TCKFixture.scala index 1aa896b338..68716a6f17 100644 --- a/okapi-tck/src/main/scala/org/opencypher/okapi/tck/test/TCKFixture.scala +++ b/okapi-tck/src/main/scala/org/opencypher/okapi/tck/test/TCKFixture.scala @@ -147,9 +147,9 @@ object ScenariosFor { object Tags { - object WhiteList extends Tag("WhiteList Scenario") + object WhiteList extends Tag("WhiteListScenario") - object BlackList extends Tag("BlackList Scenario") + object BlackList extends Tag("BlackListScenario") } diff --git a/okapi-testing/build.gradle b/okapi-testing/build.gradle index 39dc5aa4f4..b64544f141 100644 --- a/okapi-testing/build.gradle +++ b/okapi-testing/build.gradle @@ -7,9 +7,9 @@ dependencies { api libs.opencypher.frontend api libs.scala.typelevel.cats.core - api libs.testing.junit - api libs.testing.mockito.all + api libs.testing.mockito.core api libs.testing.scala.scalatest + api libs.testing.scalatest.mockito } // We ignore the license check here for unknown historic reasons. diff --git a/okapi-testing/src/main/scala/org/opencypher/okapi/testing/BaseTestSuite.scala b/okapi-testing/src/main/scala/org/opencypher/okapi/testing/BaseTestSuite.scala index 3884baf5f4..ddea5792a1 100644 --- a/okapi-testing/src/main/scala/org/opencypher/okapi/testing/BaseTestSuite.scala +++ b/okapi-testing/src/main/scala/org/opencypher/okapi/testing/BaseTestSuite.scala @@ -26,22 +26,21 @@ */ package org.opencypher.okapi.testing -import org.junit.runner.RunWith import org.mockito.Mockito.when import org.opencypher.okapi.api.graph.{GraphName, Namespace, QualifiedGraphName} import org.opencypher.okapi.api.io.PropertyGraphDataSource import org.opencypher.okapi.api.schema.PropertyGraphSchema import org.opencypher.okapi.impl.graph.QGNGenerator import org.scalactic.source -import org.scalatestplus.junit.JUnitRunner import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{FunSpec, Matchers, Tag} +import org.scalatest.Tag +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers import scala.collection.convert.DecorateAsJava import scala.util.Random -@RunWith(classOf[JUnitRunner]) -abstract class BaseTestSuite extends FunSpec with Matchers with MockitoSugar with DecorateAsJava { +abstract class BaseTestSuite extends AnyFunSpec with Matchers with MockitoSugar with DecorateAsJava { /* Shared test objects */ val testNamespace = Namespace("testNamespace") diff --git a/okapi-testing/src/main/scala/org/opencypher/okapi/testing/PGDSAcceptanceTest.scala b/okapi-testing/src/main/scala/org/opencypher/okapi/testing/PGDSAcceptanceTest.scala index 73d60c44cd..04c3838b69 100644 --- a/okapi-testing/src/main/scala/org/opencypher/okapi/testing/PGDSAcceptanceTest.scala +++ b/okapi-testing/src/main/scala/org/opencypher/okapi/testing/PGDSAcceptanceTest.scala @@ -49,16 +49,14 @@ trait PGDSAcceptanceTest[Session <: CypherSession, Graph <: PropertyGraph] { } case class Scenario( - override val name: String, + name: String, initGraphs: List[GraphName] = Nil - )(val test: TestContext => Unit) extends Tag(name) + )(val test: TestContext => Unit) abstract class TestContextFactory { self => - val tag: Tag = new Tag(self.toString) - def initializeContext(graphNames: List[GraphName]): TestContext = TestContext(initSession, initPgds(graphNames)) def initPgds(graphNames: List[GraphName]): PropertyGraphDataSource @@ -94,7 +92,7 @@ trait PGDSAcceptanceTest[Session <: CypherSession, Graph <: PropertyGraph] { def executeScenariosWithContext(scenarios: List[Scenario], contextFactory: TestContextFactory): Unit = { val scenarioTable = Table("Scenario", scenarios: _*) forAll(scenarioTable) { scenario => - test(s"[$contextFactory] ${scenario.name}", contextFactory.tag, scenario) { + test(s"[$contextFactory] ${scenario.name}") { val ctx: TestContext = contextFactory.initializeContext(scenario.initGraphs) Try(scenario.test(ctx)) match { case Success(_) => diff --git a/okapi-testing/src/test/scala/org/opencypher/okapi/testing/BagTest.scala b/okapi-testing/src/test/scala/org/opencypher/okapi/testing/BagTest.scala index 99da877bac..b9217def48 100644 --- a/okapi-testing/src/test/scala/org/opencypher/okapi/testing/BagTest.scala +++ b/okapi-testing/src/test/scala/org/opencypher/okapi/testing/BagTest.scala @@ -27,7 +27,6 @@ package org.opencypher.okapi.testing import org.opencypher.okapi.api.value.CypherValue.CypherMap -import org.scalatest.{FunSpec, Matchers} class BagTest extends BaseTestSuite { diff --git a/okapi-trees/build.gradle b/okapi-trees/build.gradle index a3c82de3f2..bca06973e5 100644 --- a/okapi-trees/build.gradle +++ b/okapi-trees/build.gradle @@ -2,6 +2,4 @@ description = 'Okapi Trees - Tree rewriting framework for Okapi' dependencies { api libs.scala.typelevel.cats.core - - testImplementation libs.testing.junit } diff --git a/okapi-trees/src/test/scala/org/opencypher/okapi/trees/TreeNodeTest.scala b/okapi-trees/src/test/scala/org/opencypher/okapi/trees/TreeNodeTest.scala index d9354057ea..5248636d74 100644 --- a/okapi-trees/src/test/scala/org/opencypher/okapi/trees/TreeNodeTest.scala +++ b/okapi-trees/src/test/scala/org/opencypher/okapi/trees/TreeNodeTest.scala @@ -27,12 +27,27 @@ package org.opencypher.okapi.trees import cats.data.NonEmptyList -import org.junit.runner.RunWith -import org.scalatestplus.junit.JUnitRunner -import org.scalatest.{FunSpec, Matchers} - -@RunWith(classOf[JUnitRunner]) -class TreeNodeTest extends FunSpec with Matchers { +import org.opencypher.okapi.trees.TreeNodeTest.Add +import org.opencypher.okapi.trees.TreeNodeTest.AddList +import org.opencypher.okapi.trees.TreeNodeTest.CalcExpr +import org.opencypher.okapi.trees.TreeNodeTest.Dummy +import org.opencypher.okapi.trees.TreeNodeTest.ListBeforeFixed +import org.opencypher.okapi.trees.TreeNodeTest.Multi +import org.opencypher.okapi.trees.TreeNodeTest.NoOp +import org.opencypher.okapi.trees.TreeNodeTest.Number +import org.opencypher.okapi.trees.TreeNodeTest.SimpleA +import org.opencypher.okapi.trees.TreeNodeTest.SimpleB +import org.opencypher.okapi.trees.TreeNodeTest.SimpleC +import org.opencypher.okapi.trees.TreeNodeTest.SimpleD +import org.opencypher.okapi.trees.TreeNodeTest.SimpleList +import org.scalatest.funspec.AnyFunSpec +import org.scalatest.matchers.should.Matchers + +import java.lang +import java.lang +import scala.collection.mutable + +class TreeNodeTest extends AnyFunSpec with Matchers { val calculation = Add(Number(5), Add(Number(4), Number(3))) @@ -185,60 +200,6 @@ class TreeNodeTest extends FunSpec with Matchers { calculation.withNewChildren(Array(calculation.left, calculation.right)) should be theSameInstanceAs calculation } - abstract class UnsupportedTree extends AbstractTreeNode[UnsupportedTree] - - case class Unsupported(elems: NonEmptyList[Object]) extends UnsupportedTree - - case object UnsupportedLeaf extends UnsupportedTree - - case class UnsupportedNode( - elems1: NonEmptyList[UnsupportedTree], - elems2: NonEmptyList[UnsupportedTree] - ) extends UnsupportedTree - - abstract class UnsupportedTree2 extends AbstractTreeNode[UnsupportedTree2] - - case object UnsupportedLeaf2 extends UnsupportedTree2 - - case class UnsupportedNode2(elems: NonEmptyList[UnsupportedTree2], elem: UnsupportedTree2) extends UnsupportedTree2 - - abstract class CalcExpr extends AbstractTreeNode[CalcExpr] { - def eval: Int - } - - case class Dummy( - print1: Option[String], - print2: List[String], - dontPrint1: Option[CalcExpr], - dontPrint2: List[CalcExpr] - ) extends CalcExpr { - def eval = 0 - } - - case class AddList( - dummy1: NonEmptyList[Int], - first: CalcExpr, - dummy2: Int, - remaining: NonEmptyList[CalcExpr], - dummy3: NonEmptyList[Object] - ) - extends CalcExpr { - def eval: Int = first.eval + remaining.map(_.eval).toList.sum - } - - case class Add(left: CalcExpr, right: CalcExpr) extends CalcExpr { - def eval: Int = left.eval + right.eval - } - - case class Number(v: Int) extends CalcExpr { - def eval: Int = v - } - - case class NoOp(in: CalcExpr) extends CalcExpr { - def eval: Int = in.eval - } - - it("can infer children for complex case classes") { val instance = Multi( NonEmptyList.one(1), @@ -298,6 +259,61 @@ class TreeNodeTest extends FunSpec with Matchers { """|Could not assign children [SimpleB] to parameters of SimpleList |Inferred constructor parameters: SimpleList(List(SimpleA))""".stripMargin) } +} + +object TreeNodeTest { + abstract class UnsupportedTree extends AbstractTreeNode[UnsupportedTree] + + case class Unsupported(elems: NonEmptyList[Object]) extends UnsupportedTree + + case object UnsupportedLeaf extends UnsupportedTree + + case class UnsupportedNode( + elems1: NonEmptyList[UnsupportedTree], + elems2: NonEmptyList[UnsupportedTree] + ) extends UnsupportedTree + + abstract class UnsupportedTree2 extends AbstractTreeNode[UnsupportedTree2] + + case object UnsupportedLeaf2 extends UnsupportedTree2 + + case class UnsupportedNode2(elems: NonEmptyList[UnsupportedTree2], elem: UnsupportedTree2) extends UnsupportedTree2 + + abstract class CalcExpr extends AbstractTreeNode[CalcExpr] { + def eval: Int + } + + case class Dummy( + print1: Option[String], + print2: List[String], + dontPrint1: Option[CalcExpr], + dontPrint2: List[CalcExpr] + ) extends CalcExpr { + def eval = 0 + } + + case class AddList( + dummy1: NonEmptyList[Int], + first: CalcExpr, + dummy2: Int, + remaining: NonEmptyList[CalcExpr], + dummy3: NonEmptyList[Object] + ) + extends CalcExpr { + def eval: Int = first.eval + remaining.map(_.eval).toList.sum + } + + case class Add(left: CalcExpr, right: CalcExpr) extends CalcExpr { + def eval: Int = left.eval + right.eval + } + + case class Number(v: Int) extends CalcExpr { + def eval: Int = v + } + + case class NoOp(in: CalcExpr) extends CalcExpr { + def eval: Int = in.eval + } abstract class ComplexExample extends AbstractTreeNode[ComplexExample] @@ -324,5 +340,4 @@ class TreeNodeTest extends FunSpec with Matchers { maybeC: Option[SimpleC], maybeD: Option[SimpleD] ) extends ComplexExample - -} +} \ No newline at end of file