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.opendaylight.mdsal.binding.api.DataBroker;
28 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
29 import org.opendaylight.mdsal.binding.api.RpcProviderService;
30 import org.opendaylight.yangtools.yang.common.RpcResult;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
34 import static org.junit.Assert.*;
35 import static org.mockito.Mockito.mock;
39 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200224.NbrlistChangeNotificationInputBuilder;
40 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200224.NbrlistChangeNotificationOutput;
42 import com.google.common.util.concurrent.ListenableFuture;
46 public class TestCMNotify {
48 private CMNotifyProvider cMNotifyProvider;
49 private static final Logger LOG = LoggerFactory.getLogger(CMNotifyProvider.class);
52 public void setUp() throws Exception {
53 if (null == cMNotifyProvider) {
54 DataBroker dataBroker = mock(DataBroker.class);
55 NotificationPublishService mockNotification = mock(NotificationPublishService.class);
56 RpcProviderService mockRpcRegistry = mock(RpcProviderService.class);
57 CMNotifyClient mockSliClient = mock(CMNotifyClient.class);
58 cMNotifyProvider = new CMNotifyProvider();
59 cMNotifyProvider.setDataBroker(dataBroker);
60 cMNotifyProvider.setNotificationPublishService(mockNotification);
61 cMNotifyProvider.setRpcProviderRegistry(mockRpcRegistry);
62 cMNotifyProvider.setClient(mockSliClient);
66 //Testcase should return error 503 when No service logic active for NbrlistChangeNotification
68 public void testNbrlistChangeNotification() {
70 NbrlistChangeNotificationInputBuilder inputBuilder = new NbrlistChangeNotificationInputBuilder();
72 inputBuilder.setFapServiceNumberOfEntriesChanged(new BigInteger("1"));
74 // TODO: currently initialize SvcLogicServiceClient is failing, need to fix
75 ListenableFuture<RpcResult<NbrlistChangeNotificationOutput>> future = cMNotifyProvider
76 .nbrlistChangeNotification(inputBuilder.build());
77 RpcResult<NbrlistChangeNotificationOutput> rpcResult = null;
79 rpcResult = future.get();
80 } catch (Exception e) {
83 LOG.info("result: {}", rpcResult);
84 assertEquals("503", rpcResult.getResult().getResponseCode());
87 //Input parameter validation
89 public void testvValidation() {
91 ListenableFuture<RpcResult<NbrlistChangeNotificationOutput>> future = cMNotifyProvider
92 .nbrlistChangeNotification(null);
93 RpcResult<NbrlistChangeNotificationOutput> rpcResult = null;
95 rpcResult = future.get();
96 } catch (Exception e) {
99 LOG.info("result: {}", rpcResult);
100 assertEquals("Input is null", rpcResult.getResult().getResponseCode());