diff options
author | 2018-02-09 15:05:00 +0800 | |
---|---|---|
committer | 2018-02-09 15:05:00 +0800 | |
commit | a2a8f5e656808766dd7afc0bcffe907c3056565d (patch) | |
tree | c8c6ab0bebf01805be2b7b9f9b916525d720ff0e /ResmanagementService | |
parent | a5daca3fc85954fd3393e6d51dd0b303fe5c022b (diff) |
Remove unused UT for resmgr
Change-Id: I9b8fa5a83d49972795d30ecc47cc861da7a75001
Issue-ID: VFC-747
Signed-off-by: luxin <luxin7@huawei.com>
Diffstat (limited to 'ResmanagementService')
2 files changed, 28 insertions, 97 deletions
diff --git a/ResmanagementService/service/src/test/java/org/onap/vfc/nfvo/resmanagement/common/util/RestfulUtilTest.java b/ResmanagementService/service/src/test/java/org/onap/vfc/nfvo/resmanagement/common/util/RestfulUtilTest.java index 531b8e5..e75a823 100644 --- a/ResmanagementService/service/src/test/java/org/onap/vfc/nfvo/resmanagement/common/util/RestfulUtilTest.java +++ b/ResmanagementService/service/src/test/java/org/onap/vfc/nfvo/resmanagement/common/util/RestfulUtilTest.java @@ -19,16 +19,11 @@ package org.onap.vfc.nfvo.resmanagement.common.util; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import java.util.HashMap; -import java.util.Map; - import org.junit.Test; -import org.onap.vfc.nfvo.resmanagement.common.constant.Constant; -import org.onap.vfc.nfvo.resmanagement.common.util.RestfulUtil; -import org.onap.vfc.nfvo.resmanagement.common.util.restclient.ServiceException; import org.onap.vfc.nfvo.resmanagement.common.util.restclient.RestfulOptions; import org.onap.vfc.nfvo.resmanagement.common.util.restclient.RestfulParametes; import org.onap.vfc.nfvo.resmanagement.common.util.restclient.RestfulResponse; +import org.onap.vfc.nfvo.resmanagement.common.util.restclient.ServiceException; import mockit.Mock; import mockit.MockUp; @@ -40,13 +35,13 @@ public class RestfulUtilTest { @Test public void testGetResponseObjWithTwoParams() { + mockGetResponseContent(); JSONObject result = RestfulUtil.getResponseObj(null, null); - JSONObject expectedResult = null; + JSONObject expectedResult = new JSONObject().fromObject("{\"ResponseContent\":\"123\"}"); assertEquals(expectedResult, result); } - @Test - public void testGetResponseObjWithThreeParams() { + private void mockGetResponseContent() { new MockUp<RestfulUtil>() { @Mock @@ -55,103 +50,53 @@ public class RestfulUtilTest { return "{\"ResponseContent\":\"123\"}"; } }; - JSONObject result = RestfulUtil.getResponseObj(null, null, null); - @SuppressWarnings("static-access") - JSONObject expectedResult = new JSONObject().fromObject("{\"ResponseContent\":\"123\"}"); - assertEquals(expectedResult, result); } - @Test - public void testGetResponseObjExpections() { + private void mockGetResponseContentReturnNull() { new MockUp<RestfulUtil>() { @Mock public String getResponseContent(String url, RestfulParametes restParametes, RestfulOptions opt, String type) { - throw new JSONException(); + return null; } }; - JSONObject result = RestfulUtil.getResponseObj(null, null, null); - JSONObject expectedResult = null; - assertEquals(expectedResult, result); - } - - @Test - public void testGetResponseContent() { - String result = RestfulUtil.getResponseContent(null, null, null); - String expectedResult = null; - assertEquals(expectedResult, result); } @Test - public void testGetResponseMap() { - Map<String, Object> result = RestfulUtil.getResponseMap(null, null, null, null); - Map<String, Object> expectedResult = new HashMap<String, Object>(10); - expectedResult.put(Constant.RESPONSE_CONTENT, null); - expectedResult.put(Constant.STATUS_CODE, -1); - assertEquals(expectedResult, result); - } + public void testGetResponseObjWithThreeParams() { + new MockUp<RestfulUtil>() { - @Test - public void testGetResponseContentMap() { - Map<String, Object> result = RestfulUtil.getResponseContentMap(null, null); - Map<String, Object> expectedResult = new HashMap<String, Object>(10); - expectedResult.put(Constant.RESPONSE_CONTENT, null); - expectedResult.put(Constant.STATUS_CODE, -1); + @Mock + public String getResponseContent(String url, RestfulParametes restParametes, RestfulOptions opt, + String type) { + return "{\"ResponseContent\":\"123\"}"; + } + }; + JSONObject result = RestfulUtil.getResponseObj(null, null, null); + @SuppressWarnings("static-access") + JSONObject expectedResult = new JSONObject().fromObject("{\"ResponseContent\":\"123\"}"); assertEquals(expectedResult, result); } @Test - public void testGetResponseContentWithFourParams() { - new MockUp<RestfulResponse>() { + public void testGetResponseObjExpections() { + new MockUp<RestfulUtil>() { @Mock - public int getStatus() { - return 200; + public String getResponseContent(String url, RestfulParametes restParametes, RestfulOptions opt, + String type) { + throw new JSONException(); } }; - String result = RestfulUtil.getResponseContent(null, null, null); - String expectedResult = null; + JSONObject result = RestfulUtil.getResponseObj(null, null, null); + JSONObject expectedResult = null; assertEquals(expectedResult, result); } @Test - public void testGetRestfulResponse() { - RestfulResponse result = RestfulUtil.getRestfulResponse(null, null, null); - RestfulResponse expectedResult = new RestfulResponse(); - assertEquals(expectedResult.getStatus(), result.getStatus()); - } - - @Test - public void testRestfulResponse() { - RestfulResponse result = RestfulUtil.getRestfulResponse(null, null, "get"); - RestfulResponse expectedResult = new RestfulResponse(); - assertEquals(expectedResult.getStatus(), result.getStatus()); - } - - @Test - public void testRestfulResponse1() { - RestfulResponse result = RestfulUtil.getRestfulResponse(null, null, "add"); - RestfulResponse expectedResult = new RestfulResponse(); - assertEquals(expectedResult.getStatus(), result.getStatus()); - } - - @Test - public void testRestfulResponse2() { - RestfulResponse result = RestfulUtil.getRestfulResponse(null, null, "put"); - RestfulResponse expectedResult = new RestfulResponse(); - assertEquals(expectedResult.getStatus(), result.getStatus()); - } - - @Test - public void testRestfulResponse3() { - RestfulResponse result = RestfulUtil.getRestfulResponse(null, null, "delete"); - RestfulResponse expectedResult = new RestfulResponse(); - assertEquals(expectedResult.getStatus(), result.getStatus()); - } - - @Test public void testGetRestResObjectsIsNull() { + mockGetResponseContentReturnNull(); RestfulResponse result = RestfulUtil.getRestRes(null, null); RestfulResponse expectedResult = null; assertEquals(expectedResult, result); @@ -172,15 +117,6 @@ public class RestfulUtilTest { } @Test - public void testGetResponseResResultIsNull() throws ServiceException { - try { - RestfulUtil.getResponseRes(null, null); - } catch (ServiceException e) { - assertTrue(true); - } - } - - @Test public void testGetResponse() throws ServiceException { new MockUp<RestfulUtil>() { @@ -205,7 +141,7 @@ public class RestfulUtilTest { }; try { RestfulUtil.getResponseRes(null, null); - } catch (ServiceException e) { + } catch(ServiceException e) { assertTrue(true); } } @@ -221,7 +157,7 @@ public class RestfulUtilTest { }; try { RestfulUtil.getResponseRes(null, null, null); - } catch (ServiceException e) { + } catch(ServiceException e) { assertTrue(true); } } @@ -237,7 +173,7 @@ public class RestfulUtilTest { }; try { RestfulUtil.getResponseRes(null, null, null); - } catch (ServiceException e) { + } catch(ServiceException e) { assertTrue(true); } } diff --git a/ResmanagementService/service/src/test/java/org/onap/vfc/nfvo/resmanagement/common/util/restclient/TestRestHttpContentExchange.java b/ResmanagementService/service/src/test/java/org/onap/vfc/nfvo/resmanagement/common/util/restclient/TestRestHttpContentExchange.java index d89876a..ef0769b 100644 --- a/ResmanagementService/service/src/test/java/org/onap/vfc/nfvo/resmanagement/common/util/restclient/TestRestHttpContentExchange.java +++ b/ResmanagementService/service/src/test/java/org/onap/vfc/nfvo/resmanagement/common/util/restclient/TestRestHttpContentExchange.java @@ -283,9 +283,6 @@ public class TestRestHttpContentExchange { }; final String actual = exchange.decompressGzipToStr(binaryData); - - System.out.println("actual: '" + actual + "'"); - System.out.println("expected: '" + expected + "'"); assertEquals(actual, expected); } @@ -304,8 +301,6 @@ public class TestRestHttpContentExchange { final String expected = ""; final String actual = exchange.decompressGzipToStr(null); - System.out.println("actual: '" + actual + "'"); - System.out.println("expected: '" + expected + "'"); assertEquals(actual, expected); } |