Release 1.7.3 DCAEGEN2 VESCollector container
[dcaegen2/collectors/ves.git] / src / test / java / org / onap / dcae / controller / EnvPropertiesReaderTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * org.onap.dcaegen2.collectors.ves
4  * ================================================================================
5  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * Copyright (C) 2018 Nokia. All rights reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.dcae.controller;
23
24 import static io.vavr.API.Map;
25 import static org.junit.Assert.assertFalse;
26 import static org.junit.Assert.assertTrue;
27 import static org.onap.dcae.controller.EnvPropertiesReader.readEnvProps;
28
29 import io.vavr.collection.Map;
30 import org.junit.Test;
31
32
33 public class EnvPropertiesReaderTest {
34
35     @Test
36     public void shouldReturnEmptyOnMissingConsulHost() {
37         Map<String, String> envs = Map(
38             "CONFIG_BINDING_SERVICE", "doesNotMatter",
39             "HOSTNAME", "doesNotMatter");
40         assertTrue(readEnvProps(envs).isEmpty());
41     }
42
43     @Test
44     public void shouldReturnEmptyOnMissingCBSName() {
45         Map<String, String> envs = Map(
46             "CONSUL_HOST", "doesNotMatter",
47             "HOSTNAME", "doesNotMatter");
48         assertTrue(readEnvProps(envs).isEmpty());
49     }
50
51     @Test
52     public void shouldReturnEmptyOnMissingVESAppName() {
53         Map<String, String> envs = Map(
54             "CONSUL_HOST", "doesNotMatter",
55             "CONFIG_BINDING_SERVICE", "doesNotMatter");
56         assertTrue(readEnvProps(envs).isEmpty());
57     }
58
59     @Test
60     public void shouldReturnSomeOfAllProperties() {
61         Map<String, String> envs = Map(
62             "CONSUL_HOST", "doesNotMatter",
63             "HOSTNAME", "doesNotMatter",
64             "CONFIG_BINDING_SERVICE", "doesNotMatter");
65         assertFalse(readEnvProps(envs).isEmpty());
66     }
67
68 }
69