Multiple jsonPath-Validations not working
Citrus Version 3.4.0
Question Why is the following code not working:
$(http()
.client(myclient)
.receive()
.response(HttpStatus.OK)
.message()
.type(MessageType.JSON)
.validate(jsonPath().expression("$.name", "meier"))
.validate(jsonPath().expression("$.vorname", "heinz"))
.validate(jsonPath().expression("$.city", "München")));
What I've tried so far The following is working
$(http()
.client(myclient)
.receive()
.response(HttpStatus.OK)
.message()
.type(MessageType.JSON)
.validate(jsonPath().expression("$.name", "meier")
.expression("$.vorname", "heinz")
.expression("$.city", "München")));
Additional information I think at least an error should be thrown. In the first case only the first validation is executed. Better would be to except both variants, isn't it?
Btw: a chain of extract value is working e.g.
.extract(JsonPathSupport.jsonPath().expression("$.id", "${itemId1}"))
.extract(JsonPathSupport.jsonPath().expression("$.barcode", "${barcode1}")))
Agreed! both options should be valid
Seems to be the case in 3.3.0 too.
Multiple calls of .validate(jsonPath()...) create multiple JsonPath Validation Contexts. However AbstractMessageValidator.validateMessage() takes only the first validationContext. I created a pull request.