use of io.confluent.kafkarest.entities.v3.SearchReplicasByBrokerResponse in project kafka-rest by confluentinc.
the class SearchReplicasByBrokerActionTest method searchReplicasByBroker_existingBroker_returnsReplicas.
@Test
public void searchReplicasByBroker_existingBroker_returnsReplicas() {
expect(replicaManager.searchReplicasByBrokerId(CLUSTER_ID, BROKER_ID)).andReturn(completedFuture(Arrays.asList(REPLICA_1, REPLICA_2)));
replay(replicaManager);
FakeAsyncResponse response = new FakeAsyncResponse();
searchReplicasByBrokerAction.searchReplicasByBroker(response, CLUSTER_ID, BROKER_ID);
SearchReplicasByBrokerResponse expected = SearchReplicasByBrokerResponse.create(ReplicaDataList.builder().setMetadata(ResourceCollection.Metadata.builder().setSelf("/v3/clusters/cluster-1/brokers/1/partition-replicas").build()).setData(Arrays.asList(ReplicaData.builder().setMetadata(Resource.Metadata.builder().setSelf("/v3/clusters/cluster-1/topics/topic-1/partitions/1" + "/replicas/1").setResourceName("crn:///kafka=cluster-1/topic=topic-1/partition=1" + "/replica=1").build()).setClusterId(CLUSTER_ID).setTopicName(TOPIC_NAME).setPartitionId(REPLICA_1.getPartitionId()).setBrokerId(BROKER_ID).setLeader(true).setInSync(true).setBroker(Resource.Relationship.create("/v3/clusters/cluster-1/brokers/1")).build(), ReplicaData.builder().setMetadata(Resource.Metadata.builder().setSelf("/v3/clusters/cluster-1/topics/topic-1/partitions/2" + "/replicas/1").setResourceName("crn:///kafka=cluster-1/topic=topic-1/partition=2" + "/replica=1").build()).setClusterId(CLUSTER_ID).setTopicName(TOPIC_NAME).setPartitionId(REPLICA_2.getPartitionId()).setBrokerId(BROKER_ID).setLeader(false).setInSync(false).setBroker(Resource.Relationship.create("/v3/clusters/cluster-1/brokers/1")).build())).build());
assertEquals(expected, response.getValue());
}
use of io.confluent.kafkarest.entities.v3.SearchReplicasByBrokerResponse in project kafka-rest by confluentinc.
the class SearchReplicasByBrokerActionIntegrationTest method searchReplicasByBroker_existingBroker_returnsReplicas.
@Test
public void searchReplicasByBroker_existingBroker_returnsReplicas() {
String baseUrl = restConnect;
String clusterId = getClusterId();
SearchReplicasByBrokerResponse expected = SearchReplicasByBrokerResponse.create(ReplicaDataList.builder().setMetadata(ResourceCollection.Metadata.builder().setSelf(baseUrl + "/v3/clusters/" + clusterId + "/brokers/" + BROKER_ID + "/partition-replicas").build()).setData(Arrays.asList(ReplicaData.builder().setMetadata(Resource.Metadata.builder().setSelf(baseUrl + "/v3/clusters/" + clusterId + "/topics/" + TOPIC_NAME + "/partitions/0/replicas/" + BROKER_ID).setResourceName("crn:///kafka=" + clusterId + "/topic=" + TOPIC_NAME + "/partition=0/replica=" + BROKER_ID).build()).setClusterId(clusterId).setTopicName(TOPIC_NAME).setPartitionId(0).setBrokerId(BROKER_ID).setLeader(true).setInSync(true).setBroker(Resource.Relationship.create(baseUrl + "/v3/clusters/" + clusterId + "/brokers/" + BROKER_ID)).build(), ReplicaData.builder().setMetadata(Resource.Metadata.builder().setSelf(baseUrl + "/v3/clusters/" + clusterId + "/topics/" + TOPIC_NAME + "/partitions/1/replicas/" + BROKER_ID).setResourceName("crn:///kafka=" + clusterId + "/topic=" + TOPIC_NAME + "/partition=1/replica=" + BROKER_ID).build()).setClusterId(clusterId).setTopicName(TOPIC_NAME).setPartitionId(1).setBrokerId(BROKER_ID).setLeader(false).setInSync(true).setBroker(Resource.Relationship.create(baseUrl + "/v3/clusters/" + clusterId + "/brokers/" + BROKER_ID)).build())).build());
Response response = request("/v3/clusters/" + clusterId + "/brokers/" + BROKER_ID + "/partition-replicas").accept(MediaType.APPLICATION_JSON).get();
assertEquals(Status.OK.getStatusCode(), response.getStatus());
SearchReplicasByBrokerResponse actual = response.readEntity(SearchReplicasByBrokerResponse.class);
assertEquals(expected, actual);
}
Aggregations