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.rest.services.cbs.client.api.streams;
22 import static org.assertj.core.api.Assertions.assertThat;
23 import static org.onap.dcaegen2.services.sdk.rest.services.cbs.client.api.streams.StreamPredicates.streamWithName;
25 import com.google.gson.JsonObject;
26 import io.vavr.collection.List;
27 import java.io.IOException;
28 import org.junit.jupiter.api.Test;
29 import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.impl.streams.gson.GsonUtils;
30 import org.onap.dcaegen2.services.sdk.model.streams.DataStreamDirection;
31 import org.onap.dcaegen2.services.sdk.model.streams.RawDataStream;
32 import org.onap.dcaegen2.services.sdk.model.streams.StreamType;
33 import org.onap.dcaegen2.services.sdk.model.streams.dmaap.DataRouterSink;
34 import org.onap.dcaegen2.services.sdk.model.streams.dmaap.DataRouterSource;
35 import org.onap.dcaegen2.services.sdk.model.streams.dmaap.MessageRouterSource;
38 * @author <a href="mailto:piotr.jaszczyk@nokia.com">Piotr Jaszczyk</a>
41 class MixedDmaapStreamsIT {
43 final JsonObject json = GsonUtils.readObjectFromResource("/streams/integration_mixed_dmaap.json");
44 final List<RawDataStream<JsonObject>> sources = DataStreams.namedSources(json).toList();
45 final List<RawDataStream<JsonObject>> sinks = DataStreams.namedSinks(json).toList();
47 MixedDmaapStreamsIT() throws IOException {
51 void thereShouldBeSomeSinksDefined() {
52 assertThat(sinks).isNotEmpty();
53 assertThat(sinks).hasSize(3);
57 void thereShouldBeSomeSourcesDefined() {
58 assertThat(sources).isNotEmpty();
59 assertThat(sources).hasSize(3);
63 void allStreamsShouldBeOfProperType() {
64 assertThat(sources.map(RawDataStream::type).distinct()).containsExactly(StreamType.DATA_ROUTER, StreamType.MESSAGE_ROUTER);
65 assertThat(sinks.map(RawDataStream::type).distinct()).containsExactly(StreamType.DATA_ROUTER);
69 void sinksShouldHaveProperDirection() {
70 assertThat(sinks.map(RawDataStream::direction).distinct())
71 .containsExactly(DataStreamDirection.SINK);
75 void sourcesShouldHaveProperDirection() {
76 assertThat(sources.map(RawDataStream::direction).distinct())
77 .containsExactly(DataStreamDirection.SOURCE);
81 void verifyDcaeGuestOsSource() {
83 final String streamName = "DCAE_GUEST_OS";
84 final RawDataStream<JsonObject> source = sources.find(streamWithName(streamName)).get();
87 final DataRouterSource parsedSource = StreamFromGsonParsers.dataRouterSourceParser().unsafeParse(source);
90 assertThat(parsedSource.name()).describedAs("name").isEqualTo(streamName);
91 assertThat(parsedSource.location()).describedAs("location").isEqualTo("mtn23");
92 assertThat(parsedSource.username()).describedAs("user name").isEqualTo("xyz");
93 assertThat(parsedSource.password()).describedAs("password").isEqualTo("abc");
94 assertThat(parsedSource.deliveryUrl()).describedAs("delivery url")
95 .isEqualTo("https://dr.global:8666/DCAE_SAM_GUEST_OS");
96 assertThat(parsedSource.subscriberId()).describedAs("subscriber id").isEqualTo("811");
100 void verifyDcaeRawDataSource() {
102 final String streamName = "DCAE_RAW_DATA";
103 final RawDataStream<JsonObject> source = sources.find(streamWithName(streamName)).get();
106 final DataRouterSource parsedSource = StreamFromGsonParsers.dataRouterSourceParser().unsafeParse(source);
109 assertThat(parsedSource.name()).describedAs("name").isEqualTo(streamName);
110 assertThat(parsedSource.location()).describedAs("location").isEqualTo("mtn23");
111 assertThat(parsedSource.username()).describedAs("user name").isEqualTo("abc");
112 assertThat(parsedSource.password()).describedAs("password").isEqualTo("xyz");
113 assertThat(parsedSource.deliveryUrl()).describedAs("delivery url")
114 .isEqualTo("https://dr.global:8666/DCAE_CEILOMETER_RAW_DATA");
115 assertThat(parsedSource.subscriberId()).describedAs("subscriber id").isEqualTo("812");
119 void verifySecMeasurementOutputSource() {
121 final String streamName = "sec-measurement-output";
122 final RawDataStream<JsonObject> source = sources.find(streamWithName(streamName))
126 final MessageRouterSource parsedSource = StreamFromGsonParsers.messageRouterSourceParser().unsafeParse(source);
129 assertThat(parsedSource.name()).describedAs("name").isEqualTo(streamName);
130 assertThat(parsedSource.aafCredentials()).describedAs("aaf credentials").isNotNull();
131 assertThat(parsedSource.aafCredentials().username()).describedAs("aaf user name").isEqualTo("aaf_username");
132 assertThat(parsedSource.aafCredentials().password()).describedAs("aaf password").isEqualTo("aaf_password");
133 assertThat(parsedSource.location()).describedAs("location").isEqualTo("mtn23");
134 assertThat(parsedSource.clientId()).describedAs("client id").isEqualTo("1111");
135 assertThat(parsedSource.clientRole()).describedAs("client role").isEqualTo("com.att.dcae.member");
136 assertThat(parsedSource.topicUrl()).describedAs("topic url")
137 .isEqualTo("https://mr.hostname:3905/events/com.att.dcae.dmaap.SEC-MEASUREMENT-OUTPUT-v1");
141 void verifyDcaeVoipPmDataSink() {
143 final String streamName = "DCAE_VOIP_PM_DATA";
144 final RawDataStream<JsonObject> sink = sinks.find(streamWithName(streamName)).get();
147 final DataRouterSink parsedSink = StreamFromGsonParsers.dataRouterSinkParser().unsafeParse(sink);
150 assertThat(parsedSink.name()).describedAs("name").isEqualTo(streamName);
151 assertThat(parsedSink.location()).describedAs("location").isEqualTo("mtn23");
152 assertThat(parsedSink.username()).describedAs("user name").isEqualTo("abc");
153 assertThat(parsedSink.password()).describedAs("password").isEqualTo("xyz");
154 assertThat(parsedSink.logUrl()).describedAs("log url")
155 .isEqualTo("https://dcae-drps/feedlog/206");
156 assertThat(parsedSink.publishUrl()).describedAs("publish url")
157 .isEqualTo("https://dcae-drps/publish/206");
158 assertThat(parsedSink.publisherId()).describedAs("publisher id").isEqualTo("206.518hu");
162 void verifyDcaeGuestOsOSink() {
164 final String streamName = "DCAE_GUEST_OS_O";
165 final RawDataStream<JsonObject> sink = sinks.find(streamWithName(streamName)).get();
168 final DataRouterSink parsedSink = StreamFromGsonParsers.dataRouterSinkParser().unsafeParse(sink);
171 assertThat(parsedSink.name()).describedAs("name").isEqualTo(streamName);
172 assertThat(parsedSink.location()).describedAs("location").isEqualTo("mtn23");
173 assertThat(parsedSink.username()).describedAs("user name").isEqualTo("axyz");
174 assertThat(parsedSink.password()).describedAs("password").isEqualTo("abc");
175 assertThat(parsedSink.logUrl()).describedAs("log url")
176 .isEqualTo("https://dcae-drps/feedlog/203");
177 assertThat(parsedSink.publishUrl()).describedAs("publish url")
178 .isEqualTo("https://dcae-drps/publish/203");
179 assertThat(parsedSink.publisherId()).describedAs("publisher id").isEqualTo("203.2od8s");
184 void verifyDcaePmDataSink() {
186 final String streamName = "DCAE_PM_DATA";
187 final RawDataStream<JsonObject> sink = sinks.find(streamWithName(streamName)).get();
190 final DataRouterSink parsedSink = StreamFromGsonParsers.dataRouterSinkParser().unsafeParse(sink);
193 assertThat(parsedSink.name()).describedAs("name").isEqualTo(streamName);
194 assertThat(parsedSink.location()).describedAs("location").isEqualTo("mtn23bdce2");
195 assertThat(parsedSink.username()).describedAs("user name").isEqualTo("xyz");
196 assertThat(parsedSink.password()).describedAs("password").isEqualTo("abc");
197 assertThat(parsedSink.logUrl()).describedAs("log url")
198 .isEqualTo("https://dcae-drps/feedlog/493");
199 assertThat(parsedSink.publishUrl()).describedAs("publish url")
200 .isEqualTo("https://dcae-drps/publish/493");
201 assertThat(parsedSink.publisherId()).describedAs("publisher id").isEqualTo("493.eacqs");