2 * ============LICENSE_START=======================================================
3 * DCAEGEN2-SERVICES-SDK
4 * ================================================================================
5 * Copyright (C) 2019 Nokia. All rights reserved.
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.dcaegen2.services.sdk.services.hvves.client.producer.ct;
22 import io.netty.buffer.ByteBuf;
23 import org.junit.jupiter.api.AfterEach;
24 import org.junit.jupiter.api.BeforeEach;
25 import org.junit.jupiter.api.Test;
26 import org.onap.dcaegen2.services.sdk.services.hvves.client.producer.impl.encoders.PayloadType;
27 import org.onap.ves.MeasDataCollectionOuterClass;
28 import org.onap.ves.VesEventOuterClass.CommonEventHeader;
29 import org.onap.ves.VesEventOuterClass.VesEvent;
30 import reactor.core.publisher.Flux;
32 import static org.assertj.core.api.Assertions.assertThat;
35 * @author <a href="mailto:piotr.jaszczyk@nokia.com">Piotr Jaszczyk</a>
37 class HvVesProducerIT {
39 private static final int INFO_ID = 17;
40 private static final long VALUE = 5l;
41 private static final int MEAS_TYPE = 3;
42 private static final int PERIOD = 1000;
43 private static final String OBJECT_INSTANCE_ID = "DH-1";
45 private final SystemUnderTestWrapper sut = new SystemUnderTestWrapper();
58 void singleMessageTest() throws Exception {
61 final VesEvent sampleEvent = createSimpleVesEvent();
62 final Flux<VesEvent> input = Flux.just(sampleEvent);
65 final ByteBuf receivedData = sut.blockingSend(input);
68 WireProtocolDecoder decoded = WireProtocolDecoder.decode(receivedData);
69 assertThat(decoded.type).isEqualTo(PayloadType.PROTOBUF.getPayloadTypeBytes().getShort());
70 assertThat(decoded.event).isEqualTo(sampleEvent);
73 private VesEvent createSimpleVesEvent() {
74 final MeasDataCollectionOuterClass.MeasDataCollection content = MeasDataCollectionOuterClass.MeasDataCollection.newBuilder()
75 .addMeasInfo(MeasDataCollectionOuterClass.MeasInfo.newBuilder()
76 .addMeasValues(MeasDataCollectionOuterClass.MeasValue.newBuilder()
77 .addMeasResults(MeasDataCollectionOuterClass.MeasResult.newBuilder()
78 .setIValue(VALUE).build())
80 .setIMeasInfoId(INFO_ID)
81 .setIMeasTypes(MeasDataCollectionOuterClass.MeasInfo.IMeasTypes.newBuilder()
82 .addIMeasType(MEAS_TYPE))
84 .setGranularityPeriod(PERIOD)
85 .addMeasObjInstIdList(OBJECT_INSTANCE_ID)
87 return VesEvent.newBuilder()
88 .setCommonEventHeader(CommonEventHeader.newBuilder()
91 .setEventFields(content.toByteString())