2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2021 China Mobile.
4 * Copyright (C) 2022 Wipro Limited.
5 * ================================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * SPDX-License-Identifier: Apache-2.0
19 * ============LICENSE_END=========================================================
22 package org.onap.dcaegen2.kpi.dmaap;
24 import static org.junit.Assert.assertNotNull;
25 import static org.mockito.Mockito.when;
27 import java.time.Duration;
29 import org.junit.Test;
30 import org.junit.runner.RunWith;
31 import org.mockito.InjectMocks;
32 import org.mockito.Mock;
33 import org.mockito.Mockito;
34 import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.api.MessageRouterSubscriber;
35 import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.model.MessageRouterSubscribeRequest;
36 import org.springframework.boot.test.context.SpringBootTest;
37 import org.springframework.test.context.junit4.SpringRunner;
39 import com.google.gson.JsonElement;
41 import reactor.core.CoreSubscriber;
42 import reactor.core.publisher.Flux;
44 @RunWith(SpringRunner.class)
45 @SpringBootTest(classes = NotificationConsumerTest.class)
46 public class NotificationConsumerTest {
49 NotificationCallback notificationCallback;
52 NotificationConsumer notificationConsumer;
55 MessageRouterSubscriber messageSubscriber;
58 MessageRouterSubscribeRequest subscriberRequest;
61 public void testNotificationConsumer() {
63 Flux<JsonElement> json = new Flux<JsonElement>() {
65 public void subscribe(CoreSubscriber<? super JsonElement> actual) {
68 Mockito.doNothing().when(notificationCallback).activateCallBack(Mockito.anyString());
69 when(messageSubscriber.subscribeForElements(subscriberRequest, Duration.ofMinutes(1))).thenReturn(json);
70 assertNotNull(messageSubscriber.subscribeForElements(subscriberRequest, Duration.ofMinutes(1)));
71 } catch (Exception e) {