diff options
author | liamfallon <liam.fallon@est.tech> | 2018-12-19 19:11:01 +0000 |
---|---|---|
committer | liamfallon <liam.fallon@est.tech> | 2018-12-20 13:28:37 +0000 |
commit | 9013b63b082dcc3c7e6a10b52976bcc46ca3f019 (patch) | |
tree | f7e7ae7f4c05b5f7221f43b4f5e862d9fb36f5c4 /main/src/test/java | |
parent | 5654548387d1ba2c3776d1a01276103481ac41cd (diff) |
Fix checkstyle issues in distribution
Some fixes for minor checkstyle issues.
Issue-ID: POLICY-1221
Change-Id: I86577f47283a6fa97be25d7550ed9c2d7ec026a9
Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'main/src/test/java')
2 files changed, 38 insertions, 50 deletions
diff --git a/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsDistributionRestServer.java b/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsDistributionRestServer.java index 604bdd9a..f093b2ac 100644 --- a/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsDistributionRestServer.java +++ b/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsDistributionRestServer.java @@ -21,7 +21,6 @@ package org.onap.policy.distribution.main.rest; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import java.security.KeyManagementException; import java.security.NoSuchAlgorithmException; @@ -45,8 +44,6 @@ import org.onap.policy.common.endpoints.report.HealthCheckReport; import org.onap.policy.common.logging.flexlogger.FlexLogger; import org.onap.policy.common.logging.flexlogger.Logger; import org.onap.policy.distribution.main.PolicyDistributionException; -import org.onap.policy.distribution.main.parameters.CommonTestData; -import org.onap.policy.distribution.main.parameters.RestServerParameters; import org.onap.policy.distribution.main.startstop.Main; /** @@ -57,15 +54,14 @@ import org.onap.policy.distribution.main.startstop.Main; public class TestHttpsDistributionRestServer { private static final Logger LOGGER = FlexLogger.getLogger(TestDistributionRestServer.class); - private static final String NOT_ALIVE = "not alive"; private static final String ALIVE = "alive"; private static final String SELF = "self"; private static final String NAME = "Policy SSD"; private static String KEYSTORE = System.getProperty("user.dir") + "/src/test/resources/ssl/policy-keystore"; @Test - public void testHealthCheckSuccess() throws PolicyDistributionException, InterruptedException, - KeyManagementException, NoSuchAlgorithmException { + public void testHealthCheckSuccess() + throws PolicyDistributionException, InterruptedException, KeyManagementException, NoSuchAlgorithmException { final String reportString = "Report [name=Policy SSD, url=self, healthy=true, code=200, message=alive]"; final Main main = startDistributionService(); final HealthCheckReport report = performHealthCheck(); @@ -87,32 +83,30 @@ public class TestHttpsDistributionRestServer { main.shutdown(); } - private HealthCheckReport performHealthCheck() throws InterruptedException, KeyManagementException, - NoSuchAlgorithmException { + private HealthCheckReport performHealthCheck() + throws InterruptedException, KeyManagementException, NoSuchAlgorithmException { HealthCheckReport response = null; - TrustManager[] noopTrustManager = new TrustManager[]{ - new X509TrustManager() { + TrustManager[] noopTrustManager = new TrustManager[] { new X509TrustManager() { - @Override - public X509Certificate[] getAcceptedIssuers() { - return new X509Certificate[0]; - } + @Override + public X509Certificate[] getAcceptedIssuers() { + return new X509Certificate[0]; + } - @Override - public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) { - } + @Override + public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) { + } - @Override - public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) { - } + @Override + public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) { } - }; + } }; SSLContext sc = SSLContext.getInstance("TLSv1.2"); sc.init(null, noopTrustManager, new SecureRandom()); - final ClientBuilder clientBuilder = - ClientBuilder.newBuilder().sslContext(sc).hostnameVerifier((host, session) -> true); + final ClientBuilder clientBuilder = ClientBuilder.newBuilder().sslContext(sc) + .hostnameVerifier((host, session) -> true); final Client client = clientBuilder.build(); final HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic("healthcheck", "zb!XztG34"); client.register(feature); @@ -132,7 +126,7 @@ public class TestHttpsDistributionRestServer { } private void validateReport(final String name, final String url, final boolean healthy, final int code, - final String message, final String reportString, final HealthCheckReport report) { + final String message, final String reportString, final HealthCheckReport report) { assertEquals(name, report.getName()); assertEquals(url, report.getUrl()); assertEquals(healthy, report.isHealthy()); diff --git a/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsStatisticDistributionRestServer.java b/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsStatisticDistributionRestServer.java index f1beb0af..4d5aa7a8 100644 --- a/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsStatisticDistributionRestServer.java +++ b/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsStatisticDistributionRestServer.java @@ -21,7 +21,6 @@ package org.onap.policy.distribution.main.rest; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import java.security.KeyManagementException; import java.security.NoSuchAlgorithmException; @@ -44,8 +43,6 @@ import org.junit.Test; import org.onap.policy.common.logging.flexlogger.FlexLogger; import org.onap.policy.common.logging.flexlogger.Logger; import org.onap.policy.distribution.main.PolicyDistributionException; -import org.onap.policy.distribution.main.parameters.CommonTestData; -import org.onap.policy.distribution.main.parameters.RestServerParameters; import org.onap.policy.distribution.main.startstop.Main; /** @@ -59,11 +56,10 @@ public class TestHttpsStatisticDistributionRestServer { private static String KEYSTORE = System.getProperty("user.dir") + "/src/test/resources/ssl/policy-keystore"; @Test - public void testHealthCheckSuccess() throws PolicyDistributionException, InterruptedException, - KeyManagementException, NoSuchAlgorithmException { + public void testHealthCheckSuccess() + throws PolicyDistributionException, InterruptedException, KeyManagementException, NoSuchAlgorithmException { final String reportString = "StatisticsReport [code=200, totalDistributionCount=0, distributionSuccessCount=0, " - + "distributionFailureCount=0, totalDownloadCount=0, " - + "downloadSuccessCount=0, downloadFailureCount=0]"; + + "distributionFailureCount=0, totalDownloadCount=0, " + "downloadSuccessCount=0, downloadFailureCount=0]"; final Main main = startDistributionService(); final StatisticsReport report = performStatisticCheck(); validateReport(200, 0, 0, 0, 0, 0, 0, reportString, report); @@ -84,32 +80,30 @@ public class TestHttpsStatisticDistributionRestServer { main.shutdown(); } - private StatisticsReport performStatisticCheck() throws InterruptedException, KeyManagementException, - NoSuchAlgorithmException { + private StatisticsReport performStatisticCheck() + throws InterruptedException, KeyManagementException, NoSuchAlgorithmException { StatisticsReport response = null; - TrustManager[] noopTrustManager = new TrustManager[]{ - new X509TrustManager() { + TrustManager[] noopTrustManager = new TrustManager[] { new X509TrustManager() { - @Override - public X509Certificate[] getAcceptedIssuers() { - return new X509Certificate[0]; - } + @Override + public X509Certificate[] getAcceptedIssuers() { + return new X509Certificate[0]; + } - @Override - public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) { - } + @Override + public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) { + } - @Override - public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) { - } + @Override + public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) { } - }; + } }; SSLContext sc = SSLContext.getInstance("TLSv1.2"); sc.init(null, noopTrustManager, new SecureRandom()); - final ClientBuilder clientBuilder = - ClientBuilder.newBuilder().sslContext(sc).hostnameVerifier((host, session) -> true); + final ClientBuilder clientBuilder = ClientBuilder.newBuilder().sslContext(sc) + .hostnameVerifier((host, session) -> true); final Client client = clientBuilder.build(); final HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic("healthcheck", "zb!XztG34"); client.register(feature); @@ -129,8 +123,8 @@ public class TestHttpsStatisticDistributionRestServer { } private void validateReport(final int code, final int total, final int successCount, final int failureCount, - final int download, final int downloadSuccess, final int downloadFailure, final String reportString, - final StatisticsReport report) { + final int download, final int downloadSuccess, final int downloadFailure, final String reportString, + final StatisticsReport report) { assertEquals(code, report.getCode()); assertEquals(total, report.getTotalDistributionCount()); assertEquals(successCount, report.getDistributionSuccessCount()); |