53893a591ed843876aa01965d00d23dd6b713049
[vfc/nfvo/driver/vnfm/gvnfm.git] / juju / juju-vnfmadapter / Juju-vnfmadapterService / service / src / test / java / org / openo / nfvo / jujuvnfmadapter / service / rest / ConfigRoaTest.java
1 /*
2  * Copyright 2016-2017 Huawei Technologies Co., Ltd.
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.openo.nfvo.jujuvnfmadapter.service.rest;
17
18 import static org.junit.Assert.*;
19
20 import javax.servlet.http.HttpServletRequest;
21 import javax.servlet.http.HttpServletResponse;
22
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;
30
31 import mockit.Mock;
32 import mockit.MockUp;
33 import net.sf.json.JSONObject;
34
35 public class ConfigRoaTest {
36     ConfigRoa roa;
37
38     @Before
39     public void setUp() {
40         roa = new ConfigRoa();
41     }
42
43     @Test
44     public void initUITest() {
45         HttpServletRequest context = null;
46         HttpServletResponse resp = new MockHttpServletResponse();
47         String res = roa.initUI(context, resp);
48         assertNotNull(res);
49     }
50
51     @Test
52     public void setDebugModelTest() throws ServiceException {
53         HttpServletRequest context = null;
54         HttpServletResponse resp = new MockHttpServletResponse();
55         boolean res = roa.setDebugModel(1, context, resp);
56         assertTrue(res);
57     }
58
59     @Test
60     public void setDebug2ModelTest() throws ServiceException {
61         HttpServletRequest context = null;
62         HttpServletResponse resp = new MockHttpServletResponse();
63         boolean res = roa.setDebugModel(2, context, resp);
64         assertFalse(res);
65     }
66
67     @Test
68     public void testmock() throws ServiceException {
69         HttpServletRequest context = null;
70         HttpServletResponse resp = new MockHttpServletResponse();
71         String methodName = "getVnfmById";
72         JSONObject json = new JSONObject();
73
74         new MockUp<JujuConfigUtil>() {
75             @Mock
76             public String getValue(String key) {
77                 return null;
78             }
79
80         };
81         roa.mock(methodName, context, resp);
82         roa.unmock(methodName, context, resp);
83
84     }
85 }