2 * ============LICENSE_START=======================================================
3 * dcaegen2-collectors-veshv
4 * ================================================================================
5 * Copyright (C) 2018-2019 NOKIA
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 package org.onap.dcae.collectors.veshv.ves.message.generator.impl.vesevent
22 import org.assertj.core.api.Assertions.assertThat
23 import org.jetbrains.spek.api.Spek
24 import org.jetbrains.spek.api.dsl.describe
25 import org.jetbrains.spek.api.dsl.given
26 import org.jetbrains.spek.api.dsl.it
27 import org.jetbrains.spek.api.dsl.on
28 import org.onap.dcae.collectors.veshv.domain.VesEventDomain.FAULT
29 import org.onap.dcae.collectors.veshv.domain.VesEventDomain.PERF3GPP
30 import org.onap.dcae.collectors.veshv.tests.utils.commonHeader
31 import org.onap.dcae.collectors.veshv.ves.message.generator.api.VesEventParameters
32 import org.onap.dcae.collectors.veshv.ves.message.generator.api.VesEventType
33 import reactor.test.test
36 * @author Jakub Dudycz <jakub.dudycz@nokia.com>
39 object VesEventGeneratorTest : Spek({
40 describe("message factory") {
41 val maxPayloadSizeBytes = 1024
42 val cut = VesEventGenerator(PayloadGenerator(), maxPayloadSizeBytes)
44 given("single message parameters") {
45 on("messages amount not specified in parameters") {
46 it("should createVesEventGenerator infinite flux") {
49 .createMessageFlux(VesEventParameters(
50 commonHeader(PERF3GPP),
55 .expectNextCount(limit)
60 on("messages amount = 0 specified in parameters") {
61 it("should createVesEventGenerator empty message flux") {
63 .createMessageFlux(VesEventParameters(
64 commonHeader(PERF3GPP),
73 on("messages amount specified in parameters") {
74 it("should createVesEventGenerator message flux of specified size") {
76 .createMessageFlux(VesEventParameters(
77 commonHeader(PERF3GPP),
87 on("message type requesting valid message") {
88 it("should createVesEventGenerator flux of valid messages with given domain") {
90 .createMessageFlux(VesEventParameters(
97 assertThat(it.toByteArray().size).isLessThan(maxPayloadSizeBytes)
98 assertThat(it.commonEventHeader.domain).isEqualTo(FAULT.domainName)
104 on("message type requesting too big payload") {
105 it("should createVesEventGenerator flux of messages with given domain and payload exceeding threshold") {
108 .createMessageFlux(VesEventParameters(
109 commonHeader(PERF3GPP),
110 VesEventType.TOO_BIG_PAYLOAD,
115 assertThat(it.toByteArray().size).isGreaterThan(maxPayloadSizeBytes)
116 assertThat(it.commonEventHeader.domain).isEqualTo(PERF3GPP.domainName)
124 on("message type requesting fixed payload") {
125 it("should createVesEventGenerator flux of valid messages with fixed payload") {
127 .createMessageFlux(VesEventParameters(
129 VesEventType.FIXED_PAYLOAD,
134 assertThat(it.toByteArray().size).isLessThan(maxPayloadSizeBytes)
135 assertThat(it.eventFields.size()).isEqualTo(VesEventGenerator.FIXED_PAYLOAD_SIZE)
136 assertThat(it.commonEventHeader.domain).isEqualTo(FAULT.domainName)