From a101fdd32b1896d9100b038a161d11c77a81afd2 Mon Sep 17 00:00:00 2001 From: Matthias Fischer Date: Fri, 10 May 2024 16:12:40 +0200 Subject: [PATCH] feat(impl): [#528] add step definitions for cucumber tests for validating error response message --- ...2ETestStepDefinitionsForPolicyStoreApi.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/irs-cucumber-tests/src/test/java/org/eclipse/tractusx/irs/cucumber/E2ETestStepDefinitionsForPolicyStoreApi.java b/irs-cucumber-tests/src/test/java/org/eclipse/tractusx/irs/cucumber/E2ETestStepDefinitionsForPolicyStoreApi.java index 884d5199cb..5d533b1a23 100644 --- a/irs-cucumber-tests/src/test/java/org/eclipse/tractusx/irs/cucumber/E2ETestStepDefinitionsForPolicyStoreApi.java +++ b/irs-cucumber-tests/src/test/java/org/eclipse/tractusx/irs/cucumber/E2ETestStepDefinitionsForPolicyStoreApi.java @@ -316,7 +316,23 @@ public void theCreatePolicyResponseShouldHaveStatus(final int httpStatus) { @Then("the create policy response should have message containing {string}") public void theCreatePolicyResponseShouldHaveMessageContaining(final String string) { - this.createPoliciesResponse.body("messages", Matchers.hasItem(Matchers.containsString(string))); + final ValidatableResponse validatableResponse = this.createPoliciesResponse; + assertThatResponseHasMessageContaining(validatableResponse, string); + } + + @Then("the delete policy response should have message containing {string}") + public void thedeletePolicyResponseShouldHaveMessageContaining(final String string) { + assertThatResponseHasMessageContaining(this.deletePoliciesResponse, string); + } + + @Then("the update policy response should have message containing {string}") + public void theUpdatePolicyResponseShouldHaveMessageContaining(final String string) { + assertThatResponseHasMessageContaining(this.updatePoliciesResponse, string); + } + + private static void assertThatResponseHasMessageContaining(final ValidatableResponse validatableResponse, + final String string) { + validatableResponse.body("messages", Matchers.hasItem(Matchers.containsString(string))); } @Then("the update policy response should have HTTP status {int}")