@Test public void getConsumer_nonExistingConsumer_throwsNotFound() { expect( consumerAssignmentManager.getConsumerAssignment( CLUSTER_ID, CONSUMER_GROUP_ID, CONSUMER_ID, "topic-1", 1)) .andReturn(completedFuture(Optional.empty())); replay(consumerAssignmentManager); FakeAsyncResponse response = new FakeAsyncResponse(); consumerAssignmentsResource.getConsumerAssignment( response, CLUSTER_ID, CONSUMER_GROUP_ID, CONSUMER_ID, "topic-1", 1); assertEquals(NotFoundException.class, response.getException().getClass()); }
@GET @Path("/{topicName}/partitions/{partitionId}") @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.consumer-assignments.get") public void getConsumerAssignment( @Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId, @PathParam("consumerGroupId") String consumerGroupId, @PathParam("consumerId") String consumerId, @PathParam("topicName") String topicName, @PathParam("partitionId") int partitionId ) { CompletableFuture<GetConsumerAssignmentResponse> response = consumerAssignmentManager.get() .getConsumerAssignment(clusterId, consumerGroupId, consumerId, topicName, partitionId) .thenApply(assignment -> assignment.orElseThrow(NotFoundException::new)) .thenApply( assignment -> GetConsumerAssignmentResponse.create(toConsumerAssignmentData(assignment))); AsyncResponses.asyncResume(asyncResponse, response); }
ConsumerAssignmentsResource { @GET @Path("/{topicName}/partitions/{partitionId}") @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.consumer-assignments.get") public void getConsumerAssignment( @Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId, @PathParam("consumerGroupId") String consumerGroupId, @PathParam("consumerId") String consumerId, @PathParam("topicName") String topicName, @PathParam("partitionId") int partitionId ) { CompletableFuture<GetConsumerAssignmentResponse> response = consumerAssignmentManager.get() .getConsumerAssignment(clusterId, consumerGroupId, consumerId, topicName, partitionId) .thenApply(assignment -> assignment.orElseThrow(NotFoundException::new)) .thenApply( assignment -> GetConsumerAssignmentResponse.create(toConsumerAssignmentData(assignment))); AsyncResponses.asyncResume(asyncResponse, response); } }
ConsumerAssignmentsResource { @GET @Path("/{topicName}/partitions/{partitionId}") @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.consumer-assignments.get") public void getConsumerAssignment( @Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId, @PathParam("consumerGroupId") String consumerGroupId, @PathParam("consumerId") String consumerId, @PathParam("topicName") String topicName, @PathParam("partitionId") int partitionId ) { CompletableFuture<GetConsumerAssignmentResponse> response = consumerAssignmentManager.get() .getConsumerAssignment(clusterId, consumerGroupId, consumerId, topicName, partitionId) .thenApply(assignment -> assignment.orElseThrow(NotFoundException::new)) .thenApply( assignment -> GetConsumerAssignmentResponse.create(toConsumerAssignmentData(assignment))); AsyncResponses.asyncResume(asyncResponse, response); } @Inject  ConsumerAssignmentsResource(
      Provider<ConsumerAssignmentManager> consumerAssignmentManager,
      CrnFactory crnFactory,
      UrlFactory urlFactory
  ); }
ConsumerAssignmentsResource { @GET @Path("/{topicName}/partitions/{partitionId}") @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.consumer-assignments.get") public void getConsumerAssignment( @Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId, @PathParam("consumerGroupId") String consumerGroupId, @PathParam("consumerId") String consumerId, @PathParam("topicName") String topicName, @PathParam("partitionId") int partitionId ) { CompletableFuture<GetConsumerAssignmentResponse> response = consumerAssignmentManager.get() .getConsumerAssignment(clusterId, consumerGroupId, consumerId, topicName, partitionId) .thenApply(assignment -> assignment.orElseThrow(NotFoundException::new)) .thenApply( assignment -> GetConsumerAssignmentResponse.create(toConsumerAssignmentData(assignment))); AsyncResponses.asyncResume(asyncResponse, response); } @Inject  ConsumerAssignmentsResource(
      Provider<ConsumerAssignmentManager> consumerAssignmentManager,
      CrnFactory crnFactory,
      UrlFactory urlFactory
  ); @GET @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.consumer-assignments.list") void listConsumerAssignments(
      @Suspended AsyncResponse asyncResponse,
      @PathParam("clusterId") String clusterId,
      @PathParam("consumerGroupId") String consumerGroupId,
      @PathParam("consumerId") String consumerId
  ); @GET @Path("/{topicName}/partitions/{partitionId}") @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.consumer-assignments.get") void getConsumerAssignment(
      @Suspended AsyncResponse asyncResponse,
      @PathParam("clusterId") String clusterId,
      @PathParam("consumerGroupId") String consumerGroupId,
      @PathParam("consumerId") String consumerId,
      @PathParam("topicName") String topicName,
      @PathParam("partitionId") int partitionId
  ); }
ConsumerAssignmentsResource { @GET @Path("/{topicName}/partitions/{partitionId}") @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.consumer-assignments.get") public void getConsumerAssignment( @Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId, @PathParam("consumerGroupId") String consumerGroupId, @PathParam("consumerId") String consumerId, @PathParam("topicName") String topicName, @PathParam("partitionId") int partitionId ) { CompletableFuture<GetConsumerAssignmentResponse> response = consumerAssignmentManager.get() .getConsumerAssignment(clusterId, consumerGroupId, consumerId, topicName, partitionId) .thenApply(assignment -> assignment.orElseThrow(NotFoundException::new)) .thenApply( assignment -> GetConsumerAssignmentResponse.create(toConsumerAssignmentData(assignment))); AsyncResponses.asyncResume(asyncResponse, response); } @Inject  ConsumerAssignmentsResource(
      Provider<ConsumerAssignmentManager> consumerAssignmentManager,
      CrnFactory crnFactory,
      UrlFactory urlFactory
  ); @GET @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.consumer-assignments.list") void listConsumerAssignments(
      @Suspended AsyncResponse asyncResponse,
      @PathParam("clusterId") String clusterId,
      @PathParam("consumerGroupId") String consumerGroupId,
      @PathParam("consumerId") String consumerId
  ); @GET @Path("/{topicName}/partitions/{partitionId}") @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.consumer-assignments.get") void getConsumerAssignment(
      @Suspended AsyncResponse asyncResponse,
      @PathParam("clusterId") String clusterId,
      @PathParam("consumerGroupId") String consumerGroupId,
      @PathParam("consumerId") String consumerId,
      @PathParam("topicName") String topicName,
      @PathParam("partitionId") int partitionId
  );  }