citrusframework / citrus

Framework for automated integration tests with focus on messaging integration
https://citrusframework.org
Apache License 2.0
456 stars 134 forks source link

Only one Validator is called in receive response #814

Open chokdee opened 2 years ago

chokdee commented 2 years ago

Citrus Version 3.1.0

Expected behavior All validator shall be called

Actual behavior Only the first is called

Test case sample

$(http().client(client).send()
    .post("/url")
    .message()            
    .header("Content-Type", "application/json")
    .body(new ClassPathResource("citrus/testcase.json")));
$(http()
    .client(cwsClient)
    .receive()
    .response(HttpStatus.BAD_REQUEST)
    .message()
    .type(MessageType.JSON)
    .validate(jsonPath().expression("$.*" , containsString("items[0].state: Destination state can have between 2 and 20 characters.")))
    .validate(jsonPath().expression("$.*" , containsString("items[0].recipient: size must be between 1 and 30"))));
christophd commented 2 years ago

This is because the expression key $.* is the same for both validate calls. I suppose to use allOf() and combine the validations into one single validate statement