From d7a99a5e31aec4ab3c04778fb147d869472588e7 Mon Sep 17 00:00:00 2001 From: Christoph Deppisch Date: Thu, 28 Nov 2024 10:33:34 +0100 Subject: [PATCH] fix: Set validate expressions on Http YAML DSL - Making it possible to set validate expressions when verifying Http request/response in YAML DSL --- .../org/citrusframework/http/yaml/Http.java | 20 +++++++++++++------ .../http/yaml/http-client-test.yaml | 4 ++++ .../http/yaml/http-server-test.yaml | 4 ++++ 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/endpoints/citrus-http/src/main/java/org/citrusframework/http/yaml/Http.java b/endpoints/citrus-http/src/main/java/org/citrusframework/http/yaml/Http.java index 418de9bc2f..cdbe416926 100644 --- a/endpoints/citrus-http/src/main/java/org/citrusframework/http/yaml/Http.java +++ b/endpoints/citrus-http/src/main/java/org/citrusframework/http/yaml/Http.java @@ -273,7 +273,7 @@ protected ReceiveMessageAction doBuild() { receive.setTimeout(request.timeout); } - request.getValidates().forEach(receive.getValidate()::add); + request.getValidate().forEach(receive.getValidate()::add); if (request.extract != null) { receive.setExtract(request.extract); @@ -503,7 +503,7 @@ public static class ServerRequest { protected Receive.Selector selector; - protected List validates; + protected List validate; protected Message.Extract extract; @@ -627,12 +627,16 @@ public void setSelector(Receive.Selector selector) { this.selector = selector; } - public List getValidates() { - if (validates == null) { - validates = new ArrayList<>(); + public List getValidate() { + if (validate == null) { + validate = new ArrayList<>(); } - return validates; + return validate; + } + + public void setValidate(List validate) { + this.validate = validate; } public Message.Extract getExtract() { @@ -754,6 +758,10 @@ public List getValidate() { return validate; } + public void setValidate(List validate) { + this.validate = validate; + } + public Message.Extract getExtract() { return extract; } diff --git a/endpoints/citrus-http/src/test/resources/org/citrusframework/http/yaml/http-client-test.yaml b/endpoints/citrus-http/src/test/resources/org/citrusframework/http/yaml/http-client-test.yaml index 348542410f..c36c54a909 100644 --- a/endpoints/citrus-http/src/test/resources/org/citrusframework/http/yaml/http-client-test.yaml +++ b/endpoints/citrus-http/src/test/resources/org/citrusframework/http/yaml/http-client-test.yaml @@ -41,6 +41,10 @@ actions: body: data: | ${id}foo + validate: + - xpath: + - expression: //order/item + value: foo extract: body: - variable: "orderId" diff --git a/endpoints/citrus-http/src/test/resources/org/citrusframework/http/yaml/http-server-test.yaml b/endpoints/citrus-http/src/test/resources/org/citrusframework/http/yaml/http-server-test.yaml index 1636c21375..7f8b012ab4 100644 --- a/endpoints/citrus-http/src/test/resources/org/citrusframework/http/yaml/http-server-test.yaml +++ b/endpoints/citrus-http/src/test/resources/org/citrusframework/http/yaml/http-server-test.yaml @@ -50,6 +50,10 @@ actions: body: data: | 1001new_user + validate: + - xpath: + - expression: //user/name + value: new_user extract: body: - variable: "userId"