aboutsummaryrefslogtreecommitdiffstats
path: root/hv-collector-dcae-app-simulator
diff options
context:
space:
mode:
authorfkrzywka <filip.krzywka@nokia.com>2018-07-31 14:26:09 +0200
committerPiotr Jaszczyk <piotr.jaszczyk@nokia.com>2018-08-03 11:02:26 +0200
commit185bc70fa1c024e532649bea650183e05c2d3d87 (patch)
treedafcd1a21d71948d79f903380b860cca36bebb6c /hv-collector-dcae-app-simulator
parent8a0e9e5d4d7613793d2804d7e16a9352e3883874 (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-dcae-app-simulator')
-rw-r--r--hv-collector-dcae-app-simulator/pom.xml6
-rw-r--r--hv-collector-dcae-app-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/simulators/dcaeapp/config/ArgDcaeAppSimulatorConfigurationTest.kt25
2 files changed, 13 insertions, 18 deletions
diff --git a/hv-collector-dcae-app-simulator/pom.xml b/hv-collector-dcae-app-simulator/pom.xml
index f3c17357..e38e3cd9 100644
--- a/hv-collector-dcae-app-simulator/pom.xml
+++ b/hv-collector-dcae-app-simulator/pom.xml
@@ -98,6 +98,12 @@
<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>
<artifactId>arrow-effects</artifactId>
</dependency>
diff --git a/hv-collector-dcae-app-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/simulators/dcaeapp/config/ArgDcaeAppSimulatorConfigurationTest.kt b/hv-collector-dcae-app-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/simulators/dcaeapp/config/ArgDcaeAppSimulatorConfigurationTest.kt
index 5ca64e3e..622a9a22 100644
--- a/hv-collector-dcae-app-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/simulators/dcaeapp/config/ArgDcaeAppSimulatorConfigurationTest.kt
+++ b/hv-collector-dcae-app-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/simulators/dcaeapp/config/ArgDcaeAppSimulatorConfigurationTest.kt
@@ -19,12 +19,13 @@
*/
package org.onap.dcae.collectors.veshv.simulators.dcaeapp.config
-import arrow.core.identity
import org.assertj.core.api.Assertions.assertThat
import org.jetbrains.spek.api.Spek
import org.jetbrains.spek.api.dsl.describe
import org.jetbrains.spek.api.dsl.given
import org.jetbrains.spek.api.dsl.it
+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
@@ -39,25 +40,13 @@ internal class ArgDcaeAppSimulatorConfigurationTest : Spek({
cut = ArgDcaeAppSimConfiguration()
}
- fun parseExpectingSuccess(vararg cmdLine: String): DcaeAppSimConfiguration =
- 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") {
lateinit var result: DcaeAppSimConfiguration
given("all parameters are present in the long form") {
beforeEachTest {
- result = parseExpectingSuccess(
+ result = cut.parseExpectingSuccess(
"--listen-port", listenPort,
"--kafka-bootstrap-servers", kafkaBootstrapServers,
"--kafka-topics", kafkaTopics
@@ -83,7 +72,7 @@ internal class ArgDcaeAppSimulatorConfigurationTest : Spek({
given("some parameters are present in the short form") {
beforeEachTest {
- result = parseExpectingSuccess(
+ result = cut.parseExpectingSuccess(
"-p", listenPort,
"--kafka-bootstrap-servers", kafkaBootstrapServers,
"-f", kafkaTopics)
@@ -107,7 +96,7 @@ internal class ArgDcaeAppSimulatorConfigurationTest : Spek({
describe("required parameter is absent") {
given("kafka topics are missing") {
it("should throw exception") {
- assertThat(parseExpectingFailure(
+ assertThat(cut.parseExpectingFailure(
"-p", listenPort,
"-s", kafkaBootstrapServers
)).isInstanceOf(WrongArgumentError::class.java)
@@ -116,7 +105,7 @@ internal class ArgDcaeAppSimulatorConfigurationTest : Spek({
given("kafka bootstrap servers is missing") {
it("should throw exception") {
- assertThat(parseExpectingFailure(
+ assertThat(cut.parseExpectingFailure(
"-p", listenPort,
"-f", kafkaTopics
)).isInstanceOf(WrongArgumentError::class.java)
@@ -125,7 +114,7 @@ internal class ArgDcaeAppSimulatorConfigurationTest : Spek({
given("listen port is missing") {
it("should throw exception") {
- assertThat(parseExpectingFailure(
+ assertThat(cut.parseExpectingFailure(
"-p", kafkaTopics,
"-s", kafkaBootstrapServers
)).isInstanceOf(WrongArgumentError::class.java)