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.Test;
27 import org.onap.dcaegen2.services.sdk.services.hvves.client.producer.api.options.PayloadType;
28 import org.onap.ves.MeasDataCollectionOuterClass;
29 import org.onap.ves.VesEventOuterClass.CommonEventHeader;
30 import org.onap.ves.VesEventOuterClass.VesEvent;
31 import reactor.core.publisher.Flux;
33 import java.time.Duration;
36 * @author <a href="mailto:piotr.jaszczyk@nokia.com">Piotr Jaszczyk</a>
38 class HvVesProducerIT {
40 private static final int INFO_ID = 17;
41 private static final long VALUE = 5l;
42 private static final int MEAS_TYPE = 3;
43 private static final int PERIOD = 1000;
44 private static final String OBJECT_INSTANCE_ID = "DH-1";
46 private final SystemUnderTestWrapper sut = new SystemUnderTestWrapper(Duration.ofSeconds(10));
54 void singleMessageTest_withUnsecureConnection() throws Exception {
56 final VesEvent sampleEvent = createSimpleVesEvent();
57 final Flux<VesEvent> input = Flux.just(sampleEvent);
61 final ByteBuf receivedData = sut.blockingSend(input);
64 WireProtocolDecoder decoded = WireProtocolDecoder.decode(receivedData);
65 assertThat(decoded.type).isEqualTo(PayloadType.PROTOBUF.getPayloadTypeBytes().getShort());
66 assertThat(decoded.event).isEqualTo(sampleEvent);
71 void singleMessageTest_withSecureConnection() throws Exception {
73 final VesEvent sampleEvent = createSimpleVesEvent();
74 final Flux<VesEvent> input = Flux.just(sampleEvent);
78 final ByteBuf receivedData = sut.blockingSend(input);
81 WireProtocolDecoder decoded = WireProtocolDecoder.decode(receivedData);
82 assertThat(decoded.type).isEqualTo(PayloadType.PROTOBUF.getPayloadTypeBytes().getShort());
83 assertThat(decoded.event).isEqualTo(sampleEvent);
87 private VesEvent createSimpleVesEvent() {
88 final MeasDataCollectionOuterClass.MeasDataCollection content = MeasDataCollectionOuterClass.MeasDataCollection
90 .addMeasInfo(MeasDataCollectionOuterClass.MeasInfo.newBuilder()
91 .addMeasValues(MeasDataCollectionOuterClass.MeasValue.newBuilder()
92 .addMeasResults(MeasDataCollectionOuterClass.MeasResult.newBuilder()
93 .setIValue(VALUE).build())
95 .setIMeasInfoId(INFO_ID)
96 .setIMeasTypes(MeasDataCollectionOuterClass.MeasInfo.IMeasTypes.newBuilder()
97 .addIMeasType(MEAS_TYPE))
99 .setGranularityPeriod(PERIOD)
100 .addMeasObjInstIdList(OBJECT_INSTANCE_ID)
102 return VesEvent.newBuilder()
103 .setCommonEventHeader(CommonEventHeader.newBuilder()
106 .setEventFields(content.toByteString())