Skip to content

Commit 155a5be

Browse files
Add some more tests
1 parent 68e153b commit 155a5be

2 files changed

Lines changed: 21 additions & 10 deletions

File tree

‎src/main/scala/eu/neverblink/jelly/cli/command/rdf/RdfFromJelly.scala‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ object RdfFromJelly extends JellyCommand[RdfFromJellyOptions]:
9393

9494
/** This method reads the Jelly file, rewrites it to Jelly text and writes it to some output
9595
* stream
96-
*
9796
* @param inputStream
9897
* InputStream
9998
* @param outputStream

‎src/test/scala/eu/neverblink/jelly/cli/command/RdfFromJellySpec.scala‎

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ class RdfFromJellySpec extends AnyWordSpec with Matchers with CleanUpAfterTest:
3131
"input stream to output stream" in {
3232
DataGenHelper.generateJellyInputStream(3)
3333
val nQuadString = DataGenHelper.generateNQuadString(3)
34-
val (out, err) = RdfFromJelly.runTestCommand(List("rdf", "from-jelly"))
34+
val (out, err) = RdfFromJelly.runTestCommand(
35+
List("rdf", "from-jelly", "--out-format", RdfFormatOptions.NQuads.cliOption),
36+
)
3537
val sortedOut = out.split("\n").map(_.trim).sorted
3638
val sortedQuads = nQuadString.split("\n").map(_.trim).sorted
3739
sortedOut should contain theSameElementsAs sortedQuads
@@ -66,25 +68,35 @@ class RdfFromJellySpec extends AnyWordSpec with Matchers with CleanUpAfterTest:
6668
}
6769
}
6870
"handle conversion of Jelly binary to text" when {
69-
"a file to file" in {
71+
"a file to output stream" in {
7072
val jellyFile = DataGenHelper.generateJellyFile(3)
7173
val jellyData = DataGenHelper.generateJellyInputStream(3)
72-
val outputFile = DataGenHelper.generateOutputFile()
7374
val (out, err) =
7475
RdfFromJelly.runTestCommand(
7576
List(
7677
"rdf",
7778
"from-jelly",
78-
"--to",
79-
outputFile,
8079
"--out-format",
8180
RdfFormatOptions.JellyText.cliOption,
8281
),
8382
)
84-
val sortedOut = Using.resource(Source.fromFile(outputFile)) { content =>
85-
content.getLines().toList.map(_.trim).sorted
86-
}
87-
out.length should be(0)
83+
val outString = """# Frame 0
84+
|rows {
85+
| options {
86+
| stream_name: ""
87+
| physical_type: PHYSICAL_STREAM_TYPE_TRIPLES
88+
| generalized_statements: true
89+
| rdf_star: true
90+
| max_name_table_size: 128
91+
| max_prefix_table_size: 16
92+
| max_datatype_table_size: 16
93+
| logical_type: LOGICAL_STREAM_TYPE_FLAT_TRIPLES
94+
| version: 1
95+
| }
96+
|}""".stripMargin
97+
out should include(outString)
98+
"rows".r.findAllIn(out).length should be(10)
99+
"http://example.org/predicate/".r.findAllIn(out).length should be(1)
88100
}
89101
}
90102
"throw proper exception" when {

0 commit comments

Comments
 (0)