Skip to content

Commit f6dc3ad

Browse files
author
Pawel Czajka
committed
shorten tests
1 parent 99c96cc commit f6dc3ad

File tree

1 file changed

+10
-35
lines changed
  • engine/flink/components/base-tests/src/test/scala/pl/touk/nussknacker/engine/flink/table/source

1 file changed

+10
-35
lines changed

engine/flink/components/base-tests/src/test/scala/pl/touk/nussknacker/engine/flink/table/source/TableSourceTest.scala

Lines changed: 10 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import pl.touk.nussknacker.engine.flink.table.source.TableSource.SQL_EXPRESSION_
1616
import pl.touk.nussknacker.engine.flink.table.utils.ModelClassLoaderSimulationSuite
1717
import pl.touk.nussknacker.engine.flink.util.test.FlinkTestScenarioRunner
1818
import pl.touk.nussknacker.engine.process.FlinkJobConfig.ExecutionMode
19-
import pl.touk.nussknacker.engine.util.test.TestScenarioRunner
19+
import pl.touk.nussknacker.engine.util.test.{RunListResult, TestScenarioRunner}
2020
import pl.touk.nussknacker.test.{PatientScalaFutures, ValidatedValuesDetailedMessage}
2121

2222
class TableSourceTest
@@ -66,8 +66,6 @@ class TableSourceTest
6666
val scenario = ScenarioBuilder
6767
.streaming("test")
6868
.source("start", "table", "Table" -> s"'`default_catalog`.`default_database`.`test_table`'".spel)
69-
// TODO_PAWEL this is only to test in debug
70-
// .buildSimpleVariable("sth", "someVariable", "#input.![#this]".spel)
7169
.emptySink(s"end", TestScenarioRunner.testResultSink, "value" -> "#input".spel)
7270

7371
val result = runner
@@ -80,12 +78,11 @@ class TableSourceTest
8078
result.successes.loneElement
8179
}
8280

83-
test("be possible to use merge") {
84-
import scala.jdk.CollectionConverters._
81+
private def evaluateExpression(expression: String) = {
8582
val scenario = ScenarioBuilder
8683
.streaming("test")
8784
.source("start", "table", "Table" -> s"'`default_catalog`.`default_database`.`test_table`'".spel)
88-
.buildSimpleVariable("sth", "someVariable", "#COLLECTION.merge(#input, #input).get('quantity')".spel)
85+
.buildSimpleVariable("sth", "someVariable", expression.spel)
8986
.emptySink(s"end", TestScenarioRunner.testResultSink, "value" -> "#someVariable".spel)
9087

9188
val result = runner
@@ -94,46 +91,24 @@ class TableSourceTest
9491
nodesData = NodesDeploymentData(Map(NodeId("start") -> Map(SQL_EXPRESSION_PARAMETER_NAME -> "true = true")))
9592
)
9693
.validValue
94+
result
95+
}
96+
97+
test("be possible to use merge") {
98+
val result = evaluateExpression("#COLLECTION.merge(#input, #input).get('quantity')")
9799
result.errors shouldBe empty
98100
result.successes(0) shouldBe a[Int]
99101
}
100102

101103
test("be possible to use selection") {
102-
import scala.jdk.CollectionConverters._
103-
val scenario = ScenarioBuilder
104-
.streaming("test")
105-
.source("start", "table", "Table" -> s"'`default_catalog`.`default_database`.`test_table`'".spel)
106-
.buildSimpleVariable(
107-
"sth",
108-
"someVariable",
109-
"#input.?[(#this.value / 10 + 42 - #this.value / 10) == 42].quantity".spel
110-
)
111-
.emptySink(s"end", TestScenarioRunner.testResultSink, "value" -> "#someVariable".spel)
112-
113-
val result = runner
114-
.runWithoutData[Row](
115-
scenario,
116-
nodesData = NodesDeploymentData(Map(NodeId("start") -> Map(SQL_EXPRESSION_PARAMETER_NAME -> "true = true")))
117-
)
118-
.validValue
104+
val result = evaluateExpression("#input.?[(#this.value / 10 + 42 - #this.value / 10) == 42].quantity")
119105
result.errors shouldBe empty
120106
result.successes(0) shouldBe a[Int]
121107
}
122108

123109
test("be possible to use projection") {
124110
import scala.jdk.CollectionConverters._
125-
val scenario = ScenarioBuilder
126-
.streaming("test")
127-
.source("start", "table", "Table" -> s"'`default_catalog`.`default_database`.`test_table`'".spel)
128-
.buildSimpleVariable("sth", "someVariable", "#input.![#this.value / 10 + 42 - #this.value / 10]".spel)
129-
.emptySink(s"end", TestScenarioRunner.testResultSink, "value" -> "#someVariable".spel)
130-
131-
val result = runner
132-
.runWithoutData[Row](
133-
scenario,
134-
nodesData = NodesDeploymentData(Map(NodeId("start") -> Map(SQL_EXPRESSION_PARAMETER_NAME -> "true = true")))
135-
)
136-
.validValue
111+
val result = evaluateExpression("#input.![#this.value / 10 + 42 - #this.value / 10]")
137112
result.errors shouldBe empty
138113
result.successes(0) shouldBe List(42).asJava
139114
}

0 commit comments

Comments
 (0)