TableMetadataResource { @GET @Path("/{name}") public Table get(@PathParam("name") final String name) throws Exception { Table table = tableMetadataManager.get(name); if (table == null) { throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND).build()); } return table; } TableMetadataResource(TableMetadataManager tableMetadataManager); @POST Table save(@Valid final Table table); @GET @Path("/{name}") Table get(@PathParam("name") final String name); @DELETE @Path("/{name}/delete") void delete(@PathParam("name") final String name); @GET List<Table> get();  }
@Test public void testGet() throws Exception { Table table = new Table(TestUtils.TEST_TABLE_NAME, 30); tableMetadataManager.save(table); Table response = client().resource(String.format("/v1/tables/%s", table.getName())).get(Table.class); assertNotNull(response); assertEquals(table.getName(), response.getName()); assertEquals(table.getTtl(), response.getTtl()); }
@Test public void testGetMissingTable() throws Exception { try { client().resource(String.format("/v1/tables/%s", TestUtils.TEST_TABLE_NAME)).get(Table.class); } catch (UniformInterfaceException ex) { assertEquals(Response.Status.NOT_FOUND.getStatusCode(), ex.getResponse().getStatus()); } }