I'm having an issue, the issue seems to me very strange , I don't really got it , in order to explain you guys , let me share the code.
so I'm testing API with rest assured, programming language is JAVA, so the problem is here , when I run my test using JUnit's @TEST annotation , it works fine , the code as follows
@Test
public void searchData() {
Response response = given()
.header("Authorization", PropertiesReader.getPropertiesValue("TokenPub"))
.queryParam("langId", "PdOnv3OV")
.queryParam("Regions", "52aAGOZ7")
.queryParam("From","2022-01-30")
.queryParam("To","2022-02-06")
.when()
.request(String.valueOf(RestHttpRequest.HttpMethods.GET), "/api/product/search");
response.prettyPrint();
}
And I'm getting expected output as follows
{
"fromDate": "2022-01-30",
"toDate": "2022-02-06",
"products": [
{
"id": "k8p0V0lJ",
"name": "ביקור באתר התיירות ראש הנקרה",
"minOfficialPrice": 40.0000,
"customerTypeId": "q1lox9O7",
"currencyId": "Belm3pnb"
},
{
"id": "5bpJgVaV",
"name": "אירוח ביתי בוכרי",
"minOfficialPrice": 30.0000,
"customerTypeId": "q7OxNwa6",
"currencyId": "Belm3pnb"
},
{
"id": "3pWok6p4",
"name": "ghjkl",
"minOfficialPrice": 123.0000,
"customerTypeId": "vApRn5pY",
"currencyId": "Belm3pnb"
},
{
"id": "ApRDK9lY",
"name": "טיול רייזרים בשבליי ההרים",
"minOfficialPrice": 500.0000,
"customerTypeId": "oylKk6l8",
"currencyId": "Belm3pnb"
},
{
"id": "Bl5165lX",
"name": "טיול רייזרים למבצרים וכפר עתיק",
"minOfficialPrice": 5.0000,
"customerTypeId": "BJpgYvlq",
"currencyId": "Belm3pnb"
}
],
"warning": null
}
Attention here is the issue , when i try to run the same thing using cucumber , I'm getting an exception com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
I have the following scenario
Feature: data is being searched in public API
Scenario: searching the data in public API
Given searching the data in public api
I have the following step definition
@Given("^searching the data in public api$")
public void searching_the_data_in_public_api_with_the_following_fields() throws Throwable {
CommonData.response = given()
.header("Authorization", PropertiesReader.getPropertiesValue("TokenPub"))
.queryParam("langId", "PdOnv3OV")
.queryParam("Regions", "52aAGOZ7")
.queryParam("From","2022-01-30")
.queryParam("To","2022-02-06")
.when()
.request(String.valueOf(RestHttpRequest.HttpMethods.GET), "/api/product/search");
CommonData.response.prettyPrint();
}
please help me, all opinions and comments will be much appreciated, Thanks in advance