2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2021 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.dcae.multiplestreamreducer;
22 import io.vavr.collection.HashMap;
23 import io.vavr.collection.Map;
24 import org.junit.jupiter.api.Test;
26 import static org.junit.jupiter.api.Assertions.*;
28 class MultipleStreamReducerTest {
30 private final MultipleStreamReducer multipleStreamReducer = new MultipleStreamReducer();
31 private final Map<String, String[]> domainToStreams = HashMap.of(
32 "fault", new String[]{"ves-fault", "stream1", "stream2"},
33 "log", new String[]{"ves-syslog", "stream3", "stream4", "stream5"},
34 "test", new String[]{"stream6"}
38 void shouldReduceStreamsToTheFirstOne() {
40 Map<String, String> expected = HashMap.of(
47 final Map<String, String> domainToStreamsAfterReduce = multipleStreamReducer.reduce(domainToStreams);
50 assertEquals(expected, domainToStreamsAfterReduce);
54 void shouldReturnInfoAboutDomainToStreamsConfig() {
56 final Map<String, String> domainToStreamsAfterReduce = multipleStreamReducer.reduce(domainToStreams);
57 String expectedRedundantStreamsInfo =
58 "Domain: fault has active stream: ves-fault\n" +
59 "Domain: log has active stream: ves-syslog\n" +
60 "Domain: test has active stream: stream6\n";
63 final String domainToStreamsConfigInfo = multipleStreamReducer.getDomainToStreamsInfo(domainToStreamsAfterReduce);
66 assertEquals(expectedRedundantStreamsInfo, domainToStreamsConfigInfo);