use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class ConsumerLagsResourceTest method getConsumerLag_returnsConsumerLag.
@Test
public void getConsumerLag_returnsConsumerLag() {
expect(consumerLagManager.getConsumerLag(CLUSTER_ID, CONSUMER_GROUP_ID, TOPIC, 1)).andReturn(completedFuture(Optional.of(CONSUMER_LAG_1)));
replay(consumerLagManager);
FakeAsyncResponse response = new FakeAsyncResponse();
consumerLagsResource.getConsumerLag(response, CLUSTER_ID, CONSUMER_GROUP_ID, TOPIC, 1);
GetConsumerLagResponse expected = GetConsumerLagResponse.create(ConsumerLagData.fromConsumerLag(CONSUMER_LAG_1).setMetadata(Resource.Metadata.builder().setSelf("/v3/clusters/cluster-1/consumer-groups/consumer-group-1/" + "lags/topic-1/partitions/1").setResourceName("crn:///kafka=cluster-1/consumer-group=consumer-group-1/" + "lag=topic-1/partition=1").build()).build());
assertEquals(expected, response.getValue());
}
use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class ConsumerLagsResourceTest method getConsumerLag_nonExistingConsumerLag_throwsNotFound.
@Test
public void getConsumerLag_nonExistingConsumerLag_throwsNotFound() {
expect(consumerLagManager.getConsumerLag(CLUSTER_ID, CONSUMER_GROUP_ID, TOPIC, 1)).andReturn(completedFuture(Optional.empty()));
replay(consumerLagManager);
FakeAsyncResponse response = new FakeAsyncResponse();
consumerLagsResource.getConsumerLag(response, CLUSTER_ID, CONSUMER_GROUP_ID, TOPIC, 1);
assertEquals(NotFoundException.class, response.getException().getClass());
}
use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class ConsumersResourceTest method listConsumers_returnsConsumers.
@Test
public void listConsumers_returnsConsumers() {
expect(consumerManager.listConsumers(CLUSTER_ID, CONSUMER_GROUP.getConsumerGroupId())).andReturn(completedFuture(Arrays.asList(CONSUMERS)));
replay(consumerManager);
FakeAsyncResponse response = new FakeAsyncResponse();
consumersResource.listConsumers(response, CLUSTER_ID, CONSUMER_GROUP.getConsumerGroupId());
ListConsumersResponse expected = ListConsumersResponse.create(ConsumerDataList.builder().setMetadata(ResourceCollection.Metadata.builder().setSelf("/v3/clusters/cluster-1/consumer-groups/consumer-group-1/consumers").build()).setData(Arrays.asList(ConsumerData.fromConsumer(CONSUMERS[0]).setMetadata(Resource.Metadata.builder().setSelf("/v3/clusters/cluster-1/consumer-groups/consumer-group-1" + "/consumers/consumer-1").setResourceName("crn:///kafka=cluster-1/consumer-group=consumer-group-1" + "/consumer=consumer-1").build()).setAssignments(Relationship.create("/v3/clusters/cluster-1/consumer-groups/consumer-group-1" + "/consumers/consumer-1/assignments")).build(), ConsumerData.fromConsumer(CONSUMERS[1]).setMetadata(Resource.Metadata.builder().setSelf("/v3/clusters/cluster-1/consumer-groups/consumer-group-1" + "/consumers/consumer-2").setResourceName("crn:///kafka=cluster-1/consumer-group=consumer-group-1" + "/consumer=consumer-2").build()).setAssignments(Relationship.create("/v3/clusters/cluster-1/consumer-groups/consumer-group-1" + "/consumers/consumer-2/assignments")).build(), ConsumerData.fromConsumer(CONSUMERS[2]).setMetadata(Resource.Metadata.builder().setSelf("/v3/clusters/cluster-1/consumer-groups/consumer-group-1" + "/consumers/consumer-3").setResourceName("crn:///kafka=cluster-1/consumer-group=consumer-group-1" + "/consumer=consumer-3").build()).setAssignments(Relationship.create("/v3/clusters/cluster-1/consumer-groups/consumer-group-1" + "/consumers/consumer-3/assignments")).build())).build());
assertEquals(expected, response.getValue());
}
use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class ConsumersResourceTest method getConsumer_returnsConsumer.
@Test
public void getConsumer_returnsConsumer() {
expect(consumerManager.getConsumer(CLUSTER_ID, CONSUMER_GROUP.getConsumerGroupId(), CONSUMERS[0].getConsumerId())).andReturn(completedFuture(Optional.of(CONSUMERS[0])));
replay(consumerManager);
FakeAsyncResponse response = new FakeAsyncResponse();
consumersResource.getConsumer(response, CLUSTER_ID, CONSUMER_GROUP.getConsumerGroupId(), CONSUMERS[0].getConsumerId());
GetConsumerResponse expected = GetConsumerResponse.create(ConsumerData.fromConsumer(CONSUMERS[0]).setMetadata(Resource.Metadata.builder().setSelf("/v3/clusters/cluster-1/consumer-groups/consumer-group-1" + "/consumers/consumer-1").setResourceName("crn:///kafka=cluster-1/consumer-group=consumer-group-1" + "/consumer=consumer-1").build()).setAssignments(Relationship.create("/v3/clusters/cluster-1/consumer-groups/consumer-group-1" + "/consumers/consumer-1/assignments")).build());
assertEquals(expected, response.getValue());
}
use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class ListAllBrokersConfigsActionTest method listAllBrokerConfigs_nonExistingCluster_throwsNotFound.
@Test
public void listAllBrokerConfigs_nonExistingCluster_throwsNotFound() {
expect(brokerManager.listBrokers(CLUSTER_ID)).andReturn(failedFuture(new NotFoundException()));
replay(brokerManager);
FakeAsyncResponse response = new FakeAsyncResponse();
allBrokersConfigsAction.listBrokersConfigs(response, CLUSTER_ID);
assertEquals(NotFoundException.class, response.getException().getClass());
}
Aggregations