14061532ba07ed257ff522a70307a07547b47640
[dcaegen2/collectors/hv-ves.git] /
1 /*
2  * ============LICENSE_START=======================================================
3  * dcaegen2-collectors-veshv
4  * ================================================================================
5  * Copyright (C) 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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20 package org.onap.dcae.collectors.veshv.main
21
22 import com.nhaarman.mockitokotlin2.any
23 import com.nhaarman.mockitokotlin2.eq
24 import com.nhaarman.mockitokotlin2.mock
25 import com.nhaarman.mockitokotlin2.verify
26 import com.nhaarman.mockitokotlin2.whenever
27 import org.jetbrains.spek.api.Spek
28 import org.jetbrains.spek.api.dsl.describe
29 import org.jetbrains.spek.api.dsl.it
30 import org.onap.dcae.collectors.veshv.simulators.xnf.impl.adapters.HvVesClient
31 import org.onap.dcaegen2.services.sdk.services.hvves.client.producer.api.HvVesProducer
32 import org.onap.ves.VesEventOuterClass
33 import reactor.core.publisher.Flux
34 import reactor.core.publisher.Mono
35 import java.nio.ByteBuffer
36
37
38 /**
39  * @author Jakub Dudycz <jakub.dudycz@nokia.com>
40  * @since February 2019
41  */
42 internal class HvVesClientTest : Spek({
43     describe("HvVesClient") {
44         val hvVesProducer: HvVesProducer = mock()
45         val cut = HvVesClient(hvVesProducer)
46
47         describe("handling raw message stream") {
48
49             val rawMessages = Flux.empty<ByteBuffer>()
50             whenever(hvVesProducer.sendRaw(any(), any())).thenReturn(Mono.empty())
51             cut.sendRawPayload(rawMessages)
52
53             it("should perform sending operation") {
54                 verify(hvVesProducer).sendRaw(eq(rawMessages), any())
55             }
56         }
57     }
58 })