Search in sources :

Example 1 with GetClusterResponse

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

the class ClustersResourceIntegrationTest method getCluster_ownCluster_returnsOwnCluster.

@Test
public void getCluster_ownCluster_returnsOwnCluster() {
    String baseUrl = restConnect;
    String clusterId = getClusterId();
    int controllerId = getControllerID();
    GetClusterResponse expected = GetClusterResponse.create(ClusterData.builder().setMetadata(Resource.Metadata.builder().setSelf(baseUrl + "/v3/clusters/" + clusterId).setResourceName("crn:///kafka=" + clusterId).build()).setClusterId(clusterId).setController(Resource.Relationship.create(baseUrl + "/v3/clusters/" + clusterId + "/brokers/" + controllerId)).setAcls(Resource.Relationship.create(baseUrl + "/v3/clusters/" + clusterId + "/acls")).setBrokers(Resource.Relationship.create(baseUrl + "/v3/clusters/" + clusterId + "/brokers")).setBrokerConfigs(Resource.Relationship.create(baseUrl + "/v3/clusters/" + clusterId + "/broker-configs")).setConsumerGroups(Resource.Relationship.create(baseUrl + "/v3/clusters/" + clusterId + "/consumer-groups")).setTopics(Resource.Relationship.create(baseUrl + "/v3/clusters/" + clusterId + "/topics")).setPartitionReassignments(Resource.Relationship.create(baseUrl + "/v3/clusters/" + clusterId + "/topics/-/partitions/-/reassignment")).build());
    Response response = request(String.format("/v3/clusters/%s", clusterId)).accept(MediaType.APPLICATION_JSON).get();
    assertEquals(Status.OK.getStatusCode(), response.getStatus());
    GetClusterResponse actual = response.readEntity(GetClusterResponse.class);
    assertEquals(expected, actual);
}
Also used : GetClusterResponse(io.confluent.kafkarest.entities.v3.GetClusterResponse) GetClusterResponse(io.confluent.kafkarest.entities.v3.GetClusterResponse) ListClustersResponse(io.confluent.kafkarest.entities.v3.ListClustersResponse) Response(javax.ws.rs.core.Response) Test(org.junit.jupiter.api.Test)

Example 2 with GetClusterResponse

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

the class ClustersResourceTest method getCluster_ownCluster_returnsCluster.

@Test
public void getCluster_ownCluster_returnsCluster() {
    expect(clusterManager.getCluster(CLUSTER_1.getClusterId())).andReturn(CompletableFuture.completedFuture(Optional.of(CLUSTER_1)));
    replay(clusterManager);
    FakeAsyncResponse response = new FakeAsyncResponse();
    clustersResource.getCluster(response, CLUSTER_1.getClusterId());
    GetClusterResponse expected = GetClusterResponse.create(ClusterData.builder().setMetadata(Resource.Metadata.builder().setSelf("/v3/clusters/cluster-1").setResourceName("crn:///kafka=cluster-1").build()).setClusterId("cluster-1").setController(Resource.Relationship.create("/v3/clusters/cluster-1/brokers/1")).setAcls(Resource.Relationship.create("/v3/clusters/cluster-1/acls")).setBrokers(Resource.Relationship.create("/v3/clusters/cluster-1/brokers")).setBrokerConfigs(Resource.Relationship.create("/v3/clusters/cluster-1/broker-configs")).setConsumerGroups(Resource.Relationship.create("/v3/clusters/cluster-1/consumer-groups")).setTopics(Resource.Relationship.create("/v3/clusters/cluster-1/topics")).setPartitionReassignments(Resource.Relationship.create("/v3/clusters/cluster-1/topics/-/partitions" + "/-/reassignment")).build());
    assertEquals(expected, response.getValue());
}
Also used : GetClusterResponse(io.confluent.kafkarest.entities.v3.GetClusterResponse) FakeAsyncResponse(io.confluent.kafkarest.response.FakeAsyncResponse) Test(org.junit.jupiter.api.Test)

Aggregations

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