@Test public void getClusterSummary() { final String requestClusterId = "CLUSTER_TO_GET_SUMMARY"; final ClusterSummary mockedClusterSummary = new ClusterSummary(); when(clusterServiceMock.getClusterSummary(anyString())).then(new Answer<ClusterSummary>() { @Override public ClusterSummary answer(InvocationOnMock invocation) throws Throwable { String argClusterId = (String) invocation.getArguments()[0]; assertEquals("Service cluster ID should match the requested cluster ID", argClusterId, requestClusterId); return mockedClusterSummary; } }); ClusterSummary responseClusterSummary = resource() .path("/api/clusters/" + requestClusterId + "/summary") .accept(MediaType.APPLICATION_JSON).get(ClusterSummary.class); assertEquals("Response cluster summary should match the mocked cluster summary", mockedClusterSummary, responseClusterSummary); verify(clusterServiceMock).getClusterSummary(anyString()); }
@GET @Path("/{clusterId}/summary") @Produces(MediaType.APPLICATION_JSON) public ClusterSummary getClusterSummary(@PathParam("clusterId") String clusterId) { return clusterService.getClusterSummary(clusterId); }
ClusterResource { @GET @Path("/{clusterId}/summary") @Produces(MediaType.APPLICATION_JSON) public ClusterSummary getClusterSummary(@PathParam("clusterId") String clusterId) { return clusterService.getClusterSummary(clusterId); } }
ClusterResource { @GET @Path("/{clusterId}/summary") @Produces(MediaType.APPLICATION_JSON) public ClusterSummary getClusterSummary(@PathParam("clusterId") String clusterId) { return clusterService.getClusterSummary(clusterId); } @Inject  ClusterResource(ClusterService clusterService); }
ClusterResource { @GET @Path("/{clusterId}/summary") @Produces(MediaType.APPLICATION_JSON) public ClusterSummary getClusterSummary(@PathParam("clusterId") String clusterId) { return clusterService.getClusterSummary(clusterId); } @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 { @GET @Path("/{clusterId}/summary") @Produces(MediaType.APPLICATION_JSON) public ClusterSummary getClusterSummary(@PathParam("clusterId") String clusterId) { return clusterService.getClusterSummary(clusterId); } @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);  }