diff options
Diffstat (limited to 'src/test/java/org/onap/ves/openapi/manager/config/DistributionClientConfigTest.java')
-rw-r--r-- | src/test/java/org/onap/ves/openapi/manager/config/DistributionClientConfigTest.java | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/src/test/java/org/onap/ves/openapi/manager/config/DistributionClientConfigTest.java b/src/test/java/org/onap/ves/openapi/manager/config/DistributionClientConfigTest.java new file mode 100644 index 0000000..9118f82 --- /dev/null +++ b/src/test/java/org/onap/ves/openapi/manager/config/DistributionClientConfigTest.java @@ -0,0 +1,89 @@ +/* + * ============LICENSE_START======================================================= + * VES-OPENAPI-MANAGER + * ================================================================================ + * Copyright (C) 2021 Nokia. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.ves.openapi.manager.config; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.context.properties.bind.BindResult; +import org.springframework.boot.context.properties.bind.Binder; +import org.springframework.boot.context.properties.source.ConfigurationPropertySource; +import org.springframework.boot.context.properties.source.MapConfigurationPropertySource; + +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.assertj.core.api.Assertions.assertThat; + +public class DistributionClientConfigTest { + + @Test + void shouldCreateDistributionClientConfig() { + //given + String asdcAddress = "sdc-be.onap:8443"; + String msgBusAddress = "message-router.onap"; + String user = "dcae"; + String password = "Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U"; + Integer pollingInterval = 20; + Integer pollingTimeout = 20; + String consumerGroup = "ves-openapi-manager"; + String environmentName = "AUTO"; + String consumerID = "ves-openapi-manager"; + Map<String, Object> properties = new HashMap<>(); + properties.put("vesopenapimanager.distribution.asdcAddress", asdcAddress); + properties.put("vesopenapimanager.distribution.msgBusAddress", msgBusAddress); + properties.put("vesopenapimanager.distribution.user", user); + properties.put("vesopenapimanager.distribution.password", password); + properties.put("vesopenapimanager.distribution.pollingInterval", pollingInterval); + properties.put("vesopenapimanager.distribution.pollingTimeout", pollingTimeout); + properties.put("vesopenapimanager.distribution.consumerGroup", consumerGroup); + properties.put("vesopenapimanager.distribution.environmentName", environmentName); + properties.put("vesopenapimanager.distribution.consumerID", consumerID); + properties.put("vesopenapimanager.distribution.activateServerTLSAuth", false); + properties.put("vesopenapimanager.distribution.isFilterInEmptyResources", false); + properties.put("vesopenapimanager.distribution.isUseHttpsWithDmaap", false); + ConfigurationPropertySource source = new MapConfigurationPropertySource(properties); + Binder binder = new Binder(source); + + //when + BindResult<DistributionClientConfig> result = binder.bind("vesopenapimanager.distribution", DistributionClientConfig.class); + + //then + assertThat(result.isBound()).isTrue(); + DistributionClientConfig config = result.get(); + assertThat(config.getAsdcAddress()).isEqualTo(asdcAddress); + assertThat(config.getMsgBusAddress()).isEqualTo(List.of(msgBusAddress)); + assertThat(config.getUser()).isEqualTo(user); + assertThat(config.getPassword()).isEqualTo(password); + assertThat(config.getPollingInterval()).isEqualTo(pollingInterval); + assertThat(config.getPollingTimeout()).isEqualTo(pollingTimeout); + assertThat(config.getRelevantArtifactTypes()).isEqualTo(Collections.singletonList("VES_EVENTS")); + assertThat(config.getConsumerGroup()).isEqualTo(consumerGroup); + assertThat(config.getEnvironmentName()).isEqualTo(environmentName); + assertThat(config.getConsumerID()).isEqualTo(consumerID); + assertThat(config.getKeyStorePath()).isNull(); + assertThat(config.getKeyStorePassword()).isNull(); + assertThat(config.activateServerTLSAuth()).isFalse(); + assertThat(config.isFilterInEmptyResources()).isFalse(); + assertThat(config.activateServerTLSAuth()).isFalse(); + assertThat(config.isUseHttpsWithDmaap()).isFalse(); + } +} |