summaryrefslogtreecommitdiffstats
path: root/hv-collector-client-simulator/src/test
diff options
context:
space:
mode:
authorkjaniak <kornel.janiak@nokia.com>2018-06-14 13:10:53 +0200
committerPiotr Jaszczyk <piotr.jaszczyk@nokia.com>2018-08-02 09:19:48 +0200
commite7987b7a660060746d5f49e1ec90b1ff90fcf55a (patch)
tree61343137ebc270bbadf957cf053f627ad96d0638 /hv-collector-client-simulator/src/test
parent0ba97c7eac5a821c813bfa8ac31b1063956d3824 (diff)
VESEvent payload generation introduction
Change-Id: Ida15b9739d26b5db2f69a5296876f20ea83de761 Signed-off-by: kjaniak <kornel.janiak@nokia.com> Issue-ID: DCAEGEN2-601
Diffstat (limited to 'hv-collector-client-simulator/src/test')
-rw-r--r--hv-collector-client-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/MessageFactoryTest.kt2
-rw-r--r--hv-collector-client-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/PayloadGeneratorTest.kt74
2 files changed, 75 insertions, 1 deletions
diff --git a/hv-collector-client-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/MessageFactoryTest.kt b/hv-collector-client-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/MessageFactoryTest.kt
index ee1d1cf2..2f592641 100644
--- a/hv-collector-client-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/MessageFactoryTest.kt
+++ b/hv-collector-client-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/MessageFactoryTest.kt
@@ -40,7 +40,7 @@ const val SAMPLE_LAST_EPOCH: Long = 120034455
object MessageFactoryTest : Spek({
describe("message factory") {
- val factory = MessageFactory
+ val factory = MessageFactory.INSTANCE
given("only common header") {
it("should return infinite flux") {
diff --git a/hv-collector-client-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/PayloadGeneratorTest.kt b/hv-collector-client-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/PayloadGeneratorTest.kt
new file mode 100644
index 00000000..73129a7f
--- /dev/null
+++ b/hv-collector-client-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/PayloadGeneratorTest.kt
@@ -0,0 +1,74 @@
+/*
+ * ============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)
+ }
+
+ }
+ }
+})