Skip to content

Commit

Permalink
Merge pull request #700 from camunda/582_context_filter_null_comparisons
Browse files Browse the repository at this point in the history
Verify filtering list of contexts where some part is null or non-existing
  • Loading branch information
remcowesterhoud authored Aug 18, 2023
2 parents 63925de + 77e4540 commit 01c12cd
Showing 1 changed file with 63 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class InterpreterContextExpressionTest

val items = list.asInstanceOf[ValList].items
items should have size 1
val context = items(0)
val context = items.head

context
.asInstanceOf[ValContext]
Expand All @@ -84,6 +84,68 @@ class InterpreterContextExpressionTest
.getVariables should be(Map("a" -> ValNumber(3), "b" -> ValNumber(4)))
}

it should "be filtered via comparison with missing entry" in {

val list = eval("[{x: 1, y: 2}, {x: 3}][y > 1]")
list shouldBe a[ValList]

val items = list.asInstanceOf[ValList].items
items should have size 1
val context = items.head

context
.asInstanceOf[ValContext]
.context
.variableProvider
.getVariables should be(Map("x" -> ValNumber(1), "y" -> ValNumber(2)))
}

it should "be filtered via comparison with null value" in {
val list = eval("[{x: 1}, {x: null}][x > 0]")
list shouldBe a[ValList]

val items = list.asInstanceOf[ValList].items
items should have size 1
val context = items.head

context
.asInstanceOf[ValContext]
.context
.variableProvider
.getVariables should be(Map("x" -> ValNumber(1)))
}

it should "be filtered via matching null comparison" in {
val list = eval("[{x: 1}, {x: null}][x = null]")
list shouldBe a[ValList]

val items = list.asInstanceOf[ValList].items
items should have size 1
val context = items.head

context
.asInstanceOf[ValContext]
.context
.variableProvider
.getVariables should be(Map("x" -> ValNull))
}

// note that a missing entry is equivalent to that entry containing null
it should "be filtered via missing entry null comparison" in {
val list = eval("[{x: 1}, {y: 1}][x = null]")
list shouldBe a[ValList]

val items = list.asInstanceOf[ValList].items
items should have size 1
val context = items.head

context
.asInstanceOf[ValContext]
.context
.variableProvider
.getVariables should be(Map("y" -> ValNumber(1)))
}

it should "be filtered by name 'item'" in {

eval("[ {item:1}, {item:2}, {item:3} ][item >= 2]") match {
Expand Down

0 comments on commit 01c12cd

Please sign in to comment.