@Test public void searchReassignments_existingCluster_returnsReassignments() { expect(reassignmentManager.searchReassignmentsByTopicName(CLUSTER_ID, TOPIC_1)) .andReturn( CompletableFuture.completedFuture( asList(REASSIGNMENT_1, REASSIGNMENT_2, REASSIGNMENT_3))); replay(reassignmentManager); FakeAsyncResponse response = new FakeAsyncResponse(); listReassignmentsByTopicAction.listReassignmentsByTopic(response, CLUSTER_ID, TOPIC_1); SearchReassignmentsByTopicResponse expected = SearchReassignmentsByTopicResponse.create( ReassignmentDataList.builder() .setMetadata( ResourceCollection.Metadata.builder() .setSelf("/v3/clusters/cluster-1/topics/topic-1/partitions/-/reassignments") .build()) .setData( Arrays.asList( ReassignmentData.builder() .setMetadata( Resource.Metadata.builder() .setSelf( "/v3/clusters/cluster-1/topics/topic-1/partitions/1" + "/reassignments") .setResourceName( "crn: + "/reassignments") .build()) .setClusterId(CLUSTER_ID) .setTopicName(TOPIC_1) .setPartitionId(PARTITION_ID_1) .setAddingReplicas(ADDING_REPLICAS_1) .setRemovingReplicas(REMOVING_REPLICAS_1) .setReplicas( Resource.Relationship.create( "/v3/clusters/cluster-1/topics/topic-1/partitions/1/replicas")) .build(), ReassignmentData.builder() .setMetadata( Resource.Metadata.builder() .setSelf( "/v3/clusters/cluster-1/topics/topic-1/partitions/2" + "/reassignments") .setResourceName( "crn: + "/reassignments") .build()) .setClusterId(CLUSTER_ID) .setTopicName(TOPIC_1) .setPartitionId(PARTITION_ID_2) .setAddingReplicas(ADDING_REPLICAS_2) .setRemovingReplicas(REMOVING_REPLICAS_2) .setReplicas( Resource.Relationship.create( "/v3/clusters/cluster-1/topics/topic-1/partitions/2/replicas")) .build(), ReassignmentData.builder() .setMetadata( Resource.Metadata.builder() .setSelf( "/v3/clusters/cluster-1/topics/topic-1/partitions/3" + "/reassignments") .setResourceName( "crn: + "/reassignments") .build()) .setClusterId(CLUSTER_ID) .setTopicName(TOPIC_1) .setPartitionId(PARTITION_ID_3) .setAddingReplicas(ADDING_REPLICAS_3) .setRemovingReplicas(REMOVING_REPLICAS_3) .setReplicas( Resource.Relationship.create( "/v3/clusters/cluster-1/topics/topic-1/partitions/3/replicas")) .build())) .build()); assertEquals(expected, response.getValue()); }
@GET @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.topics.partitions-reassignment.list") public void listReassignmentsByTopic( @Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId, @PathParam("topicName") String topicName) { CompletableFuture<SearchReassignmentsByTopicResponse> response = reassignmentManager.get().searchReassignmentsByTopicName(clusterId, topicName) .thenApply( reassignments -> SearchReassignmentsByTopicResponse.create( ReassignmentDataList.builder() .setMetadata( ResourceCollection.Metadata.builder() .setSelf( urlFactory.create( "v3", "clusters", clusterId, "topics", topicName, "partitions", "-", "reassignments")) .build()) .setData( reassignments.stream() .map(this::toReassignmentData) .collect(Collectors.toList())) .build())); AsyncResponses.asyncResume(asyncResponse, response); }
SearchReassignmentsByTopicAction { @GET @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.topics.partitions-reassignment.list") public void listReassignmentsByTopic( @Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId, @PathParam("topicName") String topicName) { CompletableFuture<SearchReassignmentsByTopicResponse> response = reassignmentManager.get().searchReassignmentsByTopicName(clusterId, topicName) .thenApply( reassignments -> SearchReassignmentsByTopicResponse.create( ReassignmentDataList.builder() .setMetadata( ResourceCollection.Metadata.builder() .setSelf( urlFactory.create( "v3", "clusters", clusterId, "topics", topicName, "partitions", "-", "reassignments")) .build()) .setData( reassignments.stream() .map(this::toReassignmentData) .collect(Collectors.toList())) .build())); AsyncResponses.asyncResume(asyncResponse, response); } }
SearchReassignmentsByTopicAction { @GET @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.topics.partitions-reassignment.list") public void listReassignmentsByTopic( @Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId, @PathParam("topicName") String topicName) { CompletableFuture<SearchReassignmentsByTopicResponse> response = reassignmentManager.get().searchReassignmentsByTopicName(clusterId, topicName) .thenApply( reassignments -> SearchReassignmentsByTopicResponse.create( ReassignmentDataList.builder() .setMetadata( ResourceCollection.Metadata.builder() .setSelf( urlFactory.create( "v3", "clusters", clusterId, "topics", topicName, "partitions", "-", "reassignments")) .build()) .setData( reassignments.stream() .map(this::toReassignmentData) .collect(Collectors.toList())) .build())); AsyncResponses.asyncResume(asyncResponse, response); } @Inject  SearchReassignmentsByTopicAction(
      Provider<ReassignmentManager> reassignmentManager,
      CrnFactory crnFactory,
      UrlFactory urlFactory); }
SearchReassignmentsByTopicAction { @GET @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.topics.partitions-reassignment.list") public void listReassignmentsByTopic( @Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId, @PathParam("topicName") String topicName) { CompletableFuture<SearchReassignmentsByTopicResponse> response = reassignmentManager.get().searchReassignmentsByTopicName(clusterId, topicName) .thenApply( reassignments -> SearchReassignmentsByTopicResponse.create( ReassignmentDataList.builder() .setMetadata( ResourceCollection.Metadata.builder() .setSelf( urlFactory.create( "v3", "clusters", clusterId, "topics", topicName, "partitions", "-", "reassignments")) .build()) .setData( reassignments.stream() .map(this::toReassignmentData) .collect(Collectors.toList())) .build())); AsyncResponses.asyncResume(asyncResponse, response); } @Inject  SearchReassignmentsByTopicAction(
      Provider<ReassignmentManager> reassignmentManager,
      CrnFactory crnFactory,
      UrlFactory urlFactory); @GET @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.topics.partitions-reassignment.list") void listReassignmentsByTopic(
      @Suspended AsyncResponse asyncResponse,
      @PathParam("clusterId") String clusterId,
      @PathParam("topicName") String topicName); }
SearchReassignmentsByTopicAction { @GET @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.topics.partitions-reassignment.list") public void listReassignmentsByTopic( @Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId, @PathParam("topicName") String topicName) { CompletableFuture<SearchReassignmentsByTopicResponse> response = reassignmentManager.get().searchReassignmentsByTopicName(clusterId, topicName) .thenApply( reassignments -> SearchReassignmentsByTopicResponse.create( ReassignmentDataList.builder() .setMetadata( ResourceCollection.Metadata.builder() .setSelf( urlFactory.create( "v3", "clusters", clusterId, "topics", topicName, "partitions", "-", "reassignments")) .build()) .setData( reassignments.stream() .map(this::toReassignmentData) .collect(Collectors.toList())) .build())); AsyncResponses.asyncResume(asyncResponse, response); } @Inject  SearchReassignmentsByTopicAction(
      Provider<ReassignmentManager> reassignmentManager,
      CrnFactory crnFactory,
      UrlFactory urlFactory); @GET @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.topics.partitions-reassignment.list") void listReassignmentsByTopic(
      @Suspended AsyncResponse asyncResponse,
      @PathParam("clusterId") String clusterId,
      @PathParam("topicName") String topicName);  }