X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=components%2Fkpi-computation-ms%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fdcaegen2%2Fkpi%2Fdmaap%2FNotificationConsumerTest.java;fp=components%2Fkpi-computation-ms%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fdcaegen2%2Fkpi%2Fdmaap%2FNotificationConsumerTest.java;h=8d72d3cd538a926722cb9fea986a71c05d212d3f;hb=8db39359abef9f94c8cbec10189cd295cf1d814f;hp=1d04a627e720ffe4751409d667bb25a8ef367cab;hpb=113d2b262579a49492e8f95d8a767053b52d2a42;p=dcaegen2%2Fservices.git diff --git a/components/kpi-computation-ms/src/test/java/org/onap/dcaegen2/kpi/dmaap/NotificationConsumerTest.java b/components/kpi-computation-ms/src/test/java/org/onap/dcaegen2/kpi/dmaap/NotificationConsumerTest.java index 1d04a627..8d72d3cd 100644 --- a/components/kpi-computation-ms/src/test/java/org/onap/dcaegen2/kpi/dmaap/NotificationConsumerTest.java +++ b/components/kpi-computation-ms/src/test/java/org/onap/dcaegen2/kpi/dmaap/NotificationConsumerTest.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2021 China Mobile. + * Copyright (C) 2022 Wipro Limited. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,43 +21,53 @@ package org.onap.dcaegen2.kpi.dmaap; +import static org.junit.Assert.assertNotNull; import static org.mockito.Mockito.when; -import java.util.ArrayList; -import java.util.List; +import java.time.Duration; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; +import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.api.MessageRouterSubscriber; +import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.model.MessageRouterSubscribeRequest; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; -import com.att.nsa.cambria.client.CambriaConsumer; +import com.google.gson.JsonElement; + +import reactor.core.CoreSubscriber; +import reactor.core.publisher.Flux; @RunWith(SpringRunner.class) @SpringBootTest(classes = NotificationConsumerTest.class) public class NotificationConsumerTest { - @Mock - CambriaConsumer cambriaConsumer; - @Mock NotificationCallback notificationCallback; @InjectMocks NotificationConsumer notificationConsumer; + + @Mock + MessageRouterSubscriber messageSubscriber; + + @Mock + MessageRouterSubscribeRequest subscriberRequest; @Test public void testNotificationConsumer() { try { - List notifications = new ArrayList<>(); - notifications.add("notification1"); - when(cambriaConsumer.fetch()).thenReturn(notifications); + Flux json = new Flux() { + @Override + public void subscribe(CoreSubscriber actual) { + } + }; Mockito.doNothing().when(notificationCallback).activateCallBack(Mockito.anyString()); - notificationConsumer.run(); - + when(messageSubscriber.subscribeForElements(subscriberRequest, Duration.ofMinutes(1))).thenReturn(json); + assertNotNull(messageSubscriber.subscribeForElements(subscriberRequest, Duration.ofMinutes(1))); } catch (Exception e) { e.printStackTrace(); }