How to verify the response headers in Rest Assured framework? I tried the below way to check for response headers, but my code is not giving any result.
Util file
public void verifyResponseHeaders(Map<String, String> data {
softAssert = new SoftAssert();
data.forEach((headers, expected) -> {
LogUtil.log(String.format("Validating => %s", headers));
Object actual = response.headers();
LogUtil.log(String.format("Assertion for headers Expected = %s; Actual = %s", headers,expected, actual));
assertValue(actual, expected);
});
softAssert.assertAll();
}
Cucumber file common Step:
@And("I see headers matches for fields")
public void verifyResponseHeaders(DataTable data) {
apiUtil.verifyResponseHeaders(new HashMap<>(data.asMap()));
}
Login.feature
And I see headers matches for fields
| Content-Type | application/json |