@Test public void getReplica_nonExistingReplica_throwNotFound() { expect(replicaManager.getReplica(CLUSTER_ID, TOPIC_NAME, PARTITION_ID, REPLICA_1.getBrokerId())) .andReturn(completedFuture(Optional.empty())); replay(replicaManager); FakeAsyncResponse response = new FakeAsyncResponse(); replicasResource.getReplica( response, CLUSTER_ID, TOPIC_NAME, PARTITION_ID, REPLICA_1.getBrokerId()); assertEquals(NotFoundException.class, response.getException().getClass()); }
@GET @Path("/{brokerId}") @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.replicas.get") public void getReplica( @Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId, @PathParam("topicName") String topicName, @PathParam("partitionId") Integer partitionId, @PathParam("brokerId") Integer brokerId ) { CompletableFuture<GetReplicaResponse> response = replicaManager.get() .getReplica(clusterId, topicName, partitionId, brokerId) .thenApply(replica -> replica.orElseThrow(NotFoundException::new)) .thenApply(replica -> GetReplicaResponse.create(toReplicaData(replica))); AsyncResponses.asyncResume(asyncResponse, response); }
ReplicasResource { @GET @Path("/{brokerId}") @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.replicas.get") public void getReplica( @Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId, @PathParam("topicName") String topicName, @PathParam("partitionId") Integer partitionId, @PathParam("brokerId") Integer brokerId ) { CompletableFuture<GetReplicaResponse> response = replicaManager.get() .getReplica(clusterId, topicName, partitionId, brokerId) .thenApply(replica -> replica.orElseThrow(NotFoundException::new)) .thenApply(replica -> GetReplicaResponse.create(toReplicaData(replica))); AsyncResponses.asyncResume(asyncResponse, response); } }
ReplicasResource { @GET @Path("/{brokerId}") @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.replicas.get") public void getReplica( @Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId, @PathParam("topicName") String topicName, @PathParam("partitionId") Integer partitionId, @PathParam("brokerId") Integer brokerId ) { CompletableFuture<GetReplicaResponse> response = replicaManager.get() .getReplica(clusterId, topicName, partitionId, brokerId) .thenApply(replica -> replica.orElseThrow(NotFoundException::new)) .thenApply(replica -> GetReplicaResponse.create(toReplicaData(replica))); AsyncResponses.asyncResume(asyncResponse, response); } @Inject  ReplicasResource(
      Provider<ReplicaManager> replicaManager, CrnFactory crnFactory, UrlFactory urlFactory); }
ReplicasResource { @GET @Path("/{brokerId}") @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.replicas.get") public void getReplica( @Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId, @PathParam("topicName") String topicName, @PathParam("partitionId") Integer partitionId, @PathParam("brokerId") Integer brokerId ) { CompletableFuture<GetReplicaResponse> response = replicaManager.get() .getReplica(clusterId, topicName, partitionId, brokerId) .thenApply(replica -> replica.orElseThrow(NotFoundException::new)) .thenApply(replica -> GetReplicaResponse.create(toReplicaData(replica))); AsyncResponses.asyncResume(asyncResponse, response); } @Inject  ReplicasResource(
      Provider<ReplicaManager> replicaManager, CrnFactory crnFactory, UrlFactory urlFactory); @GET @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.replicas.list") void listReplicas(
      @Suspended AsyncResponse asyncResponse,
      @PathParam("clusterId") String clusterId,
      @PathParam("topicName") String topicName,
      @PathParam("partitionId") Integer partitionId
  ); @GET @Path("/{brokerId}") @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.replicas.get") void getReplica(
      @Suspended AsyncResponse asyncResponse,
      @PathParam("clusterId") String clusterId,
      @PathParam("topicName") String topicName,
      @PathParam("partitionId") Integer partitionId,
      @PathParam("brokerId") Integer brokerId
  ); }
ReplicasResource { @GET @Path("/{brokerId}") @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.replicas.get") public void getReplica( @Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId, @PathParam("topicName") String topicName, @PathParam("partitionId") Integer partitionId, @PathParam("brokerId") Integer brokerId ) { CompletableFuture<GetReplicaResponse> response = replicaManager.get() .getReplica(clusterId, topicName, partitionId, brokerId) .thenApply(replica -> replica.orElseThrow(NotFoundException::new)) .thenApply(replica -> GetReplicaResponse.create(toReplicaData(replica))); AsyncResponses.asyncResume(asyncResponse, response); } @Inject  ReplicasResource(
      Provider<ReplicaManager> replicaManager, CrnFactory crnFactory, UrlFactory urlFactory); @GET @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.replicas.list") void listReplicas(
      @Suspended AsyncResponse asyncResponse,
      @PathParam("clusterId") String clusterId,
      @PathParam("topicName") String topicName,
      @PathParam("partitionId") Integer partitionId
  ); @GET @Path("/{brokerId}") @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.replicas.get") void getReplica(
      @Suspended AsyncResponse asyncResponse,
      @PathParam("clusterId") String clusterId,
      @PathParam("topicName") String topicName,
      @PathParam("partitionId") Integer partitionId,
      @PathParam("brokerId") Integer brokerId
  );  }