diff options
author | luxin <luxin7@huawei.com> | 2018-02-11 14:50:11 +0800 |
---|---|---|
committer | luxin <luxin7@huawei.com> | 2018-02-11 14:50:11 +0800 |
commit | 86e1ac9541a1dd6bfe6d1e3c7a4b9b679a26b904 (patch) | |
tree | 63950683939a23211f1354ec59c6847f77c4b505 /ResmanagementService/service/src | |
parent | 37dfb03f3f8557214867d44f4edfabd282cea429 (diff) |
Add UT case for grant resource
Change-Id: I4989145288ecd3b971d64f5565308aabbb485ba0
Issue-ID: VFC-747
Signed-off-by: luxin <luxin7@huawei.com>
Diffstat (limited to 'ResmanagementService/service/src')
-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;
}
+
}
|