diff options
Diffstat (limited to 'huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/servicetoken/VnfmRestfulUtilTest.java')
-rw-r--r-- | huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/servicetoken/VnfmRestfulUtilTest.java | 79 |
1 files changed, 46 insertions, 33 deletions
diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/servicetoken/VnfmRestfulUtilTest.java b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/servicetoken/VnfmRestfulUtilTest.java index fec98449..60b5f639 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/servicetoken/VnfmRestfulUtilTest.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/servicetoken/VnfmRestfulUtilTest.java @@ -53,51 +53,51 @@ public class VnfmRestfulUtilTest { @Test public void testSendReqToApp() { - new MockUp<VnfmRestfulUtil>() { - - @Mock - public RestfulResponse getRestResByDefault(String path, String methodNames, JSONObject bodyParam) { - RestfulResponse restfulResponse = new RestfulResponse(); - restfulResponse.setStatus(Constant.HTTP_OK); - String responseString = "{\"retCode\":1,\"data\":\"success\"}"; - restfulResponse.setResponseJson(responseString); - return restfulResponse; - } - }; +// new MockUp<VnfmRestfulUtil>() { +// +// @Mock +// public RestfulResponse getRestResByDefault(String path, String methodNames, JSONObject bodyParam) { +// RestfulResponse restfulResponse = new RestfulResponse(); +// restfulResponse.setStatus(Constant.HTTP_OK); +// String responseString = "{\"retCode\":1,\"data\":\"success\"}"; +// restfulResponse.setResponseJson(responseString); +// return restfulResponse; +// } +// }; JSONObject result = VnfmRestfulUtil.sendReqToApp("path", "put", new JSONObject()); assertEquals(Constant.REST_SUCCESS, result.get("retCode")); } @Test public void testSendReqToAppByErrorMsg() { - new MockUp<VnfmRestfulUtil>() { - - @Mock - public RestfulResponse getRestResByDefault(String path, String methodNames, JSONObject bodyParam) { - RestfulResponse restfulResponse = new RestfulResponse(); - restfulResponse.setStatus(Constant.HTTP_OK); - String responseString = "{\"retCode\":-1,\"data\":\"fail\",\"msg\":\"fail\"}"; - restfulResponse.setResponseJson(responseString); - return restfulResponse; - } - }; +// new MockUp<VnfmRestfulUtil>() { +// +// @Mock +// public RestfulResponse getRestResByDefault(String path, String methodNames, JSONObject bodyParam) { +// RestfulResponse restfulResponse = new RestfulResponse(); +// restfulResponse.setStatus(Constant.HTTP_OK); +// String responseString = "{\"retCode\":-1,\"data\":\"fail\",\"msg\":\"fail\"}"; +// restfulResponse.setResponseJson(responseString); +// return restfulResponse; +// } +// }; JSONObject result = VnfmRestfulUtil.sendReqToApp("path", "put", new JSONObject()); assertEquals(Constant.REST_FAIL, result.get("retCode")); } @Test public void testSendReqToAppByError() { - new MockUp<VnfmRestfulUtil>() { - - @Mock - public RestfulResponse getRestResByDefault(String path, String methodNames, JSONObject bodyParam) { - RestfulResponse restfulResponse = new RestfulResponse(); - restfulResponse.setStatus(Constant.HTTP_OK); - String responseString = "{\"retCode\":-1,\"data\":\"fail\"}"; - restfulResponse.setResponseJson(responseString); - return restfulResponse; - } - }; +// new MockUp<VnfmRestfulUtil>() { +// +// @Mock +// public RestfulResponse getRestResByDefault(String path, String methodNames, JSONObject bodyParam) { +// RestfulResponse restfulResponse = new RestfulResponse(); +// restfulResponse.setStatus(Constant.HTTP_OK); +// String responseString = "{\"retCode\":-1,\"data\":\"fail\"}"; +// restfulResponse.setResponseJson(responseString); +// return restfulResponse; +// } +// }; JSONObject result = VnfmRestfulUtil.sendReqToApp("path", "put", new JSONObject()); assertEquals(Constant.REST_FAIL, result.get("retCode")); } @@ -238,4 +238,17 @@ public class VnfmRestfulUtilTest { RestfulResponse resp = VnfmRestfulUtil.getRemoteResponse("/test/123", "", "test123"); assertNull(resp); } + + @Test + public void getRemoteResponse() { + Map <String, String > headerMap = new HashMap<String, String>(); + + VnfmRestfulUtil.getRemoteResponse( "url", "get", headerMap,"params"); + VnfmRestfulUtil.getRemoteResponse( "url", "post", headerMap,"params"); + VnfmRestfulUtil.getRemoteResponse( "url", "put", headerMap,"params"); + assertNull(VnfmRestfulUtil.getRemoteResponse( "url", "delete", headerMap,"params")); + + + + } } |