From 6fad32f15f524759f9134a8f1573a052731071ad Mon Sep 17 00:00:00 2001 From: Nik Kozlov Date: Fri, 30 May 2025 16:35:24 +0200 Subject: [PATCH 1/2] Fix printing differing options in Rdf Validate --- .../jelly/cli/command/rdf/RdfValidate.scala | 4 ++-- .../command/rdf/util/StreamOptionsUtil.scala | 12 ++++++++++++ .../cli/command/rdf/RdfValidateSpec.scala | 18 ++++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 src/main/scala/eu/neverblink/jelly/cli/command/rdf/util/StreamOptionsUtil.scala diff --git a/src/main/scala/eu/neverblink/jelly/cli/command/rdf/RdfValidate.scala b/src/main/scala/eu/neverblink/jelly/cli/command/rdf/RdfValidate.scala index 72138d1..bed8fbb 100644 --- a/src/main/scala/eu/neverblink/jelly/cli/command/rdf/RdfValidate.scala +++ b/src/main/scala/eu/neverblink/jelly/cli/command/rdf/RdfValidate.scala @@ -123,8 +123,8 @@ object RdfValidate extends JellyCommand[RdfValidateOptions]: if streamOptions != o then throw CriticalException( s"Stream options do not match the expected options in $optionsFileName\n" + - s"Expected: $o\n" + - s"Actual: $streamOptions", + s"Expected: ${StreamOptionsUtil.prettyPrint(o)}\n" + + s"Actual: ${StreamOptionsUtil.prettyPrint(streamOptions)}", ) o } diff --git a/src/main/scala/eu/neverblink/jelly/cli/command/rdf/util/StreamOptionsUtil.scala b/src/main/scala/eu/neverblink/jelly/cli/command/rdf/util/StreamOptionsUtil.scala new file mode 100644 index 0000000..c137211 --- /dev/null +++ b/src/main/scala/eu/neverblink/jelly/cli/command/rdf/util/StreamOptionsUtil.scala @@ -0,0 +1,12 @@ +package eu.neverblink.jelly.cli.command.rdf.util + +import eu.neverblink.jelly.core.proto.google.v1 as google +import eu.neverblink.jelly.core.proto.v1.RdfStreamOptions + +object StreamOptionsUtil: + + def prettyPrint(streamOptions: RdfStreamOptions): String = { + val streamOptionsBytes = streamOptions.toByteArray + val googleStreamOptions = google.RdfStreamOptions.parseFrom(streamOptionsBytes) + return googleStreamOptions.toString + } diff --git a/src/test/scala/eu/neverblink/jelly/cli/command/rdf/RdfValidateSpec.scala b/src/test/scala/eu/neverblink/jelly/cli/command/rdf/RdfValidateSpec.scala index 12b4584..19c6b0f 100644 --- a/src/test/scala/eu/neverblink/jelly/cli/command/rdf/RdfValidateSpec.scala +++ b/src/test/scala/eu/neverblink/jelly/cli/command/rdf/RdfValidateSpec.scala @@ -431,6 +431,24 @@ class RdfValidateSpec extends AnyWordSpec, Matchers, TestFixtureHelper: } e.cause.get shouldBe a[CriticalException] e.cause.get.getMessage should include("Stream options do not match the expected options") + e.cause.get.getMessage should include("Stream options do not match the expected options") + e.cause.get.getMessage should include( + """Expected: stream_name: "Stream" + |physical_type: PHYSICAL_STREAM_TYPE_TRIPLES + |generalized_statements: true + |rdf_star: true + |max_name_table_size: 128 + |max_prefix_table_size: 16 + |max_datatype_table_size: 16 + |logical_type: LOGICAL_STREAM_TYPE_FLAT_TRIPLES + |version: 1""".stripMargin) + + e.cause.get.getMessage should include( + """Actual: physical_type: PHYSICAL_STREAM_TYPE_TRIPLES + |max_name_table_size: 4000 + |max_prefix_table_size: 150 + |max_datatype_table_size: 32 + |version: 1""".stripMargin) } } From 14e4849b9847fadbdc0b83ec1e0d05173ef4a727 Mon Sep 17 00:00:00 2001 From: Nik Kozlov Date: Fri, 30 May 2025 16:37:31 +0200 Subject: [PATCH 2/2] Reformat --- .../jelly/cli/command/rdf/util/StreamOptionsUtil.scala | 2 +- .../neverblink/jelly/cli/command/rdf/RdfValidateSpec.scala | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/scala/eu/neverblink/jelly/cli/command/rdf/util/StreamOptionsUtil.scala b/src/main/scala/eu/neverblink/jelly/cli/command/rdf/util/StreamOptionsUtil.scala index c137211..aa89c8d 100644 --- a/src/main/scala/eu/neverblink/jelly/cli/command/rdf/util/StreamOptionsUtil.scala +++ b/src/main/scala/eu/neverblink/jelly/cli/command/rdf/util/StreamOptionsUtil.scala @@ -4,7 +4,7 @@ import eu.neverblink.jelly.core.proto.google.v1 as google import eu.neverblink.jelly.core.proto.v1.RdfStreamOptions object StreamOptionsUtil: - + def prettyPrint(streamOptions: RdfStreamOptions): String = { val streamOptionsBytes = streamOptions.toByteArray val googleStreamOptions = google.RdfStreamOptions.parseFrom(streamOptionsBytes) diff --git a/src/test/scala/eu/neverblink/jelly/cli/command/rdf/RdfValidateSpec.scala b/src/test/scala/eu/neverblink/jelly/cli/command/rdf/RdfValidateSpec.scala index 19c6b0f..a9eb319 100644 --- a/src/test/scala/eu/neverblink/jelly/cli/command/rdf/RdfValidateSpec.scala +++ b/src/test/scala/eu/neverblink/jelly/cli/command/rdf/RdfValidateSpec.scala @@ -432,8 +432,7 @@ class RdfValidateSpec extends AnyWordSpec, Matchers, TestFixtureHelper: e.cause.get shouldBe a[CriticalException] e.cause.get.getMessage should include("Stream options do not match the expected options") e.cause.get.getMessage should include("Stream options do not match the expected options") - e.cause.get.getMessage should include( - """Expected: stream_name: "Stream" + e.cause.get.getMessage should include("""Expected: stream_name: "Stream" |physical_type: PHYSICAL_STREAM_TYPE_TRIPLES |generalized_statements: true |rdf_star: true @@ -443,8 +442,7 @@ class RdfValidateSpec extends AnyWordSpec, Matchers, TestFixtureHelper: |logical_type: LOGICAL_STREAM_TYPE_FLAT_TRIPLES |version: 1""".stripMargin) - e.cause.get.getMessage should include( - """Actual: physical_type: PHYSICAL_STREAM_TYPE_TRIPLES + e.cause.get.getMessage should include("""Actual: physical_type: PHYSICAL_STREAM_TYPE_TRIPLES |max_name_table_size: 4000 |max_prefix_table_size: 150 |max_datatype_table_size: 32