use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class ListAllTopicsConfigsActionTest method listTopicConfigs_noTopics_returnsEmptyConfigs.
@Test
public void listTopicConfigs_noTopics_returnsEmptyConfigs() {
expect(topicManager.listTopics(CLUSTER_ID)).andReturn(completedFuture(new ArrayList<>()));
expect(topicConfigManager.listTopicConfigs(CLUSTER_ID, new ArrayList<>())).andReturn(completedFuture(new HashMap<String, List<TopicConfig>>()));
replay(topicManager, topicConfigManager);
FakeAsyncResponse response = new FakeAsyncResponse();
allTopicConfigsResource.listTopicConfigs(response, CLUSTER_ID);
ListTopicConfigsResponse expected = ListTopicConfigsResponse.create(TopicConfigDataList.builder().setMetadata(ResourceCollection.Metadata.builder().setSelf("/v3/clusters/cluster-1/topics/-/configs").build()).setData(new ArrayList<>()).build());
assertEquals(expected, response.getValue());
}
use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class ListAllTopicsConfigsActionTest method listTopicConfigs_nonExistingCluster_throwsNotFound.
@Test
public void listTopicConfigs_nonExistingCluster_throwsNotFound() {
expect(topicManager.listTopics(CLUSTER_ID)).andReturn(failedFuture(new NotFoundException()));
replay(topicManager);
FakeAsyncResponse response = new FakeAsyncResponse();
allTopicConfigsResource.listTopicConfigs(response, CLUSTER_ID);
assertEquals(NotFoundException.class, response.getException().getClass());
}
use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class ClusterConfigResourceTest method listClusterConfigs_nonExistingCluster_throwsNotFound.
@Test
public void listClusterConfigs_nonExistingCluster_throwsNotFound() {
expect(clusterConfigManager.listClusterConfigs(CLUSTER_ID, ClusterConfig.Type.BROKER)).andReturn(failedFuture(new NotFoundException()));
replay(clusterConfigManager);
FakeAsyncResponse response = new FakeAsyncResponse();
clusterConfigsResource.listClusterConfigs(response, CLUSTER_ID, ClusterConfig.Type.BROKER);
assertEquals(NotFoundException.class, response.getException().getClass());
}
use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class ClusterConfigResourceTest method listClusterConfigs_existingCluster_returnsConfigs.
@Test
public void listClusterConfigs_existingCluster_returnsConfigs() {
expect(clusterConfigManager.listClusterConfigs(CLUSTER_ID, ClusterConfig.Type.BROKER)).andReturn(completedFuture(Arrays.asList(CONFIG_1, CONFIG_2, CONFIG_3)));
replay(clusterConfigManager);
FakeAsyncResponse response = new FakeAsyncResponse();
clusterConfigsResource.listClusterConfigs(response, CLUSTER_ID, ClusterConfig.Type.BROKER);
ListClusterConfigsResponse expected = ListClusterConfigsResponse.create(ClusterConfigDataList.builder().setMetadata(ResourceCollection.Metadata.builder().setSelf("/v3/clusters/cluster-1/broker-configs").build()).setData(Arrays.asList(ClusterConfigData.builder().setMetadata(Resource.Metadata.builder().setSelf("/v3/clusters/cluster-1/broker-configs/config-1").setResourceName("crn:///kafka=cluster-1/broker-config=config-1").build()).setClusterId(CLUSTER_ID).setConfigType(ClusterConfig.Type.BROKER).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(), ClusterConfigData.builder().setMetadata(Resource.Metadata.builder().setSelf("/v3/clusters/cluster-1/broker-configs/config-2").setResourceName("crn:///kafka=cluster-1/broker-config=config-2").build()).setClusterId(CLUSTER_ID).setConfigType(ClusterConfig.Type.BROKER).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(), ClusterConfigData.builder().setMetadata(Resource.Metadata.builder().setSelf("/v3/clusters/cluster-1/broker-configs/config-3").setResourceName("crn:///kafka=cluster-1/broker-config=config-3").build()).setClusterId(CLUSTER_ID).setConfigType(ClusterConfig.Type.BROKER).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());
}
use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class ClusterConfigResourceTest method getClusterConfig_nonExistingConfig_throwsNotFound.
@Test
public void getClusterConfig_nonExistingConfig_throwsNotFound() {
expect(clusterConfigManager.getClusterConfig(CLUSTER_ID, ClusterConfig.Type.BROKER, CONFIG_1.getName())).andReturn(failedFuture(new NotFoundException()));
replay(clusterConfigManager);
FakeAsyncResponse response = new FakeAsyncResponse();
clusterConfigsResource.getClusterConfig(response, CLUSTER_ID, ClusterConfig.Type.BROKER, CONFIG_1.getName());
assertEquals(NotFoundException.class, response.getException().getClass());
}
Aggregations