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 | |
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')
3 files changed, 67 insertions, 75 deletions
diff --git a/main/src/main/java/org/onap/policy/distribution/main/parameters/DistributionParameterGroup.java b/main/src/main/java/org/onap/policy/distribution/main/parameters/DistributionParameterGroup.java index c7fbbd84..f9673755 100644 --- a/main/src/main/java/org/onap/policy/distribution/main/parameters/DistributionParameterGroup.java +++ b/main/src/main/java/org/onap/policy/distribution/main/parameters/DistributionParameterGroup.java @@ -38,17 +38,17 @@ import org.onap.policy.distribution.reception.parameters.ReceptionHandlerParamet * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com) */ public class DistributionParameterGroup implements ParameterGroup { + // @formatter:off private String name; private RestServerParameters restServerParameters; private Map<String, ReceptionHandlerParameters> receptionHandlerParameters; - private Map<String, ReceptionHandlerConfigurationParameterGroup> receptionHandlerConfigurationParameters = - new LinkedHashMap<>(); - private Map<String, PolicyForwarderConfigurationParameterGroup> policyForwarderConfigurationParameters = - new LinkedHashMap<>(); - private Map<String, PolicyDecoderConfigurationParameterGroup> policyDecoderConfigurationParameters = - new LinkedHashMap<>(); - - + private Map<String, ReceptionHandlerConfigurationParameterGroup> receptionHandlerConfigurationParameters + = new LinkedHashMap<>(); + private Map<String, PolicyForwarderConfigurationParameterGroup> policyForwarderConfigurationParameters + = new LinkedHashMap<>(); + private Map<String, PolicyDecoderConfigurationParameterGroup> policyDecoderConfigurationParameters + = new LinkedHashMap<>(); + // @formatter:on /** * Create the distribution parameter group. @@ -56,10 +56,10 @@ public class DistributionParameterGroup implements ParameterGroup { * @param name the parameter group name */ public DistributionParameterGroup(final String name, final RestServerParameters restServerParameters, - final Map<String, ReceptionHandlerParameters> receptionHandlerParameters, - final Map<String, ReceptionHandlerConfigurationParameterGroup> receptionHandlerConfigurationParameters, - final Map<String, PolicyForwarderConfigurationParameterGroup> policyForwarderConfigurationParameters, - final Map<String, PolicyDecoderConfigurationParameterGroup> policyDecoderConfigurationParameters) { + final Map<String, ReceptionHandlerParameters> receptionHandlerParameters, + final Map<String, ReceptionHandlerConfigurationParameterGroup> receptionHandlerConfigurationParameters, + final Map<String, PolicyForwarderConfigurationParameterGroup> policyForwarderConfigurationParameters, + final Map<String, PolicyDecoderConfigurationParameterGroup> policyDecoderConfigurationParameters) { this.name = name; this.restServerParameters = restServerParameters; this.receptionHandlerParameters = receptionHandlerParameters; @@ -118,10 +118,10 @@ public class DistributionParameterGroup implements ParameterGroup { /** * Sets the reception handler configuration parameter map. * - * @param eventInputParameters the reception handler configuration parameters + * @param receptionHandlerConfigurationParameters the reception handler configuration parameters */ public void setReceptionHandlerConfigurationParameters( - final Map<String, ReceptionHandlerConfigurationParameterGroup> receptionHandlerConfigurationParameters) { + final Map<String, ReceptionHandlerConfigurationParameterGroup> receptionHandlerConfigurationParameters) { this.receptionHandlerConfigurationParameters = receptionHandlerConfigurationParameters; } @@ -140,7 +140,7 @@ public class DistributionParameterGroup implements ParameterGroup { * @param policyForwarderConfigurationParameters the policy forwarder configuration parameters */ public void setPolicyForwarderConfigurationParameters( - final Map<String, PolicyForwarderConfigurationParameterGroup> policyForwarderConfigurationParameters) { + final Map<String, PolicyForwarderConfigurationParameterGroup> policyForwarderConfigurationParameters) { this.policyForwarderConfigurationParameters = policyForwarderConfigurationParameters; } @@ -159,7 +159,7 @@ public class DistributionParameterGroup implements ParameterGroup { * @param policyDecoderConfigurationParameters the policyDecoderConfigurationParameters to set */ public void setPolicyDecoderConfigurationParameters( - final Map<String, PolicyDecoderConfigurationParameterGroup> policyDecoderConfigurationParameters) { + final Map<String, PolicyDecoderConfigurationParameterGroup> policyDecoderConfigurationParameters) { this.policyDecoderConfigurationParameters = policyDecoderConfigurationParameters; } @@ -176,7 +176,7 @@ public class DistributionParameterGroup implements ParameterGroup { } if (restServerParameters == null) { validationResult.setResult("restServerParameters", ValidationStatus.INVALID, - "must have restServerParameters to configure distribution rest server"); + "must have restServerParameters to configure distribution rest server"); } else { validationResult.setResult("restServerParameters", restServerParameters.validate()); } @@ -189,29 +189,33 @@ public class DistributionParameterGroup implements ParameterGroup { private void validateReceptionHandlers(final GroupValidationResult validationResult) { if (receptionHandlerParameters == null || receptionHandlerParameters.size() == 0) { validationResult.setResult("receptionHandlerParameters", ValidationStatus.INVALID, - "must have at least one reception handler"); + "must have at least one reception handler"); } else { for (final Entry<String, ReceptionHandlerParameters> nestedGroupEntry : receptionHandlerParameters - .entrySet()) { + .entrySet()) { validationResult.setResult("receptionHandlerParameters", nestedGroupEntry.getKey(), - nestedGroupEntry.getValue().validate()); + nestedGroupEntry.getValue().validate()); } } } private void validateForwarderConfigurations(final GroupValidationResult validationResult) { - for (final Entry<String, PolicyForwarderConfigurationParameterGroup> configurationParameters : - policyForwarderConfigurationParameters.entrySet()) { + // @formatter:off + for (final Entry<String, PolicyForwarderConfigurationParameterGroup> configurationParameters : + policyForwarderConfigurationParameters.entrySet()) { validationResult.setResult("policyForwarderConfigurationParameters", configurationParameters.getKey(), - configurationParameters.getValue().validate()); + configurationParameters.getValue().validate()); } + // @formatter:on } private void validateDecoderConfigurations(final GroupValidationResult validationResult) { + // @formatter:off for (final Entry<String, PolicyDecoderConfigurationParameterGroup> configurationParameters : - policyDecoderConfigurationParameters.entrySet()) { + policyDecoderConfigurationParameters.entrySet()) { validationResult.setResult("policyDecoderConfigurationParameters", configurationParameters.getKey(), - configurationParameters.getValue().validate()); + configurationParameters.getValue().validate()); } + // @formatter:on } } 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()); |