46f652206198add1c998a0dcdece8f389e2c323e
[usecase-ui/server.git] / server / src / test / java / org / onap / usecaseui / server / controller / sotn / SotnControllerTest.java
1 /*
2  * Copyright (C) 2018 CMCC, Inc. and others. All rights reserved.
3  *
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
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 package org.onap.usecaseui.server.controller.sotn;
17
18 import static org.mockito.Mockito.mock;
19 import static org.mockito.Mockito.times;
20 import static org.mockito.Mockito.verify;
21
22 import java.util.ArrayList;
23
24 import javax.servlet.http.HttpServletRequest;
25
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;
30
31 public class SotnControllerTest {
32         
33         public SOTNService sotnService;
34         
35         private SotnController sotnController = new SotnController();
36         
37         @Before
38     public void setUp() {
39                 sotnService = mock(SOTNService.class);
40                 sotnController.setSotnService(sotnService);
41     }
42         
43         @Test
44         public void TestGetNetWorkResources(){
45                 sotnController.getNetWorkResources();
46                 verify(sotnService, times(1)).getNetWorkResources();
47         }
48         
49         @Test
50         public void TestGetPinterfaceByPnfName(){
51                 String pnfName="pnfName";
52                 sotnController.getPinterfaceByPnfName(pnfName);
53                 verify(sotnService, times(1)).getPinterfaceByPnfName(pnfName);
54         }
55         
56         @Test
57         public void TestGetLogicalLinks(){
58                 sotnController.getLogicalLinks();
59                 verify(sotnService, times(1)).getLogicalLinks();
60         }
61         
62         @Test
63         public void TestGetSpecificLogicalLink(){
64                 String linkName="pnfName";
65                 sotnController.getSpecificLogicalLink(linkName);
66                 verify(sotnService, times(1)).getSpecificLogicalLink(linkName);
67         }
68         
69         @Test
70         public void TestGetHostUrl(){
71                 String linkName="pnfName";
72                 sotnController.getHostUrl(linkName);
73                 verify(sotnService, times(1)).getHostUrl(linkName);
74         }
75         
76         @Test
77         public void TestGetExtAaiId(){
78                 String linkName="pnfName";
79                 sotnController.getExtAaiId(linkName);
80                 verify(sotnService, times(1)).getExtAaiId(linkName);
81         }
82         
83         @Test
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);
89         }
90         
91         @Test
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);
97         }
98         
99         @Test
100         public void TestCreateTerminationPoint(){
101                 String linkName="pnfName";
102                 String tpid="tpid";
103                 HttpServletRequest request = mock(HttpServletRequest.class);
104                 sotnController.createTerminationPoint(request,linkName,tpid);
105                 verify(sotnService, times(1)).createTerminationPoint(request,linkName,tpid);
106         }
107         
108         @Test
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);
114         }
115         
116         @Test
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);
122         }
123         
124         @Test
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);
130         }
131         
132         @Test
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);
140         }
141         
142         @Test
143         public void TestGetPnfInfo(){
144                 String linkName="pnfName";
145                 sotnController.getPnfInfo(linkName);
146                 verify(sotnService, times(1)).getPnfInfo(linkName);
147         }
148         
149         @Test
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);
157         }
158         
159         @Test
160         public void TestGetConnectivityInfo(){
161                 String linkName="pnfName";
162                 sotnController.getConnectivityInfo(linkName);
163                 verify(sotnService, times(1)).getConnectivityInfo(linkName);
164         }
165         
166         @Test
167         public void TestGetPinterfaceByVpnId(){
168                 String linkName="pnfName";
169                 sotnController.getPinterfaceByVpnId(linkName);
170                 verify(sotnService, times(1)).getPinterfaceByVpnId(linkName);
171         }
172         
173         @Test
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);
180         }
181         
182         @Test
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);
188         }
189         
190         @Test
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());
202         }
203 }