@Test public void getConsumer_nonExistingConsumer_throwsNotFound() { expect( consumerManager.getConsumer( CLUSTER_ID, CONSUMER_GROUP.getConsumerGroupId(), CONSUMERS[0].getConsumerId())) .andReturn(completedFuture(Optional.empty())); replay(consumerManager); FakeAsyncResponse response = new FakeAsyncResponse(); consumersResource.getConsumer( response, CLUSTER_ID, CONSUMER_GROUP.getConsumerGroupId(), CONSUMERS[0].getConsumerId()); assertEquals(NotFoundException.class, response.getException().getClass()); }
@GET @Path("/{consumerId}") @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.consumers.get") public void getConsumer( @Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId, @PathParam("consumerGroupId") String consumerGroupId, @PathParam("consumerId") String consumerId ) { CompletableFuture<GetConsumerResponse> response = consumerManager.get() .getConsumer(clusterId, consumerGroupId, consumerId) .thenApply(consumer -> consumer.orElseThrow(NotFoundException::new)) .thenApply( consumer -> GetConsumerResponse.create(toConsumerData(consumer))); AsyncResponses.asyncResume(asyncResponse, response); }
ConsumersResource { @GET @Path("/{consumerId}") @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.consumers.get") public void getConsumer( @Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId, @PathParam("consumerGroupId") String consumerGroupId, @PathParam("consumerId") String consumerId ) { CompletableFuture<GetConsumerResponse> response = consumerManager.get() .getConsumer(clusterId, consumerGroupId, consumerId) .thenApply(consumer -> consumer.orElseThrow(NotFoundException::new)) .thenApply( consumer -> GetConsumerResponse.create(toConsumerData(consumer))); AsyncResponses.asyncResume(asyncResponse, response); } }
ConsumersResource { @GET @Path("/{consumerId}") @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.consumers.get") public void getConsumer( @Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId, @PathParam("consumerGroupId") String consumerGroupId, @PathParam("consumerId") String consumerId ) { CompletableFuture<GetConsumerResponse> response = consumerManager.get() .getConsumer(clusterId, consumerGroupId, consumerId) .thenApply(consumer -> consumer.orElseThrow(NotFoundException::new)) .thenApply( consumer -> GetConsumerResponse.create(toConsumerData(consumer))); AsyncResponses.asyncResume(asyncResponse, response); } @Inject  ConsumersResource(
      Provider<ConsumerManager> consumerManager, CrnFactory crnFactory, UrlFactory urlFactory); }
ConsumersResource { @GET @Path("/{consumerId}") @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.consumers.get") public void getConsumer( @Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId, @PathParam("consumerGroupId") String consumerGroupId, @PathParam("consumerId") String consumerId ) { CompletableFuture<GetConsumerResponse> response = consumerManager.get() .getConsumer(clusterId, consumerGroupId, consumerId) .thenApply(consumer -> consumer.orElseThrow(NotFoundException::new)) .thenApply( consumer -> GetConsumerResponse.create(toConsumerData(consumer))); AsyncResponses.asyncResume(asyncResponse, response); } @Inject  ConsumersResource(
      Provider<ConsumerManager> consumerManager, CrnFactory crnFactory, UrlFactory urlFactory); @GET @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.consumers.list") void listConsumers(
      @Suspended AsyncResponse asyncResponse,
      @PathParam("clusterId") String clusterId,
      @PathParam("consumerGroupId") String consumerGroupId
  ); @GET @Path("/{consumerId}") @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.consumers.get") void getConsumer(
      @Suspended AsyncResponse asyncResponse,
      @PathParam("clusterId") String clusterId,
      @PathParam("consumerGroupId") String consumerGroupId,
      @PathParam("consumerId") String consumerId
  ); }
ConsumersResource { @GET @Path("/{consumerId}") @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.consumers.get") public void getConsumer( @Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId, @PathParam("consumerGroupId") String consumerGroupId, @PathParam("consumerId") String consumerId ) { CompletableFuture<GetConsumerResponse> response = consumerManager.get() .getConsumer(clusterId, consumerGroupId, consumerId) .thenApply(consumer -> consumer.orElseThrow(NotFoundException::new)) .thenApply( consumer -> GetConsumerResponse.create(toConsumerData(consumer))); AsyncResponses.asyncResume(asyncResponse, response); } @Inject  ConsumersResource(
      Provider<ConsumerManager> consumerManager, CrnFactory crnFactory, UrlFactory urlFactory); @GET @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.consumers.list") void listConsumers(
      @Suspended AsyncResponse asyncResponse,
      @PathParam("clusterId") String clusterId,
      @PathParam("consumerGroupId") String consumerGroupId
  ); @GET @Path("/{consumerId}") @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.consumers.get") void getConsumer(
      @Suspended AsyncResponse asyncResponse,
      @PathParam("clusterId") String clusterId,
      @PathParam("consumerGroupId") String consumerGroupId,
      @PathParam("consumerId") String consumerId
  );  }