Skip to content

Commit 8040830

Browse files
eppdotsaig0
andauthored
refactor: adjust context#put test to use custom context
Co-authored-by: Philipp Ossler <[email protected]>
1 parent 6901795 commit 8040830

File tree

1 file changed

+11
-24
lines changed

1 file changed

+11
-24
lines changed

src/test/scala/org/camunda/feel/impl/builtin/BuiltinContextFunctionsTest.scala

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -236,30 +236,17 @@ class BuiltinContextFunctionsTest
236236
)
237237
}
238238

239-
it should "handle a lazy value mapper" in {
240-
val lazyEngine = FeelEngineBuilder()
241-
.withCustomValueMapper(new CustomValueMapper {
242-
override def toVal(x: Any, innerValueMapper: Any => Val): Option[Val] = x match {
243-
case x: Map[String, Any] =>
244-
Some {
245-
ValContext(
246-
Context.StaticContext(
247-
variables = x, // don't eagerly map inner values
248-
)
249-
)
250-
}
251-
case _ => None // fallback to default
252-
}
253-
254-
override def unpackVal(value: Val, innerValueMapper: Val => Any): Option[Any] = {
255-
None // fallback to default
256-
}
257-
})
258-
.build()
259-
260-
lazyEngine.evaluateExpression(
261-
""" context put(vars, ["a", "c"], 3) """,
262-
Map("vars" -> Map("a" -> Map("b" -> 1, "c" -> 2)))
239+
it should "override nested context entry from a custom context" in {
240+
evaluateExpression(
241+
expression = """ context put(vars, ["a", "c"], 3) """,
242+
variables = Map(
243+
"vars" ->
244+
ValContext(
245+
new MyCustomContext(
246+
Map("a" -> Map("b" -> 1, "c" -> 2))
247+
)
248+
)
249+
)
263250
) should returnResult(
264251
Map("a" -> Map("b" -> 1, "c" -> 3))
265252
)

0 commit comments

Comments
 (0)