diff --git a/pom.xml b/pom.xml index 3329307ee..5905110ea 100644 --- a/pom.xml +++ b/pom.xml @@ -30,11 +30,13 @@ 4.7.2 1.13 0.10.0 - 5.7.0 + 7.20.1 + 8.25.1 2.3.3 2.2 1.7.0 5.7.0 + 2.37.0 3.8.1 3.2.0 3.2.1 @@ -47,7 +49,7 @@ 1.8 1.4 2.3.30 - 2.11.3 + 2.18.2 ${project.rootdir}/ASL-2-header.txt 11 11 @@ -122,14 +124,15 @@ - io.cucumber - cucumber-core - ${dep.cucumber.version} + net.javacrumbs.json-unit + json-unit-assertj + ${dep.json-unit-asserth.version} + test io.cucumber - cucumber-gherkin-vintage + cucumber-core ${dep.cucumber.version} @@ -182,7 +185,13 @@ com.fasterxml.jackson.dataformat jackson-dataformat-xml - ${dep.jackson-dataformat-xml.version} + ${dep.jackson.version} + + + + com.fasterxml.jackson.core + jackson-databind + ${dep.jackson.version} diff --git a/tools/grammar/pom.xml b/tools/grammar/pom.xml index 9756a0f40..20c496187 100644 --- a/tools/grammar/pom.xml +++ b/tools/grammar/pom.xml @@ -86,12 +86,6 @@ 2.17.0 - - io.cucumber - cucumber-gherkin-vintage - true - - diff --git a/tools/tck-api/src/main/scala/org/opencypher/tools/tck/api/CypherTCK.scala b/tools/tck-api/src/main/scala/org/opencypher/tools/tck/api/CypherTCK.scala index 40fcc2c9e..d42beeb43 100644 --- a/tools/tck-api/src/main/scala/org/opencypher/tools/tck/api/CypherTCK.scala +++ b/tools/tck-api/src/main/scala/org/opencypher/tools/tck/api/CypherTCK.scala @@ -29,8 +29,8 @@ package org.opencypher.tools.tck.api import io.cucumber.core.gherkin import io.cucumber.core.gherkin.DataTableArgument -import io.cucumber.core.gherkin.DocStringArgument -import io.cucumber.core.gherkin.vintage.GherkinVintageFeatureParser +import io.cucumber.plugin.event.DocStringArgument +import io.cucumber.core.gherkin.messages.GherkinMessagesFeatureParser import org.opencypher.tools.tck.SideEffectOps.Diff import org.opencypher.tools.tck._ import org.opencypher.tools.tck.api.events.TCKEvents @@ -46,6 +46,7 @@ import java.net.URI import java.nio.charset.StandardCharsets import java.nio.file._ import java.util +import java.util.UUID import scala.annotation.tailrec import scala.collection.mutable.ListBuffer import scala.jdk.CollectionConverters._ @@ -58,7 +59,7 @@ object CypherTCK { val featuresPath = "/features" val featureSuffix = ".feature" - private lazy val parser = new GherkinVintageFeatureParser() + private lazy val parser = new GherkinMessagesFeatureParser() /** * Provides all the scenarios in the openCypher TCK. @@ -142,7 +143,7 @@ object CypherTCK { def apply(pickle: NameExtractedPickle): PickleGroupingKey = PickleGroupingKey(pickle.pickle.getKeyword, pickle.nameAndNumber) } - Try(parser.parse(featureFile.toUri, featureString, null)) match { + Try(parser.parse(featureFile.toUri, featureString, () => UUID.randomUUID)) match { case Success(featureOption) => if(featureOption.isPresent) { val feature = featureOption.get() @@ -156,7 +157,7 @@ object CypherTCK { case (_, included) => included.sortBy(_.pickle.getLocation.getLine) } - val featureName = feature.getName + val featureName = feature.getName.orElse("N/A") val scenarios = includedGroupedAndSorted.flatMap { case (PickleGroupingKey("Scenario Outline", _), pickles) => pickles.zipWithIndex.map { @@ -171,7 +172,7 @@ object CypherTCK { } else Feature(Seq[Scenario]()) case Failure(error) => - throw InvalidFeatureFormatException(s"Could not parse feature from ${featureFile.toAbsolutePath.toString}: ${error.getMessage}") + throw InvalidFeatureFormatException(s"Could not parse feature from ${featureFile.toAbsolutePath.toString}: ${error.getMessage}", error) } } @@ -470,7 +471,7 @@ case class ExpectError(errorType: String, phase: String, detail: String, source: } } -case class InvalidFeatureFormatException(message: String) extends RuntimeException(message) +case class InvalidFeatureFormatException(message: String, cause: Throwable = null) extends RuntimeException(message, cause) sealed trait QueryType diff --git a/tools/tck-api/src/main/scala/org/opencypher/tools/tck/api/PickleHelpers.scala b/tools/tck-api/src/main/scala/org/opencypher/tools/tck/api/PickleHelpers.scala index 65f9ec490..6946de1e7 100644 --- a/tools/tck-api/src/main/scala/org/opencypher/tools/tck/api/PickleHelpers.scala +++ b/tools/tck-api/src/main/scala/org/opencypher/tools/tck/api/PickleHelpers.scala @@ -60,7 +60,7 @@ case object PickleStep { case class PickleLocation(line: Int, column: Int) case object PickleLocation { - def apply(location: io.cucumber.core.gherkin.Location): PickleLocation = { + def apply(location: io.cucumber.plugin.event.Location): PickleLocation = { PickleLocation(location.getLine, location.getColumn) } } diff --git a/tools/tck-api/src/test/scala/org/opencypher/tools/tck/api/ScenarioTest.scala b/tools/tck-api/src/test/scala/org/opencypher/tools/tck/api/ScenarioTest.scala index f614b4f61..0e6d59fa1 100644 --- a/tools/tck-api/src/test/scala/org/opencypher/tools/tck/api/ScenarioTest.scala +++ b/tools/tck-api/src/test/scala/org/opencypher/tools/tck/api/ScenarioTest.scala @@ -27,9 +27,10 @@ */ package org.opencypher.tools.tck.api +import io.cucumber.plugin.event.Location + import java.net.URI import java.util - import org.scalatest.funsuite.AnyFunSuite import org.scalatest.matchers.should.Matchers @@ -39,12 +40,8 @@ class ScenarioTest extends AnyFunSuite with Matchers { val noPickleSteps = new util.ArrayList[io.cucumber.core.gherkin.Step]() val noPickleTags = new util.ArrayList[String]() - def location(line: Int, column: Int): io.cucumber.core.gherkin.Location = { - new io.cucumber.core.gherkin.Location() { - override def getLine: Int = line - - override def getColumn: Int = column - } + def location(line: Int, column: Int): io.cucumber.plugin.event.Location = { + new io.cucumber.plugin.event.Location(line, column) } def stringArgument(text: String, line: Int): io.cucumber.core.gherkin.DocStringArgument = { @@ -54,6 +51,8 @@ class ScenarioTest extends AnyFunSuite with Matchers { override def getContentType: String = "" override def getLine: Int = line + + override def getMediaType: String = "" } } @@ -63,15 +62,17 @@ class ScenarioTest extends AnyFunSuite with Matchers { override def getArgument: io.cucumber.core.gherkin.Argument = argument - override def getKeyWord: String = keyWord + override def getKeyword: String = keyWord override def getType: io.cucumber.core.gherkin.StepType = stepType - override def getPreviousGivenWhenThenKeyWord: String = "" + override def getPreviousGivenWhenThenKeyword: String = "" override def getText: String = text override def getId: String = id + + override def getLocation: Location = new Location(0, 0) } } @@ -94,9 +95,9 @@ class ScenarioTest extends AnyFunSuite with Matchers { override def getName: String = name - override def getLocation: io.cucumber.core.gherkin.Location = loc + override def getLocation: io.cucumber.plugin.event.Location = loc - override def getScenarioLocation: io.cucumber.core.gherkin.Location = loc + override def getScenarioLocation: io.cucumber.plugin.event.Location = loc override def getSteps: util.List[io.cucumber.core.gherkin.Step] = steps diff --git a/tools/tck-api/src/test/scala/org/opencypher/tools/tck/api/groups/GroupTest.scala b/tools/tck-api/src/test/scala/org/opencypher/tools/tck/api/groups/GroupTest.scala index 2a32e949b..de7e17078 100644 --- a/tools/tck-api/src/test/scala/org/opencypher/tools/tck/api/groups/GroupTest.scala +++ b/tools/tck-api/src/test/scala/org/opencypher/tools/tck/api/groups/GroupTest.scala @@ -27,10 +27,12 @@ */ package org.opencypher.tools.tck.api.groups +import io.cucumber.core.gherkin.DocStringArgument + import java.net.URI import java.util - import io.cucumber.core.gherkin.Pickle +import io.cucumber.plugin.event.Location import org.opencypher.tools.tck.api.Dummy import org.opencypher.tools.tck.api.Measure import org.opencypher.tools.tck.api.Scenario @@ -46,17 +48,9 @@ trait GroupTest extends Matchers { override val getName: String = "name" - override val getLocation: io.cucumber.core.gherkin.Location = new io.cucumber.core.gherkin.Location() { - override val getLine: Int = 1 - - override val getColumn: Int = 1 - } - - override val getScenarioLocation: io.cucumber.core.gherkin.Location = new io.cucumber.core.gherkin.Location() { - override val getLine: Int = 1 + override val getLocation: io.cucumber.plugin.event.Location = new io.cucumber.plugin.event.Location(1,1) - override val getColumn: Int = 1 - } + override val getScenarioLocation: io.cucumber.plugin.event.Location = new io.cucumber.plugin.event.Location(1,1) override val getSteps: util.List[io.cucumber.core.gherkin.Step] = new util.ArrayList[io.cucumber.core.gherkin.Step]() @@ -70,23 +64,27 @@ trait GroupTest extends Matchers { val dummyPickleStep: io.cucumber.core.gherkin.Step = new io.cucumber.core.gherkin.Step() { override val getLine: Int = 1 - override val getArgument: io.cucumber.core.gherkin.Argument = new io.cucumber.core.gherkin.DocStringArgument() { - override val getContent: String = "text" + override val getArgument: io.cucumber.core.gherkin.Argument = new DocStringArgument { + override def getContent: String = "text" - override val getContentType: String = "" + override def getContentType: String = "" - override val getLine: Int = 1 + override def getMediaType: String = "" + + override def getLine: Int = 1 } - override val getKeyWord: String = "keyWord" + override val getKeyword: String = "keyWord" override val getType: io.cucumber.core.gherkin.StepType = io.cucumber.core.gherkin.StepType.GIVEN - override val getPreviousGivenWhenThenKeyWord: String = "" + override val getPreviousGivenWhenThenKeyword: String = "" override val getText: String = "xyz" override val getId: String = "id" + + override def getLocation: Location = new Location(1, 1) } val dummySteps: List[Step] = List[Step](Dummy(dummyPickleStep), Measure(dummyPickleStep)) diff --git a/tools/tck-inspection/src/test/scala/org/opencypher/tools/tck/inspection/browser/cli/CountScenariosTest.scala b/tools/tck-inspection/src/test/scala/org/opencypher/tools/tck/inspection/browser/cli/CountScenariosTest.scala index 3ed4c0229..a287d203e 100644 --- a/tools/tck-inspection/src/test/scala/org/opencypher/tools/tck/inspection/browser/cli/CountScenariosTest.scala +++ b/tools/tck-inspection/src/test/scala/org/opencypher/tools/tck/inspection/browser/cli/CountScenariosTest.scala @@ -27,9 +27,10 @@ */ package org.opencypher.tools.tck.inspection.browser.cli +import io.cucumber.plugin.event.Location + import java.net.URI import java.util - import org.opencypher.tools.tck.api.CypherTCK import org.opencypher.tools.tck.api.Dummy import org.opencypher.tools.tck.api.Measure @@ -48,17 +49,9 @@ class CountScenariosTest extends AnyFunSuite with Matchers { override def getName: String = "name" - override def getLocation: io.cucumber.core.gherkin.Location = new io.cucumber.core.gherkin.Location() { - override def getLine: Int = 1 - - override def getColumn: Int = 1 - } - - override def getScenarioLocation: io.cucumber.core.gherkin.Location = new io.cucumber.core.gherkin.Location() { - override def getLine: Int = 1 + override def getLocation: io.cucumber.plugin.event.Location = new io.cucumber.plugin.event.Location(1,1) - override def getColumn: Int = 1 - } + override def getScenarioLocation: io.cucumber.plugin.event.Location = new io.cucumber.plugin.event.Location(1,1) override def getSteps: util.List[io.cucumber.core.gherkin.Step] = new util.ArrayList[io.cucumber.core.gherkin.Step]() @@ -72,23 +65,27 @@ class CountScenariosTest extends AnyFunSuite with Matchers { private def namedDummyPickleStep(name: String): io.cucumber.core.gherkin.Step = new io.cucumber.core.gherkin.Step() { override def getLine: Int = 1 - override def getArgument: io.cucumber.core.gherkin.Argument = new io.cucumber.core.gherkin.DocStringArgument() { + override def getArgument: io.cucumber.core.gherkin.Argument = new io.cucumber.core.gherkin.DocStringArgument { override def getContent: String = "text" override def getContentType: String = "" override def getLine: Int = 1 + + override def getMediaType: String = "" } - override def getKeyWord: String = "keyWord" + override def getKeyword: String = "keyWord" override def getType: io.cucumber.core.gherkin.StepType = io.cucumber.core.gherkin.StepType.GIVEN - override def getPreviousGivenWhenThenKeyWord: String = "" + override def getPreviousGivenWhenThenKeyword: String = "" override def getText: String = name override def getId: String = "id" + + override def getLocation: Location = new Location(1,1) } private val dummyPickleStep = namedDummyPickleStep("") diff --git a/tools/tck-inspection/src/test/scala/org/opencypher/tools/tck/inspection/diff/GroupDiffTest.scala b/tools/tck-inspection/src/test/scala/org/opencypher/tools/tck/inspection/diff/GroupDiffTest.scala index 47262bed0..d8f220a91 100644 --- a/tools/tck-inspection/src/test/scala/org/opencypher/tools/tck/inspection/diff/GroupDiffTest.scala +++ b/tools/tck-inspection/src/test/scala/org/opencypher/tools/tck/inspection/diff/GroupDiffTest.scala @@ -27,9 +27,10 @@ */ package org.opencypher.tools.tck.inspection.diff +import io.cucumber.plugin.event.Location + import java.net.URI import java.util - import org.opencypher.tools.tck.api.Dummy import org.opencypher.tools.tck.api.Measure import org.opencypher.tools.tck.api.Scenario @@ -46,17 +47,9 @@ class GroupDiffTest extends AnyFunSuite with Matchers { override def getName: String = "name" - override def getLocation: io.cucumber.core.gherkin.Location = new io.cucumber.core.gherkin.Location() { - override def getLine: Int = 1 - - override def getColumn: Int = 1 - } - - override def getScenarioLocation: io.cucumber.core.gherkin.Location = new io.cucumber.core.gherkin.Location() { - override def getLine: Int = 1 + override def getLocation: io.cucumber.plugin.event.Location = new io.cucumber.plugin.event.Location(1,1) - override def getColumn: Int = 1 - } + override def getScenarioLocation: io.cucumber.plugin.event.Location = new io.cucumber.plugin.event.Location(1,1) override def getSteps: util.List[io.cucumber.core.gherkin.Step] = new util.ArrayList[io.cucumber.core.gherkin.Step]() @@ -70,23 +63,27 @@ class GroupDiffTest extends AnyFunSuite with Matchers { private def namedDummyPickleStep(name: String): io.cucumber.core.gherkin.Step = new io.cucumber.core.gherkin.Step() { override def getLine: Int = 1 - override def getArgument: io.cucumber.core.gherkin.Argument = new io.cucumber.core.gherkin.DocStringArgument() { + override def getArgument: io.cucumber.core.gherkin.Argument = new io.cucumber.core.gherkin.DocStringArgument { override def getContent: String = "text" override def getContentType: String = "" override def getLine: Int = 1 + + override def getMediaType: String = "" } - override def getKeyWord: String = "keyWord" + override def getKeyword: String = "keyWord" override def getType: io.cucumber.core.gherkin.StepType = io.cucumber.core.gherkin.StepType.GIVEN - override def getPreviousGivenWhenThenKeyWord: String = "" + override def getPreviousGivenWhenThenKeyword: String = "" override def getText: String = name override def getId: String = "id" + + override def getLocation: Location = new Location(1,1) } private val dummyPickleStep = namedDummyPickleStep("") diff --git a/tools/tck-inspection/src/test/scala/org/opencypher/tools/tck/inspection/diff/ScenarioDiffTest.scala b/tools/tck-inspection/src/test/scala/org/opencypher/tools/tck/inspection/diff/ScenarioDiffTest.scala index b935a4518..f121d4a7d 100644 --- a/tools/tck-inspection/src/test/scala/org/opencypher/tools/tck/inspection/diff/ScenarioDiffTest.scala +++ b/tools/tck-inspection/src/test/scala/org/opencypher/tools/tck/inspection/diff/ScenarioDiffTest.scala @@ -27,9 +27,10 @@ */ package org.opencypher.tools.tck.inspection.diff +import io.cucumber.plugin.event.Location + import java.net.URI import java.util - import org.opencypher.tools.tck.api.Dummy import org.opencypher.tools.tck.api.Measure import org.opencypher.tools.tck.api.Scenario @@ -44,12 +45,8 @@ class ScenarioDiffTest extends AnyFunSuite with Matchers { val noPickleSteps = new util.ArrayList[io.cucumber.core.gherkin.Step]() val noPickleTags = new util.ArrayList[String]() - def location(line: Int, column: Int): io.cucumber.core.gherkin.Location = { - new io.cucumber.core.gherkin.Location() { - override def getLine: Int = line - - override def getColumn: Int = column - } + def location(line: Int, column: Int): io.cucumber.plugin.event.Location = { + new io.cucumber.plugin.event.Location(line,column) } def stringArgument(text: String, line: Int): io.cucumber.core.gherkin.DocStringArgument = { @@ -59,6 +56,8 @@ class ScenarioDiffTest extends AnyFunSuite with Matchers { override def getContentType: String = "" override def getLine: Int = line + + override def getMediaType: String = "" } } @@ -68,15 +67,17 @@ class ScenarioDiffTest extends AnyFunSuite with Matchers { override def getArgument: io.cucumber.core.gherkin.Argument = argument - override def getKeyWord: String = keyWord + override def getKeyword: String = keyWord override def getType: io.cucumber.core.gherkin.StepType = stepType - override def getPreviousGivenWhenThenKeyWord: String = "" + override def getPreviousGivenWhenThenKeyword: String = "" override def getText: String = text override def getId: String = id + + override def getLocation: Location = new Location(line, 1) } } @@ -99,9 +100,9 @@ class ScenarioDiffTest extends AnyFunSuite with Matchers { override def getName: String = name - override def getLocation: io.cucumber.core.gherkin.Location = loc + override def getLocation: io.cucumber.plugin.event.Location = loc - override def getScenarioLocation: io.cucumber.core.gherkin.Location = loc + override def getScenarioLocation: io.cucumber.plugin.event.Location = loc override def getSteps: util.List[io.cucumber.core.gherkin.Step] = steps diff --git a/tools/tck-inspection/src/test/scala/org/opencypher/tools/tck/inspection/diff/TckTreeDiffTest.scala b/tools/tck-inspection/src/test/scala/org/opencypher/tools/tck/inspection/diff/TckTreeDiffTest.scala index a9b4b24cd..e15d5ab5d 100644 --- a/tools/tck-inspection/src/test/scala/org/opencypher/tools/tck/inspection/diff/TckTreeDiffTest.scala +++ b/tools/tck-inspection/src/test/scala/org/opencypher/tools/tck/inspection/diff/TckTreeDiffTest.scala @@ -27,9 +27,10 @@ */ package org.opencypher.tools.tck.inspection.diff +import io.cucumber.plugin.event.Location + import java.net.URI import java.util - import org.opencypher.tools.tck.api.Dummy import org.opencypher.tools.tck.api.Measure import org.opencypher.tools.tck.api.Scenario @@ -54,17 +55,9 @@ class TckTreeDiffTest extends AnyFunSuite with Matchers { override def getName: String = "name" - override def getLocation: io.cucumber.core.gherkin.Location = new io.cucumber.core.gherkin.Location() { - override def getLine: Int = 1 - - override def getColumn: Int = 1 - } - - override def getScenarioLocation: io.cucumber.core.gherkin.Location = new io.cucumber.core.gherkin.Location() { - override def getLine: Int = 1 + override def getLocation: io.cucumber.plugin.event.Location = new io.cucumber.plugin.event.Location(1,1) - override def getColumn: Int = 1 - } + override def getScenarioLocation: io.cucumber.plugin.event.Location = new io.cucumber.plugin.event.Location(1,1) override def getSteps: util.List[io.cucumber.core.gherkin.Step] = new util.ArrayList[io.cucumber.core.gherkin.Step]() @@ -84,17 +77,21 @@ class TckTreeDiffTest extends AnyFunSuite with Matchers { override def getContentType: String = "" override def getLine: Int = 1 + + override def getMediaType: String = "" } - override def getKeyWord: String = "keyWord" + override def getKeyword: String = "keyWord" override def getType: io.cucumber.core.gherkin.StepType = io.cucumber.core.gherkin.StepType.GIVEN - override def getPreviousGivenWhenThenKeyWord: String = "" + override def getPreviousGivenWhenThenKeyword: String = "" override def getText: String = name override def getId: String = "id" + + override def getLocation: Location = new Location(1,1) } private val dummyPickleStep = namedDummyPickleStep("") diff --git a/tools/tck-integrity-tests/pom.xml b/tools/tck-integrity-tests/pom.xml index 2ed0c60ad..9457c06af 100644 --- a/tools/tck-integrity-tests/pom.xml +++ b/tools/tck-integrity-tests/pom.xml @@ -115,7 +115,7 @@ io.cucumber cucumber-scala_${scala.binary.version} - ${dep.cucumber.version} + ${dep.cucumber-scala.version} test diff --git a/tools/tck-reporting/pom.xml b/tools/tck-reporting/pom.xml index 7a548826e..84dabf419 100644 --- a/tools/tck-reporting/pom.xml +++ b/tools/tck-reporting/pom.xml @@ -73,6 +73,18 @@ junit-vintage-engine test + + + net.javacrumbs.json-unit + json-unit-assertj + test + + + + com.fasterxml.jackson.core + jackson-databind + test + diff --git a/tools/tck-reporting/src/main/java/org/opencypher/tools/tck/reporting/cucumber/CucumberReportAdapter.java b/tools/tck-reporting/src/main/java/org/opencypher/tools/tck/reporting/cucumber/CucumberReportAdapter.java index 3f9314ad7..7f0430f2e 100644 --- a/tools/tck-reporting/src/main/java/org/opencypher/tools/tck/reporting/cucumber/CucumberReportAdapter.java +++ b/tools/tck-reporting/src/main/java/org/opencypher/tools/tck/reporting/cucumber/CucumberReportAdapter.java @@ -29,13 +29,15 @@ import io.cucumber.core.options.CucumberPropertiesParser; import io.cucumber.core.options.PluginOption; -import io.cucumber.core.plugin.JSONFormatter; +import io.cucumber.core.plugin.JsonFormatter; import io.cucumber.plugin.EventListener; import io.cucumber.plugin.event.*; import io.cucumber.core.options.RuntimeOptions; +import java.io.FileOutputStream; import java.io.FileWriter; import java.io.IOException; +import java.io.OutputStream; import java.net.URI; import java.time.Duration; import java.time.Instant; @@ -83,7 +85,7 @@ public void beforeAll(ExtensionContext context) { @Override public void afterAll(ExtensionContext context) throws Exception { - bus.handle(new TestRunFinished(Instant.now())); + bus.handle(new TestRunFinished(Instant.now(), new Result(Status.UNDEFINED, Duration.ofSeconds(1), null))); output.close(); } @@ -91,19 +93,19 @@ private void initCucumberPlugins() { Map properties = System.getProperties().entrySet().stream() .collect(Collectors.toMap(e -> (String) e.getKey(), e -> (String) e.getValue())); RuntimeOptions options = new CucumberPropertiesParser().parse(properties).build(); - Appendable appendable = options.plugins().stream() + final var appendable = options.plugins().stream() .filter(PluginOption.class::isInstance) .map(PluginOption.class::cast) - .filter(pluginOption -> pluginOption.pluginClass() == JSONFormatter.class) + .filter(pluginOption -> pluginOption.pluginClass() == JsonFormatter.class) .findFirst() - .map(pluginOption -> { + .map( pluginOption -> { try { - return (Appendable) new FileWriter(pluginOption.argument()); + return new FileOutputStream(pluginOption.argument()); } catch (IOException e) { throw new IllegalStateException("File " + pluginOption.argument() + " not found"); } }).orElse(System.out); - EventListener eventListener = new JSONFormatter(appendable); + EventListener eventListener = new JsonFormatter(appendable); eventListener.setEventPublisher(bus); } diff --git a/tools/tck-reporting/src/main/java/org/opencypher/tools/tck/reporting/cucumber/model/TCKTestCase.java b/tools/tck-reporting/src/main/java/org/opencypher/tools/tck/reporting/cucumber/model/TCKTestCase.java index 38188abae..34b4c1de2 100644 --- a/tools/tck-reporting/src/main/java/org/opencypher/tools/tck/reporting/cucumber/model/TCKTestCase.java +++ b/tools/tck-reporting/src/main/java/org/opencypher/tools/tck/reporting/cucumber/model/TCKTestCase.java @@ -28,6 +28,7 @@ package org.opencypher.tools.tck.reporting.cucumber.model; import io.cucumber.core.gherkin.Pickle; +import io.cucumber.plugin.event.Location; import io.cucumber.plugin.event.TestCase; import io.cucumber.plugin.event.TestStep; @@ -86,4 +87,9 @@ public URI getUri() { public UUID getId() { return UUID.nameUUIDFromBytes(pickle.getId().getBytes()); } + + @Override + public Location getLocation() { + return pickle.getLocation(); + } } diff --git a/tools/tck-reporting/src/main/java/org/opencypher/tools/tck/reporting/cucumber/model/TCKTestStep.java b/tools/tck-reporting/src/main/java/org/opencypher/tools/tck/reporting/cucumber/model/TCKTestStep.java index ed355cee9..48fe0a915 100644 --- a/tools/tck-reporting/src/main/java/org/opencypher/tools/tck/reporting/cucumber/model/TCKTestStep.java +++ b/tools/tck-reporting/src/main/java/org/opencypher/tools/tck/reporting/cucumber/model/TCKTestStep.java @@ -29,16 +29,19 @@ import io.cucumber.core.gherkin.Step; import io.cucumber.plugin.event.Argument; +import io.cucumber.plugin.event.Location; import io.cucumber.plugin.event.PickleStepTestStep; import io.cucumber.plugin.event.StepArgument; import java.net.URI; import java.util.ArrayList; import java.util.List; +import java.util.UUID; public class TCKTestStep implements PickleStepTestStep { private Step step; private URI uri; + private final UUID id = UUID.randomUUID(); public TCKTestStep(Step step, URI uri) { this.step = step; @@ -88,8 +91,8 @@ public StepArgument getArgument() { } @Override - public String getKeyWord() { - return step.getKeyWord(); + public String getKeyword() { + return step.getKeyword(); } @Override @@ -101,6 +104,11 @@ public String getText() { public int getLine() { return step.getLine(); } + + @Override + public Location getLocation() { + return step.getLocation(); + } }; } @@ -108,4 +116,9 @@ public int getLine() { public String getCodeLocation() { return ""; } + + @Override + public UUID getId() { + return id; + } } diff --git a/tools/tck-reporting/src/test/java/org/opencypher/tools/tck/reporting/cucumber/ReportValidator.java b/tools/tck-reporting/src/test/java/org/opencypher/tools/tck/reporting/cucumber/ReportValidator.java index 019d43c94..fb5023f2d 100644 --- a/tools/tck-reporting/src/test/java/org/opencypher/tools/tck/reporting/cucumber/ReportValidator.java +++ b/tools/tck-reporting/src/test/java/org/opencypher/tools/tck/reporting/cucumber/ReportValidator.java @@ -28,6 +28,7 @@ package org.opencypher.tools.tck.reporting.cucumber; import static java.nio.file.Files.readAllBytes; +import static net.javacrumbs.jsonunit.assertj.JsonAssertions.assertThatJson; import static org.junit.jupiter.api.Assertions.assertEquals; import java.nio.file.Files; @@ -51,17 +52,6 @@ public void afterAll(ExtensionContext extensionContext) throws Exception { String expected = CucumberReportAdapterTest.getResource("expected.json"); String actual = new String(readAllBytes(cucumberReport)); - assertEquals( - ignoreTimeAndDuration(expected), - ignoreTimeAndDuration(actual)); - } - - /** - * duration 0 == no duration. See `cucumber.runtime.formatter.JSONFormatter` - */ - private String ignoreTimeAndDuration(String report) { - return report. - replaceAll("\n\\s*\"duration\":\\s*\\d+\\s*,", ""). - replaceAll("\n\\s*\"start_timestamp\":\\s*\"[\\w:.-]*\"\\s*,", ""); + assertThatJson(actual).isEqualTo(expected); } } diff --git a/tools/tck-reporting/src/test/resources/org/opencypher/tools/tck/reporting/cucumber/expected.json b/tools/tck-reporting/src/test/resources/org/opencypher/tools/tck/reporting/cucumber/expected.json index 5a6524a18..b14c61d5c 100644 --- a/tools/tck-reporting/src/test/resources/org/opencypher/tools/tck/reporting/cucumber/expected.json +++ b/tools/tck-reporting/src/test/resources/org/opencypher/tools/tck/reporting/cucumber/expected.json @@ -9,9 +9,11 @@ "id": "foo;return-literal", "type": "scenario", "keyword": "Scenario", + "start_timestamp": "${json-unit.any-string}", "steps": [ { "result": { + "duration": "${json-unit.any-number}", "status": "passed" }, "line": 32, @@ -26,6 +28,7 @@ "Producing some output 1\n" ], "result": { + "duration": "${json-unit.any-number}", "status": "passed" }, "line": 33, @@ -41,6 +44,7 @@ }, { "result": { + "duration": "${json-unit.any-number}", "status": "passed" }, "line": 37, @@ -67,6 +71,7 @@ "+labels: 0\n-labels: 0\n+nodes: 0\n-nodes: 0\n+properties: 0\n-properties: 0\n+relationships: 0\n-relationships: 0" ], "result": { + "duration": "${json-unit.any-number}", "status": "passed" }, "line": 40, @@ -85,9 +90,11 @@ "id": "foo;fail", "type": "scenario", "keyword": "Scenario", + "start_timestamp": "${json-unit.any-string}", "steps": [ { "result": { + "duration": "${json-unit.any-number}", "status": "passed" }, "line": 43, @@ -99,6 +106,7 @@ }, { "result": { + "duration": "${json-unit.any-number}", "status": "passed" }, "line": 44, @@ -114,6 +122,7 @@ }, { "result": { + "duration": "${json-unit.any-number}", "status": "passed" }, "line": 48, @@ -128,6 +137,7 @@ "+labels: 0\n-labels: 0\n+nodes: 0\n-nodes: 0\n+properties: 0\n-properties: 0\n+relationships: 0\n-relationships: 0" ], "result": { + "duration": "${json-unit.any-number}", "status": "passed" }, "line": 48, @@ -146,9 +156,11 @@ "id": "foo;outline-test;;2", "type": "scenario", "keyword": "Scenario Outline", + "start_timestamp": "${json-unit.any-string}", "steps": [ { "result": { + "duration": "${json-unit.any-number}", "status": "passed" }, "line": 51, @@ -163,6 +175,7 @@ "Producing some output 1\n" ], "result": { + "duration": "${json-unit.any-number}", "status": "passed" }, "line": 52, @@ -178,6 +191,7 @@ }, { "result": { + "duration": "${json-unit.any-number}", "status": "passed" }, "line": 56, @@ -204,6 +218,7 @@ "+labels: 0\n-labels: 0\n+nodes: 0\n-nodes: 0\n+properties: 0\n-properties: 0\n+relationships: 0\n-relationships: 0" ], "result": { + "duration": "${json-unit.any-number}", "status": "passed" }, "line": 59, @@ -222,9 +237,11 @@ "id": "foo;outline-test;;3", "type": "scenario", "keyword": "Scenario Outline", + "start_timestamp": "${json-unit.any-string}", "steps": [ { "result": { + "duration": "${json-unit.any-number}", "status": "passed" }, "line": 51, @@ -239,6 +256,7 @@ "Producing some output 2\n" ], "result": { + "duration": "${json-unit.any-number}", "status": "passed" }, "line": 52, @@ -254,6 +272,7 @@ }, { "result": { + "duration": "${json-unit.any-number}", "status": "passed" }, "line": 56, @@ -280,6 +299,7 @@ "+labels: 0\n-labels: 0\n+nodes: 0\n-nodes: 0\n+properties: 0\n-properties: 0\n+relationships: 0\n-relationships: 0" ], "result": { + "duration": "${json-unit.any-number}", "status": "passed" }, "line": 59, @@ -298,9 +318,11 @@ "id": "foo;outline-test;;4", "type": "scenario", "keyword": "Scenario Outline", + "start_timestamp": "${json-unit.any-string}", "steps": [ { "result": { + "duration": "${json-unit.any-number}", "status": "passed" }, "line": 51, @@ -315,6 +337,7 @@ "Producing some output 3\n" ], "result": { + "duration": "${json-unit.any-number}", "status": "passed" }, "line": 52, @@ -330,6 +353,7 @@ }, { "result": { + "duration": "${json-unit.any-number}", "status": "passed" }, "line": 56, @@ -356,6 +380,7 @@ "+labels: 0\n-labels: 0\n+nodes: 0\n-nodes: 0\n+properties: 0\n-properties: 0\n+relationships: 0\n-relationships: 0" ], "result": { + "duration": "${json-unit.any-number}", "status": "passed" }, "line": 59,