Skip to content

Commit 1345cf4

Browse files
committed
Fix JsonPathFilterEvaluationTest to use correct value comparison for false
Corrected !@.prop usage: it means 'property does not exist'. To check for a false boolean value, explicit comparison @.prop == false is required. Updated testComplexNestedLogic to reflect this.
1 parent 0a32fe9 commit 1345cf4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

json-java21-jsonpath/src/test/java/json/java21/jsonpath/JsonPathFilterEvaluationTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ void testParenthesesPrecedence() {
137137
@Test
138138
void testComplexNestedLogic() {
139139
LOG.info(() -> "TEST: testComplexNestedLogic");
140-
// (Price < 10 OR (Category == 'fiction' AND Not Published))
140+
// (Price < 10 OR (Category == 'fiction' AND Published is false))
141+
// Note: !@.published would mean "published does not exist".
142+
// To check for false value, use @.published == false.
141143
var json = Json.parse("""
142144
[
143145
{"id": 1, "price": 5, "category": "ref", "published": true},
@@ -147,7 +149,7 @@ void testComplexNestedLogic() {
147149
]
148150
""");
149151

150-
var results = JsonPath.parse("$[?(@.price < 10 || (@.category == 'fiction' && !@.published))]").query(json);
152+
var results = JsonPath.parse("$[?(@.price < 10 || (@.category == 'fiction' && @.published == false))]").query(json);
151153

152154
assertThat(results).hasSize(2);
153155
assertThat(results.stream().map(v -> asInt(v, "id")).toList())

0 commit comments

Comments
 (0)