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 static org.assertj.core.api.Assertions.assertThat;
24 import io.netty.buffer.ByteBuf;
25 import org.junit.jupiter.api.AfterEach;
26 import org.junit.jupiter.api.BeforeEach;
27 import org.junit.jupiter.api.Test;
28 import org.onap.dcaegen2.services.sdk.services.hvves.client.producer.api.options.PayloadType;
29 import org.onap.ves.MeasDataCollectionOuterClass;
30 import org.onap.ves.VesEventOuterClass.CommonEventHeader;
31 import org.onap.ves.VesEventOuterClass.VesEvent;
32 import reactor.core.publisher.Flux;
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
76 .addMeasInfo(MeasDataCollectionOuterClass.MeasInfo.newBuilder()
77 .addMeasValues(MeasDataCollectionOuterClass.MeasValue.newBuilder()
78 .addMeasResults(MeasDataCollectionOuterClass.MeasResult.newBuilder()
79 .setIValue(VALUE).build())
81 .setIMeasInfoId(INFO_ID)
82 .setIMeasTypes(MeasDataCollectionOuterClass.MeasInfo.IMeasTypes.newBuilder()
83 .addIMeasType(MEAS_TYPE))
85 .setGranularityPeriod(PERIOD)
86 .addMeasObjInstIdList(OBJECT_INSTANCE_ID)
88 return VesEvent.newBuilder()
89 .setCommonEventHeader(CommonEventHeader.newBuilder()
92 .setEventFields(content.toByteString())