@Test public void getCluster_ownCluster_returnsCluster() { expect(clusterManager.getCluster(CLUSTER_1.getClusterId())) .andReturn(CompletableFuture.completedFuture(Optional.of(CLUSTER_1))); replay(clusterManager); FakeAsyncResponse response = new FakeAsyncResponse(); clustersResource.getCluster(response, CLUSTER_1.getClusterId()); GetClusterResponse expected = GetClusterResponse.create( ClusterData.builder() .setMetadata( Resource.Metadata.builder() .setSelf("/v3/clusters/cluster-1") .setResourceName("crn: .build()) .setClusterId("cluster-1") .setController(Resource.Relationship.create("/v3/clusters/cluster-1/brokers/1")) .setAcls(Resource.Relationship.create("/v3/clusters/cluster-1/acls")) .setBrokers(Resource.Relationship.create("/v3/clusters/cluster-1/brokers")) .setBrokerConfigs( Resource.Relationship.create("/v3/clusters/cluster-1/broker-configs")) .setConsumerGroups( Resource.Relationship.create("/v3/clusters/cluster-1/consumer-groups")) .setTopics(Resource.Relationship.create("/v3/clusters/cluster-1/topics")) .setPartitionReassignments( Resource.Relationship.create("/v3/clusters/cluster-1/topics/-/partitions" + "/-/reassignment")) .build()); assertEquals(expected, response.getValue()); }
@GET @Path("/{clusterId}") @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.clusters.get") public void getCluster( @Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId) { CompletableFuture<GetClusterResponse> response = clusterManager.get() .getCluster(clusterId) .thenApply(cluster -> cluster.orElseThrow(NotFoundException::new)) .thenApply(cluster -> GetClusterResponse.create(toClusterData(cluster))); AsyncResponses.asyncResume(asyncResponse, response); }
ClustersResource { @GET @Path("/{clusterId}") @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.clusters.get") public void getCluster( @Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId) { CompletableFuture<GetClusterResponse> response = clusterManager.get() .getCluster(clusterId) .thenApply(cluster -> cluster.orElseThrow(NotFoundException::new)) .thenApply(cluster -> GetClusterResponse.create(toClusterData(cluster))); AsyncResponses.asyncResume(asyncResponse, response); } }
ClustersResource { @GET @Path("/{clusterId}") @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.clusters.get") public void getCluster( @Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId) { CompletableFuture<GetClusterResponse> response = clusterManager.get() .getCluster(clusterId) .thenApply(cluster -> cluster.orElseThrow(NotFoundException::new)) .thenApply(cluster -> GetClusterResponse.create(toClusterData(cluster))); AsyncResponses.asyncResume(asyncResponse, response); } @Inject  ClustersResource(
      Provider<ClusterManager> clusterManager,
      CrnFactory crnFactory,
      UrlFactory urlFactory
  ); }
ClustersResource { @GET @Path("/{clusterId}") @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.clusters.get") public void getCluster( @Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId) { CompletableFuture<GetClusterResponse> response = clusterManager.get() .getCluster(clusterId) .thenApply(cluster -> cluster.orElseThrow(NotFoundException::new)) .thenApply(cluster -> GetClusterResponse.create(toClusterData(cluster))); AsyncResponses.asyncResume(asyncResponse, response); } @Inject  ClustersResource(
      Provider<ClusterManager> clusterManager,
      CrnFactory crnFactory,
      UrlFactory urlFactory
  ); @GET @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.clusters.list") void listClusters(@Suspended AsyncResponse asyncResponse); @GET @Path("/{clusterId}") @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.clusters.get") void getCluster(
      @Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId); }
ClustersResource { @GET @Path("/{clusterId}") @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.clusters.get") public void getCluster( @Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId) { CompletableFuture<GetClusterResponse> response = clusterManager.get() .getCluster(clusterId) .thenApply(cluster -> cluster.orElseThrow(NotFoundException::new)) .thenApply(cluster -> GetClusterResponse.create(toClusterData(cluster))); AsyncResponses.asyncResume(asyncResponse, response); } @Inject  ClustersResource(
      Provider<ClusterManager> clusterManager,
      CrnFactory crnFactory,
      UrlFactory urlFactory
  ); @GET @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.clusters.list") void listClusters(@Suspended AsyncResponse asyncResponse); @GET @Path("/{clusterId}") @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.clusters.get") void getCluster(
      @Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId);  }