TableManagerResource { @GET @Timed @Path("/{name}") @ApiOperation("Get Table") public Response get(@PathParam("name") String name) { name = ElasticsearchUtils.getValidTableName(name); Table table = tableManager.get(name); return Response.ok() .entity(table) .build(); } @Inject  TableManagerResource(TableManager tableManager); @POST @Timed @ApiOperation("Save Table") Response save(@Valid final Table table, @QueryParam("forceCreate") @DefaultValue("false") boolean forceCreate); @GET @Timed @Path("/{name}") @ApiOperation("Get Table") Response get(@PathParam("name") String name); @PUT @Timed @Path("/{name}") @ApiOperation("Update Table") Response get(@PathParam("name") final String name, @Valid final Table table); @DELETE @Timed @Path("/{name}/delete") @ApiOperation("Delete Table") Response delete(@PathParam("name") String name); @GET @Timed @ApiOperation("Get all Tables") Response getAll();  }
@Test public void testGet() throws Exception { doNothing().when(getDataStore()) .initializeTable(any(Table.class), anyBoolean()); doNothing().when(getQueryStore()) .initializeTable(any(String.class)); Table response = resources.client() .target(String.format("/v1/tables/%s", TEST_TABLE_NAME)) .request() .get(Table.class); assertNotNull(response); assertEquals(TEST_TABLE_NAME, response.getName()); assertEquals(7, response.getTtl()); }
@Test public void testGetMissingTable() throws Exception { Response response = resources.client() .target(String.format("/v1/tables/%s", TEST_TABLE_NAME + "_missing")) .request() .get(); assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatus()); }