2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.mso.apihandlerinfra;
23 import static org.junit.Assert.assertTrue;
25 import java.lang.reflect.Field;
28 import javax.ws.rs.core.Response;
29 import javax.ws.rs.core.UriInfo;
34 import org.junit.Before;
35 import org.junit.Test;
36 import org.mockito.Mockito;
37 import org.openecomp.mso.apihandlerinfra.networkbeans.NetworkRequest;
38 import org.openecomp.mso.requestsdb.InfraRequests;
40 public class NetworkRequestHandlerTest {
42 NetworkRequestHandler handler = null;
44 UriInfo uriInfo = null;
47 public void setup() throws Exception{
49 uriInfo = Mockito.mock(UriInfo.class);
50 Class<?> clazz = NetworkRequestHandler.class;
51 handler = (NetworkRequestHandler)clazz.newInstance();
53 Field f1 = handler.getClass().getDeclaredField("uriInfo");
55 f1.setAccessible(true);
56 f1.set(handler, uriInfo);
60 public void manageVnfRequestTest(){
61 Response resp = handler.manageNetworkRequest("<name>Test</name>", "v2");
62 assertTrue(null != resp);
66 public void manageVnfRequest2Test(){
67 Mockito.when(uriInfo.getRequestUri())
68 .thenReturn(URI.create("http://localhost:8080/test"));
70 new MockUp<MsoPropertiesUtils>() {
72 public synchronized final boolean getNoPropertiesState() {
76 Response resp = handler.manageNetworkRequest("<name>Test</name>", "v2");
77 assertTrue(null != resp);
81 public void fillNetworkRequestTestV1(){
82 NetworkRequest qr = new NetworkRequest();
83 InfraRequests ar = new InfraRequests();
87 ar.setTenantId("48889690");
88 ar.setProvStatus("uuu");
89 ar.setVolumeGroupName("volume");
90 ar.setVolumeGroupId("38838");
91 ar.setServiceType("vnf");
92 ar.setAicNodeClli("djerfe");
93 ar.setAaiServiceId("599499");
94 ar.setAicCloudRegion("south");
95 ar.setVfModuleName("m1");
96 ar.setVfModuleId("39949");
97 ar.setVfModuleModelName("test");
98 ar.setAaiServiceId("37728");
99 ar.setVnfParams("test");
100 handler.fillNetworkRequest(qr, ar, "v1");
101 String param = (String)qr.getNetworkParams();
102 assertTrue(param.equals("test"));
105 public void fillNetworkRequestTestV2(){
106 NetworkRequest qr = new NetworkRequest();
107 InfraRequests ar = new InfraRequests();
109 ar.setVnfName("vnf");
110 ar.setVnfType("vnt");
111 ar.setTenantId("48889690");
112 ar.setProvStatus("uuu");
113 ar.setVolumeGroupName("volume");
114 ar.setVolumeGroupId("38838");
115 ar.setServiceType("vnf");
116 ar.setAicNodeClli("djerfe");
117 ar.setAaiServiceId("599499");
118 ar.setAicCloudRegion("south");
119 ar.setVfModuleName("m1");
120 ar.setVfModuleId("39949");
121 ar.setVfModuleModelName("test");
122 ar.setAaiServiceId("37728");
123 ar.setVnfParams("test");
124 handler.fillNetworkRequest(qr, ar, "v2");
125 String param = (String)qr.getNetworkParams();
126 assertTrue(param.equals("test"));
129 public void fillNetworkRequestTestV3(){
130 NetworkRequest qr = new NetworkRequest();
131 InfraRequests ar = new InfraRequests();
133 ar.setVnfName("vnf");
134 ar.setVnfType("vnt");
135 ar.setTenantId("48889690");
136 ar.setProvStatus("uuu");
137 ar.setVolumeGroupName("volume");
138 ar.setVolumeGroupId("38838");
139 ar.setServiceType("vnf");
140 ar.setAicNodeClli("djerfe");
141 ar.setAaiServiceId("599499");
142 ar.setAicCloudRegion("south");
143 ar.setVfModuleName("m1");
144 ar.setVfModuleId("39949");
145 ar.setVfModuleModelName("test");
146 ar.setAaiServiceId("37728");
147 ar.setVnfParams("test");
148 handler.fillNetworkRequest(qr, ar, "v3");
149 String param = (String)qr.getNetworkParams();
150 assertTrue(param.equals("test"));