181920212223242526
public void setUp() throws Exception { // set up t1 = new Topping(1, "Cheese"); t2 = new Topping(2, "Ham"); t3 = new Topping(3, "Pineapple"); pizza = new Pizza(3, "PizzaOne", (long)1000); pizza.addTopping(t1); pizza.addTopping(t2); }
282930313233343536
@GET @Timed @Path("{id}") public Pizza getPizza(@PathParam("id") int id) { Pizza p = dao.selectById(id); injectToppings(p); return p; }
46474849505152535455
@POST @Timed @Path("{id}/toppings") public Pizza addTopping(@PathParam("id") int id, @QueryParam("topping_id") int topping_id) { Pizza p = dao.selectById(id); dao.insertTopping(id, topping_id); injectToppings(p); return p; }
57585960616263646566
@DELETE @Timed @Path("{id}/toppings/{topping_id}") public Pizza deleteTopping(@PathParam("id") int id, @PathParam("topping_id") int topping_id) { Pizza p = dao.selectById(id); dao.deleteTopping(id, topping_id); injectToppings(p); return p; }