ItemsController extends ApiController { @GET("/{id: [0-9]+}") @ApiSummary("Get an item by id") @Return(code = 200, description = "Successful operation", onResult = Item.class) @Return(code = 404, description = "Item not found") @Metered public Item get(@Desc("ID of the item to retrieve") int id) { Item item = dao.get(id); return item; }  @GET("/{id: [0-9]+}") @ApiSummary("Get an item by id") @Return(code = 200, description = "Successful operation", onResult = Item.class) @Return(code = 404, description = "Item not found") @Metered Item get(@Desc("ID of the item to retrieve") int id);  }
@Test public void testGetJSON() { given().accept(JSON).when().header(testHeader).get("/api/items/{id}", 1).then().body("id", equalTo(1)); }
@Test public void testGetXML() { given().accept(XML).when().header(testHeader).get("/api/items/{id}", 1).then().body("item.@id", equalTo("1")); }
@Test public void testGetObject() { Item item = given().accept(JSON).when().header(testHeader).get("/api/items/{id}", 1).as(Item.class); assertEquals("Item id does not match", 1, item.getId()); assertEquals("Item name does not match", "Apples", item.getName()); }