From baf0cf9c6d6073343065805e56f98734cbe7ac81 Mon Sep 17 00:00:00 2001 From: Peter Thomas Date: Mon, 19 Aug 2019 23:04:00 -0700 Subject: [PATCH] additional tweak for #826 replaces #863 --- karate-core/src/main/java/com/intuit/karate/Script.java | 8 ++++++++ .../java/com/intuit/karate/junit4/demos/js-arrays.feature | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/karate-core/src/main/java/com/intuit/karate/Script.java b/karate-core/src/main/java/com/intuit/karate/Script.java index 4fad88c8b..26e33079a 100755 --- a/karate-core/src/main/java/com/intuit/karate/Script.java +++ b/karate-core/src/main/java/com/intuit/karate/Script.java @@ -1339,6 +1339,14 @@ public static AssertionResult matchNestedObject(char delimiter, String path, Mat if (matchType == MatchType.CONTAINS_ANY) { return AssertionResult.PASS; // exit early } + if (matchType == MatchType.NOT_CONTAINS) { + // did we just bubble-up from a map + ScriptValue childExpValue = new ScriptValue(childExp); + if (childExpValue.isMapLike()) { + // a nested map already fulfilled the NOT_CONTAINS + return AssertionResult.PASS; // exit early + } + } unMatchedKeysExp.remove(key); unMatchedKeysAct.remove(key); } else { // values for this key don't match diff --git a/karate-junit4/src/test/java/com/intuit/karate/junit4/demos/js-arrays.feature b/karate-junit4/src/test/java/com/intuit/karate/junit4/demos/js-arrays.feature index 2ceb3c63c..54e2f2564 100644 --- a/karate-junit4/src/test/java/com/intuit/karate/junit4/demos/js-arrays.feature +++ b/karate-junit4/src/test/java/com/intuit/karate/junit4/demos/js-arrays.feature @@ -316,6 +316,11 @@ Scenario: contains will recurse * def expected = { a: 1, c: 3, d: { b: 2 } } * match original contains expected +Scenario: contains will recurse in reverse ! + * def original = { "a": { "b": { "c": { "d":1, "e":2 } } } } + * def compared = { "a": { "b": { "c": { "d":1, "e":2, "f":3 } } } } + * match original !contains compared + Scenario: js eval * def temperature = { celsius: 100, fahrenheit: 212 } * string expression = 'temperature.celsius'