@Test public void getCluster_timeoutException_returnsTimeoutException() { expect(clusterManager.getCluster(CLUSTER_1.getClusterId())) .andReturn(failedFuture(new TimeoutException())); replay(clusterManager); FakeAsyncResponse response = new FakeAsyncResponse(); clustersResource.getCluster(response, CLUSTER_1.getClusterId()); assertEquals(TimeoutException.class, response.getException().getClass()); }
@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);  }