@@ -51,6 +51,10 @@ class ProcessValidatorSpec extends AnyFunSuite with Matchers with Inside with Op
51
51
private val baseDefinitionBuilder = ModelDefinitionBuilder .empty
52
52
.withGlobalVariable(" processHelper" , ProcessHelper )
53
53
.withService(" sampleEnricher" , Some (Typed [SimpleRecord ]))
54
+ .withService(
55
+ " sampleEnricherWithPlainRecord" ,
56
+ Some (Typed .record(List (" someString" -> Typed [String ], " someInt" -> Typed [Integer ])))
57
+ )
54
58
.withService(" withParamsService" , Some (Typed [SimpleRecord ]), Parameter [String ](ParameterName (" par1" )))
55
59
.withUnboundedStreamSource(" source" , Some (Typed [SimpleRecord ]))
56
60
.withUnboundedStreamSource(" sourceWithUnknown" , Some (Unknown ))
@@ -956,6 +960,45 @@ class ProcessValidatorSpec extends AnyFunSuite with Matchers with Inside with Op
956
960
}
957
961
}
958
962
963
+ test(" should allow mock expression matching enricher return type" ) {
964
+ val process = ScenarioBuilder
965
+ .streaming(" process1" )
966
+ .source(" id1" , " typed-source" )
967
+ .enricherWithMockExpression(
968
+ " enricher1" ,
969
+ " out" ,
970
+ " sampleEnricherWithPlainRecord" ,
971
+ """ {someString: "abc", someInt: 1234}""" .spel
972
+ )
973
+ .emptySink(" id2" , " sink" )
974
+
975
+ inside(validate(process, definitionWithTypedSource).result) { case Valid (_) =>
976
+ }
977
+ }
978
+
979
+ test(" should not allow mock expression not matching enricher return type" ) {
980
+ val process = ScenarioBuilder
981
+ .streaming(" process1" )
982
+ .source(" id1" , " typed-source" )
983
+ .enricherWithMockExpression(" enricher1" , " out" , " sampleEnricherWithPlainRecord" , """ {someString: "abc"}""" .spel)
984
+ .emptySink(" id2" , " sink" )
985
+
986
+ inside(validate(process, definitionWithTypedSource).result) {
987
+ case Invalid (
988
+ NonEmptyList (
989
+ ExpressionParserCompilationError (
990
+ " Bad expression type, expected: Record{someInt: Integer, someString: String}, found: Record{someString: String(abc)}" ,
991
+ " enricher1" ,
992
+ Some (ParameterName (" mockExpression" )),
993
+ _,
994
+ None
995
+ ),
996
+ Nil
997
+ )
998
+ ) =>
999
+ }
1000
+ }
1001
+
959
1002
test(" find usage of fields that does not exist in option object" ) {
960
1003
val process = ScenarioBuilder
961
1004
.streaming(" process1" )
0 commit comments