2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights
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=========================================================
22 package org.onap.ccsdk.features.sdnr.northbound.CMNotify;
24 import org.junit.Before;
25 import org.junit.Test;
27 import org.onap.ccsdk.features.sdnr.northbound.CMNotify.CMNotifyClient;
28 import org.onap.ccsdk.features.sdnr.northbound.CMNotify.CMNotifyProvider;
30 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
31 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
32 import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest;
33 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
35 import org.opendaylight.yangtools.yang.common.RpcResult;
36 import org.slf4j.Logger;
37 import org.slf4j.LoggerFactory;
39 import static org.junit.Assert.*;
40 import static org.mockito.Mockito.mock;
44 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200224.NbrlistChangeNotificationInput;
45 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200224.NbrlistChangeNotificationInputBuilder;
46 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200224.NbrlistChangeNotificationOutput;
47 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200224.NbrlistChangeNotificationOutputBuilder;
49 import com.google.common.util.concurrent.ListenableFuture;
53 public class TestCMNotify extends AbstractConcurrentDataBrokerTest {
55 private CMNotifyProvider cMNotifyProvider;
56 private static final Logger LOG = LoggerFactory.getLogger(CMNotifyProvider.class);
59 public void setUp() throws Exception {
60 if (null == cMNotifyProvider) {
61 DataBroker dataBroker = getDataBroker();
62 NotificationPublishService mockNotification = mock(NotificationPublishService.class);
63 RpcProviderRegistry mockRpcRegistry = mock(RpcProviderRegistry.class);
64 CMNotifyClient mockSliClient = mock(CMNotifyClient.class);
65 cMNotifyProvider = new CMNotifyProvider(dataBroker, mockNotification, mockRpcRegistry, mockSliClient);
69 //Testcase should return error 503 when No service logic active for NbrlistChangeNotification
71 public void testNbrlistChangeNotification() {
73 NbrlistChangeNotificationInputBuilder inputBuilder = new NbrlistChangeNotificationInputBuilder();
75 inputBuilder.setFapServiceNumberOfEntriesChanged(new BigInteger("1"));
77 // TODO: currently initialize SvcLogicServiceClient is failing, need to fix
78 ListenableFuture<RpcResult<NbrlistChangeNotificationOutput>> future = cMNotifyProvider
79 .nbrlistChangeNotification(inputBuilder.build());
80 RpcResult<NbrlistChangeNotificationOutput> rpcResult = null;
82 rpcResult = future.get();
83 } catch (Exception e) {
86 LOG.info("result: {}", rpcResult);
87 assertEquals("503", rpcResult.getResult().getResponseCode());
90 //Input parameter validation
92 public void testvValidation() {
94 ListenableFuture<RpcResult<NbrlistChangeNotificationOutput>> future = cMNotifyProvider
95 .nbrlistChangeNotification(null);
96 RpcResult<NbrlistChangeNotificationOutput> rpcResult = null;
98 rpcResult = future.get();
99 } catch (Exception e) {
100 fail("Error : " + e);
102 LOG.info("result: {}", rpcResult);
103 assertEquals("Input is null", rpcResult.getResult().getResponseCode());