summaryrefslogtreecommitdiffstats
path: root/ResmanagementService
diff options
context:
space:
mode:
Diffstat (limited to 'ResmanagementService')
-rw-r--r--ResmanagementService/service/src/test/java/org/onap/vfc/nfvo/resmanagement/service/group/impl/GrantResServiceImplTest.java90
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;
}
+
}