3c028dc38c10550233c5f65272dbebfad42ce0dc
[vfc/nfvo/resmanagement.git] /
1 /*\r
2  * Copyright 2017 Huawei Technologies Co., Ltd.\r
3  *\r
4  * Licensed under the Apache License, Version 2.0 (the "License");\r
5  * you may not use this file except in compliance with the License.\r
6  * You may obtain a copy of the License at\r
7  *\r
8  *     http://www.apache.org/licenses/LICENSE-2.0\r
9  *\r
10  * Unless required by applicable law or agreed to in writing, software\r
11  * distributed under the License is distributed on an "AS IS" BASIS,\r
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
13  * See the License for the specific language governing permissions and\r
14  * limitations under the License.\r
15  */\r
16 \r
17 package org.openo.nfvo.resmanagement.service.rest;\r
18 \r
19 import static org.junit.Assert.assertNotNull;\r
20 \r
21 import javax.servlet.http.HttpServletRequest;\r
22 \r
23 import org.junit.Before;\r
24 import org.junit.Test;\r
25 import org.openo.baseservice.remoteservice.exception.ServiceException;\r
26 import org.openo.nfvo.resmanagement.service.business.impl.LimitsBusinessImpl;\r
27 import org.openo.nfvo.resmanagement.service.business.inf.LimitsBusiness;\r
28 import org.springframework.mock.web.MockHttpServletRequest;\r
29 \r
30 import mockit.Mock;\r
31 import mockit.MockUp;\r
32 import net.sf.json.JSONObject;\r
33 \r
34 /**\r
35  * <br>\r
36  * <p>\r
37  * </p>\r
38  * \r
39  * @author\r
40  * @version NFVO 0.5 Feb 9, 2017\r
41  */\r
42 public class LimitsRoaTest {\r
43 \r
44     private LimitsRoa roa;\r
45 \r
46     private LimitsBusiness limitsBusiness;\r
47 \r
48     @Before\r
49     public void setUp() {\r
50         roa = new LimitsRoa();\r
51         limitsBusiness = new LimitsBusinessImpl();\r
52         roa.setLimitsBusiness(limitsBusiness);\r
53     }\r
54 \r
55     @Test\r
56     public void testGetLimitsResource() throws ServiceException {\r
57         new MockUp<LimitsBusinessImpl>() {\r
58 \r
59             @Mock\r
60             public JSONObject getLimits(String vimId) throws ServiceException {\r
61                 return new JSONObject();\r
62             }\r
63         };\r
64         HttpServletRequest context = new MockHttpServletRequest();\r
65         JSONObject result = roa.getLimits(context, "vimId");\r
66         assertNotNull(result);\r
67     }\r
68 }\r