2 * ============LICENSE_START=======================================================
3 * dcaegen2-collectors-veshv
4 * ================================================================================
5 * Copyright (C) 2018 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.simulators.xnf.impl
22 import com.google.protobuf.ByteString
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.onap.dcae.collectors.veshv.simulators.xnf.config.MessageParameters
28 import org.onap.ves.VesEventV5
29 import org.onap.ves.VesEventV5.VesEvent.CommonEventHeader.Domain.HVRANMEAS
30 import org.onap.ves.VesEventV5.VesEvent.CommonEventHeader.Priority.MEDIUM
31 import reactor.test.test
33 const val SAMPLE_START_EPOCH: Long = 120034455
34 const val SAMPLE_LAST_EPOCH: Long = 120034455
37 * @author Jakub Dudycz <jakub.dudycz@nokia.com>
40 object MessageFactoryTest : Spek({
41 describe("message factory") {
43 val factory = MessageFactory.INSTANCE
45 given("only common header") {
46 it("should return infinite flux") {
48 factory.createMessageFlux(getSampleMessageParameters()).take(limit).test()
49 .expectNextCount(limit)
53 given("common header and messages amount") {
54 it("should return message flux of specified size") {
55 factory.createMessageFlux((getSampleMessageParameters(5))).test()
63 fun getSampleMessageParameters(amount: Long = -1): MessageParameters{
64 val commonHeader = VesEventV5.VesEvent.CommonEventHeader.newBuilder()
65 .setVersion("sample-version")
69 .setEventId("sample-event-id")
70 .setEventName("sample-event-name")
71 .setEventType("sample-event-type")
72 .setStartEpochMicrosec(SAMPLE_START_EPOCH)
73 .setLastEpochMicrosec(SAMPLE_LAST_EPOCH)
74 .setNfNamingCode("sample-nf-naming-code")
75 .setNfcNamingCode("sample-nfc-naming-code")
76 .setReportingEntityId("sample-reporting-entity-id")
77 .setReportingEntityName(ByteString.copyFromUtf8("sample-reporting-entity-name"))
78 .setSourceId(ByteString.copyFromUtf8("sample-source-id"))
79 .setSourceName("sample-source-name")
82 return MessageParameters(commonHeader, amount)