I have a .json file and i read it to use Files.readAllBytes(Paths.get("classpath")). It works but i need to use variable in .json file and i just want to change variable in other method.
Here is my .json file:
{
"type": "FILE",
"invitationMessage": "",
"duration": "NO_EXPIRE",
"items": [
{
"uuid": "shdy28-9b03-4c21-9c80-f96f31f9cee9",
"projectId": "65ht8f99694454a658yef17a95e8f"
}
],
"invitees": [
{
"username": "[email protected]",
"role": "VIEWER"
}
]
}
This is the method I used the file:
@When("^I send share privately api$")
public void sharePrivately() throws IOException {
String body = new String(Files.readAllBytes(Paths.get("src/test/resources/config/environments/sharePrivately.json")));
RequestSpecification header = rh.share(payload.userAuth());
response = header.body(body)
.when()
.post("/shares")
.then()
.assertThat()
.extract()
.response();
System.out.println(response.getStatusCode());
}
When i read .json file i want to change username in this method. How can do that ?
Thank you for your advice