use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class TopicsResourceTest method createTopic_nonExistingTopic_createsTopic.
@Test
public void createTopic_nonExistingTopic_createsTopic() {
expect(topicManager.createTopic(CLUSTER_ID, TOPIC_1.getName(), Optional.of(TOPIC_1.getPartitions().size()), Optional.of(TOPIC_1.getReplicationFactor()), /* replicasAssignments= */
Collections.emptyMap(), singletonMap("cleanup.policy", Optional.of("compact")))).andReturn(completedFuture(null));
replay(topicManager);
FakeAsyncResponse response = new FakeAsyncResponse();
topicsResource.createTopic(response, TOPIC_1.getClusterId(), CreateTopicRequest.builder().setTopicName(TOPIC_1.getName()).setPartitionsCount(TOPIC_1.getPartitions().size()).setReplicationFactor(TOPIC_1.getReplicationFactor()).setConfigs(singletonList(CreateTopicRequest.ConfigEntry.create("cleanup.policy", "compact"))).build());
CreateTopicResponse expected = CreateTopicResponse.create(newTopicData("topic-1", false, 3, 0));
assertEquals(expected, response.getValue());
}
use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class TopicsResourceTest method deleteTopic_nonExistingTopic_throwsUnknownTopicOfPartitionException.
@Test
public void deleteTopic_nonExistingTopic_throwsUnknownTopicOfPartitionException() {
expect(topicManager.deleteTopic(CLUSTER_ID, TOPIC_1.getName())).andReturn(failedFuture(new UnknownTopicOrPartitionException("")));
replay(topicManager);
FakeAsyncResponse response = new FakeAsyncResponse();
topicsResource.deleteTopic(response, TOPIC_1.getClusterId(), TOPIC_1.getName());
assertEquals(UnknownTopicOrPartitionException.class, response.getException().getClass());
}
use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class TopicsResourceTest method listTopics_nonExistingCluster_returnsNotFound.
@Test
public void listTopics_nonExistingCluster_returnsNotFound() {
expect(topicManager.listTopics(CLUSTER_ID, false)).andReturn(failedFuture(new NotFoundException()));
replay(topicManager);
FakeAsyncResponse response = new FakeAsyncResponse();
topicsResource.listTopics(response, CLUSTER_ID, false);
assertEquals(NotFoundException.class, response.getException().getClass());
}
use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class TopicsResourceTest method createTopic_existingTopic_throwsTopicExists.
@Test
public void createTopic_existingTopic_throwsTopicExists() {
expect(topicManager.createTopic(CLUSTER_ID, TOPIC_1.getName(), Optional.of(TOPIC_1.getPartitions().size()), Optional.of(TOPIC_1.getReplicationFactor()), /* replicasAssignments= */
Collections.emptyMap(), singletonMap("cleanup.policy", Optional.of("compact")))).andReturn(failedFuture(new TopicExistsException("")));
replay(topicManager);
FakeAsyncResponse response = new FakeAsyncResponse();
topicsResource.createTopic(response, TOPIC_1.getClusterId(), CreateTopicRequest.builder().setTopicName(TOPIC_1.getName()).setPartitionsCount(TOPIC_1.getPartitions().size()).setReplicationFactor(TOPIC_1.getReplicationFactor()).setConfigs(singletonList(CreateTopicRequest.ConfigEntry.create("cleanup.policy", "compact"))).build());
assertEquals(TopicExistsException.class, response.getException().getClass());
}
use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class TopicsResourceTest method createTopic_nonExistingCluster_throwsNotFound.
@Test
public void createTopic_nonExistingCluster_throwsNotFound() {
expect(topicManager.createTopic(CLUSTER_ID, TOPIC_1.getName(), Optional.of(TOPIC_1.getPartitions().size()), Optional.of(TOPIC_1.getReplicationFactor()), /* replicasAssignments= */
Collections.emptyMap(), singletonMap("cleanup.policy", Optional.of("compact")))).andReturn(failedFuture(new NotFoundException()));
replay(topicManager);
FakeAsyncResponse response = new FakeAsyncResponse();
topicsResource.createTopic(response, TOPIC_1.getClusterId(), CreateTopicRequest.builder().setTopicName(TOPIC_1.getName()).setPartitionsCount(TOPIC_1.getPartitions().size()).setReplicationFactor(TOPIC_1.getReplicationFactor()).setConfigs(singletonList(CreateTopicRequest.ConfigEntry.create("cleanup.policy", "compact"))).build());
assertEquals(NotFoundException.class, response.getException().getClass());
}
Aggregations