### Question:
ClusterResource { @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Cluster createCluster(Cluster cluster) { return clusterService.addCluster(cluster); } @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);  }### Answer:
@Test public void createCluster() { final Cluster requestCluster = new Cluster("CLUSTER_TO_CREATE", "New Cluster"); when(clusterServiceMock.addCluster(any(Cluster.class))).then(new Answer<Cluster>() { @Override public Cluster answer(InvocationOnMock invocation) { Cluster argCluster = (Cluster) invocation.getArguments()[0]; assertEquals("Service cluster should equal the requested cluster", requestCluster, argCluster); return argCluster; } }); Cluster responseCluster = resource().path("/api/clusters") .accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON) .post(Cluster.class, requestCluster); assertEquals("Response cluster should match the request cluster", requestCluster, responseCluster); verify(clusterServiceMock).addCluster(any(Cluster.class)); }