Search in sources :

Example 1 with GetReplicaResponse

use of io.confluent.kafkarest.entities.v3.GetReplicaResponse in project kafka-rest by confluentinc.

the class ReplicasResourceTest method getReplica_existingReplica_returnsReplica.

@Test
public void getReplica_existingReplica_returnsReplica() {
    expect(replicaManager.getReplica(CLUSTER_ID, TOPIC_NAME, PARTITION_ID, REPLICA_1.getBrokerId())).andReturn(completedFuture(Optional.of(REPLICA_1)));
    replay(replicaManager);
    FakeAsyncResponse response = new FakeAsyncResponse();
    replicasResource.getReplica(response, CLUSTER_ID, TOPIC_NAME, PARTITION_ID, REPLICA_1.getBrokerId());
    GetReplicaResponse expected = GetReplicaResponse.create(ReplicaData.builder().setMetadata(Resource.Metadata.builder().setSelf("/v3/clusters/cluster-1/topics/topic-1/partitions/0/replicas/1").setResourceName("crn:///kafka=cluster-1/topic=topic-1/partition=0/replica=1").build()).setClusterId(CLUSTER_ID).setTopicName(TOPIC_NAME).setPartitionId(PARTITION_ID).setBrokerId(REPLICA_1.getBrokerId()).setLeader(true).setInSync(true).setBroker(Resource.Relationship.create("/v3/clusters/cluster-1/brokers/1")).build());
    assertEquals(expected, response.getValue());
}
Also used : GetReplicaResponse(io.confluent.kafkarest.entities.v3.GetReplicaResponse) FakeAsyncResponse(io.confluent.kafkarest.response.FakeAsyncResponse) Test(org.junit.jupiter.api.Test)

Example 2 with GetReplicaResponse

use of io.confluent.kafkarest.entities.v3.GetReplicaResponse in project kafka-rest by confluentinc.

the class ReplicasResourceIntegrationTest method getReplica_existingReplica_returnsReplica.

@Test
public void getReplica_existingReplica_returnsReplica() {
    String baseUrl = restConnect;
    String clusterId = getClusterId();
    GetReplicaResponse expected = GetReplicaResponse.create(ReplicaData.builder().setMetadata(Resource.Metadata.builder().setSelf(baseUrl + "/v3/clusters/" + clusterId + "/topics/" + TOPIC_NAME + "/partitions/0/replicas/0").setResourceName("crn:///kafka=" + clusterId + "/topic=" + TOPIC_NAME + "/partition=0/replica=0").build()).setClusterId(clusterId).setTopicName(TOPIC_NAME).setPartitionId(0).setBrokerId(0).setLeader(true).setInSync(true).setBroker(Resource.Relationship.create(baseUrl + "/v3/clusters/" + clusterId + "/brokers/0")).build());
    Response response = request("/v3/clusters/" + clusterId + "/topics/" + TOPIC_NAME + "/partitions/0/replicas/0").accept(MediaType.APPLICATION_JSON).get();
    assertEquals(Status.OK.getStatusCode(), response.getStatus());
    GetReplicaResponse actual = response.readEntity(GetReplicaResponse.class);
    assertEquals(expected, actual);
}
Also used : GetReplicaResponse(io.confluent.kafkarest.entities.v3.GetReplicaResponse) ListReplicasResponse(io.confluent.kafkarest.entities.v3.ListReplicasResponse) Response(javax.ws.rs.core.Response) GetReplicaResponse(io.confluent.kafkarest.entities.v3.GetReplicaResponse) Test(org.junit.jupiter.api.Test)

Aggregations

GetReplicaResponse (io.confluent.kafkarest.entities.v3.GetReplicaResponse)2 Test (org.junit.jupiter.api.Test)2 ListReplicasResponse (io.confluent.kafkarest.entities.v3.ListReplicasResponse)1 FakeAsyncResponse (io.confluent.kafkarest.response.FakeAsyncResponse)1 Response (javax.ws.rs.core.Response)1