Search in sources :

Example 1 with ConfigSynonymData

use of io.confluent.kafkarest.entities.v3.ConfigSynonymData in project kafka-rest by confluentinc.

the class BrokerConfigResourceTest method getBrokerConfig_existingConfig_returnsConfig.

@Test
public void getBrokerConfig_existingConfig_returnsConfig() {
    expect(brokerConfigManager.getBrokerConfig(CLUSTER_ID, BROKER_ID, CONFIG_1.getName())).andReturn(completedFuture(Optional.of(CONFIG_1)));
    replay(brokerConfigManager);
    FakeAsyncResponse response = new FakeAsyncResponse();
    brokerConfigsResource.getBrokerConfig(response, CLUSTER_ID, BROKER_ID, CONFIG_1.getName());
    GetBrokerConfigResponse expected = GetBrokerConfigResponse.create(BrokerConfigData.builder().setMetadata(Resource.Metadata.builder().setSelf("/v3/clusters/cluster-1/brokers/1/configs/config-1").setResourceName("crn:///kafka=cluster-1/broker=1/config=config-1").build()).setClusterId(CLUSTER_ID).setBrokerId(BROKER_ID).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());
    assertEquals(expected, response.getValue());
}
Also used : ConfigSynonymData(io.confluent.kafkarest.entities.v3.ConfigSynonymData) FakeAsyncResponse(io.confluent.kafkarest.response.FakeAsyncResponse) GetBrokerConfigResponse(io.confluent.kafkarest.entities.v3.GetBrokerConfigResponse) Test(org.junit.jupiter.api.Test)

Example 2 with ConfigSynonymData

use of io.confluent.kafkarest.entities.v3.ConfigSynonymData 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());
}
Also used : ListTopicConfigsResponse(io.confluent.kafkarest.entities.v3.ListTopicConfigsResponse) FakeAsyncResponse(io.confluent.kafkarest.response.FakeAsyncResponse) Test(org.junit.jupiter.api.Test)

Example 3 with ConfigSynonymData

use of io.confluent.kafkarest.entities.v3.ConfigSynonymData in project kafka-rest by confluentinc.

the class ListAllBrokersConfigsActionTest method listAllBrokerConfigs_existingBrokers_returnsConfigs.

@Test
public void listAllBrokerConfigs_existingBrokers_returnsConfigs() {
    expect(brokerManager.listBrokers(CLUSTER_ID)).andReturn(completedFuture(Arrays.asList(Broker.create(CLUSTER_ID, BROKER_ID, "localhost", 9092, "us-east"))));
    expect(brokerConfigManager.listAllBrokerConfigs(CLUSTER_ID, Arrays.asList(BROKER_ID))).andReturn(completedFuture(new HashMap<Integer, List<BrokerConfig>>() {

        {
            put(BROKER_ID, Arrays.asList(CONFIG_1, CONFIG_2, CONFIG_3));
        }
    }));
    replay(brokerManager, brokerConfigManager);
    FakeAsyncResponse response = new FakeAsyncResponse();
    allBrokersConfigsAction.listBrokersConfigs(response, CLUSTER_ID);
    ListBrokerConfigsResponse expected = ListBrokerConfigsResponse.create(BrokerConfigDataList.builder().setMetadata(ResourceCollection.Metadata.builder().setSelf("/v3/clusters/cluster-1/brokers/-/configs").build()).setData(Arrays.asList(BrokerConfigData.builder().setMetadata(Resource.Metadata.builder().setSelf("/v3/clusters/cluster-1/brokers/1/configs/config-1").setResourceName("crn:///kafka=cluster-1/broker=1/config=config-1").build()).setClusterId(CLUSTER_ID).setBrokerId(BROKER_ID).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(), BrokerConfigData.builder().setMetadata(Resource.Metadata.builder().setSelf("/v3/clusters/cluster-1/brokers/1/configs/config-2").setResourceName("crn:///kafka=cluster-1/broker=1/config=config-2").build()).setClusterId(CLUSTER_ID).setBrokerId(BROKER_ID).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(), BrokerConfigData.builder().setMetadata(Resource.Metadata.builder().setSelf("/v3/clusters/cluster-1/brokers/1/configs/config-3").setResourceName("crn:///kafka=cluster-1/broker=1/config=config-3").build()).setClusterId(CLUSTER_ID).setBrokerId(BROKER_ID).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());
}
Also used : BrokerConfig(io.confluent.kafkarest.entities.BrokerConfig) HashMap(java.util.HashMap) FakeAsyncResponse(io.confluent.kafkarest.response.FakeAsyncResponse) ListBrokerConfigsResponse(io.confluent.kafkarest.entities.v3.ListBrokerConfigsResponse) Test(org.junit.jupiter.api.Test)

Example 4 with ConfigSynonymData

use of io.confluent.kafkarest.entities.v3.ConfigSynonymData in project kafka-rest by confluentinc.

the class ListAllTopicsConfigsActionTest method listTopicConfigs_existingTopic_returnsConfigs.

@Test
public void listTopicConfigs_existingTopic_returnsConfigs() {
    expect(topicManager.listTopics(CLUSTER_ID)).andReturn(completedFuture(Arrays.asList(Topic.create(CLUSTER_ID, TOPIC_NAME, new ArrayList<>(), (short) 1, false, emptySet()))));
    expect(topicConfigManager.listTopicConfigs(CLUSTER_ID, Arrays.asList(TOPIC_NAME))).andReturn(completedFuture(new HashMap<String, List<TopicConfig>>() {

        {
            put(TOPIC_NAME, Arrays.asList(CONFIG_1, CONFIG_2, CONFIG_3));
        }
    }));
    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(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());
}
Also used : HashMap(java.util.HashMap) ListTopicConfigsResponse(io.confluent.kafkarest.entities.v3.ListTopicConfigsResponse) FakeAsyncResponse(io.confluent.kafkarest.response.FakeAsyncResponse) ArrayList(java.util.ArrayList) TopicConfig(io.confluent.kafkarest.entities.TopicConfig) Test(org.junit.jupiter.api.Test)

Example 5 with ConfigSynonymData

use of io.confluent.kafkarest.entities.v3.ConfigSynonymData in project kafka-rest by confluentinc.

the class ClusterConfigResourceTest method getClusterConfig_existingConfig_returnsConfig.

@Test
public void getClusterConfig_existingConfig_returnsConfig() {
    expect(clusterConfigManager.getClusterConfig(CLUSTER_ID, ClusterConfig.Type.BROKER, CONFIG_1.getName())).andReturn(completedFuture(Optional.of(CONFIG_1)));
    replay(clusterConfigManager);
    FakeAsyncResponse response = new FakeAsyncResponse();
    clusterConfigsResource.getClusterConfig(response, CLUSTER_ID, ClusterConfig.Type.BROKER, CONFIG_1.getName());
    GetClusterConfigResponse expected = GetClusterConfigResponse.create(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());
    assertEquals(expected, response.getValue());
}
Also used : ConfigSynonymData(io.confluent.kafkarest.entities.v3.ConfigSynonymData) GetClusterConfigResponse(io.confluent.kafkarest.entities.v3.GetClusterConfigResponse) FakeAsyncResponse(io.confluent.kafkarest.response.FakeAsyncResponse) Test(org.junit.jupiter.api.Test)

Aggregations

FakeAsyncResponse (io.confluent.kafkarest.response.FakeAsyncResponse)8 Test (org.junit.jupiter.api.Test)8 ConfigSynonymData (io.confluent.kafkarest.entities.v3.ConfigSynonymData)3 ListBrokerConfigsResponse (io.confluent.kafkarest.entities.v3.ListBrokerConfigsResponse)2 ListTopicConfigsResponse (io.confluent.kafkarest.entities.v3.ListTopicConfigsResponse)2 HashMap (java.util.HashMap)2 BrokerConfig (io.confluent.kafkarest.entities.BrokerConfig)1 TopicConfig (io.confluent.kafkarest.entities.TopicConfig)1 GetBrokerConfigResponse (io.confluent.kafkarest.entities.v3.GetBrokerConfigResponse)1 GetClusterConfigResponse (io.confluent.kafkarest.entities.v3.GetClusterConfigResponse)1 GetTopicConfigResponse (io.confluent.kafkarest.entities.v3.GetTopicConfigResponse)1 ListClusterConfigsResponse (io.confluent.kafkarest.entities.v3.ListClusterConfigsResponse)1 ArrayList (java.util.ArrayList)1