--- /dev/null
+/*\r
+ * Copyright 2018 Huawei Technologies Co., Ltd.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.vfc.nfvo.resmanagement.service.group.impl;\r
+\r
+import static org.junit.Assert.assertNotNull;\r
+\r
+import org.junit.Test;\r
+import org.onap.vfc.nfvo.resmanagement.common.VimUtil;\r
+import org.onap.vfc.nfvo.resmanagement.common.util.restclient.ServiceException;\r
+\r
+import mockit.Mock;\r
+import mockit.MockUp;\r
+import net.sf.json.JSONObject;\r
+\r
+public class GrantResServiceImplTest {\r
+\r
+ @Test\r
+ public void testGrantResource() throws ServiceException {\r
+ GrantResServiceImpl impl = new GrantResServiceImpl();\r
+ JSONObject obj = new JSONObject();\r
+ JSONObject vimObj = new JSONObject();\r
+ vimObj.put("vimId", "vimId");\r
+ obj.put("additionalParam", vimObj);\r
+ new MockUp<VimUtil>() {\r
+\r
+ @Mock\r
+ public JSONObject getVimById(String vimId) {\r
+ JSONObject vim = new JSONObject();\r
+ vim.put("tenant", "huawei");\r
+ return vim;\r
+ }\r
+ };\r
+ JSONObject result = impl.grantResource(obj);\r
+ assertNotNull(result);\r
+ }\r
+\r
+}\r