use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class TopicConfigsResourceTest method getTopicConfig_nonExistingConfig_throwsNotFound.
@Test
public void getTopicConfig_nonExistingConfig_throwsNotFound() {
expect(topicConfigManager.getTopicConfig(CLUSTER_ID, TOPIC_NAME, CONFIG_1.getName())).andReturn(completedFuture(Optional.empty()));
replay(topicConfigManager);
FakeAsyncResponse response = new FakeAsyncResponse();
topicConfigsResource.getTopicConfig(response, CLUSTER_ID, TOPIC_NAME, CONFIG_1.getName());
assertEquals(NotFoundException.class, response.getException().getClass());
}
use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class TopicConfigsResourceTest method getTopicConfig_nonExistingTopicOrCluster_throwsNotFound.
@Test
public void getTopicConfig_nonExistingTopicOrCluster_throwsNotFound() {
expect(topicConfigManager.getTopicConfig(CLUSTER_ID, TOPIC_NAME, CONFIG_1.getName())).andReturn(failedFuture(new NotFoundException()));
replay(topicConfigManager);
FakeAsyncResponse response = new FakeAsyncResponse();
topicConfigsResource.getTopicConfig(response, CLUSTER_ID, TOPIC_NAME, CONFIG_1.getName());
assertEquals(NotFoundException.class, response.getException().getClass());
}
use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class TopicConfigsResourceTest method resetTopicConfig_existingConfig_resetsConfig.
@Test
public void resetTopicConfig_existingConfig_resetsConfig() {
expect(topicConfigManager.resetTopicConfig(CLUSTER_ID, TOPIC_NAME, CONFIG_1.getName())).andReturn(completedFuture(null));
replay(topicConfigManager);
FakeAsyncResponse response = new FakeAsyncResponse();
topicConfigsResource.resetTopicConfig(response, CLUSTER_ID, TOPIC_NAME, CONFIG_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 TopicConfigsResourceTest method resetTopicConfig_nonExistingConfigOrTopicOrCluster_throwsNotFound.
@Test
public void resetTopicConfig_nonExistingConfigOrTopicOrCluster_throwsNotFound() {
expect(topicConfigManager.resetTopicConfig(CLUSTER_ID, TOPIC_NAME, CONFIG_1.getName())).andReturn(failedFuture(new NotFoundException()));
replay(topicConfigManager);
FakeAsyncResponse response = new FakeAsyncResponse();
topicConfigsResource.resetTopicConfig(response, CLUSTER_ID, TOPIC_NAME, CONFIG_1.getName());
assertEquals(NotFoundException.class, response.getException().getClass());
}
use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class TopicConfigsResourceTest method listTopicConfigs_existingTopic_returnsConfigs.
@Test
public void listTopicConfigs_existingTopic_returnsConfigs() {
expect(topicConfigManager.listTopicConfigs(CLUSTER_ID, TOPIC_NAME)).andReturn(completedFuture(Arrays.asList(CONFIG_1, CONFIG_2, CONFIG_3)));
replay(topicConfigManager);
FakeAsyncResponse response = new FakeAsyncResponse();
topicConfigsResource.listTopicConfigs(response, CLUSTER_ID, TOPIC_NAME);
ListTopicConfigsResponse expected = ListTopicConfigsResponse.create(TopicConfigDataList.builder().setMetadata(ResourceCollection.Metadata.builder().setSelf("/v3/clusters/cluster-1/topics/topic-1/configs").build()).setData(Arrays.asList(TopicConfigData.builder().setMetadata(Resource.Metadata.builder().setSelf("/v3/clusters/cluster-1/topics/topic-1/configs/config-1").setResourceName("crn:///kafka=cluster-1/topic=topic-1/config=config-1").build()).setClusterId(CLUSTER_ID).setTopicName(TOPIC_NAME).setName(CONFIG_1.getName()).setValue(CONFIG_1.getValue()).setDefault(CONFIG_1.isDefault()).setReadOnly(CONFIG_1.isReadOnly()).setSensitive(CONFIG_1.isSensitive()).setSource(CONFIG_1.getSource()).setSynonyms(CONFIG_1.getSynonyms().stream().map(ConfigSynonymData::fromConfigSynonym).collect(Collectors.toList())).build(), TopicConfigData.builder().setMetadata(Resource.Metadata.builder().setSelf("/v3/clusters/cluster-1/topics/topic-1/configs/config-2").setResourceName("crn:///kafka=cluster-1/topic=topic-1/config=config-2").build()).setClusterId(CLUSTER_ID).setTopicName(TOPIC_NAME).setName(CONFIG_2.getName()).setValue(CONFIG_2.getValue()).setDefault(CONFIG_2.isDefault()).setReadOnly(CONFIG_2.isReadOnly()).setSensitive(CONFIG_2.isSensitive()).setSource(CONFIG_2.getSource()).setSynonyms(CONFIG_2.getSynonyms().stream().map(ConfigSynonymData::fromConfigSynonym).collect(Collectors.toList())).build(), TopicConfigData.builder().setMetadata(Resource.Metadata.builder().setSelf("/v3/clusters/cluster-1/topics/topic-1/configs/config-3").setResourceName("crn:///kafka=cluster-1/topic=topic-1/config=config-3").build()).setClusterId(CLUSTER_ID).setTopicName(TOPIC_NAME).setName(CONFIG_3.getName()).setValue(CONFIG_3.getValue()).setDefault(CONFIG_3.isDefault()).setReadOnly(CONFIG_3.isReadOnly()).setSensitive(CONFIG_3.isSensitive()).setSource(CONFIG_3.getSource()).setSynonyms(CONFIG_3.getSynonyms().stream().map(ConfigSynonymData::fromConfigSynonym).collect(Collectors.toList())).build())).build());
assertEquals(expected, response.getValue());
}
Aggregations