use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class ClustersResourceTest method listClusters_returnsArrayWithOwnClusters.
@Test
public void listClusters_returnsArrayWithOwnClusters() {
expect(clusterManager.listClusters()).andReturn(CompletableFuture.completedFuture(singletonList(CLUSTER_1)));
replay(clusterManager);
FakeAsyncResponse response = new FakeAsyncResponse();
clustersResource.listClusters(response);
ListClustersResponse expected = ListClustersResponse.create(ClusterDataList.builder().setMetadata(ResourceCollection.Metadata.builder().setSelf("/v3/clusters").build()).setData(singletonList(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())).build());
assertEquals(expected, response.getValue());
}
use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class ClustersResourceTest method getCluster_timeoutException_returnsTimeoutException.
@Test
public void getCluster_timeoutException_returnsTimeoutException() {
expect(clusterManager.getCluster(CLUSTER_1.getClusterId())).andReturn(failedFuture(new TimeoutException()));
replay(clusterManager);
FakeAsyncResponse response = new FakeAsyncResponse();
clustersResource.getCluster(response, CLUSTER_1.getClusterId());
assertEquals(TimeoutException.class, response.getException().getClass());
}
use of io.confluent.kafkarest.response.FakeAsyncResponse 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());
}
use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class ConsumerGroupLagSummariesResourceTest method getConsumerGroupLagSummary_nonExistingConsumerGroupLagSummary_throwsNotFound.
@Test
public void getConsumerGroupLagSummary_nonExistingConsumerGroupLagSummary_throwsNotFound() {
expect(consumerGroupLagSummaryManager.getConsumerGroupLagSummary(CLUSTER_ID, CONSUMER_GROUP_ID)).andReturn(completedFuture(Optional.empty()));
replay(consumerGroupLagSummaryManager);
FakeAsyncResponse response = new FakeAsyncResponse();
consumerGroupLagSummariesResource.getConsumerGroupLagSummary(response, CLUSTER_ID, CONSUMER_GROUP_ID);
assertEquals(NotFoundException.class, response.getException().getClass());
}
use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class ConsumerGroupLagSummariesResourceTest method getConsumerGroupLagSummary_returnsConsumerGroupLagSummary.
@Test
public void getConsumerGroupLagSummary_returnsConsumerGroupLagSummary() {
expect(consumerGroupLagSummaryManager.getConsumerGroupLagSummary(CLUSTER_ID, CONSUMER_GROUP_ID)).andReturn(completedFuture(Optional.of(CONSUMER_GROUP_LAG_1)));
replay(consumerGroupLagSummaryManager);
FakeAsyncResponse response = new FakeAsyncResponse();
consumerGroupLagSummariesResource.getConsumerGroupLagSummary(response, CLUSTER_ID, CONSUMER_GROUP_ID);
GetConsumerGroupLagSummaryResponse expected = GetConsumerGroupLagSummaryResponse.create(ConsumerGroupLagSummaryData.fromConsumerGroupLagSummary(CONSUMER_GROUP_LAG_1).setMetadata(Resource.Metadata.builder().setSelf("/v3/clusters/cluster-1/consumer-groups/consumer-group-1/lag-summary").setResourceName("crn:///kafka=cluster-1/consumer-group=consumer-group-1/lag-summary").build()).setMaxLagConsumer(Relationship.create("/v3/clusters/cluster-1/consumer-groups/consumer-group-1/" + "consumers/consumer-1")).setMaxLagPartition(Relationship.create("/v3/clusters/cluster-1/topics/topic-1/partitions/1")).build());
assertEquals(expected, response.getValue());
}
Aggregations