From 49f43c856c8ca793bc6972d9d4b47c2d0d4c0816 Mon Sep 17 00:00:00 2001 From: kjaniak Date: Wed, 3 Apr 2019 15:48:28 +0200 Subject: Creation of server module Issue-ID: DCAEGEN2-1390 Change-Id: I07410b16ed6566b933d5f1efa35bddb965225794 Signed-off-by: kjaniak Signed-off-by: Filip Krzywka --- .../onap/dcae/collectors/veshv/impl/RouterTest.kt | 2 +- .../veshv/impl/wire/WireChunkDecoderTest.kt | 2 +- .../collectors/veshv/model/ClientContextTest.kt | 98 ---------------------- .../collectors/veshv/model/ServiceContextTest.kt | 67 --------------- 4 files changed, 2 insertions(+), 167 deletions(-) delete mode 100644 sources/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/model/ClientContextTest.kt delete mode 100644 sources/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/model/ServiceContextTest.kt (limited to 'sources/hv-collector-core/src/test') diff --git a/sources/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/impl/RouterTest.kt b/sources/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/impl/RouterTest.kt index 6b9c6803..533581d5 100644 --- a/sources/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/impl/RouterTest.kt +++ b/sources/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/impl/RouterTest.kt @@ -36,7 +36,7 @@ import org.onap.dcae.collectors.veshv.domain.RoutedMessage import org.onap.dcae.collectors.veshv.domain.VesEventDomain.PERF3GPP import org.onap.dcae.collectors.veshv.domain.VesEventDomain.HEARTBEAT import org.onap.dcae.collectors.veshv.domain.VesEventDomain.SYSLOG -import org.onap.dcae.collectors.veshv.model.ClientContext +import org.onap.dcae.collectors.veshv.domain.logging.ClientContext import org.onap.dcae.collectors.veshv.domain.VesMessage import org.onap.dcae.collectors.veshv.model.SuccessfullyConsumedMessage import org.onap.dcae.collectors.veshv.tests.utils.commonHeader diff --git a/sources/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/impl/wire/WireChunkDecoderTest.kt b/sources/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/impl/wire/WireChunkDecoderTest.kt index e0092cf9..10dea82d 100644 --- a/sources/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/impl/wire/WireChunkDecoderTest.kt +++ b/sources/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/impl/wire/WireChunkDecoderTest.kt @@ -30,7 +30,7 @@ import org.jetbrains.spek.api.dsl.it import org.onap.dcae.collectors.veshv.domain.WireFrameEncoder import org.onap.dcae.collectors.veshv.domain.WireFrameDecoder import org.onap.dcae.collectors.veshv.domain.WireFrameMessage -import org.onap.dcae.collectors.veshv.model.ClientContext +import org.onap.dcae.collectors.veshv.domain.logging.ClientContext import reactor.test.test /** diff --git a/sources/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/model/ClientContextTest.kt b/sources/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/model/ClientContextTest.kt deleted file mode 100644 index a49428a7..00000000 --- a/sources/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/model/ClientContextTest.kt +++ /dev/null @@ -1,98 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * dcaegen2-collectors-veshv - * ================================================================================ - * Copyright (C) 2018 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.model - -import arrow.core.Some -import com.nhaarman.mockitokotlin2.mock -import com.nhaarman.mockitokotlin2.whenever -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.jetbrains.spek.api.dsl.on -import org.onap.dcae.collectors.veshv.utils.logging.OnapMdc -import java.net.Inet4Address -import java.net.InetAddress -import java.net.InetSocketAddress -import java.security.cert.X509Certificate -import java.util.* -import javax.security.auth.x500.X500Principal - -/** - * @author Piotr Jaszczyk - * @since December 2018 - */ -internal object ClientContextTest : Spek({ - describe("ClientContext") { - given("default instance") { - val cut = ClientContext() - - on("mapped diagnostic context") { - val mdc = cut.mdc - - it("should contain ${OnapMdc.REQUEST_ID}") { - assertThat(mdc[OnapMdc.REQUEST_ID]).isEqualTo(cut.requestId) - } - - it("should contain ${OnapMdc.INVOCATION_ID}") { - assertThat(mdc[OnapMdc.INVOCATION_ID]).isEqualTo(cut.invocationId) - } - - it("should contain ${OnapMdc.STATUS_CODE}") { - assertThat(mdc[OnapMdc.STATUS_CODE]).isEqualTo("INPROGRESS") - } - - it("should contain ${OnapMdc.CLIENT_NAME}") { - assertThat(mdc[OnapMdc.CLIENT_NAME]).isBlank() - } - - it("should contain ${OnapMdc.CLIENT_IP}") { - assertThat(mdc[OnapMdc.CLIENT_IP]).isBlank() - } - } - } - - given("instance with client data") { - val clientDn = "C=PL, O=Nokia, CN=NokiaBTS" - val clientIp = "192.168.52.34" - val cert: X509Certificate = mock() - val principal: X500Principal = mock() - val cut = ClientContext( - clientAddress = Some(InetAddress.getByName(clientIp)), - clientCert = Some(cert)) - - whenever(cert.subjectX500Principal).thenReturn(principal) - whenever(principal.toString()).thenReturn(clientDn) - - on("mapped diagnostic context") { - val mdc = cut.mdc - - it("should contain ${OnapMdc.CLIENT_NAME}") { - assertThat(mdc[OnapMdc.CLIENT_NAME]).isEqualTo(clientDn) - } - - it("should contain ${OnapMdc.CLIENT_IP}") { - assertThat(mdc[OnapMdc.CLIENT_IP]).isEqualTo(clientIp) - } - } - } - } -}) diff --git a/sources/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/model/ServiceContextTest.kt b/sources/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/model/ServiceContextTest.kt deleted file mode 100644 index 5b6e4526..00000000 --- a/sources/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/model/ServiceContextTest.kt +++ /dev/null @@ -1,67 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * dcaegen2-collectors-veshv - * ================================================================================ - * Copyright (C) 2018 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.model - -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.jetbrains.spek.api.dsl.on -import org.onap.dcae.collectors.veshv.utils.logging.OnapMdc -import java.util.* - -/** - * @author Piotr Jaszczyk - * @since December 2018 - */ -internal object ServiceContextTest : Spek({ - describe("ServiceContext") { - given("singleton instance") { - val cut = ServiceContext - - on("instanceId") { - val instanceId = cut.instanceId - it("should be valid UUID") { - UUID.fromString(instanceId) // should not throw - } - } - - on("serverFqdn") { - val serverFqdn = cut.serverFqdn - it("should be non empty") { - assertThat(serverFqdn).isNotBlank() - } - } - - on("mapped diagnostic context") { - val mdc = cut.mdc - - it("should contain ${OnapMdc.INSTANCE_ID}") { - assertThat(mdc[OnapMdc.INSTANCE_ID]).isEqualTo(cut.instanceId) - } - - it("should contain ${OnapMdc.SERVER_FQDN}") { - assertThat(mdc[OnapMdc.SERVER_FQDN]).isEqualTo(cut.serverFqdn) - } - } - } - } -}) -- cgit 1.2.3-korg