Package com.intuit.karate
Class MatchOperator.CoreOperator
java.lang.Object
com.intuit.karate.MatchOperator.CoreOperator
- All Implemented Interfaces:
MatchOperator
- Enclosing interface:
- MatchOperator
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.intuit.karate.MatchOperator
MatchOperator.CoreOperator, MatchOperator.EachOperator, MatchOperator.NotOperator -
Method Summary
Modifier and TypeMethodDescriptionbooleanexecute(MatchOperation operation) protected MatchOperatormacroOperator(MatchOperator specifiedOperator) The operator specified by the user (^, ^+, ...) is provided as thespecifiedOperatorparameter.toString()
-
Method Details
-
execute
- Specified by:
executein interfaceMatchOperator
-
macroOperator
The operator specified by the user (^, ^+, ...) is provided as thespecifiedOperatorparameter. However, when using one of Contains Family operators, it may require some adjustments.Example:
In this example,def actual = [{ a: 1, b: 'x' }, { a: 2, b: 'y' }] def part = { a: 1 } match actual contains '#(^part)'specifiedOperatorisContains. However:- The specified operator (
^) is applied when processing the list. - Child operators are applied when processing objects within the list.
childOperator(Match.Value),Contains' child operator isEquals. As a result, the code attempts to match{ a: 1, b: 'x' } equals { a: 1 }, which fails.What we actually want is to preserve both
Containsoperators:- The one from the match instruction.
- The one implied by the macro logic.
Containsoperations.Note: If a third level of matching is required (e.g., the objects in
actualcontain other objects), it would fall back to the child operator of the child operator, which isEquals. This differs from the legacy implementation, which would enforce a deepContains, potentially triggering issue #2515.That said,
Contains Deepmay still be specified explicitly by the user, for example, to handle nested structures like objects within objects within lists. - The specified operator (
-
toString
-