diff options
author | Liam Fallon <liam.fallon@est.tech> | 2021-06-20 19:39:39 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2021-06-20 19:39:39 +0000 |
commit | f00ca4de37bbbf272e107dd89f4dbb901c787462 (patch) | |
tree | 419f19cfffa1a49e5a4be4b80d75cfc740c26cf0 /participant/participant-impl/participant-impl-dcae | |
parent | 18526e9a01fc0b0e085d2a6e3457957e6392ce27 (diff) | |
parent | 2d186df9e3ed47599dbc86c2f435f7884535398c (diff) |
Merge "Clean up CLAMP Sonar and checkstyle issues"
Diffstat (limited to 'participant/participant-impl/participant-impl-dcae')
7 files changed, 31 insertions, 24 deletions
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 @@ <artifactId>policy-clamp-participant-impl-dcae</artifactId> <name>${project.artifactId}</name> <description>DCAE participant, that allows DCAE to partake in control loops</description> - - <dependencyManagement> - <dependencies> - <!-- Spring Boot BOM --> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-dependencies</artifactId> - <version>${version.springboot}</version> - <type>pom</type> - <scope>import</scope> - </dependency> - </dependencies> - </dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> + <version>${version.springboot}</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-validation</artifactId> + <version>${version.springboot}</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> + <version>${version.springboot}</version> <scope>test</scope> </dependency> <dependency> <groupId>org.mock-server</groupId> <artifactId>mockserver-netty</artifactId> - <version>${version.mockserver}</version> <scope>test</scope> </dependency> <dependency> <groupId>org.mock-server</groupId> <artifactId>mockserver-client-java</artifactId> - <version>${version.mockserver}</version> <scope>test</scope> </dependency> </dependencies> @@ -78,7 +66,6 @@ <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> - <version>${version.springboot}</version> <executions> <execution> <goals> 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 <T> 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 extends ParameterGroup> T toObject(final Map<String, Object> source, final Class<T> 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<String, Object> getClampClientParametersMap(final boolean isEmpty) { final Map<String, Object> 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<String, Object> getConsulClientParametersMap(final boolean isEmpty) { final Map<String, Object> 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 { |