I have requirement where need to read the all response header and assert them with pre-define values store in the Hashmap. I have written the following codes but getting error as Indexout of bound
Boolean IsPass = false;
Map.Entry<String, String> item : AssertHeaderFromExcel.entrySet()) {
try {
String key = item.getKey();
String value = item.getValue();
Headers headers = response.getHeaders();
String strjson = headers.getValues(key).size() > 0 ? headers.getValues(key).get(0) : "";
System.out.println("test" +headers.getValues(key));
strjson = strjson == null ? "" : strjson;
Assert.assertEquals(strjson, value);
if (value.equalsIgnoreCase(strjson)) {
if (IsPass) {
IsPass = true;
}
} else {
IsPass = false;
}
The String value is blank for the first value read from the Hashmap. Hence cannot assert the key and value and IsPass remains as Fail only