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;
38 public class VolumeRequestHandlerTest {
39 VolumeRequestHandler handler = null;
41 UriInfo uriInfo = null;
44 public void setup() throws Exception{
46 uriInfo = Mockito.mock(UriInfo.class);
47 Class<?> clazz = VolumeRequestHandler.class;
48 handler = (VolumeRequestHandler)clazz.newInstance();
50 Field f1 = handler.getClass().getDeclaredField("uriInfo");
52 f1.setAccessible(true);
53 f1.set(handler, uriInfo);
57 public void manageVnfRequestTest(){
58 Response resp = handler.manageVolumeRequest("<name>Test</name>", "v2");
59 assertTrue(null != resp);
63 public void manageVnfRequest2Test(){
64 Mockito.when(uriInfo.getRequestUri())
65 .thenReturn(URI.create("http://localhost:8080/test"));
67 new MockUp<MsoPropertiesUtils>() {
69 public synchronized final boolean getNoPropertiesState() {
73 Response resp = handler.manageVolumeRequest("<name>Test</name>", "v2");
74 assertTrue(null != resp);