@Test public void testSaveBackendError() throws Exception { Table table = Table.builder() .name(UUID.randomUUID() .toString()) .ttl(30) .build(); Entity<Table> tableEntity = Entity.json(table); doThrow(FoxtrotExceptions.createExecutionException("dummy", new IOException())).when(tableManager) .save(Matchers.<Table>any()); Response response = resources.client() .target("/v1/tables") .request() .post(tableEntity); assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatus()); reset(tableManager); }
@POST @Timed @ApiOperation("Save Table") public Response save(@Valid final Table table, @QueryParam("forceCreate") @DefaultValue("false") boolean forceCreate) { table.setName(ElasticsearchUtils.getValidTableName(table.getName())); tableManager.save(table, forceCreate); return Response.ok(table) .build(); }
TableManagerResource { @POST @Timed @ApiOperation("Save Table") public Response save(@Valid final Table table, @QueryParam("forceCreate") @DefaultValue("false") boolean forceCreate) { table.setName(ElasticsearchUtils.getValidTableName(table.getName())); tableManager.save(table, forceCreate); return Response.ok(table) .build(); } }
TableManagerResource { @POST @Timed @ApiOperation("Save Table") public Response save(@Valid final Table table, @QueryParam("forceCreate") @DefaultValue("false") boolean forceCreate) { table.setName(ElasticsearchUtils.getValidTableName(table.getName())); tableManager.save(table, forceCreate); return Response.ok(table) .build(); } @Inject  TableManagerResource(TableManager tableManager); }
TableManagerResource { @POST @Timed @ApiOperation("Save Table") public Response save(@Valid final Table table, @QueryParam("forceCreate") @DefaultValue("false") boolean forceCreate) { table.setName(ElasticsearchUtils.getValidTableName(table.getName())); tableManager.save(table, forceCreate); return Response.ok(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(); }
TableManagerResource { @POST @Timed @ApiOperation("Save Table") public Response save(@Valid final Table table, @QueryParam("forceCreate") @DefaultValue("false") boolean forceCreate) { table.setName(ElasticsearchUtils.getValidTableName(table.getName())); tableManager.save(table, forceCreate); return Response.ok(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();  }