diff options
Diffstat (limited to 'sources/hv-collector-configuration/src/test')
4 files changed, 29 insertions, 166 deletions
diff --git a/sources/hv-collector-configuration/src/test/kotlin/org/onap/dcae/collectors/veshv/config/impl/ConfigurationValidatorTest.kt b/sources/hv-collector-configuration/src/test/kotlin/org/onap/dcae/collectors/veshv/config/impl/ConfigurationValidatorTest.kt index 696f42a2..62b43ded 100644 --- a/sources/hv-collector-configuration/src/test/kotlin/org/onap/dcae/collectors/veshv/config/impl/ConfigurationValidatorTest.kt +++ b/sources/hv-collector-configuration/src/test/kotlin/org/onap/dcae/collectors/veshv/config/impl/ConfigurationValidatorTest.kt @@ -28,7 +28,7 @@ import org.assertj.core.api.Assertions.fail import org.jetbrains.spek.api.Spek import org.jetbrains.spek.api.dsl.describe import org.jetbrains.spek.api.dsl.it -import org.onap.dcae.collectors.veshv.config.api.model.routing +import org.onap.dcae.collectors.veshv.config.api.model.Routing import org.onap.dcae.collectors.veshv.config.impl.ConfigurationValidator.Companion.DEFAULT_LOG_LEVEL import org.onap.dcae.collectors.veshv.utils.logging.LogLevel import org.onap.dcaegen2.services.sdk.security.ssl.SecurityKeys @@ -63,11 +63,12 @@ internal object ConfigurationValidatorTest : Spek({ Some(PartialSecurityConfig( Some(mock()) )), - Some(PartialCollectorConfig( - Some(4), - Some(emptyList()), - Some(routing { }.build()) - )), +// TOD0: retrieve when ConfigurationMerger is implemented +// Some(PartialCollectorConfig( +// Some(4), +// Some(emptyList()), +// someFromEmptyRouting +// )), None ) @@ -88,7 +89,6 @@ internal object ConfigurationValidatorTest : Spek({ val idleTimeoutSec = 10 val firstReqDelaySec = 10 val securityKeys = Some(mock<SecurityKeys>()) - val routing = routing { }.build() val config = PartialConfiguration( Some(PartialServerConfig( @@ -103,11 +103,12 @@ internal object ConfigurationValidatorTest : Spek({ Some(PartialSecurityConfig( securityKeys )), - Some(PartialCollectorConfig( - Some(4), - Some(emptyList()), - Some(routing) - )), +// TOD0: retrieve when ConfigurationMerger is implemented +// Some(PartialCollectorConfig( +// Some(4), +// Some(emptyList()), +// someFromEmptyRouting +// )), Some(LogLevel.INFO) ) @@ -127,8 +128,9 @@ internal object ConfigurationValidatorTest : Spek({ assertThat(it.cbs.firstRequestDelay) .isEqualTo(Duration.ofSeconds(firstReqDelaySec.toLong())) - assertThat(it.collector.routing) - .isEqualTo(routing) +// TOD0: retrieve when ConfigurationMerger is implemented +// assertThat(it.collector.routing) +// .isEqualTo(emptyRouting) } ) } @@ -138,7 +140,6 @@ internal object ConfigurationValidatorTest : Spek({ val idleTimeoutSec = 10 val firstReqDelaySec = 10 val securityKeys: Option<SecurityKeys> = None - val routing = routing { }.build() val config = PartialConfiguration( Some(PartialServerConfig( @@ -153,11 +154,12 @@ internal object ConfigurationValidatorTest : Spek({ Some(PartialSecurityConfig( securityKeys )), - Some(PartialCollectorConfig( - Some(4), - Some(emptyList()), - Some(routing) - )), +// TOD0: retrieve when ConfigurationMerger is implemented +// Some(PartialCollectorConfig( +// Some(4), +// Some(emptyList()), +// someFromEmptyRouting +// )), Some(LogLevel.INFO) ) @@ -177,8 +179,9 @@ internal object ConfigurationValidatorTest : Spek({ assertThat(it.cbs.firstRequestDelay) .isEqualTo(Duration.ofSeconds(firstReqDelaySec.toLong())) - assertThat(it.collector.routing) - .isEqualTo(routing) +// TOD0: retrieve when ConfigurationMerger is implemented +// assertThat(it.collector.routing) +// .isEqualTo(emptyRouting) } ) } @@ -186,3 +189,7 @@ internal object ConfigurationValidatorTest : Spek({ } }) + +// TOD0: retrieve when ConfigurationMerger is implemented +//val emptyRouting = Routing(emptyList()) +//val someFromEmptyRouting = Some(emptyRouting) diff --git a/sources/hv-collector-configuration/src/test/kotlin/org/onap/dcae/collectors/veshv/config/impl/FileConfigurationReaderTest.kt b/sources/hv-collector-configuration/src/test/kotlin/org/onap/dcae/collectors/veshv/config/impl/FileConfigurationReaderTest.kt index bbf259c7..73be3e43 100644 --- a/sources/hv-collector-configuration/src/test/kotlin/org/onap/dcae/collectors/veshv/config/impl/FileConfigurationReaderTest.kt +++ b/sources/hv-collector-configuration/src/test/kotlin/org/onap/dcae/collectors/veshv/config/impl/FileConfigurationReaderTest.kt @@ -24,11 +24,9 @@ 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.it -import org.onap.dcae.collectors.veshv.config.api.model.Routing import org.onap.dcae.collectors.veshv.tests.utils.resourceAsStream import org.onap.dcae.collectors.veshv.utils.logging.LogLevel import java.io.StringReader -import java.net.InetSocketAddress /** * @author Pawel Biniek <pawel.biniek@nokia.com> @@ -59,50 +57,6 @@ internal object FileConfigurationReaderTest : Spek({ assertThat(config.server.orNull()?.listenPort).isEqualTo(Some(12003)) } - it("parses ip address") { - val input = """{ "collector" : { - "kafkaServers": [ - "192.168.255.1:5005", - "192.168.255.26:5006" - ] - } - }""" - - val config = cut.loadConfig(StringReader(input)) - assertThat(config.collector.nonEmpty()).isTrue() - val collector = config.collector.orNull() as PartialCollectorConfig - assertThat(collector.kafkaServers.nonEmpty()).isTrue() - val addresses = collector.kafkaServers.orNull() as List<InetSocketAddress> - assertThat(addresses) - .isEqualTo(listOf( - InetSocketAddress("192.168.255.1", 5005), - InetSocketAddress("192.168.255.26", 5006) - )) - } - - it("parses routing array with RoutingAdapter") { - val input = """{ - "collector" : { - "routing" : [ - { - "fromDomain": "perf3gpp", - "toTopic": "HV_VES_PERF3GPP" - } - ] - } - }""".trimIndent() - val config = cut.loadConfig(StringReader(input)) - assertThat(config.collector.nonEmpty()).isTrue() - val collector = config.collector.orNull() as PartialCollectorConfig - assertThat(collector.routing.nonEmpty()).isTrue() - val routing = collector.routing.orNull() as Routing - routing.run { - assertThat(routes.size).isEqualTo(1) - assertThat(routes[0].domain).isEqualTo("perf3gpp") - assertThat(routes[0].targetTopic).isEqualTo("HV_VES_PERF3GPP") - } - } - it("parses disabled security configuration") { val input = """{ "security": { @@ -142,14 +96,6 @@ internal object FileConfigurationReaderTest : Spek({ assertThat(cbs.firstRequestDelaySec).isEqualTo(Some(7)) assertThat(cbs.requestIntervalSec).isEqualTo(Some(900)) - assertThat(config.collector.nonEmpty()).isTrue() - val collector = config.collector.orNull() as PartialCollectorConfig - collector.run { - assertThat(maxRequestSizeBytes).isEqualTo(Some(512000)) - assertThat(kafkaServers.nonEmpty()).isTrue() - assertThat(routing.nonEmpty()).isTrue() - } - assertThat(config.server.nonEmpty()).isTrue() val server = config.server.orNull() as PartialServerConfig server.run { diff --git a/sources/hv-collector-configuration/src/test/kotlin/org/onap/dcae/collectors/veshv/config/impl/gsonadapters/AddressAdapterTest.kt b/sources/hv-collector-configuration/src/test/kotlin/org/onap/dcae/collectors/veshv/config/impl/gsonadapters/AddressAdapterTest.kt deleted file mode 100644 index f70c4337..00000000 --- a/sources/hv-collector-configuration/src/test/kotlin/org/onap/dcae/collectors/veshv/config/impl/gsonadapters/AddressAdapterTest.kt +++ /dev/null @@ -1,77 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * dcaegen2-collectors-veshv - * ================================================================================ - * Copyright (C) 2019 NOKIA - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.onap.dcae.collectors.veshv.config.impl.gsonadapters - -import com.google.gson.Gson -import com.google.gson.JsonDeserializationContext -import com.google.gson.JsonParseException -import com.google.gson.reflect.TypeToken -import com.nhaarman.mockitokotlin2.mock -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.config.impl.gsonadapters.AddressAdapter.InvalidAddressException -import java.lang.NumberFormatException -import kotlin.test.assertFailsWith - - -internal object AddressAdapterTest : Spek({ - - describe("deserialization") { - val gson = Gson() - val context = mock<JsonDeserializationContext>() - val addressAdapterType = TypeToken.get(AddressAdapter::class.java).type - - val cut = AddressAdapter() - - given("valid string") { - val address = "hostname:9000" - val json = gson.toJsonTree(address) - - it("should return address") { - val deserialized = cut.deserialize(json, addressAdapterType, context) - - assertThat(deserialized.hostName).isEqualTo("hostname") - assertThat(deserialized.port).isEqualTo(9000) - } - } - - val invalidAddresses = mapOf( - Pair("missingPort", InvalidAddressException::class), - Pair("NaNPort:Hey", NumberFormatException::class), - Pair(":6036", InvalidAddressException::class)) - - invalidAddresses.forEach { address, exception -> - given("invalid address string: $address") { - - val json = gson.toJsonTree(address) - it("should throw exception") { - assertFailsWith(exception) { - cut.deserialize(json, addressAdapterType, context) - } - } - } - } - } -}) - - diff --git a/sources/hv-collector-configuration/src/test/resources/sampleConfig.json b/sources/hv-collector-configuration/src/test/resources/sampleConfig.json index 5ae9fc02..8b440ebe 100644 --- a/sources/hv-collector-configuration/src/test/resources/sampleConfig.json +++ b/sources/hv-collector-configuration/src/test/resources/sampleConfig.json @@ -18,18 +18,5 @@ "trustStoreFile": "trust.ks.pkcs12", "trustStorePassword": "changeMeToo" } - }, - "collector": { - "maxRequestSizeBytes": 512000, - "kafkaServers": [ - "192.168.255.1:5005", - "192.168.255.1:5006" - ], - "routing": [ - { - "fromDomain": "perf3gpp", - "toTopic": "HV_VES_PERF3GPP" - } - ] } }
\ No newline at end of file |