diff options
author | fkrzywka <filip.krzywka@nokia.com> | 2018-07-31 14:26:09 +0200 |
---|---|---|
committer | Piotr Jaszczyk <piotr.jaszczyk@nokia.com> | 2018-08-03 11:02:26 +0200 |
commit | 185bc70fa1c024e532649bea650183e05c2d3d87 (patch) | |
tree | dafcd1a21d71948d79f903380b860cca36bebb6c /hv-collector-main | |
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')
-rw-r--r-- | hv-collector-main/pom.xml | 10 | ||||
-rw-r--r-- | hv-collector-main/src/test/kotlin/org/onap/dcae/collectors/veshv/main/ArgVesHvConfigurationTest.kt | 22 |
2 files changed, 14 insertions, 18 deletions
diff --git a/hv-collector-main/pom.xml b/hv-collector-main/pom.xml index dbec1def..1208e15d 100644 --- a/hv-collector-main/pom.xml +++ b/hv-collector-main/pom.xml @@ -19,8 +19,8 @@ ~ ============LICENSE_END========================================================= --> <project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <licenses> @@ -89,6 +89,12 @@ <artifactId>hv-collector-core</artifactId> <version>${project.parent.version}</version> </dependency> + <dependency> + <groupId>${project.parent.groupId}</groupId> + <artifactId>hv-collector-test-utils</artifactId> + <version>${project.parent.version}</version> + <scope>test</scope> + </dependency> <dependency> <groupId>io.arrow-kt</groupId> 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, |