X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=rest-services%2Fcbs-client%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fdcaegen2%2Fservices%2Fsdk%2Frest%2Fservices%2Fcbs%2Fclient%2Fapi%2Fstreams%2FMessageRouterSinksIT.java;fp=rest-services%2Fcbs-client%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fdcaegen2%2Fservices%2Fsdk%2Frest%2Fservices%2Fcbs%2Fclient%2Fapi%2Fstreams%2FMessageRouterSinksIT.java;h=c57ce0276c81e4b377469fddeca0cbf098c6cefb;hb=015668f4a24fcc497151c6142a0bf70717c55f8e;hp=0000000000000000000000000000000000000000;hpb=51d3ae2b08dd49029cd9c86bfe8d95d1eef14326;p=dcaegen2%2Fservices%2Fsdk.git diff --git a/rest-services/cbs-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/api/streams/MessageRouterSinksIT.java b/rest-services/cbs-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/api/streams/MessageRouterSinksIT.java new file mode 100644 index 00000000..c57ce027 --- /dev/null +++ b/rest-services/cbs-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/api/streams/MessageRouterSinksIT.java @@ -0,0 +1,151 @@ +/* + * ============LICENSE_START==================================== + * DCAEGEN2-SERVICES-SDK + * ========================================================= + * Copyright (C) 2019 Nokia. All rights reserved. + * ========================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END===================================== + */ +package org.onap.dcaegen2.services.sdk.rest.services.cbs.client.api.streams; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.onap.dcaegen2.services.sdk.rest.services.cbs.client.api.streams.StreamPredicates.streamWithName; + +import com.google.gson.JsonObject; +import java.io.IOException; +import org.junit.jupiter.api.Test; +import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.impl.streams.gson.GsonUtils; +import org.onap.dcaegen2.services.sdk.model.streams.DataStreamDirection; +import org.onap.dcaegen2.services.sdk.model.streams.RawDataStream; +import org.onap.dcaegen2.services.sdk.model.streams.StreamType; +import org.onap.dcaegen2.services.sdk.model.streams.dmaap.MessageRouterSink; + +/** + * @author Piotr Jaszczyk + * @since March 2019 + */ +class MessageRouterSinksIT { + + final JsonObject json = GsonUtils.readObjectFromResource("/streams/integration_message_router.json"); + + MessageRouterSinksIT() throws IOException { + } + + @Test + void thereShouldBeNoDataSources() { + assertThat(DataStreams.namedSources(json)).isEmpty(); + } + + @Test + void thereShouldBeSomeSinksDefined() { + assertThat(DataStreams.namedSinks(json)).isNotEmpty(); + assertThat(DataStreams.namedSinks(json)).hasSize(4); + } + + @Test + void allSinksShouldBeOfMessageRouterType() { + assertThat(DataStreams.namedSinks(json).map(RawDataStream::type).distinct()) + .containsExactly(StreamType.MESSAGE_ROUTER); + } + + @Test + void sinksShouldHaveProperDirection() { + assertThat(DataStreams.namedSinks(json).map(RawDataStream::direction).distinct()) + .containsExactly(DataStreamDirection.SINK); + } + + @Test + void verifySecMeasurementSink() { + // given + final String streamName = "sec_measurement"; + final RawDataStream sink = DataStreams.namedSinks(json).find(streamWithName(streamName)) + .get(); + + // when + final MessageRouterSink parsedSink = StreamFromGsonParsers.messageRouterSinkParser().unsafeParse(sink); + + // then + assertThat(parsedSink.name()).describedAs("name").isEqualTo(streamName); + assertThat(parsedSink.aafCredentials()).describedAs("aaf credentials").isNotNull(); + assertThat(parsedSink.aafCredentials().username()).describedAs("aaf user name").isEqualTo("aaf_username"); + assertThat(parsedSink.aafCredentials().password()).describedAs("aaf password").isEqualTo("aaf_password"); + assertThat(parsedSink.location()).describedAs("location").isEqualTo("mtl5"); + assertThat(parsedSink.clientId()).describedAs("client id").isEqualTo("111111"); + assertThat(parsedSink.clientRole()).describedAs("client role").isEqualTo("com.att.dcae.member"); + assertThat(parsedSink.topicUrl()).describedAs("topic url") + .isEqualTo("https://mrlocal:3905/events/com.att.dcae.dmaap.FTL2.SEC-MEASUREMENT-OUTPUT"); + } + + @Test + void verifySecFaultUnsecureSink() { + // given + final String streamName = "sec_fault_unsecure"; + final RawDataStream sink = DataStreams.namedSinks(json).find(streamWithName(streamName)) + .get(); + + // when + final MessageRouterSink parsedSink = StreamFromGsonParsers.messageRouterSinkParser().unsafeParse(sink); + + // then + assertThat(parsedSink.name()).describedAs("name").isEqualTo(streamName); + assertThat(parsedSink.aafCredentials()).describedAs("aaf credentials").isNull(); + assertThat(parsedSink.location()).describedAs("location").isEqualTo("mtl5"); + assertThat(parsedSink.clientId()).describedAs("client id").isNull(); + assertThat(parsedSink.clientRole()).describedAs("client role").isNull(); + assertThat(parsedSink.topicUrl()).describedAs("topic url") + .isEqualTo("http://ueb.global:3904/events/DCAE-SE-COLLECTOR-EVENTS-DEV"); + } + + @Test + void verifySecMeasurementUnsecureSink() { + // given + final String streamName = "sec_measurement_unsecure"; + final RawDataStream sink = DataStreams.namedSinks(json).find(streamWithName(streamName)) + .get(); + + // when + final MessageRouterSink parsedSink = StreamFromGsonParsers.messageRouterSinkParser().unsafeParse(sink); + + // then + assertThat(parsedSink.name()).describedAs("name").isEqualTo(streamName); + assertThat(parsedSink.aafCredentials()).describedAs("aaf credentials").isNull(); + assertThat(parsedSink.location()).describedAs("location").isEqualTo("mtl5"); + assertThat(parsedSink.clientId()).describedAs("client id").isNull(); + assertThat(parsedSink.clientRole()).describedAs("client role").isNull(); + assertThat(parsedSink.topicUrl()).describedAs("topic url") + .isEqualTo("http://ueb.global:3904/events/DCAE-SE-COLLECTOR-EVENTS-DEV"); + } + + @Test + void verifySecFaultSink() { + // given + final String streamName = "sec_fault"; + final RawDataStream sink = DataStreams.namedSinks(json).find(streamWithName(streamName)) + .get(); + + // when + final MessageRouterSink parsedSink = StreamFromGsonParsers.messageRouterSinkParser().unsafeParse(sink); + + // then + assertThat(parsedSink.name()).describedAs("name").isEqualTo(streamName); + assertThat(parsedSink.aafCredentials()).describedAs("aaf credentials").isNotNull(); + assertThat(parsedSink.aafCredentials().username()).describedAs("aaf user name").isEqualTo("aaf_username"); + assertThat(parsedSink.aafCredentials().password()).describedAs("aaf password").isEqualTo("aaf_password"); + assertThat(parsedSink.location()).describedAs("location").isEqualTo("mtl5"); + assertThat(parsedSink.clientId()).describedAs("client id").isEqualTo("222222"); + assertThat(parsedSink.clientRole()).describedAs("client role").isEqualTo("com.att.dcae.member"); + assertThat(parsedSink.topicUrl()).describedAs("topic url") + .isEqualTo("https://mrlocal:3905/events/com.att.dcae.dmaap.FTL2.SEC-FAULT-OUTPUT"); + } +} \ No newline at end of file