You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Custom Comparators do not behave as expected when dealing with certain regular expressions that contain JSON Arrays #161
When using a CustomComparator based on a RegularExpressionValueMatcher to match values of the type foo[*].bar.baz the CustomComparator will be disregarded in the NON_EXTENSIBLE and LENIENT modes.
Here is a minimal example that will throw two AssertionErrors:
Stringexpected = "{\"addresses\": [ {\"address\": {\"num\": \"not_a_number\"} } ] }";
Stringactual = "{\"addresses\": [ {\"address\": {\"num\": \"not_a_number\"} } ] }";
// Correctly checks that there are number values at addresses[*].address.numJSONAssert.assertNotEquals(expected, actual,
newCustomComparator(
JSONCompareMode.STRICT,
newCustomization("addresses[*].address.num",
newRegularExpressionValueMatcher<Object>("\\d"))));
// Fails to check that a number value exists at addresses[*].address.numJSONAssert.assertNotEquals(expected, actual,
newCustomComparator(
JSONCompareMode.NON_EXTENSIBLE,
newCustomization("addresses[*].address.num",
newRegularExpressionValueMatcher<Object>("\\d"))));
// Fails to check that a number value exists at addresses[*].address.numJSONAssert.assertNotEquals(expected, actual,
newCustomComparator(
JSONCompareMode.LENIENT,
newCustomization("addresses[*].address.num",
newRegularExpressionValueMatcher<Object>("\\d"))));
I have created a PR that fixes this edge case: #160
Activity