Skip to content

Commit 16aaeee

Browse files
authored
Merge pull request #993 from camunda/eppdot-fix-lazy-value-mapper
eppdot-fix-lazy-value-mapper
2 parents 117e335 + 8040830 commit 16aaeee

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/main/scala/org/camunda/feel/impl/builtin/ContextBuiltinFunctions.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ class ContextBuiltinFunctions(valueMapper: ValueMapper) {
136136
case key :: tail =>
137137
val contextOfKey = contextValue.context.variableProvider
138138
.getVariable(key)
139+
.map(valueMapper.toVal)
139140
.map {
140141
case contextOfKey: ValContext => contextOfKey
141142
case _ => ValContext(EmptyContext)

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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@
1616
*/
1717
package org.camunda.feel.impl.builtin
1818

19-
import org.camunda.feel.context.{CustomContext, VariableProvider}
19+
import org.camunda.feel.api.FeelEngineBuilder
20+
import org.camunda.feel.context.Context
2021
import org.camunda.feel.impl.interpreter.MyCustomContext
2122
import org.camunda.feel.impl.{EvaluationResultMatchers, FeelEngineTest}
2223
import org.camunda.feel.syntaxtree._
24+
import org.camunda.feel.valuemapper.CustomValueMapper
2325
import org.scalatest.flatspec.AnyFlatSpec
2426
import org.scalatest.matchers.should.Matchers
2527

@@ -234,6 +236,22 @@ class BuiltinContextFunctionsTest
234236
)
235237
}
236238

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+
)
250+
) should returnResult(
251+
Map("a" -> Map("b" -> 1, "c" -> 3))
252+
)
253+
}
254+
237255
it should "add nested context entry if key doesn't exist" in {
238256
evaluateExpression(""" context put({x:1}, ["y", "z"], 2) """) should returnResult(
239257
Map("x" -> 1, "y" -> Map("z" -> 2))

0 commit comments

Comments
 (0)