Search in sources :

Example 1 with PersonXmlBean

use of com.axway.ats.examples.basic.http.testbeans.PersonXmlBean in project ats-framework by Axway.

the class RestOperationTests method get_xmlToJavaObject.

/**
 * A GET which returns some XML 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_xmlToJavaObject() {
    createPersonToManipulateInTheTest();
    RestClient client = new RestClient(BASE_URI + "peoplepage/get_xmlBean");
    client.addResourcePath("Chuck");
    client.addResourcePath("Norris");
    client.setResponseMediaType(RestMediaType.APPLICATION_XML);
    RestResponse response = client.get();
    // get the body as a java object
    PersonXmlBean person = response.getBodyAsObject(PersonXmlBean.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());
}
Also used : PersonXmlBean(com.axway.ats.examples.basic.http.testbeans.PersonXmlBean) RestResponse(com.axway.ats.action.rest.RestResponse) RestClient(com.axway.ats.action.rest.RestClient) Test(org.testng.annotations.Test)

Aggregations

RestClient (com.axway.ats.action.rest.RestClient)1 RestResponse (com.axway.ats.action.rest.RestResponse)1 PersonXmlBean (com.axway.ats.examples.basic.http.testbeans.PersonXmlBean)1 Test (org.testng.annotations.Test)1