Junit coverage increased
[vfc/nfvo/driver/vnfm/svnfm.git] / huawei / vnfmadapter / VnfmadapterService / service / src / test / java / org / onap / vfc / nfvo / vnfm / svnfm / vnfmadapter / common / servicetoken / VnfmRestfulUtilTest.java
index fec9844..60b5f63 100644 (file)
@@ -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"));
+
+
+
+    }
 }