I'm exploring rest-assured (Java) with cucumber based Framework. There is a method written to handle query parameters, it expects a map of<String,?> as below-
protected Response **getByQueryParams**(final String url, Map<String, ?> queryParams) {
setRootApiUrl();
return given()
.queryParams(queryParams)
.contentType(ContentType.JSON)
.accept(ContentType.JSON).get(url)
.thenReturn();
}
My Get Req. End point is:** http://localHost:8088/state-names?countryCode=IND**
I've a cucumber step for same as below-
Given I perform Get operation for "/state-names" with below query params
|countryCode|
|IND |
My Step Def code: using above (getByQueryParams) method >
@Given("I perform Get operation for {string} with below query params")
public void getAllStatesWithCountryCode(String uri,Map<String,String> table) {
var queryParMap=new HashMap<>();
for (Map.Entry<String, String> data : table.entrySet()) {
queryParMap.put(data.getKey(),data.getValue());
}
response = getByQueryParams(uri,queryParMap);
}
this is throwing an error- Required type: Map<String,?> Provided:HashMap<Object,Object>
Error seems obvious but I'm not that good in java so unable to understand how to use this method with defined Map<String,?> in my scenario by avoiding above error. Plz help.