diff options
author | Gao Weitao <victor.gao@huawei.com> | 2018-02-11 07:08:37 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-02-11 07:08:37 +0000 |
commit | 32b59c9dd5fda925ed23cdaa2f0eeefb6c6952c8 (patch) | |
tree | 47bb32254c150a720911f12312ed81ada1b0e1ab | |
parent | f21bb5f000ac8afb398234495afd331da56741a0 (diff) | |
parent | 86e1ac9541a1dd6bfe6d1e3c7a4b9b679a26b904 (diff) |
Merge "Add UT case for grant resource"
-rw-r--r-- | ResmanagementService/service/src/test/java/org/onap/vfc/nfvo/resmanagement/service/group/impl/GrantResServiceImplTest.java | 90 |
1 files changed, 90 insertions, 0 deletions
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 index 6595787..15906b1 100644 --- 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 @@ -51,6 +51,95 @@ public class GrantResServiceImplTest { }
/**
+ * <br>
+ * {
+ * "vnfInstanceId": 1,
+ * "addResource": [],
+ * "vimId": "1111",
+ * "removeResource": [],
+ * "additionalParam": {
+ * }
+ * }
+ *
+ * @throws ServiceException
+ * @since VFC 1.0
+ */
+ @Test
+ public void testGrantResourceReal() throws ServiceException {
+ GrantResServiceImpl impl = new GrantResServiceImpl();
+ JSONObject obj = new JSONObject();
+ JSONObject vimObj = getVimObj();
+ obj.put("additionalParam", vimObj);
+ obj.put("vimId", "vimId");
+ JSONArray addResource = new JSONArray();
+ addResource.add(getAddResObj());
+ obj.put("addResource", addResource);
+ new MockUp<VimUtil>() {
+
+ @Mock
+ public JSONObject getVimById(String vimId) {
+ return getVimObj();
+ }
+ };
+ new MockUp<LimitsBusinessImpl>() {
+
+ @Mock
+ public JSONObject getLimits(String vimId) throws ServiceException {
+ JSONObject result = new JSONObject();
+ result.put("vimId", "vimId");
+ result.put("vimName", "vimName");
+ result.put("totalCPU", "10");
+ result.put("totalMemory", "10");
+ result.put("totalDisk", "10");
+ result.put("usedCPU", "1");
+ result.put("usedMemory", "1");
+ result.put("usedDisk", "1");
+ return result;
+ }
+ };
+
+ JSONObject result = impl.grantResourceReal(obj);
+ assertNotNull(result);
+ }
+
+ /**
+ * {
+ * "vimId": "57674786-5b2e-4c92-bb68-578dbd79e2f5",
+ * "name": "vim",
+ * "url": "http://10.74.151.13:5000/v2.0",
+ * "userName": "admin",
+ * "password": "admin",
+ * "tenant": "admin",
+ * "vendor": "HW",
+ * "version": "v1.0",
+ * "description": "",
+ * "domain": "",
+ * "type": "openstack",
+ * "createTime": "2016-07-18 12:22:53"
+ * }
+ * <br>
+ *
+ * @return
+ * @since VFC 1.0
+ */
+ private JSONObject getVimObj() {
+ JSONObject vimObj = new JSONObject();
+ vimObj.put("vimId", "57674786-5b2e-4c92-bb68-578dbd79e2f5");
+ vimObj.put("name", "vim");
+ vimObj.put("url", "http://10.74.151.13:5000/v2.0");
+ vimObj.put("userName", "admin");
+ vimObj.put("password", "admin");
+ vimObj.put("tenant", "admin");
+ vimObj.put("vendor", "HW");
+ vimObj.put("version", "v1.0");
+ vimObj.put("description", "");
+ vimObj.put("domain", "");
+ vimObj.put("type", "openstack");
+ vimObj.put("createTime", "");
+ return vimObj;
+ }
+
+ /**
* {
* "resourceDefinitionId": "11111",
* "resourceTemplate": {
@@ -96,4 +185,5 @@ public class GrantResServiceImplTest { return addResObj;
}
+
}
|