diff options
author | Jakub Dudycz <jakub.dudycz@nokia.com> | 2018-07-24 11:48:12 +0200 |
---|---|---|
committer | Piotr Jaszczyk <piotr.jaszczyk@nokia.com> | 2018-08-03 09:41:09 +0200 |
commit | fc6ab3e5fee2bc3e607848caa665b166d6f38dd6 (patch) | |
tree | c54a032ef0093f7024cff963addca163b0dcf98e /hv-collector-main/src/test | |
parent | 53dbf8e66ad83c2d5f06279a0d7446e5e8be68e8 (diff) |
Rework argument configuration
- Unify names of argument configuration classes in
DCAE APP simulator, XNF simualtor and VES HV Collector
- Make some of the arguments required
- Adjust docker-compose and Dockerfiles
- Adjust test cases and error handling
Closes ONAP-683
Change-Id: I4a9d43791cced9dcb52eb83e2f7956462e8712d9
Signed-off-by: Jakub Dudycz <jakub.dudycz@nokia.com>
Issue-ID: DCAEGEN2-601
Diffstat (limited to 'hv-collector-main/src/test')
-rw-r--r-- | hv-collector-main/src/test/kotlin/org/onap/dcae/collectors/veshv/main/ArgVesHvConfigurationTest.kt (renamed from hv-collector-main/src/test/kotlin/org/onap/dcae/collectors/veshv/main/ArgBasedServerConfigurationTest.kt) | 50 |
1 files changed, 34 insertions, 16 deletions
diff --git a/hv-collector-main/src/test/kotlin/org/onap/dcae/collectors/veshv/main/ArgBasedServerConfigurationTest.kt b/hv-collector-main/src/test/kotlin/org/onap/dcae/collectors/veshv/main/ArgVesHvConfigurationTest.kt index fb0067ec..6b111ae4 100644 --- a/hv-collector-main/src/test/kotlin/org/onap/dcae/collectors/veshv/main/ArgBasedServerConfigurationTest.kt +++ b/hv-collector-main/src/test/kotlin/org/onap/dcae/collectors/veshv/main/ArgVesHvConfigurationTest.kt @@ -27,8 +27,9 @@ import org.jetbrains.spek.api.dsl.given import org.jetbrains.spek.api.dsl.it import org.jetbrains.spek.api.dsl.on import org.onap.dcae.collectors.veshv.domain.SecurityConfiguration -import org.onap.dcae.collectors.veshv.main.ArgBasedServerConfiguration.* +import org.onap.dcae.collectors.veshv.main.ArgVesHvConfiguration.DefaultValues import org.onap.dcae.collectors.veshv.model.ServerConfiguration +import org.onap.dcae.collectors.veshv.utils.commandline.WrongArgumentError import java.nio.file.Paths import java.time.Duration @@ -36,8 +37,8 @@ import java.time.Duration * @author Piotr Jaszczyk <piotr.jaszczyk@nokia.com> * @since May 2018 */ -object ArgBasedServerConfigurationTest : Spek({ - lateinit var cut: ArgBasedServerConfiguration +object ArgVesHvConfigurationTest : Spek({ + lateinit var cut: ArgVesHvConfiguration val configurationUrl = "http://test-address/test" val firstRequestDelay = "10" val requestInterval = "5" @@ -47,15 +48,20 @@ object ArgBasedServerConfigurationTest : Spek({ val trustCert = Paths.get("/", "etc", "ves", "trusted.crt") beforeEachTest { - cut = ArgBasedServerConfiguration() + cut = ArgVesHvConfiguration() } fun parse(vararg cmdLine: String): ServerConfiguration = cut.parse(cmdLine).fold( - {throw AssertionError("Parsing result should be present")}, + { throw AssertionError("Parsing result should be present") }, ::identity ) + fun parseExpectingFailure(vararg cmdLine: String) = + cut.parse(cmdLine).fold(::identity) { + throw AssertionError("parsing should have failed") + } + describe("parsing arguments") { given("all parameters are present in the long form") { lateinit var result: ServerConfiguration @@ -72,17 +78,17 @@ object ArgBasedServerConfigurationTest : Spek({ } it("should set proper port") { - assertThat(result.port).isEqualTo(6969) + assertThat(result.listenPort).isEqualTo(listenPort.toInt()) } it("should set proper first consul request delay") { assertThat(result.configurationProviderParams.firstRequestDelay) - .isEqualTo(Duration.ofSeconds(10)) + .isEqualTo(Duration.ofSeconds(firstRequestDelay.toLong())) } it("should set proper consul request interval") { assertThat(result.configurationProviderParams.requestInterval) - .isEqualTo(Duration.ofSeconds(5)) + .isEqualTo(Duration.ofSeconds(requestInterval.toLong())) } it("should set proper config url") { @@ -101,16 +107,16 @@ object ArgBasedServerConfigurationTest : Spek({ lateinit var result: ServerConfiguration beforeEachTest { - result = parse("-p", "666", "-c", configurationUrl, "-d", firstRequestDelay) + result = parse("-p", listenPort, "-c", configurationUrl, "-d", firstRequestDelay) } it("should set proper port") { - assertThat(result.port).isEqualTo(666) + assertThat(result.listenPort).isEqualTo(listenPort.toInt()) } it("should set proper first consul request delay") { assertThat(result.configurationProviderParams.firstRequestDelay) - .isEqualTo(Duration.ofSeconds(10)) + .isEqualTo(Duration.ofSeconds(firstRequestDelay.toLong())) } it("should set proper config url") { @@ -123,11 +129,7 @@ object ArgBasedServerConfigurationTest : Spek({ lateinit var result: ServerConfiguration beforeEachTest { - result = parse() - } - - it("should set default port") { - assertThat(result.port).isEqualTo(DefaultValues.PORT) + result = parse("--listen-port", listenPort) } it("should set default config url") { @@ -161,5 +163,21 @@ object ArgBasedServerConfigurationTest : Spek({ } } } + + describe("required parameter is absent") { + given("listen port is missing") { + it("should throw exception") { + assertThat(parseExpectingFailure( + "--ssl-disable", + "--config-url", configurationUrl, + "--first-request-delay", firstRequestDelay, + "--request-interval", requestInterval, + "--private-key-file", pk.toFile().absolutePath, + "--cert-file", cert.toFile().absolutePath, + "--trust-cert-file", trustCert.toFile().absolutePath) + ).isInstanceOf(WrongArgumentError::class.java) + } + } + } } }) |