From 2d186df9e3ed47599dbc86c2f435f7884535398c Mon Sep 17 00:00:00 2001 From: liamfallon Date: Wed, 16 Jun 2021 12:08:01 +0100 Subject: Clean up CLAMP Sonar and checkstyle issues This commit cleans up sonar and checkstyle issues identified in the CLAMP repository. Issue-ID: POLICY-3206 Change-Id: I16b61bbe771cc17de15183a24b2a5e82a8d35872 Signed-off-by: liamfallon --- .../participant-impl/participant-impl-dcae/pom.xml | 19 +++---------------- .../participant/dcae/DcaeParticipantApplication.java | 6 ++++-- .../dcae/httpclient/AbstractHttpClient.java | 12 +++++++----- .../participant/dcae/httpclient/ClampHttpClient.java | 2 ++ .../dcae/httpclient/ConsulDcaeHttpClient.java | 3 +++ .../dcae/main/handler/ControlLoopElementHandler.java | 3 +++ .../dcae/main/parameters/CommonTestData.java | 10 +++++++++- 7 files changed, 31 insertions(+), 24 deletions(-) (limited to 'participant/participant-impl/participant-impl-dcae') diff --git a/participant/participant-impl/participant-impl-dcae/pom.xml b/participant/participant-impl/participant-impl-dcae/pom.xml index 714f1551c..d59bca376 100644 --- a/participant/participant-impl/participant-impl-dcae/pom.xml +++ b/participant/participant-impl/participant-impl-dcae/pom.xml @@ -31,44 +31,32 @@ policy-clamp-participant-impl-dcae ${project.artifactId} DCAE participant, that allows DCAE to partake in control loops - - - - - - org.springframework.boot - spring-boot-dependencies - ${version.springboot} - pom - import - - - org.springframework.boot spring-boot-starter-web + ${version.springboot} org.springframework.boot spring-boot-starter-validation + ${version.springboot} org.springframework.boot spring-boot-starter-test + ${version.springboot} test org.mock-server mockserver-netty - ${version.mockserver} test org.mock-server mockserver-client-java - ${version.mockserver} test @@ -78,7 +66,6 @@ org.springframework.boot spring-boot-maven-plugin - ${version.springboot} diff --git a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/DcaeParticipantApplication.java b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/DcaeParticipantApplication.java index 25edaf552..9be83bbd3 100644 --- a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/DcaeParticipantApplication.java +++ b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/DcaeParticipantApplication.java @@ -30,8 +30,10 @@ import org.springframework.context.annotation.ComponentScan; * */ @SpringBootApplication -@ComponentScan({"org.onap.policy.clamp.controlloop.participant.dcae", - "org.onap.policy.clamp.controlloop.participant.intermediary"}) +@ComponentScan({ + "org.onap.policy.clamp.controlloop.participant.dcae", + "org.onap.policy.clamp.controlloop.participant.intermediary" +}) @ConfigurationPropertiesScan("org.onap.policy.clamp.controlloop.participant.dcae.main.parameters") public class DcaeParticipantApplication { diff --git a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/AbstractHttpClient.java b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/AbstractHttpClient.java index e23aaaf23..43326e725 100644 --- a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/AbstractHttpClient.java +++ b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/AbstractHttpClient.java @@ -24,7 +24,6 @@ import java.io.Closeable; import java.io.IOException; import java.util.Collections; import javax.ws.rs.client.Entity; -import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException; import org.onap.policy.clamp.controlloop.participant.dcae.model.Loop; @@ -46,6 +45,9 @@ public abstract class AbstractHttpClient implements Closeable { /** * Constructor. + * + * @param restClientParameters the REST client parameters + * @throws ControlLoopRuntimeException on errors */ protected AbstractHttpClient(BusTopicParams restClientParameters) { try { @@ -58,7 +60,7 @@ public abstract class AbstractHttpClient implements Closeable { protected boolean executePut(String path, String jsonEntity, int statusCode) { try { - Response response = httpclient.put(path, Entity.json(jsonEntity), Collections.emptyMap()); + var response = httpclient.put(path, Entity.json(jsonEntity), Collections.emptyMap()); return response.getStatus() == statusCode; } catch (Exception e) { LOGGER.error(MSG_REQUEST_FAILED, httpclient.getName(), e); @@ -68,7 +70,7 @@ public abstract class AbstractHttpClient implements Closeable { protected boolean executePut(String path, int statusCode) { try { - Response response = httpclient.put(path, Entity.json(""), Collections.emptyMap()); + var response = httpclient.put(path, Entity.json(""), Collections.emptyMap()); return response.getStatus() == statusCode; } catch (Exception e) { LOGGER.error(MSG_REQUEST_FAILED, httpclient.getName(), e); @@ -78,7 +80,7 @@ public abstract class AbstractHttpClient implements Closeable { protected Loop executePost(String path, int statusCode) { try { - Response response = httpclient.post(path, Entity.json(""), Collections.emptyMap()); + var response = httpclient.post(path, Entity.json(""), Collections.emptyMap()); if (response.getStatus() != statusCode) { return null; } @@ -91,7 +93,7 @@ public abstract class AbstractHttpClient implements Closeable { protected Loop executeGet(String path, int statusCode) { try { - Response response = httpclient.get(path); + var response = httpclient.get(path); if (response.getStatus() != statusCode) { return null; diff --git a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ClampHttpClient.java b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ClampHttpClient.java index e928c138f..fd19d9d3a 100644 --- a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ClampHttpClient.java +++ b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ClampHttpClient.java @@ -40,6 +40,8 @@ public class ClampHttpClient extends AbstractHttpClient { /** * Constructor. + * + * @param parameters the DCAE parameters */ public ClampHttpClient(ParticipantDcaeParameters parameters) { super(parameters.getClampClientParameters()); diff --git a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ConsulDcaeHttpClient.java b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ConsulDcaeHttpClient.java index 4f76e3025..154dd09be 100644 --- a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ConsulDcaeHttpClient.java +++ b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ConsulDcaeHttpClient.java @@ -31,6 +31,8 @@ public class ConsulDcaeHttpClient extends AbstractHttpClient { /** * Constructor. + * + * @param parameters the DCAE parameters */ public ConsulDcaeHttpClient(ParticipantDcaeParameters parameters) { super(parameters.getConsulClientParameters()); @@ -39,6 +41,7 @@ public class ConsulDcaeHttpClient extends AbstractHttpClient { /** * Call consult. * + * @param name the name to deploy * @param jsonEntity the Entity * @return true */ diff --git a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/handler/ControlLoopElementHandler.java b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/handler/ControlLoopElementHandler.java index 76ed1122c..6c5ff1d78 100644 --- a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/handler/ControlLoopElementHandler.java +++ b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/handler/ControlLoopElementHandler.java @@ -74,6 +74,9 @@ public class ControlLoopElementHandler implements ControlLoopElementListener { /** * Constructor. + * + * @param clampClient the CLAMP client + * @param consulClient the Consul client */ public ControlLoopElementHandler(ClampHttpClient clampClient, ConsulDcaeHttpClient consulClient) { this.clampClient = clampClient; diff --git a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/CommonTestData.java b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/CommonTestData.java index cb06fcb15..5d8881eb3 100644 --- a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/CommonTestData.java +++ b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/CommonTestData.java @@ -59,16 +59,19 @@ public class CommonTestData { /** * Converts the contents of a map to a parameter class. * + * @param specific type of ParameterGroup class * @param source property map * @param clazz class of object to be created from the map * @return a new object represented by the map + * @throws ControlLoopRuntimeException on errors */ public T toObject(final Map source, final Class clazz) { try { return coder.convert(source, clazz); } catch (final CoderException e) { - throw new RuntimeException("cannot create " + clazz.getName() + " from map", e); + throw new ControlLoopRuntimeException(Response.Status.INTERNAL_SERVER_ERROR, + "cannot create " + clazz.getName() + " from map", e); } } @@ -95,6 +98,7 @@ public class CommonTestData { * * @param isEmpty boolean value to represent that object created should be empty or not * @return a property map suitable for constructing an object + * @throws ControlLoopRuntimeException on errors */ public Map getClampClientParametersMap(final boolean isEmpty) { final Map map = new TreeMap<>(); @@ -121,6 +125,7 @@ public class CommonTestData { * * @param isEmpty boolean value to represent that object created should be empty or not * @return a property map suitable for constructing an object + * @throws ControlLoopRuntimeException on errors */ public Map getConsulClientParametersMap(final boolean isEmpty) { final Map map = new TreeMap<>(); @@ -228,6 +233,7 @@ public class CommonTestData { * * @param port port to be inserted into the parameters * @return the standard participant parameters + * @throws ControlLoopRuntimeException on errors */ public ParticipantDcaeParameters getParticipantParameterGroup(int port) { try { @@ -244,6 +250,7 @@ public class CommonTestData { * * @param port port to be inserted into the parameters * @return the standard participant parameters + * @throws ControlLoopRuntimeException on errors */ public static String getParticipantParameterGroupAsString(int port) { @@ -289,6 +296,7 @@ public class CommonTestData { * * @param status the status of Partecipant * @return the JSON + * @throws ControlLoopRuntimeException on errors */ public static String createJsonStatus(String status) { try { -- cgit 1.2.3-korg