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;
31 import org.junit.Before;
32 import org.junit.Test;
33 import org.mockito.Mockito;
34 import org.openecomp.mso.apihandlerinfra.vnfbeans.VnfRequest;
35 import org.openecomp.mso.requestsdb.InfraRequests;
37 import javax.ws.rs.core.Response;
38 import javax.ws.rs.core.UriInfo;
40 public class VnfRequestHandlerTest {
41 VnfRequestHandler handler = null;
42 UriInfo uriInfo = null;
45 public void setup() throws Exception{
47 uriInfo = Mockito.mock(UriInfo.class);
48 Class<?> clazz = VnfRequestHandler.class;
49 handler = (VnfRequestHandler)clazz.newInstance();
51 Field f1 = handler.getClass().getDeclaredField("uriInfo");
53 f1.setAccessible(true);
54 f1.set(handler, uriInfo);
58 public void manageVnfRequestTest(){
59 Response resp = handler.manageVnfRequest("<name>Test</name>", "v2");
60 assertTrue(null != resp);
64 public void manageVnfRequest2Test(){
65 Mockito.when(uriInfo.getRequestUri())
66 .thenReturn(URI.create("http://localhost:8080/test"));
68 new MockUp<MsoPropertiesUtils>() {
70 public synchronized final boolean getNoPropertiesState() {
74 Response resp = handler.manageVnfRequest("<name>Test</name>", "v2");
75 assertTrue(null != resp);
79 public void fillVnfRequestTest(){
80 VnfRequest qr = new VnfRequest();
81 InfraRequests ar = new InfraRequests();
85 ar.setTenantId("48889690");
86 ar.setProvStatus("uuu");
87 ar.setVolumeGroupName("volume");
88 ar.setVolumeGroupId("38838");
89 ar.setServiceType("vnf");
90 ar.setAicNodeClli("djerfe");
91 ar.setAaiServiceId("599499");
92 ar.setAicCloudRegion("south");
93 ar.setVfModuleName("m1");
94 ar.setVfModuleId("39949");
95 ar.setVfModuleModelName("test");
96 ar.setAaiServiceId("37728");
97 ar.setVnfParams("test");
98 handler.fillVnfRequest(qr, ar, "v1");
99 String param = (String)qr.getVnfParams();
100 assertTrue(param.equals("test"));
104 public void fillVnfRequestTestV2(){
105 VnfRequest qr = new VnfRequest();
106 InfraRequests ar = new InfraRequests();
108 ar.setVnfName("vnf");
109 ar.setVnfType("vnt");
110 ar.setTenantId("48889690");
111 ar.setProvStatus("uuu");
112 ar.setVolumeGroupName("volume");
113 ar.setVolumeGroupId("38838");
114 ar.setServiceType("vnf");
115 ar.setAicNodeClli("djerfe");
116 ar.setAaiServiceId("599499");
117 ar.setAicCloudRegion("south");
118 ar.setVfModuleName("m1");
119 ar.setVfModuleId("39949");
120 ar.setVfModuleModelName("test");
121 ar.setAaiServiceId("37728");
122 ar.setVnfParams("test");
123 handler.fillVnfRequest(qr, ar, "v2");
124 String param = (String)qr.getVnfParams();
125 assertTrue(param.equals("test"));
128 public void fillVnfRequestTestV3(){
129 VnfRequest qr = new VnfRequest();
130 InfraRequests ar = new InfraRequests();
132 ar.setVnfName("vnf");
133 ar.setVnfType("vnt");
134 ar.setTenantId("48889690");
135 ar.setProvStatus("uuu");
136 ar.setVolumeGroupName("volume");
137 ar.setVolumeGroupId("38838");
138 ar.setServiceType("vnf");
139 ar.setAicNodeClli("djerfe");
140 ar.setAaiServiceId("599499");
141 ar.setAicCloudRegion("south");
142 ar.setVfModuleName("m1");
143 ar.setVfModuleId("39949");
144 ar.setVfModuleModelName("test");
145 ar.setAaiServiceId("37728");
146 ar.setVnfParams("test");
147 ar.setServiceInstanceId("38829");
148 handler.fillVnfRequest(qr, ar, "v3");
149 String param = (String)qr.getVnfParams();
150 assertTrue(param.equals("test"));