use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class TopicsResourceTest method deleteTopic_existingTopic_deletesTopic.
@Test
public void deleteTopic_existingTopic_deletesTopic() {
expect(topicManager.deleteTopic(CLUSTER_ID, TOPIC_1.getName())).andReturn(completedFuture(null));
replay(topicManager);
FakeAsyncResponse response = new FakeAsyncResponse();
topicsResource.deleteTopic(response, TOPIC_1.getClusterId(), TOPIC_1.getName());
assertNull(response.getValue());
assertNull(response.getException());
assertTrue(response.isDone());
}
use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class TopicsResourceTest method deleteTopic_nonExistingCluster_throwsNotFound.
@Test
public void deleteTopic_nonExistingCluster_throwsNotFound() {
expect(topicManager.deleteTopic(CLUSTER_ID, TOPIC_1.getName())).andReturn(failedFuture(new NotFoundException()));
replay(topicManager);
FakeAsyncResponse response = new FakeAsyncResponse();
topicsResource.deleteTopic(response, TOPIC_1.getClusterId(), TOPIC_1.getName());
assertEquals(NotFoundException.class, response.getException().getClass());
}
use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class TopicsResourceTest method getTopics_nonExistingCluster_throwsNotFoundException.
@Test
public void getTopics_nonExistingCluster_throwsNotFoundException() {
expect(topicManager.getTopic(CLUSTER_ID, TOPIC_1.getName(), false)).andReturn(failedFuture(new NotFoundException()));
replay(topicManager);
FakeAsyncResponse response = new FakeAsyncResponse();
topicsResource.getTopic(response, CLUSTER_ID, TOPIC_1.getName(), false);
assertEquals(NotFoundException.class, response.getException().getClass());
}
use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class ClustersResourceTest method listClusters_timeoutException_returnsTimeoutException.
@Test
public void listClusters_timeoutException_returnsTimeoutException() {
expect(clusterManager.listClusters()).andReturn(failedFuture(new TimeoutException()));
replay(clusterManager);
FakeAsyncResponse response = new FakeAsyncResponse();
clustersResource.listClusters(response);
assertEquals(TimeoutException.class, response.getException().getClass());
}
use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class ConsumerLagsResourceTest method listConsumerLags_returnsConsumerLags.
@Test
public void listConsumerLags_returnsConsumerLags() {
expect(consumerLagManager.listConsumerLags(CLUSTER_ID, CONSUMER_GROUP_ID)).andReturn(completedFuture(CONSUMER_LAG_LIST));
replay(consumerLagManager);
FakeAsyncResponse response = new FakeAsyncResponse();
consumerLagsResource.listConsumerLags(response, CLUSTER_ID, CONSUMER_GROUP_ID);
ListConsumerLagsResponse expected = ListConsumerLagsResponse.create(ConsumerLagDataList.builder().setMetadata(ResourceCollection.Metadata.builder().setSelf("/v3/clusters/cluster-1/consumer-groups/consumer-group-1/lags").build()).setData(Arrays.asList(ConsumerLagData.fromConsumerLag(CONSUMER_LAG_2).setMetadata(Resource.Metadata.builder().setSelf("/v3/clusters/cluster-1/consumer-groups/consumer-group-1/" + "lags/topic-1/partitions/2").setResourceName("crn:///kafka=cluster-1/consumer-group=consumer-group-1/" + "lag=topic-1/partition=2").build()).build(), 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())).build());
assertEquals(expected, response.getValue());
}
Aggregations