Search in sources :

Example 1 with Customer

use of org.glassfish.jersey.examples.xmlmoxy.beans.Customer in project jersey by jersey.

the class MoxyAppTest method testCustomer.

/**
     * Test that the expected response is sent back.
     * @throws java.lang.Exception
     */
@Test
public void testCustomer() throws Exception {
    final WebTarget webTarget = target().path("customer");
    Customer customer = webTarget.request(MediaType.APPLICATION_XML).get(Customer.class);
    customer.setName("Tom Dooley");
    webTarget.request(MediaType.APPLICATION_XML).put(Entity.entity(customer, MediaType.APPLICATION_XML));
    Customer updatedCustomer = webTarget.request(MediaType.APPLICATION_XML).get(Customer.class);
    assertEquals(customer, updatedCustomer);
}
Also used : Customer(org.glassfish.jersey.examples.xmlmoxy.beans.Customer) WebTarget(javax.ws.rs.client.WebTarget) JerseyTest(org.glassfish.jersey.test.JerseyTest) Test(org.junit.Test)

Example 2 with Customer

use of org.glassfish.jersey.examples.xmlmoxy.beans.Customer in project jersey by jersey.

the class CustomerResource method createInitialCustomer.

private static Customer createInitialCustomer() {
    final Customer result = new Customer();
    result.setName("Jane Doe");
    result.setAddress(new Address("123 Any Street", "My Town"));
    result.getPhoneNumbers().add(new PhoneNumber("work", "613-555-1111"));
    result.getPhoneNumbers().add(new PhoneNumber("cell", "613-555-2222"));
    return result;
}
Also used : Address(org.glassfish.jersey.examples.xmlmoxy.beans.Address) Customer(org.glassfish.jersey.examples.xmlmoxy.beans.Customer) PhoneNumber(org.glassfish.jersey.examples.xmlmoxy.beans.PhoneNumber)

Aggregations

Customer (org.glassfish.jersey.examples.xmlmoxy.beans.Customer)2 WebTarget (javax.ws.rs.client.WebTarget)1 Address (org.glassfish.jersey.examples.xmlmoxy.beans.Address)1 PhoneNumber (org.glassfish.jersey.examples.xmlmoxy.beans.PhoneNumber)1 JerseyTest (org.glassfish.jersey.test.JerseyTest)1 Test (org.junit.Test)1