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 static org.junit.Assert.*;
25 import static org.mockito.Mockito.*;
27 import java.util.Properties;
29 import org.junit.Before;
30 import org.junit.Test;
31 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
32 import org.onap.ccsdk.sli.core.sli.provider.MdsalHelper;
33 import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService;
35 import org.onap.ccsdk.features.sdnr.northbound.CMNotify.CMNotifyClient;
37 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200224.NbrlistChangeNotificationInput;
38 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200224.NbrlistChangeNotificationInputBuilder;
39 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200224.NbrlistChangeNotificationOutput;
40 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200224.NbrlistChangeNotificationOutputBuilder;
42 import org.slf4j.Logger;
43 import org.slf4j.LoggerFactory;
45 public class CMNotifyClientTest {
47 SvcLogicService mockSvcLogicService;
48 String module = "test-module";
49 String rpc = "test-rpc";
50 String version = "test-version";
51 String mode = "test-mode";
52 Properties localProp = new Properties();
55 public void setUp() throws Exception {
56 mockSvcLogicService = mock(SvcLogicService.class);
57 when(mockSvcLogicService.hasGraph(module, rpc, version, mode)).thenReturn(true);
61 public void testCMNotifyClientConstructor() {
62 CMNotifyClient CMNotifyClient = new CMNotifyClient(mockSvcLogicService);
63 assertNotNull(CMNotifyClient);
67 public void testHasGraph() throws SvcLogicException {
68 CMNotifyClient CMNotifyClient = new CMNotifyClient(mockSvcLogicService);
69 boolean result = CMNotifyClient.hasGraph(module, rpc, version, mode);
74 public void testExecuteSvcLogicStatusFailure() throws SvcLogicException {
75 NbrlistChangeNotificationOutputBuilder serviceData = mock(NbrlistChangeNotificationOutputBuilder.class);
76 Properties parms = mock(Properties.class);
77 SvcLogicService svcLogicService = mock(SvcLogicService.class);
78 Properties properties = new Properties();
79 properties.setProperty("SvcLogic.status", "failure");
80 when(svcLogicService.execute(module, rpc, version, mode, properties)).thenReturn(properties);
81 CMNotifyClient sliClient = new CMNotifyClient(svcLogicService);
82 Properties prop = sliClient.execute(module, rpc, version, mode, serviceData, properties);
83 assertTrue(prop != null);