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 java.io.IOException;
27 import org.junit.jupiter.api.Test;
28 import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.impl.streams.gson.GsonUtils;
29 import org.onap.dcaegen2.services.sdk.model.streams.DataStreamDirection;
30 import org.onap.dcaegen2.services.sdk.model.streams.RawDataStream;
31 import org.onap.dcaegen2.services.sdk.model.streams.StreamType;
32 import org.onap.dcaegen2.services.sdk.model.streams.dmaap.MessageRouterSink;
35 * @author <a href="mailto:piotr.jaszczyk@nokia.com">Piotr Jaszczyk</a>
38 class MessageRouterSinksIT {
40 final JsonObject json = GsonUtils.readObjectFromResource("/streams/integration_message_router.json");
42 MessageRouterSinksIT() throws IOException {
46 void thereShouldBeNoDataSources() {
47 assertThat(DataStreams.namedSources(json)).isEmpty();
51 void thereShouldBeSomeSinksDefined() {
52 assertThat(DataStreams.namedSinks(json)).isNotEmpty();
53 assertThat(DataStreams.namedSinks(json)).hasSize(4);
57 void allSinksShouldBeOfMessageRouterType() {
58 assertThat(DataStreams.namedSinks(json).map(RawDataStream::type).distinct())
59 .containsExactly(StreamType.MESSAGE_ROUTER);
63 void sinksShouldHaveProperDirection() {
64 assertThat(DataStreams.namedSinks(json).map(RawDataStream::direction).distinct())
65 .containsExactly(DataStreamDirection.SINK);
69 void verifySecMeasurementSink() {
71 final String streamName = "sec_measurement";
72 final RawDataStream<JsonObject> sink = DataStreams.namedSinks(json).find(streamWithName(streamName))
76 final MessageRouterSink parsedSink = StreamFromGsonParsers.messageRouterSinkParser().unsafeParse(sink);
79 assertThat(parsedSink.name()).describedAs("name").isEqualTo(streamName);
80 assertThat(parsedSink.aafCredentials()).describedAs("aaf credentials").isNotNull();
81 assertThat(parsedSink.aafCredentials().username()).describedAs("aaf user name").isEqualTo("aaf_username");
82 assertThat(parsedSink.aafCredentials().password()).describedAs("aaf password").isEqualTo("aaf_password");
83 assertThat(parsedSink.location()).describedAs("location").isEqualTo("mtl5");
84 assertThat(parsedSink.clientId()).describedAs("client id").isEqualTo("111111");
85 assertThat(parsedSink.clientRole()).describedAs("client role").isEqualTo("com.att.dcae.member");
86 assertThat(parsedSink.topicUrl()).describedAs("topic url")
87 .isEqualTo("https://mrlocal:3905/events/com.att.dcae.dmaap.FTL2.SEC-MEASUREMENT-OUTPUT");
91 void verifySecFaultUnsecureSink() {
93 final String streamName = "sec_fault_unsecure";
94 final RawDataStream<JsonObject> sink = DataStreams.namedSinks(json).find(streamWithName(streamName))
98 final MessageRouterSink parsedSink = StreamFromGsonParsers.messageRouterSinkParser().unsafeParse(sink);
101 assertThat(parsedSink.name()).describedAs("name").isEqualTo(streamName);
102 assertThat(parsedSink.aafCredentials()).describedAs("aaf credentials").isNull();
103 assertThat(parsedSink.location()).describedAs("location").isEqualTo("mtl5");
104 assertThat(parsedSink.clientId()).describedAs("client id").isNull();
105 assertThat(parsedSink.clientRole()).describedAs("client role").isNull();
106 assertThat(parsedSink.topicUrl()).describedAs("topic url")
107 .isEqualTo("http://ueb.global:3904/events/DCAE-SE-COLLECTOR-EVENTS-DEV");
111 void verifySecMeasurementUnsecureSink() {
113 final String streamName = "sec_measurement_unsecure";
114 final RawDataStream<JsonObject> sink = DataStreams.namedSinks(json).find(streamWithName(streamName))
118 final MessageRouterSink parsedSink = StreamFromGsonParsers.messageRouterSinkParser().unsafeParse(sink);
121 assertThat(parsedSink.name()).describedAs("name").isEqualTo(streamName);
122 assertThat(parsedSink.aafCredentials()).describedAs("aaf credentials").isNull();
123 assertThat(parsedSink.location()).describedAs("location").isEqualTo("mtl5");
124 assertThat(parsedSink.clientId()).describedAs("client id").isNull();
125 assertThat(parsedSink.clientRole()).describedAs("client role").isNull();
126 assertThat(parsedSink.topicUrl()).describedAs("topic url")
127 .isEqualTo("http://ueb.global:3904/events/DCAE-SE-COLLECTOR-EVENTS-DEV");
131 void verifySecFaultSink() {
133 final String streamName = "sec_fault";
134 final RawDataStream<JsonObject> sink = DataStreams.namedSinks(json).find(streamWithName(streamName))
138 final MessageRouterSink parsedSink = StreamFromGsonParsers.messageRouterSinkParser().unsafeParse(sink);
141 assertThat(parsedSink.name()).describedAs("name").isEqualTo(streamName);
142 assertThat(parsedSink.aafCredentials()).describedAs("aaf credentials").isNotNull();
143 assertThat(parsedSink.aafCredentials().username()).describedAs("aaf user name").isEqualTo("aaf_username");
144 assertThat(parsedSink.aafCredentials().password()).describedAs("aaf password").isEqualTo("aaf_password");
145 assertThat(parsedSink.location()).describedAs("location").isEqualTo("mtl5");
146 assertThat(parsedSink.clientId()).describedAs("client id").isEqualTo("222222");
147 assertThat(parsedSink.clientRole()).describedAs("client role").isEqualTo("com.att.dcae.member");
148 assertThat(parsedSink.topicUrl()).describedAs("topic url")
149 .isEqualTo("https://mrlocal:3905/events/com.att.dcae.dmaap.FTL2.SEC-FAULT-OUTPUT");