diff options
author | 2018-07-31 14:26:09 +0200 | |
---|---|---|
committer | 2018-08-03 11:02:26 +0200 | |
commit | 185bc70fa1c024e532649bea650183e05c2d3d87 (patch) | |
tree | dafcd1a21d71948d79f903380b860cca36bebb6c /hv-collector-main/src | |
parent | 8a0e9e5d4d7613793d2804d7e16a9352e3883874 (diff) |
Extract test-utils module
- removed duplicate code that was creating VesMessages
and similiar objects
- removed duplicate code in command line parsing tests
- made minor refactorings to avoid passing unnecessary params
and to be as verbose as possible in tests
Closes ONAP-699
Change-Id: I2607f1f775054ae1c5f275c231895f838b415371
Signed-off-by: fkrzywka <filip.krzywka@nokia.com>
Issue-ID: DCAEGEN2-601
Diffstat (limited to 'hv-collector-main/src')
-rw-r--r-- | hv-collector-main/src/test/kotlin/org/onap/dcae/collectors/veshv/main/ArgVesHvConfigurationTest.kt | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/hv-collector-main/src/test/kotlin/org/onap/dcae/collectors/veshv/main/ArgVesHvConfigurationTest.kt b/hv-collector-main/src/test/kotlin/org/onap/dcae/collectors/veshv/main/ArgVesHvConfigurationTest.kt index 6b111ae4..f15f7f49 100644 --- a/hv-collector-main/src/test/kotlin/org/onap/dcae/collectors/veshv/main/ArgVesHvConfigurationTest.kt +++ b/hv-collector-main/src/test/kotlin/org/onap/dcae/collectors/veshv/main/ArgVesHvConfigurationTest.kt @@ -19,7 +19,6 @@ */ package org.onap.dcae.collectors.veshv.main -import arrow.core.identity import org.assertj.core.api.Assertions.assertThat import org.jetbrains.spek.api.Spek import org.jetbrains.spek.api.dsl.describe @@ -29,6 +28,8 @@ import org.jetbrains.spek.api.dsl.on import org.onap.dcae.collectors.veshv.domain.SecurityConfiguration import org.onap.dcae.collectors.veshv.main.ArgVesHvConfiguration.DefaultValues import org.onap.dcae.collectors.veshv.model.ServerConfiguration +import org.onap.dcae.collectors.veshv.tests.utils.parseExpectingFailure +import org.onap.dcae.collectors.veshv.tests.utils.parseExpectingSuccess import org.onap.dcae.collectors.veshv.utils.commandline.WrongArgumentError import java.nio.file.Paths import java.time.Duration @@ -51,23 +52,12 @@ object ArgVesHvConfigurationTest : Spek({ cut = ArgVesHvConfiguration() } - fun parse(vararg cmdLine: String): ServerConfiguration = - cut.parse(cmdLine).fold( - { 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 beforeEachTest { - result = parse("--ssl-disable", + result = cut.parseExpectingSuccess("--ssl-disable", "--listen-port", listenPort, "--config-url", configurationUrl, "--first-request-delay", firstRequestDelay, @@ -107,7 +97,7 @@ object ArgVesHvConfigurationTest : Spek({ lateinit var result: ServerConfiguration beforeEachTest { - result = parse("-p", listenPort, "-c", configurationUrl, "-d", firstRequestDelay) + result = cut.parseExpectingSuccess("-p", listenPort, "-c", configurationUrl, "-d", firstRequestDelay) } it("should set proper port") { @@ -129,7 +119,7 @@ object ArgVesHvConfigurationTest : Spek({ lateinit var result: ServerConfiguration beforeEachTest { - result = parse("--listen-port", listenPort) + result = cut.parseExpectingSuccess("--listen-port", listenPort) } it("should set default config url") { @@ -167,7 +157,7 @@ object ArgVesHvConfigurationTest : Spek({ describe("required parameter is absent") { given("listen port is missing") { it("should throw exception") { - assertThat(parseExpectingFailure( + assertThat(cut.parseExpectingFailure( "--ssl-disable", "--config-url", configurationUrl, "--first-request-delay", firstRequestDelay, |