1

I have a json file which I am passing within api request - which is working but I need to have the date passed as dynamic as per this from current date:

  final LocalDate plus180Days = LocalDate.now().plusDays(180);

here is the sample json file I am using:

 {
  "city": {
    "details": {
      "a1": "AUS",
      "a2": "AUS",
      "country": "AUS"
    }
  },
  "detail": {
        "getCountryDetail": {
            "b1": "SYD",
            "b2": "MEL",
            "country": {
                "2022-09-29|AUS|1234|SYD|MEL": {
                    "date1": "2022-09-29",
                    "time1": "15:38",
                    "date2": "2022-09-29",
                    "time2": "19:13"
                },
                "2022-09-29|AUS|1234|ADL|MEL": {
                    "date1": "2022-09-29",
                    "time1": "15:38",
                    "date2": "2022-09-29",
                    "time2": "19:13"
                }
            }
        }
    }
}

And this is method I was using to create the request for RestAssured Request:

  @Test
  public void RestAssuredRequest_Method()
      throws IOException
  {
    Response response = RestAssured.given()
        .header(readConfigFile())
        .contentType("application/json")
        .body(jsonFile) //Where I am passing the json file itself
        .when()
        .post(readBaseUrl() + "homepage")
        .then().statusCode(200)
        .assertThat()
        .log().all()
  }

As you can see, there is "country" there is date within a long string and also two dates (1 & 2) within that array. So in total three dates that I am looking to update. But I don't how can I actually reach those dates and update it with plus180Days. Also as you can see, the dates appear multiple times within the json, so would it be possible to do that for updating json prior to run?

gg_man
  • 11
  • 3

0 Answers0