use of com.axway.ats.examples.basic.http.testbeans.PersonPojo in project ats-framework by Axway.
the class RestOperationTests method get_jsonToJavaObject.
/**
* A GET which returns some JSON body.
*
* We serialize the response body to a java instance and use its particular class methods to retrieve the needed data
*/
@Test
public void get_jsonToJavaObject() {
createPersonToManipulateInTheTest();
RestClient client = new RestClient(BASE_URI + "peoplepage/get_jsonPojo");
client.addResourcePath("Chuck");
client.setResponseMediaType(RestMediaType.APPLICATION_JSON);
RestResponse response = client.get();
// get the body as a java object
PersonPojo person = response.getBodyAsObject(PersonPojo.class);
// now call the different java methods to retrieve the needed data
assertEquals(person.getFirstName(), "Chuck");
assertEquals(person.getLastName(), "Norris");
assertEquals(person.getAge(), 70);
log.info("Got back a java object which is: " + person.toString());
}
Aggregations