summaryrefslogtreecommitdiffstats
path: root/participant/participant-impl/participant-impl-policy/src
diff options
context:
space:
mode:
authorLiam Fallon <liam.fallon@est.tech>2021-06-20 19:39:39 +0000
committerGerrit Code Review <gerrit@onap.org>2021-06-20 19:39:39 +0000
commitf00ca4de37bbbf272e107dd89f4dbb901c787462 (patch)
tree419f19cfffa1a49e5a4be4b80d75cfc740c26cf0 /participant/participant-impl/participant-impl-policy/src
parent18526e9a01fc0b0e085d2a6e3457957e6392ce27 (diff)
parent2d186df9e3ed47599dbc86c2f435f7884535398c (diff)
Merge "Clean up CLAMP Sonar and checkstyle issues"
Diffstat (limited to 'participant/participant-impl/participant-impl-policy/src')
-rw-r--r--participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/PolicyParticipantApplication.java5
-rw-r--r--participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/client/AbstractHttpClient.java19
-rw-r--r--participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/client/PolicyApiHttpClient.java3
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/CommonTestData.java17
4 files changed, 28 insertions, 16 deletions
diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/PolicyParticipantApplication.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/PolicyParticipantApplication.java
index bdc09c8b9..4869b7c2f 100644
--- a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/PolicyParticipantApplication.java
+++ b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/PolicyParticipantApplication.java
@@ -30,8 +30,9 @@ import org.springframework.context.annotation.ComponentScan;
*
*/
@SpringBootApplication
-@ComponentScan({"org.onap.policy.clamp.controlloop.participant.policy",
- "org.onap.policy.clamp.controlloop.participant.intermediary"})
+@ComponentScan({
+ "org.onap.policy.clamp.controlloop.participant.policy",
+ "org.onap.policy.clamp.controlloop.participant.intermediary"})
@ConfigurationPropertiesScan("org.onap.policy.clamp.controlloop.participant.policy.main.parameters")
public class PolicyParticipantApplication {
diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/client/AbstractHttpClient.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/client/AbstractHttpClient.java
index 4b6686156..2579585e5 100644
--- a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/client/AbstractHttpClient.java
+++ b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/client/AbstractHttpClient.java
@@ -41,25 +41,26 @@ public abstract class AbstractHttpClient implements Closeable {
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractHttpClient.class);
private final HttpClient httpclient;
-
/**
* Constructor.
+ *
+ * @param policyParticipantParameters the parameters for the policy participant
+ * @throws ControlLoopRuntimeException on client start errors
*/
- protected AbstractHttpClient(BusTopicParams policyApiParameters) {
+ protected AbstractHttpClient(BusTopicParams policyParticipantParameters) {
try {
- httpclient = HttpClientFactoryInstance.getClientFactory().build(policyApiParameters);
+ httpclient = HttpClientFactoryInstance.getClientFactory().build(policyParticipantParameters);
} catch (final Exception e) {
throw new ControlLoopRuntimeException(Status.INTERNAL_SERVER_ERROR, " Client failed to start", e);
}
}
protected Response executePost(String path, final Entity<?> entity) {
- Response response = httpclient.post(path, entity, Map.of(HttpHeaders.ACCEPT,
- MediaType.APPLICATION_JSON, HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON));
+ var response = httpclient.post(path, entity, Map.of(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON,
+ HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON));
if (response.getStatus() / 100 != 2) {
- LOGGER.error(
- "Invocation of path {} failed for entity {}. Response status: {}, Response status info: {}",
- path, entity, response.getStatus(), response.getStatusInfo());
+ LOGGER.error("Invocation of path {} failed for entity {}. Response status: {}, Response status info: {}",
+ path, entity, response.getStatus(), response.getStatusInfo());
}
return response;
}
@@ -72,4 +73,4 @@ public abstract class AbstractHttpClient implements Closeable {
public void close() throws IOException {
httpclient.shutdown();
}
-} \ No newline at end of file
+}
diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/client/PolicyApiHttpClient.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/client/PolicyApiHttpClient.java
index 3d1047ce4..38a79f7f6 100644
--- a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/client/PolicyApiHttpClient.java
+++ b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/client/PolicyApiHttpClient.java
@@ -35,6 +35,8 @@ public class PolicyApiHttpClient extends AbstractHttpClient {
/**
* Constructor.
+ *
+ * @param parameters the policy participant parameters
*/
public PolicyApiHttpClient(ParticipantPolicyParameters parameters) {
super(parameters.getPolicyApiParameters());
@@ -45,6 +47,7 @@ public class PolicyApiHttpClient extends AbstractHttpClient {
*
* @param toscaServiceTemplate the whole ToscaServiceTemplate
* @return Response
+ * @throws PfModelException on errors creating the policy type
*/
public Response createPolicyType(ToscaServiceTemplate toscaServiceTemplate) throws PfModelException {
return executePost(POLICY_URI + "policytypes", Entity.entity(toscaServiceTemplate, MediaType.APPLICATION_JSON));
diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/CommonTestData.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/CommonTestData.java
index e3d7e3aa5..1acc2c838 100644
--- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/CommonTestData.java
+++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/CommonTestData.java
@@ -29,6 +29,7 @@ import java.util.List;
import java.util.Map;
import java.util.TreeMap;
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.common.endpoints.parameters.TopicParameters;
import org.onap.policy.common.parameters.ParameterGroup;
@@ -51,15 +52,18 @@ public class CommonTestData {
/**
* Converts the contents of a map to a parameter class.
*
+ * @param <T> the type of ParameterGroup to process
* @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 decoding 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(Status.NOT_ACCEPTABLE,
+ "cannot create " + clazz.getName() + " from map", e);
}
}
@@ -163,14 +167,15 @@ public class CommonTestData {
*
* @param port port to be inserted into the parameters
* @return the standard participant parameters
+ * @throws ControlLoopRuntimeException on parameter read errors
*/
public ParticipantPolicyParameters getParticipantPolicyParameters(int port) {
try {
return coder.decode(getParticipantPolicyParametersAsString(port), ParticipantPolicyParameters.class);
} catch (CoderException e) {
- throw new ControlLoopRuntimeException(Response.Status.NOT_ACCEPTABLE,
- "cannot read participant parameters", e);
+ throw new ControlLoopRuntimeException(Response.Status.NOT_ACCEPTABLE, "cannot read participant parameters",
+ e);
}
}
@@ -179,6 +184,7 @@ public class CommonTestData {
*
* @param port port to be inserted into the parameters
* @return the standard participant parameters
+ * @throws ControlLoopRuntimeException on parameter read errors
*/
public static String getParticipantPolicyParametersAsString(int port) {
@@ -192,8 +198,8 @@ public class CommonTestData {
return json;
} catch (IOException e) {
- throw new ControlLoopRuntimeException(Response.Status.NOT_ACCEPTABLE,
- "cannot read participant parameters", e);
+ throw new ControlLoopRuntimeException(Response.Status.NOT_ACCEPTABLE, "cannot read participant parameters",
+ e);
}
}
@@ -211,6 +217,7 @@ public class CommonTestData {
/**
* Nulls out a field within a JSON string.
+ *
* @param json JSON string
* @param field field to be nulled out
* @return a new JSON string with the field nulled out