@Test public void getConsumerGroup_returnsConsumerGroup() { expect( consumerGroupManager.getConsumerGroup( CLUSTER_ID, CONSUMER_GROUPS[0].getConsumerGroupId())) .andReturn(completedFuture(Optional.of(CONSUMER_GROUPS[0]))); replay(consumerGroupManager); FakeAsyncResponse response = new FakeAsyncResponse(); consumerGroupsResource.getConsumerGroup( response, CLUSTER_ID, CONSUMER_GROUPS[0].getConsumerGroupId()); GetConsumerGroupResponse expected = GetConsumerGroupResponse.create( ConsumerGroupData.fromConsumerGroup(CONSUMER_GROUPS[0]) .setMetadata( Resource.Metadata.builder() .setSelf( "/v3/clusters/cluster-1/consumer-groups/consumer-group-1") .setResourceName( "crn: .build()) .setCoordinator( Relationship.create("/v3/clusters/cluster-1/brokers/1")) .setConsumers( Relationship.create( "/v3/clusters/cluster-1/consumer-groups/consumer-group-1" + "/consumers")) .build()); assertEquals(expected, response.getValue()); }
@GET @Path("/{consumerGroupId}") @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.consumer-groups.get") public void getConsumerGroup( @Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId, @PathParam("consumerGroupId") String consumerGroupId ) { CompletableFuture<GetConsumerGroupResponse> response = consumerGroupManager.get() .getConsumerGroup(clusterId, consumerGroupId) .thenApply(consumerGroup -> consumerGroup.orElseThrow(NotFoundException::new)) .thenApply( consumerGroup -> GetConsumerGroupResponse.create(toConsumerGroupData(clusterId, consumerGroup))); AsyncResponses.asyncResume(asyncResponse, response); }
ConsumerGroupsResource { @GET @Path("/{consumerGroupId}") @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.consumer-groups.get") public void getConsumerGroup( @Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId, @PathParam("consumerGroupId") String consumerGroupId ) { CompletableFuture<GetConsumerGroupResponse> response = consumerGroupManager.get() .getConsumerGroup(clusterId, consumerGroupId) .thenApply(consumerGroup -> consumerGroup.orElseThrow(NotFoundException::new)) .thenApply( consumerGroup -> GetConsumerGroupResponse.create(toConsumerGroupData(clusterId, consumerGroup))); AsyncResponses.asyncResume(asyncResponse, response); } }
ConsumerGroupsResource { @GET @Path("/{consumerGroupId}") @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.consumer-groups.get") public void getConsumerGroup( @Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId, @PathParam("consumerGroupId") String consumerGroupId ) { CompletableFuture<GetConsumerGroupResponse> response = consumerGroupManager.get() .getConsumerGroup(clusterId, consumerGroupId) .thenApply(consumerGroup -> consumerGroup.orElseThrow(NotFoundException::new)) .thenApply( consumerGroup -> GetConsumerGroupResponse.create(toConsumerGroupData(clusterId, consumerGroup))); AsyncResponses.asyncResume(asyncResponse, response); } @Inject  ConsumerGroupsResource(
      Provider<ConsumerGroupManager> consumerGroupManager,
      CrnFactory crnFactory,
      UrlFactory urlFactory); }
ConsumerGroupsResource { @GET @Path("/{consumerGroupId}") @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.consumer-groups.get") public void getConsumerGroup( @Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId, @PathParam("consumerGroupId") String consumerGroupId ) { CompletableFuture<GetConsumerGroupResponse> response = consumerGroupManager.get() .getConsumerGroup(clusterId, consumerGroupId) .thenApply(consumerGroup -> consumerGroup.orElseThrow(NotFoundException::new)) .thenApply( consumerGroup -> GetConsumerGroupResponse.create(toConsumerGroupData(clusterId, consumerGroup))); AsyncResponses.asyncResume(asyncResponse, response); } @Inject  ConsumerGroupsResource(
      Provider<ConsumerGroupManager> consumerGroupManager,
      CrnFactory crnFactory,
      UrlFactory urlFactory); @GET @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.consumer-groups.list") void listConsumerGroups(
      @Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId); @GET @Path("/{consumerGroupId}") @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.consumer-groups.get") void getConsumerGroup(
      @Suspended AsyncResponse asyncResponse,
      @PathParam("clusterId") String clusterId,
      @PathParam("consumerGroupId") String consumerGroupId
  ); }
ConsumerGroupsResource { @GET @Path("/{consumerGroupId}") @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.consumer-groups.get") public void getConsumerGroup( @Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId, @PathParam("consumerGroupId") String consumerGroupId ) { CompletableFuture<GetConsumerGroupResponse> response = consumerGroupManager.get() .getConsumerGroup(clusterId, consumerGroupId) .thenApply(consumerGroup -> consumerGroup.orElseThrow(NotFoundException::new)) .thenApply( consumerGroup -> GetConsumerGroupResponse.create(toConsumerGroupData(clusterId, consumerGroup))); AsyncResponses.asyncResume(asyncResponse, response); } @Inject  ConsumerGroupsResource(
      Provider<ConsumerGroupManager> consumerGroupManager,
      CrnFactory crnFactory,
      UrlFactory urlFactory); @GET @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.consumer-groups.list") void listConsumerGroups(
      @Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId); @GET @Path("/{consumerGroupId}") @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.consumer-groups.get") void getConsumerGroup(
      @Suspended AsyncResponse asyncResponse,
      @PathParam("clusterId") String clusterId,
      @PathParam("consumerGroupId") String consumerGroupId
  );  }