0d2188cac684ce6831f395924f3ffe85e1f6bc9c
[dcaegen2/collectors/hv-ves.git] /
1 /*
2  * ============LICENSE_START=======================================================
3  * dcaegen2-collectors-veshv
4  * ================================================================================
5  * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20 package org.onap.dcae.collectors.veshv.main
21
22 import org.assertj.core.api.Assertions.assertThat
23 import org.jetbrains.spek.api.Spek
24 import org.jetbrains.spek.api.dsl.given
25 import org.jetbrains.spek.api.dsl.it
26
27 /**
28  * @author Piotr Jaszczyk <piotr.jaszczyk@nokia.com>
29  * @since May 2018
30  */
31 object ArgBasedServerConfigurationTest : Spek({
32     val cut = ArgBasedServerConfiguration
33     val configurationUrl = "http://test-address/test"
34
35     fun parse(vararg cmdLine: String) = cut.parse(cmdLine)
36
37     given("all parameters are present in the long form") {
38         val result = parse("--listen-port", "6969", "--config-url", configurationUrl)
39
40         it("should set proper port") {
41             assertThat(result.port).isEqualTo(6969)
42         }
43
44         it("should set proper config url") {
45             assertThat(result.configurationUrl).isEqualTo(configurationUrl)
46         }
47     }
48
49     given("all parameters are present in the short form") {
50         val result = parse("-p", "666", "-c", configurationUrl)
51
52         it("should set proper port") {
53             assertThat(result.port).isEqualTo(666)
54         }
55
56         it("should set proper config url") {
57             assertThat(result.configurationUrl).isEqualTo(configurationUrl)
58         }
59     }
60
61     given("all optional parameters are absent") {
62         val result = parse()
63
64         it("should set default port") {
65             assertThat(result.port).isEqualTo(DefaultValues.PORT)
66         }
67
68         it("should set default config url") {
69             assertThat(result.configurationUrl).isEqualTo(DefaultValues.CONFIG_URL)
70         }
71     }
72 })