aboutsummaryrefslogtreecommitdiffstats
path: root/hv-collector-xnf-simulator/src/test
diff options
context:
space:
mode:
authorkjaniak <kornel.janiak@nokia.com>2018-07-12 10:57:58 +0200
committerPiotr Jaszczyk <piotr.jaszczyk@nokia.com>2018-08-02 14:47:46 +0200
commit3bdd41724d031c5d787239ce1b4186ac7680d03c (patch)
tree1276e35c4402b9c0d417a7bd7588f180ea688716 /hv-collector-xnf-simulator/src/test
parentece457cd2470f65275b695991bf0bee1e144c24d (diff)
Extract message generator module
Closes ONAP-501 Change-Id: Ia5dc5f67e18c302abbeac7e0373cef479f4befb8 Signed-off-by: kjaniak <kornel.janiak@nokia.com> Issue-ID: DCAEGEN2-601
Diffstat (limited to 'hv-collector-xnf-simulator/src/test')
-rw-r--r--hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/MessageFactoryTest.kt83
-rw-r--r--hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/PayloadGeneratorTest.kt74
2 files changed, 0 insertions, 157 deletions
diff --git a/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/MessageFactoryTest.kt b/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/MessageFactoryTest.kt
deleted file mode 100644
index 6f8a95a4..00000000
--- a/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/MessageFactoryTest.kt
+++ /dev/null
@@ -1,83 +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.simulators.xnf.impl
-
-import com.google.protobuf.ByteString
-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.simulators.xnf.config.MessageParameters
-import org.onap.ves.VesEventV5
-import org.onap.ves.VesEventV5.VesEvent.CommonEventHeader.Domain.HVRANMEAS
-import org.onap.ves.VesEventV5.VesEvent.CommonEventHeader.Priority.MEDIUM
-import reactor.test.test
-
-const val SAMPLE_START_EPOCH: Long = 120034455
-const val SAMPLE_LAST_EPOCH: Long = 120034455
-
-/**
- * @author Jakub Dudycz <jakub.dudycz@nokia.com>
- * @since June 2018
- */
-object MessageFactoryTest : Spek({
- describe("message factory") {
-
- val factory = MessageGeneratorImpl.INSTANCE
-
- given("only common header") {
- it("should return infinite flux") {
- val limit = 1000L
- factory.createMessageFlux(getSampleMessageParameters()).take(limit).test()
- .expectNextCount(limit)
- .verifyComplete()
- }
- }
- given("common header and messages amount") {
- it("should return message flux of specified size") {
- factory.createMessageFlux((getSampleMessageParameters(5))).test()
- .expectNextCount(5)
- .verifyComplete()
- }
- }
- }
-})
-
-fun getSampleMessageParameters(amount: Long = -1): MessageParameters{
- val commonHeader = VesEventV5.VesEvent.CommonEventHeader.newBuilder()
- .setVersion("sample-version")
- .setDomain(HVRANMEAS)
- .setSequence(1)
- .setPriority(MEDIUM)
- .setEventId("sample-event-id")
- .setEventName("sample-event-name")
- .setEventType("sample-event-type")
- .setStartEpochMicrosec(SAMPLE_START_EPOCH)
- .setLastEpochMicrosec(SAMPLE_LAST_EPOCH)
- .setNfNamingCode("sample-nf-naming-code")
- .setNfcNamingCode("sample-nfc-naming-code")
- .setReportingEntityId("sample-reporting-entity-id")
- .setReportingEntityName(ByteString.copyFromUtf8("sample-reporting-entity-name"))
- .setSourceId(ByteString.copyFromUtf8("sample-source-id"))
- .setSourceName("sample-source-name")
- .build()
-
- return MessageParameters(commonHeader, amount)
-}
diff --git a/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/PayloadGeneratorTest.kt b/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/PayloadGeneratorTest.kt
deleted file mode 100644
index 73129a7f..00000000
--- a/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/PayloadGeneratorTest.kt
+++ /dev/null
@@ -1,74 +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.simulators.xnf.impl
-
-import org.jetbrains.spek.api.Spek
-import org.jetbrains.spek.api.dsl.given
-import org.jetbrains.spek.api.dsl.it
-import org.assertj.core.api.Assertions.assertThat
-import org.jetbrains.spek.api.dsl.on
-
-private const val DEFAULT_MEASUREMENTS_NUMBER = 2
-private const val DEFAULT_COUNTERS_NUMBER = 2
-
-private val uriRegex = """sample/uri(\d+)""".toRegex()
-
-object PayloadGeneratorTest : Spek({
-
- given("payload factory object") {
- val payloadGenerator = PayloadGenerator()
-
- on("two generated payloads") {
- val generatedPayload0 = payloadGenerator.generatePayload()
- val generatedPayload1 = payloadGenerator.generatePayload()
- it("URIs should have different names") {
- val matchResult0 = uriRegex.find(generatedPayload0.getPmObject(0).uri)!!.value
- val matchResult1 = uriRegex.find(generatedPayload1.getPmObject(0).uri)!!.value
- assertThat(matchResult0 != matchResult1).isTrue()
- }
- }
-
- on("call with default parameters") {
- val generatedPayload = payloadGenerator.generatePayload()
- it("should contain default numbers of measurements") {
- assertThat(generatedPayload.getPmObject(0).hvRanMeasCount).isEqualTo(DEFAULT_MEASUREMENTS_NUMBER)
- }
- it("should contain default numbers of counters in measurement") {
- assertThat(generatedPayload.getPmObject(0).getHvRanMeas(0).counterSubidCount).isEqualTo(DEFAULT_COUNTERS_NUMBER)
- }
- }
-
- on("call with specified parameters") {
- val numOfCountPerMeas: Long = 5
- val numOfMeasPerObject: Int = 10
- val generatedPayload = payloadGenerator.generatePayload(numOfCountPerMeas, numOfMeasPerObject)
- it("should contain specified number of measurements") {
- assertThat(generatedPayload.getPmObject(0).hvRanMeasCount).isEqualTo(numOfMeasPerObject)
- }
- it("measurement should contain specified number of counters") {
- assertThat(generatedPayload.getPmObject(0).hvRanMeasList
- .filter { numOfCountPerMeas.toInt() == it.counterSubidCount }
- .size)
- .isEqualTo(numOfMeasPerObject)
- }
-
- }
- }
-})