2 * Copyright 2016-2017 Huawei Technologies Co., Ltd.
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.openo.nfvo.jujuvnfmadapter.service.rest;
18 import static org.junit.Assert.*;
20 import javax.servlet.http.HttpServletRequest;
21 import javax.servlet.http.HttpServletResponse;
23 import org.junit.Before;
24 import org.junit.Test;
25 import org.openo.baseservice.remoteservice.exception.ServiceException;
26 import org.openo.baseservice.roa.util.restclient.RestfulResponse;
27 import org.openo.nfvo.jujuvnfmadapter.common.JujuConfigUtil;
28 import org.openo.nfvo.jujuvnfmadapter.common.servicetoken.VnfmRestfulUtil;
29 import org.springframework.mock.web.MockHttpServletResponse;
33 import net.sf.json.JSONObject;
35 public class ConfigRoaTest {
40 roa = new ConfigRoa();
44 public void initUITest() {
45 HttpServletRequest context = null;
46 HttpServletResponse resp = new MockHttpServletResponse();
47 String res = roa.initUI(context, resp);
52 public void setDebugModelTest() throws ServiceException {
53 HttpServletRequest context = null;
54 HttpServletResponse resp = new MockHttpServletResponse();
55 boolean res = roa.setDebugModel(1, context, resp);
60 public void setDebug2ModelTest() throws ServiceException {
61 HttpServletRequest context = null;
62 HttpServletResponse resp = new MockHttpServletResponse();
63 boolean res = roa.setDebugModel(2, context, resp);
68 public void testmock() throws ServiceException {
69 HttpServletRequest context = null;
70 HttpServletResponse resp = new MockHttpServletResponse();
71 String methodName = "getVnfmById";
72 JSONObject json = new JSONObject();
74 new MockUp<JujuConfigUtil>() {
76 public String getValue(String key) {
81 roa.mock(methodName, context, resp);
82 roa.unmock(methodName, context, resp);