Skip to content

Commit

Permalink
fix: Set validate expressions on Http YAML DSL
Browse files Browse the repository at this point in the history
- Making it possible to set validate expressions when verifying Http request/response in YAML DSL
  • Loading branch information
christophd committed Nov 28, 2024
1 parent 73c118b commit d7a99a5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -503,7 +503,7 @@ public static class ServerRequest {

protected Receive.Selector selector;

protected List<Receive.Validate> validates;
protected List<Receive.Validate> validate;

protected Message.Extract extract;

Expand Down Expand Up @@ -627,12 +627,16 @@ public void setSelector(Receive.Selector selector) {
this.selector = selector;
}

public List<Receive.Validate> getValidates() {
if (validates == null) {
validates = new ArrayList<>();
public List<Receive.Validate> getValidate() {
if (validate == null) {
validate = new ArrayList<>();
}

return validates;
return validate;
}

public void setValidate(List<Receive.Validate> validate) {
this.validate = validate;
}

public Message.Extract getExtract() {
Expand Down Expand Up @@ -754,6 +758,10 @@ public List<Receive.Validate> getValidate() {
return validate;
}

public void setValidate(List<Receive.Validate> validate) {
this.validate = validate;
}

public Message.Extract getExtract() {
return extract;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ actions:
body:
data: |
<order><id>${id}</id><item>foo</item></order>
validate:
- xpath:
- expression: //order/item
value: foo
extract:
body:
- variable: "orderId"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ actions:
body:
data: |
<user><id>1001</id><name>new_user</name></user>
validate:
- xpath:
- expression: //user/name
value: new_user
extract:
body:
- variable: "userId"
Expand Down

0 comments on commit d7a99a5

Please sign in to comment.