From fad6fa4890538fe8f4cbb96ae3fb0be6767d28d1 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Thu, 27 Jun 2019 14:58:28 +0000 Subject: Fix Sonar/Checkstyle issues in apex-pdp BBS Java code introduced Sonar issues, these are resolved. Also fixed checkstyle errors in other classes. Also fiexed "unexpected type" eclipse errors. Issue-ID: POLICY-1791 Change-Id: I3931051f0944c6d53745c8dd1db7cca4ee118f1c Signed-off-by: liamfallon --- .../onap/policy/apex/examples/bbs/WebClientTest.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'examples/examples-onap-bbs/src/test') diff --git a/examples/examples-onap-bbs/src/test/java/org/onap/policy/apex/examples/bbs/WebClientTest.java b/examples/examples-onap-bbs/src/test/java/org/onap/policy/apex/examples/bbs/WebClientTest.java index 8012c1e30..2ff9435b2 100644 --- a/examples/examples-onap-bbs/src/test/java/org/onap/policy/apex/examples/bbs/WebClientTest.java +++ b/examples/examples-onap-bbs/src/test/java/org/onap/policy/apex/examples/bbs/WebClientTest.java @@ -21,6 +21,7 @@ package org.onap.policy.apex.examples.bbs; +import static org.junit.Assert.assertNotNull; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -35,13 +36,15 @@ import org.mockito.Mockito; public class WebClientTest { HttpsURLConnection mockedHttpsUrlConnection; String sampleString = "Response Code :200"; + /** * Set up the mocked REST manager. - * @throws IOException + * + * @throws IOException on I/O errors */ @Before public void setupMockedRest() throws IOException { - mockedHttpsUrlConnection = mock(HttpsURLConnection.class); + mockedHttpsUrlConnection = mock(HttpsURLConnection.class); InputStream inputStream = new ByteArrayInputStream(sampleString.getBytes()); when(mockedHttpsUrlConnection.getInputStream()).thenReturn(inputStream); Mockito.doNothing().when(mockedHttpsUrlConnection).connect(); @@ -50,17 +53,17 @@ public class WebClientTest { @Test public void httpsRequest() { WebClient cl = new WebClient(); - String result = cl.httpsRequest("https://some.random.url/data", "POST", null, - "admin", "admin", "application/json",true, true); - + String result = cl.httpRequest("https://some.random.url/data", "POST", null, "admin", "admin", + "application/json", true); + assertNotNull(result); } @Test public void httpRequest() { WebClient cl = new WebClient(); - String result = cl.httpRequest("http://some.random.url/data", "GET", null, - "admin", "admin", "application/json",true, true); - + String result = + cl.httpRequest("http://some.random.url/data", "GET", null, "admin", "admin", "application/json", false); + assertNotNull(result); } @Test -- cgit 1.2.3-korg