Add test case for resmgr 03/31003/2
authorluxin <luxin7@huawei.com>
Fri, 9 Feb 2018 07:38:49 +0000 (15:38 +0800)
committerluxin <luxin7@huawei.com>
Fri, 9 Feb 2018 07:46:19 +0000 (15:46 +0800)
Change-Id: I2818886baaa5d9b6a0be6324b8f991dc12700e0c
Issue-ID: VFC-747
Signed-off-by: luxin <luxin7@huawei.com>
ResmanagementService/service/src/test/java/org/onap/vfc/nfvo/resmanagement/service/group/impl/GrantResServiceImplTest.java [new file with mode: 0644]

diff --git a/ResmanagementService/service/src/test/java/org/onap/vfc/nfvo/resmanagement/service/group/impl/GrantResServiceImplTest.java b/ResmanagementService/service/src/test/java/org/onap/vfc/nfvo/resmanagement/service/group/impl/GrantResServiceImplTest.java
new file mode 100644 (file)
index 0000000..16690f0
--- /dev/null
@@ -0,0 +1,51 @@
+/*\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