2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019-2020 Fujitsu Limited 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=========================================================
21 package org.onap.sdnc.northbound;
23 import static org.junit.Assert.*;
24 import static org.mockito.Mockito.*;
26 import java.util.Properties;
28 import org.junit.Before;
29 import org.junit.Test;
30 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
31 import org.onap.ccsdk.sli.core.sli.provider.MdsalHelper;
32 import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService;
33 import org.onap.sdnc.northbound.OpticalServiceClient;
34 import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.optical.service.rev191206.OpticalServiceCreateOutputBuilder;
35 import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.optical.service.rev191206.OpticalServiceDeleteOutputBuilder;
37 public class OpticalServiceClientTest {
39 SvcLogicService mockSvcLogicService;
40 String module = "test-module";
41 String rpc = "test-rpc";
42 String version = "test-version";
43 String mode = "test-mode";
44 Properties localProp = new Properties();
47 public void setUp() throws Exception {
48 mockSvcLogicService = mock(SvcLogicService.class);
49 when(mockSvcLogicService.hasGraph(module, rpc, version, mode)).thenReturn(true);
53 public void testOpticalServiceClientConstructor() {
54 OpticalServiceClient opticalServiceClient = new OpticalServiceClient(mockSvcLogicService);
55 assertNotNull(opticalServiceClient);
59 public void testHasGraph() throws SvcLogicException {
60 OpticalServiceClient opticalServiceClient = new OpticalServiceClient(mockSvcLogicService);
61 boolean result = opticalServiceClient.hasGraph(module, rpc, version, mode);
66 public void testExecuteSvcLogicStatusFailureCreate() throws SvcLogicException {
67 OpticalServiceCreateOutputBuilder serviceData = mock(OpticalServiceCreateOutputBuilder.class);
68 Properties parms = mock(Properties.class);
69 SvcLogicService svcLogicService = mock(SvcLogicService.class);
70 Properties properties = new Properties();
71 properties.setProperty("SvcLogic.status", "failure");
72 when(svcLogicService.execute(module, rpc, version, mode, properties)).thenReturn(properties);
73 OpticalServiceClient sliClient = new OpticalServiceClient(svcLogicService);
74 Properties prop = sliClient.execute(module, rpc, version, mode, serviceData, properties);
75 assertTrue(prop != null);
79 public void testExecuteSvcLogicStatusFailureDelete() throws SvcLogicException {
80 OpticalServiceDeleteOutputBuilder serviceData = mock(OpticalServiceDeleteOutputBuilder.class);
81 Properties parms = mock(Properties.class);
82 SvcLogicService svcLogicService = mock(SvcLogicService.class);
83 Properties properties = new Properties();
84 properties.setProperty("SvcLogic.status", "failure");
85 when(svcLogicService.execute(module, rpc, version, mode, properties)).thenReturn(properties);
86 OpticalServiceClient sliClient = new OpticalServiceClient(svcLogicService);
87 Properties prop = sliClient.execute(module, rpc, version, mode, serviceData, properties);
88 assertTrue(prop != null);