diff options
author | kurczews <krzysztof.kurczewski@nokia.com> | 2017-12-12 15:47:55 +0100 |
---|---|---|
committer | kurczews <krzysztof.kurczewski@nokia.com> | 2017-12-13 08:42:33 +0100 |
commit | d52d6366effdbbcb243c06c031fe9f324f16c4a9 (patch) | |
tree | 93917b4e3b9d409ea358deff6dfd21045a5ce12f /status-control/src/test/java | |
parent | 32c33b3a3ee9a76bf2a78662ee36e05ce53a8854 (diff) |
Reduce complexity of HealthCheckUtils
* Split bulk conditionals
* Split health checks to separate methods
* Fix minor issues
Issue-ID: SO-353
Change-Id: Ib6298bc488a94aa4fbb253e3894532708547533d
Signed-off-by: kurczews <krzysztof.kurczewski@nokia.com>
Diffstat (limited to 'status-control/src/test/java')
-rw-r--r-- | status-control/src/test/java/org/openecomp/mso/HealthCheckUtilsTest.java | 39 |
1 files changed, 4 insertions, 35 deletions
diff --git a/status-control/src/test/java/org/openecomp/mso/HealthCheckUtilsTest.java b/status-control/src/test/java/org/openecomp/mso/HealthCheckUtilsTest.java index cdb5695f2c..91016d2475 100644 --- a/status-control/src/test/java/org/openecomp/mso/HealthCheckUtilsTest.java +++ b/status-control/src/test/java/org/openecomp/mso/HealthCheckUtilsTest.java @@ -21,22 +21,16 @@ package org.openecomp.mso; -import org.openecomp.mso.logger.MsoLogger; -import org.openecomp.mso.properties.MsoJavaProperties; -import org.openecomp.mso.requestsdb.RequestsDatabase; import org.apache.http.HttpStatus; import org.apache.http.HttpVersion; import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.message.BasicStatusLine; import org.junit.BeforeClass; import org.junit.Test; import org.mockito.Mockito; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; +import org.openecomp.mso.properties.MsoJavaProperties; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -63,7 +57,7 @@ public class HealthCheckUtilsTest { private static CloseableHttpResponse nokRes, okRes; @BeforeClass - public static final void prepareMockvalues() { + public static void prepareMockvalues() { utils = Mockito.mock(HealthCheckUtils.class); client = Mockito.mock(CloseableHttpClient.class); nokRes = Mockito.mock(CloseableHttpResponse.class); @@ -207,11 +201,11 @@ public class HealthCheckUtilsTest { try { Mockito.when (client.execute (any(HttpUriRequest.class))).thenReturn (okRes); - Boolean res1 = (Boolean)invokeProtectedMethod(tempUtil, "verifyLocalHealth", ip1, port, apihUrl1, sslEnable, null); + boolean res1 = tempUtil.verifyLocalHealth(ip1, port, apihUrl1, sslEnable, null); assertTrue(res1); Mockito.when (client.execute (any(HttpUriRequest.class))).thenReturn (nokRes); - Boolean res2 = (Boolean)invokeProtectedMethod(tempUtil, "verifyLocalHealth", ip1, port, apihUrl1, sslEnable, null); + boolean res2 = tempUtil.verifyLocalHealth(ip1, port, apihUrl1, sslEnable, null); assertFalse(res2); } catch (Exception e) { @@ -270,29 +264,4 @@ public class HealthCheckUtilsTest { Mockito.when(utils.loadTopologyProperties()).thenReturn(properties); } - // User reflection to invoke to avoid change the publicity of the method - private static Object invokeProtectedMethod (HealthCheckUtils tempUtil, String methodName, String arg1, String arg2, String arg3, String arg4, String arg5) { - Method method; - try { - method = HealthCheckUtils.class.getDeclaredMethod(methodName, String.class, String.class, String.class, String.class, String.class); - method.setAccessible(true); - return method.invoke(tempUtil, arg1, arg2, arg3, arg4, arg5); - } catch (NoSuchMethodException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (SecurityException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IllegalAccessException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IllegalArgumentException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (InvocationTargetException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return null; - } }
\ No newline at end of file |