+ String res = roa.getVnf(vnfmId, resp, "vnfInstanceId", context);
+ assertNotNull(res);
+ }
+
+ @Test
+ public void getVnfSuccess() throws ServiceException {
+ new MockUp<StringUtil>() {
+
+ @Mock
+ public <T> T getJsonFromContexts(HttpServletRequest vnfReq) {
+ return null;
+ }
+ };
+ new MockUp<VnfMgr>() {
+
+ @Mock
+ public JSONObject getVnf(String vnfId, String vnfmId) {
+ JSONObject result = new JSONObject();
+ result.put("retCode", 1);
+ JSONObject data = new JSONObject();
+ data.put("result", "success");
+ result.put("data", data);
+ return result;
+ }
+ };
+ HttpServletRequest context = null;
+ HttpServletResponse resp = new MockHttpServletResponse();
+ String vnfmId = "1234";
+ String res = roa.getVnf(vnfmId, resp, "vnfInstanceId", context);
+ assertNotNull(res);
+ }
+
+ @Test
+ public void getVnfFail() throws ServiceException {
+ new MockUp<StringUtil>() {
+
+ @Mock
+ public <T> T getJsonFromContexts(HttpServletRequest vnfReq) {
+ return null;
+ }
+ };
+ new MockUp<VnfMgr>() {
+
+ @Mock
+ public JSONObject getVnf(String vnfId, String vnfmId) {
+ JSONObject result = new JSONObject();
+ result.put("retCode", -1);
+ return result;
+ }
+ };
+ HttpServletRequest context = null;
+ HttpServletResponse resp = new MockHttpServletResponse();
+ String vnfmId = "1234";
+ String res = roa.getVnf(vnfmId, resp, "vnfInstanceId", context);