@Test public void deleteCluster() { final String requestClusterId = "CLUSTER_TO_DELETE"; doAnswer(new Answer<Void>() { @Override public Void answer(InvocationOnMock invocation) throws Throwable { String argClusterId = (String) invocation.getArguments()[0]; assertEquals("Service cluster ID should match the requested cluster ID", argClusterId, requestClusterId); return null; } }).when(clusterServiceMock).deleteCluster(anyString()); ClientResponse clientResponse = resource().path("/api/clusters/" + requestClusterId) .delete(ClientResponse.class); assertEquals("Response HTTP status code should be 200 (OK)", clientResponse.getStatus(), 200); verify(clusterServiceMock).deleteCluster(anyString()); }
@DELETE @Path("/{clusterId}") public Response deleteCluster(@PathParam("clusterId") String clusterId) { clusterService.deleteCluster(clusterId); return Response.ok().build(); }
ClusterResource { @DELETE @Path("/{clusterId}") public Response deleteCluster(@PathParam("clusterId") String clusterId) { clusterService.deleteCluster(clusterId); return Response.ok().build(); } }
ClusterResource { @DELETE @Path("/{clusterId}") public Response deleteCluster(@PathParam("clusterId") String clusterId) { clusterService.deleteCluster(clusterId); return Response.ok().build(); } @Inject  ClusterResource(ClusterService clusterService); }
ClusterResource { @DELETE @Path("/{clusterId}") public Response deleteCluster(@PathParam("clusterId") String clusterId) { clusterService.deleteCluster(clusterId); return Response.ok().build(); } @Inject  ClusterResource(ClusterService clusterService); @GET @Produces(MediaType.APPLICATION_JSON) Collection<Cluster> listClusters(); @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Cluster createCluster(Cluster cluster); @GET @Path("/{clusterId}") @Produces(MediaType.APPLICATION_JSON) Cluster getCluster(@PathParam("clusterId") String clusterId); @PUT @Path("/{clusterId}") @Consumes(MediaType.APPLICATION_JSON) Response updateCluster(@PathParam("clusterId") String clusterId, Cluster cluster); @DELETE @Path("/{clusterId}") Response deleteCluster(@PathParam("clusterId") String clusterId); @GET @Path("/{clusterId}/summary") @Produces(MediaType.APPLICATION_JSON) ClusterSummary getClusterSummary(@PathParam("clusterId") String clusterId); }
ClusterResource { @DELETE @Path("/{clusterId}") public Response deleteCluster(@PathParam("clusterId") String clusterId) { clusterService.deleteCluster(clusterId); return Response.ok().build(); } @Inject  ClusterResource(ClusterService clusterService); @GET @Produces(MediaType.APPLICATION_JSON) Collection<Cluster> listClusters(); @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Cluster createCluster(Cluster cluster); @GET @Path("/{clusterId}") @Produces(MediaType.APPLICATION_JSON) Cluster getCluster(@PathParam("clusterId") String clusterId); @PUT @Path("/{clusterId}") @Consumes(MediaType.APPLICATION_JSON) Response updateCluster(@PathParam("clusterId") String clusterId, Cluster cluster); @DELETE @Path("/{clusterId}") Response deleteCluster(@PathParam("clusterId") String clusterId); @GET @Path("/{clusterId}/summary") @Produces(MediaType.APPLICATION_JSON) ClusterSummary getClusterSummary(@PathParam("clusterId") String clusterId);  }