1 /*******************************************************************************
 
   2  *  ============LICENSE_START=======================================================
 
   4  *  ================================================================================
 
   5  *   Copyright (C) 2020 Wipro Limited.
 
   6  *   Copyright (C) 2022 CTC, Inc.
 
   7  *   ==============================================================================
 
   8  *     Licensed under the Apache License, Version 2.0 (the "License");
 
   9  *     you may not use this file except in compliance with the License.
 
  10  *     You may obtain a copy of the License at
 
  12  *          http://www.apache.org/licenses/LICENSE-2.0
 
  14  *     Unless required by applicable law or agreed to in writing, software
 
  15  *     distributed under the License is distributed on an "AS IS" BASIS,
 
  16  *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  17  *     See the License for the specific language governing permissions and
 
  18  *     limitations under the License.
 
  19  *     ============LICENSE_END=========================================================
 
  21  *******************************************************************************/
 
  24 package org.onap.slice.analysis.ms.dmaap;
 
  26 import static org.mockito.ArgumentMatchers.any;
 
  27 import static org.mockito.Mockito.when;
 
  29 import com.google.gson.JsonPrimitive;
 
  30 import org.junit.Test;
 
  31 import org.junit.runner.RunWith;
 
  32 import org.mockito.InjectMocks;
 
  33 import org.mockito.Mock;
 
  34 import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.api.MessageRouterPublisher;
 
  35 import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.model.ImmutableMessageRouterPublishResponse;
 
  36 import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.model.MessageRouterPublishRequest;
 
  37 import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.model.MessageRouterPublishResponse;
 
  38 import org.springframework.boot.test.context.SpringBootTest;
 
  39 import org.springframework.test.context.junit4.SpringRunner;
 
  40 import reactor.core.publisher.Flux;
 
  42 import java.io.IOException;
 
  44 @RunWith(SpringRunner.class)
 
  45 @SpringBootTest(classes = NotificationProducerTest.class)
 
  46 public class NotificationProducerTest {
 
  49     MessageRouterPublisher publisher;
 
  52     MessageRouterPublishRequest request;
 
  55     NotificationProducer notificationProducer;
 
  58     public void notificationProducerTest() throws IOException {
 
  59             io.vavr.collection.List<String> expectedItems = io.vavr.collection.List.of("I", "like", "pizza");
 
  60             MessageRouterPublishResponse expectedResponse = ImmutableMessageRouterPublishResponse
 
  61                     .builder().items(expectedItems.map(JsonPrimitive::new))
 
  63             Flux<MessageRouterPublishResponse> responses = Flux.just(expectedResponse);
 
  64 //            Flux<JsonPrimitive> singleMessage = Flux.just("msg").map(JsonPrimitive::new);
 
  65             when(publisher.put(any(), any())).thenReturn(responses);
 
  67             notificationProducer.sendNotification("msg");