2 * Copyright (C) 2018 CMCC, Inc. and others. All rights reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.onap.usecaseui.server.controller.sotn;
18 import static org.mockito.Mockito.mock;
19 import static org.mockito.Mockito.times;
20 import static org.mockito.Mockito.verify;
22 import java.util.ArrayList;
24 import javax.servlet.http.HttpServletRequest;
26 import org.junit.Before;
27 import org.junit.Test;
28 import org.onap.usecaseui.server.bean.sotn.NetWorkResource;
29 import org.onap.usecaseui.server.service.sotn.SOTNService;
31 public class SotnControllerTest {
33 public SOTNService sotnService;
35 private SotnController sotnController = new SotnController();
39 sotnService = mock(SOTNService.class);
40 sotnController.setSotnService(sotnService);
44 public void TestGetNetWorkResources(){
45 sotnController.getNetWorkResources();
46 verify(sotnService, times(1)).getNetWorkResources();
50 public void TestGetPinterfaceByPnfName(){
51 String pnfName="pnfName";
52 sotnController.getPinterfaceByPnfName(pnfName);
53 verify(sotnService, times(1)).getPinterfaceByPnfName(pnfName);
57 public void TestGetLogicalLinks(){
58 sotnController.getLogicalLinks();
59 verify(sotnService, times(1)).getLogicalLinks();
63 public void TestGetSpecificLogicalLink(){
64 String linkName="pnfName";
65 sotnController.getSpecificLogicalLink(linkName);
66 verify(sotnService, times(1)).getSpecificLogicalLink(linkName);
70 public void TestGetHostUrl(){
71 String linkName="pnfName";
72 sotnController.getHostUrl(linkName);
73 verify(sotnService, times(1)).getHostUrl(linkName);
77 public void TestGetExtAaiId(){
78 String linkName="pnfName";
79 sotnController.getExtAaiId(linkName);
80 verify(sotnService, times(1)).getExtAaiId(linkName);
84 public void TestCreateHostUrl(){
85 String linkName="pnfName";
86 HttpServletRequest request = mock(HttpServletRequest.class);
87 sotnController.createHostUrl(request,linkName);
88 verify(sotnService, times(1)).createHostUrl(request,linkName);
92 public void TestCreateTopoNetwork(){
93 String linkName="pnfName";
94 HttpServletRequest request = mock(HttpServletRequest.class);
95 sotnController.createTopoNetwork(request,linkName);
96 verify(sotnService, times(1)).createTopoNetwork(request,linkName);
100 public void TestCreateTerminationPoint(){
101 String linkName="pnfName";
103 HttpServletRequest request = mock(HttpServletRequest.class);
104 sotnController.createTerminationPoint(request,linkName,tpid);
105 verify(sotnService, times(1)).createTerminationPoint(request,linkName,tpid);
109 public void TestCreateLink(){
110 String linkName="pnfName";
111 HttpServletRequest request = mock(HttpServletRequest.class);
112 sotnController.createLink(request,linkName);
113 verify(sotnService, times(1)).createLink(request,linkName);
117 public void TestCreatePnf(){
118 String linkName="pnfName";
119 HttpServletRequest request = mock(HttpServletRequest.class);
120 sotnController.createPnf(request,linkName);
121 verify(sotnService, times(1)).createPnf(request,linkName);
125 public void TestDeleteLink(){
126 String linkName="pnfName";
127 String resourceVersion="resourceVersion";
128 sotnController.deleteLink(linkName,resourceVersion);
129 verify(sotnService, times(1)).deleteLink(linkName,resourceVersion);
133 public void TestGetServiceInstanceInfo(){
134 String linkName="pnfName";
135 String resourceVersion="resourceVersion";
136 String serviceType="serviceType";
137 HttpServletRequest request = mock(HttpServletRequest.class);
138 sotnController.getServiceInstanceInfo(request);
139 verify(sotnService, times(1)).serviceInstanceInfo(linkName,resourceVersion,serviceType);
143 public void TestGetPnfInfo(){
144 String linkName="pnfName";
145 sotnController.getPnfInfo(linkName);
146 verify(sotnService, times(1)).getPnfInfo(linkName);
150 public void TestGetAllottedResources(){
151 String linkName="pnfName";
152 String resourceVersion="resourceVersion";
153 String serviceType="serviceType";
154 HttpServletRequest request = mock(HttpServletRequest.class);
155 sotnController.getAllottedResources(request);
156 verify(sotnService, times(1)).getAllottedResources(linkName,resourceVersion,serviceType);
160 public void TestGetConnectivityInfo(){
161 String linkName="pnfName";
162 sotnController.getConnectivityInfo(linkName);
163 verify(sotnService, times(1)).getConnectivityInfo(linkName);
167 public void TestGetPinterfaceByVpnId(){
168 String linkName="pnfName";
169 sotnController.getPinterfaceByVpnId(linkName);
170 verify(sotnService, times(1)).getPinterfaceByVpnId(linkName);
174 public void TestGetServiceInstanceList(){
175 String linkName="pnfName";
176 String resourceVersion="resourceVersion";
177 HttpServletRequest request = mock(HttpServletRequest.class);
178 sotnController.getServiceInstanceList(request);
179 verify(sotnService, times(1)).getServiceInstances(linkName,resourceVersion);
183 public void TestDeleteExtNetwork(){
184 String linkName="pnfName";
185 String resourceVersion="resourceVersion";
186 sotnController.deleteExtNetwork(linkName,resourceVersion);
187 verify(sotnService, times(1)).deleteExtNetwork(linkName,resourceVersion);
191 public void testNetWorkResource(){
192 NetWorkResource netWorkResource = new NetWorkResource ();
193 netWorkResource = new NetWorkResource("networkId",new ArrayList(),new ArrayList(),"aaiId");
194 netWorkResource.getAaiId();
195 netWorkResource.getNetworkId();
196 netWorkResource.getPnfs();
197 netWorkResource.getTps();
198 netWorkResource.setAaiId("testaaai");
199 netWorkResource.setNetworkId("testnet");
200 netWorkResource.setPnfs(new ArrayList());
201 netWorkResource.setTps(new ArrayList());