diff options
author | Jim Hahn <jrh3@att.com> | 2019-06-24 15:46:36 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2019-06-26 08:55:15 -0400 |
commit | 67fcc6f6abb7904ecd4b4444fa23b355cf9fd4ae (patch) | |
tree | f5c63d96a4d337e8210f4d83c3dd14caf8e1c051 /policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java | |
parent | d1ab0ec8471deeb7739206dc2ef0aac3dc5b245f (diff) |
Fix some sonar issues in policy-endpoints
Refactored various classes to reduce cyclomatic complexity.
Introduced some endpoint utility classes to facilitate extraction
and conversion of property values, and populating of common
"builder" values.
Change-Id: Ie1c91cd94cb54700dc9127f72780b4d94b82ec39
Issue-ID: POLICY-1791
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java')
-rw-r--r-- | policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java index 41ad2122..c6ff2f32 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java @@ -20,6 +20,7 @@ package org.onap.policy.common.endpoints.http.server.test; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -75,7 +76,7 @@ public class HttpServerTest { */ @Before public void setUp() { - port += 10; + incrementPort(); portUrl = LOCALHOST_PREFIX + port; HttpServletServer.factory.destroy(); @@ -84,6 +85,10 @@ public class HttpServerTest { MyGsonProvider.resetSome(); } + private static void incrementPort() { + port += 10; + } + @AfterClass public static void tearDownAfterClass() { HttpServletServer.factory.destroy(); @@ -264,13 +269,7 @@ public class HttpServerTest { String response = http(portUrl + JUNIT_ECHO_HELLO); assertEquals(HELLO, response); - response = null; - try { - response = http(portUrl + SWAGGER_JSON); - } catch (IOException e) { - // Expected - } - assertTrue(response == null); + assertThatThrownBy(() -> http(portUrl + SWAGGER_JSON)).isInstanceOf(IOException.class); response = http(portUrl + "/junit/echo/hello?block=true"); assertEquals("FILTERED", response); @@ -311,13 +310,7 @@ public class HttpServerTest { response = http(LOCALHOST_PREFIX + port2 + JUNIT_ECHO_HELLO); assertTrue(HELLO.equals(response)); - response = null; - try { - response = http(LOCALHOST_PREFIX + port2 + SWAGGER_JSON); - } catch (IOException e) { - // Expected - } - assertTrue(response == null); + assertThatThrownBy(() -> http(LOCALHOST_PREFIX + port2 + SWAGGER_JSON)).isInstanceOf(IOException.class); HttpServletServer.factory.destroy(); assertTrue(HttpServletServer.factory.inventory().isEmpty()); |