aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiam Fallon <liam.fallon@est.tech>2021-06-25 12:34:04 +0000
committerGerrit Code Review <gerrit@onap.org>2021-06-25 12:34:04 +0000
commit78d0be555197b29cd9de4b882c9525d6b6b2e524 (patch)
tree5473d222ccf01be249fb716d78d8f4853f681667
parentc2f0aac6784db56706931a5fa409e18a3dc872cd (diff)
parentdbc13c78875a3d5493054a7252a7804daae8cf1f (diff)
Merge "Move parameters from config Json file to application.yaml"
-rw-r--r--common/src/test/resources/demo/Notes.txt14
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java4
-rw-r--r--participant/participant-impl/participant-impl-dcae/pom.xml3
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ClampHttpClient.java21
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ConsulDcaeHttpClient.java8
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/handler/ControlLoopElementHandler.java32
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/ClampEndPoints.java (renamed from participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/config/ParametersConfig.java)45
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/ConsulEndPoints.java (renamed from participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/configurations/ParametersConfig.java)32
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/ParticipantDcaeParameterHandler.java82
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/ParticipantDcaeParameters.java91
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/main/resources/config/DCAEParticipantConfig.json70
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/main/resources/config/application.yaml54
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/main/resources/parameters/consul.json62
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/endtoend/PartecipantDcaeTest.java2
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ClampHttpClientTest.java4
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ConsulDcaeHttpClientTest.java4
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/handler/ControlLoopElementHandlerTest.java144
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/CommonTestData.java116
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/ParticipantDcaeParametersTest.java163
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/TestParticipantDcaeParameterHandler.java64
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/TestParticipantDcaeParameters.java88
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/rest/TestListenerUtils.java2
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/test/resources/application_test.properties41
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/InvalidParameters.json3
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/MinimumParametersH2.json61
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/NoParameters.json2
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/TestParameters.json70
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/TestParametersStd.json71
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/Unreadable.json61
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/pom.xml4
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/Application.java4
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/parameters/ParticipantK8sParameterHandler.java73
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/parameters/ParticipantK8sParameters.java34
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartStore.java3
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/KubernetesParticipantConfig.json56
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/application.yaml27
-rw-r--r--participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/config/ParametersConfig.java40
-rw-r--r--participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/ParticipantPolicyParameterHandler.java75
-rw-r--r--participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/ParticipantPolicyParameters.java34
-rw-r--r--participant/participant-impl/participant-impl-policy/src/main/resources/config/PolicyParticipantConfig.json53
-rw-r--r--participant/participant-impl/participant-impl-policy/src/main/resources/config/application.yaml32
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/endtoend/ParticipantPolicyTest.java2
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/CommonTestData.java102
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/ParticipantPolicyParametersTest.java66
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/TestParticipantPolicyParameterHandler.java58
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/TestParticipantPolicyParameters.java106
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/application_test.properties27
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/parameters/InvalidParameters.json3
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/parameters/MinimumParametersH2.json53
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/parameters/NoParameters.json2
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/parameters/TestParameters.json53
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/parameters/TestParametersStd.json53
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/parameters/Unreadable.json53
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/ParticipantSimulatorApplication.java2
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/ParametersConfig.java40
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/ParticipantSimulatorParameterHandler.java76
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/ParticipantSimulatorParameters.java33
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/ParticipantErrorController.java4
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/resources/config/CDSParticipantConfig.json61
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/resources/config/DCAEParticipantConfig.json31
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/resources/config/PolicyParticipantConfig.json31
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/resources/config/application.yaml32
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/CommonTestData.java106
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/TestParticipantSimulatorParameterHandler.java71
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/TestParticipantSimulatorParameters.java85
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/resources/application_test.properties30
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/EmptyParameters.json0
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/InvalidParameters.json3
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/NoParameters.json2
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/TestParameters.json61
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/TestParametersStd.json61
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/Unreadable.json61
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java20
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java8
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/parameters/ParticipantIntermediaryParameters.java32
75 files changed, 957 insertions, 2320 deletions
diff --git a/common/src/test/resources/demo/Notes.txt b/common/src/test/resources/demo/Notes.txt
index 21be91449..315d6407c 100644
--- a/common/src/test/resources/demo/Notes.txt
+++ b/common/src/test/resources/demo/Notes.txt
@@ -14,10 +14,16 @@ Run CL from command line
Go to clamp/tosca-controlloop/runtime
mvn exec:java -Dexec.mainClass=org.onap.policy.clamp.controlloop.runtime.main.startstop.Main -Dexec.args="-c src/test/resources/parameters/TestParametersMariaDB.json"
-Run Participant from command line
-mvn exec:java -Dexec.mainClass=org.onap.policy.clamp.controlloop.participants.ParticipantMain -Dexec.args=" -c src/main/resources/config/CDSParticipantConfig.json"
-mvn exec:java -Dexec.mainClass=org.onap.policy.clamp.controlloop.participant.dcae.main.startstop.Main -Dexec.args=" -c src/main/resources/config/DCAEParticipantConfig.json"
-mvn exec:java -Dexec.mainClass=org.onap.policy.clamp.controlloop.participants.ParticipantMain -Dexec.args=" -c src/main/resources/config/PolicyParticipantConfig.json"
+Run Participant from command line using Maven
+mvn spring-boot:run -Dspring-boot.run.arguments="--server.port=8080 --topicServer=localhost"
+mvn spring-boot:run -Dspring-boot.run.arguments="--server.port=8081 --topicServer=localhost"
+mvn spring-boot:run -Dspring-boot.run.arguments="--server.port=8082 --topicServer=localhost"
+
+Run Participant from command line using Jar
+java -jar -Dserver.port=8080 -DtopicServer=localhost target/policy-clamp-participant-impl-simulator-6.1.2-SNAPSHOT.jar
+java -jar -Dserver.port=8081 -DtopicServer=localhost target/policy-clamp-participant-impl-dcae-6.1.2-SNAPSHOT.jar
+java -jar -Dserver.port=8082 -DtopicServer=localhost target/policy-clamp-participant-impl-policy-6.1.2-SNAPSHOT.jar
+java -jar -DtopicServer=localhost target/policy-clamp-participant-impl-kubernetes-6.1.2-SNAPSHOT.jar
Config of DB
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java
index a7216ed7f..272333b88 100644
--- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java
@@ -74,7 +74,6 @@ public class ParticipantStatisticsProvider extends AbstractModelsProvider {
}
}
-
/**
* Get filtered participant statistics.
*
@@ -108,7 +107,6 @@ public class ParticipantStatisticsProvider extends AbstractModelsProvider {
return asParticipantStatisticsList(getPfDao().getFiltered(JpaParticipantStatistics.class, filterParams));
}
-
/**
* Creates Participant statistics.
*
@@ -138,8 +136,6 @@ public class ParticipantStatisticsProvider extends AbstractModelsProvider {
return participantStatistics;
}
-
-
/**
* Convert JPA participant statistics list to participant statistics list.
*
diff --git a/participant/participant-impl/participant-impl-dcae/pom.xml b/participant/participant-impl/participant-impl-dcae/pom.xml
index d59bca376..947862626 100644
--- a/participant/participant-impl/participant-impl-dcae/pom.xml
+++ b/participant/participant-impl/participant-impl-dcae/pom.xml
@@ -36,17 +36,14 @@
<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>
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 fd19d9d3a..74c1ee5c1 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
@@ -21,6 +21,7 @@
package org.onap.policy.clamp.controlloop.participant.dcae.httpclient;
import org.apache.http.HttpStatus;
+import org.onap.policy.clamp.controlloop.participant.dcae.main.parameters.ClampEndPoints;
import org.onap.policy.clamp.controlloop.participant.dcae.main.parameters.ParticipantDcaeParameters;
import org.onap.policy.clamp.controlloop.participant.dcae.model.ExternalComponent;
import org.onap.policy.clamp.controlloop.participant.dcae.model.Loop;
@@ -29,12 +30,7 @@ import org.springframework.stereotype.Component;
@Component
public class ClampHttpClient extends AbstractHttpClient {
- private static final String STATUS = "/restservices/clds/v2/loop/getstatus/";
- private static final String CREATE = "/restservices/clds/v2/loop/create/%s?templateName=%s";
- private static final String DEPLOY = "/restservices/clds/v2/loop/deploy/";
- private static final String STOP = "/restservices/clds/v2/loop/stop/";
- private static final String DELETE = "/restservices/clds/v2/loop/delete/";
- private static final String UNDEPLOY = "/restservices/clds/v2/loop/undeploy/";
+ private final ClampEndPoints endPoints;
public static final String STATUS_NOT_FOUND = "STATUS_NOT_FOUND";
public static final String POLICY_NOT_FOUND = "POLICY_NOT_FOUND";
@@ -45,6 +41,7 @@ public class ClampHttpClient extends AbstractHttpClient {
*/
public ClampHttpClient(ParticipantDcaeParameters parameters) {
super(parameters.getClampClientParameters());
+ this.endPoints = parameters.getClampClientEndPoints();
}
/**
@@ -55,7 +52,7 @@ public class ClampHttpClient extends AbstractHttpClient {
* @return the Loop object or null if error occurred
*/
public Loop create(String loopName, String templateName) {
- return executePost(String.format(CREATE, loopName, templateName), HttpStatus.SC_OK);
+ return executePost(String.format(endPoints.getCreate(), loopName, templateName), HttpStatus.SC_OK);
}
/**
@@ -65,7 +62,7 @@ public class ClampHttpClient extends AbstractHttpClient {
* @return true
*/
public boolean deploy(String loopName) {
- return executePut(DEPLOY + loopName, HttpStatus.SC_ACCEPTED);
+ return executePut(endPoints.getDeploy() + loopName, HttpStatus.SC_ACCEPTED);
}
/**
@@ -75,7 +72,7 @@ public class ClampHttpClient extends AbstractHttpClient {
* @return the Loop object or null if error occurred
*/
public Loop getstatus(String loopName) {
- return executeGet(STATUS + loopName, HttpStatus.SC_OK);
+ return executeGet(endPoints.getStatus() + loopName, HttpStatus.SC_OK);
}
/**
@@ -85,7 +82,7 @@ public class ClampHttpClient extends AbstractHttpClient {
* @return true
*/
public boolean undeploy(String loopName) {
- return executePut(UNDEPLOY + loopName, HttpStatus.SC_ACCEPTED);
+ return executePut(endPoints.getUndeploy() + loopName, HttpStatus.SC_ACCEPTED);
}
/**
@@ -95,7 +92,7 @@ public class ClampHttpClient extends AbstractHttpClient {
* @return true
*/
public boolean stop(String loopName) {
- return executePut(STOP + loopName, HttpStatus.SC_OK);
+ return executePut(endPoints.getStop() + loopName, HttpStatus.SC_OK);
}
/**
@@ -105,7 +102,7 @@ public class ClampHttpClient extends AbstractHttpClient {
* @return true
*/
public boolean delete(String loopName) {
- return executePut(DELETE + loopName, HttpStatus.SC_OK);
+ return executePut(endPoints.getDelete() + loopName, HttpStatus.SC_OK);
}
/**
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 154dd09be..4cdcf7c7f 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
@@ -21,13 +21,14 @@
package org.onap.policy.clamp.controlloop.participant.dcae.httpclient;
import org.apache.http.HttpStatus;
+import org.onap.policy.clamp.controlloop.participant.dcae.main.parameters.ConsulEndPoints;
import org.onap.policy.clamp.controlloop.participant.dcae.main.parameters.ParticipantDcaeParameters;
import org.springframework.stereotype.Component;
@Component
public class ConsulDcaeHttpClient extends AbstractHttpClient {
- private static final String DEPLOY = "/v1/kv/dcae-pmsh:";
+ private final ConsulEndPoints endPoints;
/**
* Constructor.
@@ -36,16 +37,17 @@ public class ConsulDcaeHttpClient extends AbstractHttpClient {
*/
public ConsulDcaeHttpClient(ParticipantDcaeParameters parameters) {
super(parameters.getConsulClientParameters());
+ this.endPoints = parameters.getConsulClientEndPoints();
}
/**
- * Call consult.
+ * Call deploy consult.
*
* @param name the name to deploy
* @param jsonEntity the Entity
* @return true
*/
public boolean deploy(String name, String jsonEntity) {
- return executePut(DEPLOY + name, jsonEntity, HttpStatus.SC_OK);
+ return executePut(endPoints.getDeploy() + name, jsonEntity, HttpStatus.SC_OK);
}
}
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 6c5ff1d78..5a0ddabfd 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
@@ -30,9 +30,11 @@ import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState;
import org.onap.policy.clamp.controlloop.participant.dcae.httpclient.ClampHttpClient;
import org.onap.policy.clamp.controlloop.participant.dcae.httpclient.ConsulDcaeHttpClient;
+import org.onap.policy.clamp.controlloop.participant.dcae.main.parameters.ParticipantDcaeParameters;
import org.onap.policy.clamp.controlloop.participant.dcae.model.Loop;
import org.onap.policy.clamp.controlloop.participant.intermediary.api.ControlLoopElementListener;
import org.onap.policy.clamp.controlloop.participant.intermediary.api.ParticipantIntermediaryApi;
+import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.slf4j.Logger;
@@ -58,19 +60,11 @@ public class ControlLoopElementHandler implements ControlLoopElementListener {
private static final String BLUEPRINT_DEPLOYED = "BLUEPRINT_DEPLOYED";
private static final String MICROSERVICE_INSTALLED_SUCCESSFULLY = "MICROSERVICE_INSTALLED_SUCCESSFULLY";
- private static final int CHECK_COUNT = 10;
-
- private static final String BODY_CONSUL =
- "{ \"subscription\": { \"subscriptionName\": \"subscriptiona\", \"administrativeState\": \"UNLOCKED\", "
- + "\"fileBasedGP\": 15, \"fileLocation\": \"/pm/pm.xml\", \"nfFilter\": "
- + "{ \"nfNames\": [ \"^pnf1.*\" ], \"modelInvariantIDs\": "
- + "[ \"5845y423-g654-6fju-po78-8n53154532k6\", \"7129e420-d396-4efb-af02-6b83499b12f8\" ], "
- + "\"modelVersionIDs\": [ \"e80a6ae3-cafd-4d24-850d-e14c084a5ca9\" ] }, \"measurementGroups\": "
- + "[ { \"measurementGroup\": { \"measurementTypes\": [ { \"measurementType\": \"countera\" }, "
- + "{ \"measurementType\": \"counterb\" } ], \"managedObjectDNsBasic\": [ { \"DN\": \"dna\" }, "
- + "{ \"DN\": \"dnb\" } ] } }, { \"measurementGroup\": { \"measurementTypes\": "
- + "[ { \"measurementType\": \"counterc\" }, { \"measurementType\": \"counterd\" } ], "
- + "\"managedObjectDNsBasic\": " + "[ { \"DN\": \"dnc\" }, { \"DN\": \"dnd\" } ] } } ] } }";
+
+ private int checkCount;
+ private int secCount;
+
+ private String bodyConsul;
/**
* Constructor.
@@ -78,9 +72,13 @@ public class ControlLoopElementHandler implements ControlLoopElementListener {
* @param clampClient the CLAMP client
* @param consulClient the Consul client
*/
- public ControlLoopElementHandler(ClampHttpClient clampClient, ConsulDcaeHttpClient consulClient) {
+ public ControlLoopElementHandler(ClampHttpClient clampClient, ConsulDcaeHttpClient consulClient,
+ ParticipantDcaeParameters parameters) {
this.clampClient = clampClient;
this.consulClient = consulClient;
+ this.checkCount = parameters.getCheckCount();
+ this.secCount = parameters.getSecCount();
+ bodyConsul = ResourceUtils.getResourceAsString(parameters.getJsonBodyConsulPath());
}
/**
@@ -126,7 +124,7 @@ public class ControlLoopElementHandler implements ControlLoopElementListener {
}
private void deploy() throws PfModelException {
- if (!consulClient.deploy(POLICY, BODY_CONSUL)) {
+ if (!consulClient.deploy(POLICY, bodyConsul)) {
throw new PfModelException(null, "deploy to consul failed");
}
if (!clampClient.deploy(LOOP)) {
@@ -150,9 +148,9 @@ public class ControlLoopElementHandler implements ControlLoopElementListener {
if (BLUEPRINT_DEPLOYED.equals(ClampHttpClient.getStatusCode(loop))) {
deploy();
boolean deployedFlag = false;
- for (int i = 0; i < CHECK_COUNT; i++) {
+ for (int i = 0; i < checkCount; i++) {
// sleep 10 seconds
- TimeUnit.SECONDS.sleep(CHECK_COUNT);
+ TimeUnit.SECONDS.sleep(secCount);
loop = getStatus();
String status = ClampHttpClient.getStatusCode(loop);
if (MICROSERVICE_INSTALLED_SUCCESSFULLY.equals(status)) {
diff --git a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/config/ParametersConfig.java b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/ClampEndPoints.java
index ee649c993..12b67ebda 100644
--- a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/config/ParametersConfig.java
+++ b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/ClampEndPoints.java
@@ -18,23 +18,38 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.participant.dcae.config;
+package org.onap.policy.clamp.controlloop.participant.dcae.main.parameters;
-import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
-import org.onap.policy.clamp.controlloop.participant.dcae.main.parameters.ParticipantDcaeParameterHandler;
-import org.onap.policy.clamp.controlloop.participant.dcae.main.parameters.ParticipantDcaeParameters;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
+import javax.validation.constraints.NotBlank;
+import lombok.Getter;
+import lombok.Setter;
+import org.springframework.validation.annotation.Validated;
-@Configuration
-public class ParametersConfig {
+/**
+ * Class to hold all end points needed for clamp client.
+ *
+ */
+@Validated
+@Getter
+@Setter
+public class ClampEndPoints {
+
+ @NotBlank
+ private String status;
+
+ @NotBlank
+ private String create;
+
+ @NotBlank
+ private String deploy;
+
+ @NotBlank
+ private String stop;
+
+ @NotBlank
+ private String delete;
- @Value("${participant.file}")
- private String file;
+ @NotBlank
+ private String undeploy;
- @Bean
- public ParticipantDcaeParameters participantDcaeParameters() throws ControlLoopException {
- return new ParticipantDcaeParameterHandler().toParticipantDcaeParameters(file);
- }
}
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/configurations/ParametersConfig.java b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/ConsulEndPoints.java
index 5f2a4e4ad..ffbfa409c 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/configurations/ParametersConfig.java
+++ b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/ConsulEndPoints.java
@@ -18,24 +18,22 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.participant.kubernetes.configurations;
+package org.onap.policy.clamp.controlloop.participant.dcae.main.parameters;
-import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
-import org.onap.policy.clamp.controlloop.participant.kubernetes.parameters.ParticipantK8sParameterHandler;
-import org.onap.policy.clamp.controlloop.participant.kubernetes.parameters.ParticipantK8sParameters;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
+import javax.validation.constraints.NotBlank;
+import lombok.Getter;
+import lombok.Setter;
+import org.springframework.validation.annotation.Validated;
-@Configuration
-public class ParametersConfig {
-
- @Value("${participant.file}")
- private String file;
+/**
+ * Class to hold all end points needed for consul client.
+ *
+ */
+@Validated
+@Getter
+@Setter
+public class ConsulEndPoints {
- @Bean
- public ParticipantK8sParameters participantK8sParameters() throws ControlLoopException {
- return new ParticipantK8sParameterHandler().toParticipantK8sParameters(file);
- }
+ @NotBlank
+ private String deploy;
}
-
diff --git a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/ParticipantDcaeParameterHandler.java b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/ParticipantDcaeParameterHandler.java
deleted file mode 100644
index 689bb40c2..000000000
--- a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/ParticipantDcaeParameterHandler.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.controlloop.participant.dcae.main.parameters;
-
-import java.io.File;
-import javax.ws.rs.core.Response;
-import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
-import org.onap.policy.common.parameters.BeanValidationResult;
-import org.onap.policy.common.utils.coder.Coder;
-import org.onap.policy.common.utils.coder.CoderException;
-import org.onap.policy.common.utils.coder.StandardCoder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * This class handles reading, parsing and validating of control loop runtime parameters from JSON files.
- */
-public class ParticipantDcaeParameterHandler {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantDcaeParameterHandler.class);
-
- private static final Coder CODER = new StandardCoder();
-
- /**
- * Read the parameters from the path of the file.
- *
- * @param path path of the config file.
- * @return the parameters read from the configuration file
- * @throws ControlLoopException on parameter exceptions
- */
- public ParticipantDcaeParameters toParticipantDcaeParameters(String path) throws ControlLoopException {
- ParticipantDcaeParameters parameters = null;
- // Read the parameters
- try {
- // Read the parameters from JSON
- File file = new File(path);
- parameters = CODER.decode(file, ParticipantDcaeParameters.class);
- } catch (final CoderException e) {
- final String errorMessage =
- "error reading parameters from \"" + path + "\"\n" + "(" + e.getClass().getSimpleName() + ")";
- throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE, errorMessage, e);
- }
-
- // The JSON processing returns null if there is an empty file
- if (parameters == null) {
- final String errorMessage = "no parameters found in \"" + path + "\"";
- LOGGER.error(errorMessage);
- throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE, errorMessage);
- }
-
- // validate the parameters
- final BeanValidationResult validationResult = parameters.validate();
- if (!validationResult.isValid()) {
- final String returnMessage =
- "validation error(s) on parameters from \"" + path + "\"\n" + validationResult.getResult();
-
- LOGGER.error(returnMessage);
- throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE, returnMessage);
- }
-
- return parameters;
- }
-
-}
diff --git a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/ParticipantDcaeParameters.java b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/ParticipantDcaeParameters.java
index 469a6fe79..798781177 100644
--- a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/ParticipantDcaeParameters.java
+++ b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/ParticipantDcaeParameters.java
@@ -20,77 +20,56 @@
package org.onap.policy.clamp.controlloop.participant.dcae.main.parameters;
+import javax.validation.Valid;
+import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
import lombok.Getter;
-import org.apache.commons.lang3.StringUtils;
+import lombok.Setter;
import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantIntermediaryParameters;
-import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
-import org.onap.policy.common.parameters.BeanValidationResult;
-import org.onap.policy.common.parameters.ParameterGroupImpl;
-import org.onap.policy.common.parameters.ValidationStatus;
-import org.onap.policy.common.parameters.annotations.NotNull;
-import org.onap.policy.common.parameters.annotations.Valid;
-import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+import org.onap.policy.common.endpoints.parameters.RestClientParameters;
+import org.onap.policy.common.parameters.validation.ParameterGroupConstraint;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.validation.annotation.Validated;
/**
* Class to hold all parameters needed for the participant dcae.
*
*/
-@NotNull
-@NotBlank
+@Validated
@Getter
-public class ParticipantDcaeParameters extends ParameterGroupImpl {
+@Setter
+@ConfigurationProperties(prefix = "participant")
+public class ParticipantDcaeParameters {
- private static final String MSG_IS_BLANK = "is blank";
+ @NotNull
+ @Min(10)
+ private int checkCount = 10;
- @Valid
- private BusTopicParams clampClientParameters;
+ @NotNull
+ @Min(1)
+ private int secCount = 10;
+
+ @NotBlank
+ private String jsonBodyConsulPath;
+ @NotNull
@Valid
- private BusTopicParams consulClientParameters;
+ private ClampEndPoints clampClientEndPoints;
- private ParticipantIntermediaryParameters intermediaryParameters;
- private PolicyModelsProviderParameters databaseProviderParameters;
+ @NotNull
+ @Valid
+ private ConsulEndPoints consulClientEndPoints;
- /**
- * Create the participant dcae parameter group.
- *
- * @param name the parameter group name
- */
- public ParticipantDcaeParameters(final String name) {
- super(name);
- }
+ @NotNull
+ @ParameterGroupConstraint
+ private RestClientParameters clampClientParameters;
- /**
- * {@inheritDoc}.
- */
- @Override
- public BeanValidationResult validate() {
- BeanValidationResult result = super.validate();
- if (result.isValid()) {
- result.addResult(checkMissingMandatoryParams(clampClientParameters));
- result.addResult(checkMissingMandatoryParams(consulClientParameters));
- }
- return result;
- }
+ @NotNull
+ @ParameterGroupConstraint
+ private RestClientParameters consulClientParameters;
- private BeanValidationResult checkMissingMandatoryParams(BusTopicParams clientParameters) {
- BeanValidationResult result = new BeanValidationResult(clientParameters.getClientName(), clientParameters);
- if (clientParameters.isHostnameInvalid()) {
- result.addResult("Host", clientParameters.getHostname(), ValidationStatus.INVALID, MSG_IS_BLANK);
- }
- if (clientParameters.isClientNameInvalid()) {
- result.addResult("Name", clientParameters.getClientName(), ValidationStatus.INVALID, MSG_IS_BLANK);
- }
- if (StringUtils.isBlank(clientParameters.getPassword())) {
- result.addResult("Password", clientParameters.getPassword(), ValidationStatus.INVALID, MSG_IS_BLANK);
- }
- if (StringUtils.isBlank(clientParameters.getUserName())) {
- result.addResult("UserName", clientParameters.getUserName(), ValidationStatus.INVALID, MSG_IS_BLANK);
- }
- if (clientParameters.isPortInvalid()) {
- result.addResult("Port", clientParameters.getPort(), ValidationStatus.INVALID, "is not valid");
- }
- return result;
- }
+ @NotNull
+ @Valid
+ private ParticipantIntermediaryParameters intermediaryParameters;
}
diff --git a/participant/participant-impl/participant-impl-dcae/src/main/resources/config/DCAEParticipantConfig.json b/participant/participant-impl/participant-impl-dcae/src/main/resources/config/DCAEParticipantConfig.json
deleted file mode 100644
index a7ea089b2..000000000
--- a/participant/participant-impl/participant-impl-dcae/src/main/resources/config/DCAEParticipantConfig.json
+++ /dev/null
@@ -1,70 +0,0 @@
-{
- "name": "ControlLoopParticipantDcae",
- "clampClientParameters": {
- "clientName": "Clamp",
- "hostname": "0.0.0.0",
- "port": 8443,
- "userName": "admin",
- "password": "password",
- "useHttps": true,
- "allowSelfSignedCerts": false
- },
- "consulClientParameters": {
- "clientName": "Consul",
- "hostname": "consul",
- "port": 31321,
- "userName": "admin",
- "password": "password",
- "useHttps": false
- },
- "intermediaryParameters": {
- "name": "Participant parameters",
- "reportingTimeInterval": 120000,
- "description": "Participant Description",
- "participantId": {
- "name": "DCAEParticipant0",
- "version": "1.0.0"
- },
- "participantType": {
- "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant",
- "version": "2.3.4"
- },
- "clampControlLoopTopics": {
- "topicSources": [
- {
- "topic": "POLICY-CLRUNTIME-PARTICIPANT",
- "servers": [
- "localhost"
- ],
- "topicCommInfrastructure": "dmaap",
- "fetchTimeout": 15000
- }
- ],
- "topicSinks": [
- {
- "topic": "POLICY-CLRUNTIME-PARTICIPANT",
- "servers": [
- "localhost"
- ],
- "topicCommInfrastructure": "dmaap"
- },
- {
- "topic": "POLICY-NOTIFICATION",
- "servers": [
- "localhost"
- ],
- "topicCommInfrastructure": "dmaap"
- }
- ]
- }
- },
- "databaseProviderParameters": {
- "name": "PolicyProviderParameterGroup",
- "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
- "databaseDriver": "org.h2.Driver",
- "databaseUrl": "jdbc:h2:mem:testdb",
- "databaseUser": "policy",
- "databasePassword": "P01icY",
- "persistenceUnit": "ToscaConceptTest"
- }
-}
diff --git a/participant/participant-impl/participant-impl-dcae/src/main/resources/config/application.yaml b/participant/participant-impl/participant-impl-dcae/src/main/resources/config/application.yaml
index 58908cf8d..36b9f846a 100644
--- a/participant/participant-impl/participant-impl-dcae/src/main/resources/config/application.yaml
+++ b/participant/participant-impl/participant-impl-dcae/src/main/resources/config/application.yaml
@@ -1,3 +1,55 @@
participant:
- file: src/main/resources/config/DCAEParticipantConfig.json
+ name: ControlLoopParticipantDcae
+ clampClientEndPoints:
+ status: /restservices/clds/v2/loop/getstatus/
+ create: /restservices/clds/v2/loop/create/%s?templateName=%s
+ deploy: /restservices/clds/v2/loop/deploy/
+ stop: /restservices/clds/v2/loop/stop/
+ delete: /restservices/clds/v2/loop/delete/
+ undeploy: /restservices/clds/v2/loop/undeploy/
+ clampClientParameters:
+ clientName: Clamp
+ hostname: 0.0.0.0
+ port: 8443
+ userName: admin
+ password: password
+ https: true
+ aaf: false
+ consulClientEndPoints:
+ deploy: "/v1/kv/dcae-pmsh:"
+ consulClientParameters:
+ clientName: Consul
+ hostname: consul
+ port: 31321
+ userName: admin
+ password: password
+ https: false
+ aaf: false
+ intermediaryParameters:
+ name: Participant parameters
+ reportingTimeInterval: 120000
+ description: Participant Description
+ participantId:
+ name: DCAEParticipant0
+ version: 1.0.0
+ participantType:
+ name: org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant
+ version: 2.3.4
+ clampControlLoopTopics:
+ topicSources[0]:
+ topic: POLICY-CLRUNTIME-PARTICIPANT
+ servers[0]: ${topicServer:message-router}
+ topicCommInfrastructure: dmaap
+ fetchTimeout: 15000
+ topicSinks[0]:
+ topic: POLICY-CLRUNTIME-PARTICIPANT
+ servers[0]: ${topicServer:message-router}
+ topicCommInfrastructure: dmaap
+ topicSinks[1]:
+ topic: POLICY-NOTIFICATION
+ servers[0]: ${topicServer:message-router}
+ topicCommInfrastructure: dmaap
+ checkCount: 10
+ secCount: 10
+ jsonBodyConsulPath: src/main/resources/parameters/consul.json
diff --git a/participant/participant-impl/participant-impl-dcae/src/main/resources/parameters/consul.json b/participant/participant-impl/participant-impl-dcae/src/main/resources/parameters/consul.json
new file mode 100644
index 000000000..3aad78ee8
--- /dev/null
+++ b/participant/participant-impl/participant-impl-dcae/src/main/resources/parameters/consul.json
@@ -0,0 +1,62 @@
+{
+ "subscription": {
+ "subscriptionName": "subscriptiona",
+ "administrativeState": "UNLOCKED",
+ "fileBasedGP": 15,
+ "fileLocation": "/pm/pm.xml",
+ "nfFilter": {
+ "nfNames": [
+ "^pnf1.*"
+ ],
+ "modelInvariantIDs": [
+ "5845y423-g654-6fju-po78-8n53154532k6",
+ "7129e420-d396-4efb-af02-6b83499b12f8"
+ ],
+ "modelVersionIDs": [
+ "e80a6ae3-cafd-4d24-850d-e14c084a5ca9"
+ ]
+ },
+ "measurementGroups": [
+ {
+ "measurementGroup": {
+ "measurementTypes": [
+ {
+ "measurementType": "countera"
+ },
+ {
+ "measurementType": "counterb"
+ }
+ ],
+ "managedObjectDNsBasic": [
+ {
+ "DN": "dna"
+ },
+ {
+ "DN": "dnb"
+ }
+ ]
+ }
+ },
+ {
+ "measurementGroup": {
+ "measurementTypes": [
+ {
+ "measurementType": "counterc"
+ },
+ {
+ "measurementType": "counterd"
+ }
+ ],
+ "managedObjectDNsBasic": [
+ {
+ "DN": "dnc"
+ },
+ {
+ "DN": "dnd"
+ }
+ ]
+ }
+ }
+ ]
+ }
+}
diff --git a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/endtoend/PartecipantDcaeTest.java b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/endtoend/PartecipantDcaeTest.java
index 6d7592db0..46317729a 100644
--- a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/endtoend/PartecipantDcaeTest.java
+++ b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/endtoend/PartecipantDcaeTest.java
@@ -48,7 +48,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
-@TestPropertySource(properties = "participant.file=src/test/resources/parameters/TestParameters.json")
+@TestPropertySource(locations = {"classpath:application_test.properties"})
class PartecipantDcaeTest {
private static final CommInfrastructure INFRA = CommInfrastructure.NOOP;
diff --git a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ClampHttpClientTest.java b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ClampHttpClientTest.java
index 6e375222e..f730f36f4 100644
--- a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ClampHttpClientTest.java
+++ b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ClampHttpClientTest.java
@@ -60,9 +60,7 @@ class ClampHttpClientTest {
public static void setUp() {
CommonTestData commonTestData = new CommonTestData();
- parameters = commonTestData.toObject(
- commonTestData.getParticipantParameterGroupMap(CommonTestData.PARTICIPANT_GROUP_NAME),
- ParticipantDcaeParameters.class);
+ parameters = commonTestData.getParticipantDcaeParameters();
mockServer = ClientAndServer.startClientAndServer(parameters.getClampClientParameters().getPort());
diff --git a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ConsulDcaeHttpClientTest.java b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ConsulDcaeHttpClientTest.java
index 734919e4c..5155fed1d 100644
--- a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ConsulDcaeHttpClientTest.java
+++ b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ConsulDcaeHttpClientTest.java
@@ -48,9 +48,7 @@ class ConsulDcaeHttpClientTest {
public static void startServer() {
CommonTestData commonTestData = new CommonTestData();
- parameters = commonTestData.toObject(
- commonTestData.getParticipantParameterGroupMap(CommonTestData.PARTICIPANT_GROUP_NAME),
- ParticipantDcaeParameters.class);
+ parameters = commonTestData.getParticipantDcaeParameters();
mockServer = ClientAndServer.startClientAndServer(parameters.getConsulClientParameters().getPort());
diff --git a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/handler/ControlLoopElementHandlerTest.java b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/handler/ControlLoopElementHandlerTest.java
new file mode 100644
index 000000000..ab181d476
--- /dev/null
+++ b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/handler/ControlLoopElementHandlerTest.java
@@ -0,0 +1,144 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.controlloop.participant.dcae.main.handler;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.util.UUID;
+import org.json.JSONException;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState;
+import org.onap.policy.clamp.controlloop.participant.dcae.httpclient.ClampHttpClient;
+import org.onap.policy.clamp.controlloop.participant.dcae.httpclient.ConsulDcaeHttpClient;
+import org.onap.policy.clamp.controlloop.participant.dcae.main.parameters.CommonTestData;
+import org.onap.policy.clamp.controlloop.participant.dcae.model.Loop;
+import org.onap.policy.clamp.controlloop.participant.intermediary.api.ParticipantIntermediaryApi;
+import org.onap.policy.common.utils.coder.Coder;
+import org.onap.policy.common.utils.coder.CoderException;
+import org.onap.policy.common.utils.coder.StandardCoder;
+import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+
+/**
+ * Class to perform unit test of {@link ControlLoopElementHandler}.
+ *
+ */
+@ExtendWith(SpringExtension.class)
+class ControlLoopElementHandlerTest {
+
+ private static final String LOOP = "pmsh_loop";
+ private static final String TEMPLATE = "LOOP_TEMPLATE_k8s_pmsh";
+ private static final String BLUEPRINT_DEPLOYED = "BLUEPRINT_DEPLOYED";
+ private static final String MICROSERVICE_INSTALLED_SUCCESSFULLY = "MICROSERVICE_INSTALLED_SUCCESSFULLY";
+
+ public static final Coder CODER = new StandardCoder();
+ private CommonTestData commonTestData = new CommonTestData();
+
+ @Test
+ void test_ControlLoopElementStateChange() {
+ ClampHttpClient clampClient = spy(mock(ClampHttpClient.class));
+ ConsulDcaeHttpClient consulClient = mock(ConsulDcaeHttpClient.class);
+ ControlLoopElementHandler controlLoopElementHandler =
+ new ControlLoopElementHandler(clampClient, consulClient, commonTestData.getParticipantDcaeParameters());
+
+ when(clampClient.getstatus(eq(LOOP))).thenReturn(new Loop());
+
+ ParticipantIntermediaryApi intermediaryApi = mock(ParticipantIntermediaryApi.class);
+ controlLoopElementHandler.setIntermediaryApi(intermediaryApi);
+
+ controlLoopElementHandler.controlLoopElementStateChange(UUID.randomUUID(), ControlLoopState.PASSIVE,
+ ControlLoopOrderedState.UNINITIALISED);
+
+ verify(clampClient).undeploy(eq(LOOP));
+ }
+
+ @Test
+ void testCreate_ControlLoopElementUpdate() throws PfModelException, JSONException, CoderException {
+ ClampHttpClient clampClient = spy(mock(ClampHttpClient.class));
+ Loop loopDeployed = CODER.convert(CommonTestData.createJsonStatus(BLUEPRINT_DEPLOYED), Loop.class);
+ when(clampClient.create(eq(LOOP), eq(TEMPLATE))).thenReturn(loopDeployed);
+ when(clampClient.deploy(eq(LOOP))).thenReturn(true);
+
+ Loop loopInstalled =
+ CODER.convert(CommonTestData.createJsonStatus(MICROSERVICE_INSTALLED_SUCCESSFULLY), Loop.class);
+ when(clampClient.getstatus(eq(LOOP))).thenReturn(null, loopInstalled);
+
+ ConsulDcaeHttpClient consulClient = spy(mock(ConsulDcaeHttpClient.class));
+ when(consulClient.deploy(any(String.class), any(String.class))).thenReturn(true);
+
+ ControlLoopElementHandler controlLoopElementHandler =
+ new ControlLoopElementHandler(clampClient, consulClient, commonTestData.getParticipantDcaeParameters());
+
+ ParticipantIntermediaryApi intermediaryApi = mock(ParticipantIntermediaryApi.class);
+ controlLoopElementHandler.setIntermediaryApi(intermediaryApi);
+
+ ControlLoopElement element = new ControlLoopElement();
+ element.setId(UUID.randomUUID());
+ element.setOrderedState(ControlLoopOrderedState.PASSIVE);
+
+ final ToscaServiceTemplate controlLoopDefinition = new ToscaServiceTemplate();
+ controlLoopElementHandler.controlLoopElementUpdate(element, controlLoopDefinition);
+
+ verify(clampClient).create(eq(LOOP), eq(TEMPLATE));
+ verify(consulClient).deploy(any(String.class), any(String.class));
+ verify(clampClient).deploy(eq(LOOP));
+ }
+
+ @Test
+ void test_ControlLoopElementUpdate() throws PfModelException, JSONException, CoderException {
+ ClampHttpClient clampClient = spy(mock(ClampHttpClient.class));
+ Loop loopDeployed = CODER.convert(CommonTestData.createJsonStatus(BLUEPRINT_DEPLOYED), Loop.class);
+ Loop loopInstalled =
+ CODER.convert(CommonTestData.createJsonStatus(MICROSERVICE_INSTALLED_SUCCESSFULLY), Loop.class);
+ when(clampClient.getstatus(eq(LOOP))).thenReturn(loopDeployed, loopInstalled);
+ when(clampClient.deploy(eq(LOOP))).thenReturn(true);
+
+ ConsulDcaeHttpClient consulClient = spy(mock(ConsulDcaeHttpClient.class));
+ when(consulClient.deploy(any(String.class), any(String.class))).thenReturn(true);
+
+ ControlLoopElementHandler controlLoopElementHandler =
+ new ControlLoopElementHandler(clampClient, consulClient, commonTestData.getParticipantDcaeParameters());
+
+ ParticipantIntermediaryApi intermediaryApi = mock(ParticipantIntermediaryApi.class);
+ controlLoopElementHandler.setIntermediaryApi(intermediaryApi);
+
+ ControlLoopElement element = new ControlLoopElement();
+ element.setId(UUID.randomUUID());
+ element.setOrderedState(ControlLoopOrderedState.PASSIVE);
+
+ ToscaServiceTemplate controlLoopDefinition = new ToscaServiceTemplate();
+ controlLoopElementHandler.controlLoopElementUpdate(element, controlLoopDefinition);
+
+ verify(clampClient, times(0)).create(eq(LOOP), eq(TEMPLATE));
+ verify(consulClient).deploy(any(String.class), any(String.class));
+ verify(clampClient).deploy(eq(LOOP));
+ }
+}
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 5d8881eb3..4b6dcd619 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
@@ -31,7 +31,6 @@ import java.util.TreeMap;
import javax.ws.rs.core.Response;
import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
import org.onap.policy.common.endpoints.parameters.TopicParameters;
-import org.onap.policy.common.parameters.ParameterGroup;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
@@ -54,24 +53,19 @@ public class CommonTestData {
private static final boolean REST_CONSUL_HTTPS = false;
private static final boolean REST_CLIENT_AAF = false;
- public static final Coder coder = new StandardCoder();
+ public static final Coder CODER = new StandardCoder();
/**
- * Converts the contents of a map to a parameter class.
+ * Get ParticipantDcaeParameters.
*
- * @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
+ * @return ParticipantDcaeParameters
*/
- public <T extends ParameterGroup> T toObject(final Map<String, Object> source, final Class<T> clazz) {
+ public ParticipantDcaeParameters getParticipantDcaeParameters() {
try {
- return coder.convert(source, clazz);
-
+ return CODER.convert(getParticipantParameterGroupMap(PARTICIPANT_GROUP_NAME),
+ ParticipantDcaeParameters.class);
} catch (final CoderException e) {
- throw new ControlLoopRuntimeException(Response.Status.INTERNAL_SERVER_ERROR,
- "cannot create " + clazz.getName() + " from map", e);
+ throw new RuntimeException("cannot create ParticipantDcaeParameters from map", e);
}
}
@@ -86,10 +80,31 @@ public class CommonTestData {
final Map<String, Object> map = new TreeMap<>();
map.put("name", name);
+ map.put("checkCount", 10);
+ map.put("secCount", 10);
+ map.put("jsonBodyConsulPath", "src/main/resources/parameters/consul.json");
map.put("clampClientParameters", getClampClientParametersMap(false));
map.put("consulClientParameters", getConsulClientParametersMap(false));
map.put("intermediaryParameters", getIntermediaryParametersMap(false));
- map.put("databaseProviderParameters", getDatabaseProviderParametersMap(false));
+ map.put("clampClientEndPoints", getClampClientEndPoints());
+ map.put("consulClientEndPoints", getConsulClientEndPoints());
+ return map;
+ }
+
+ private Map<String, Object> getConsulClientEndPoints() {
+ final Map<String, Object> map = new TreeMap<>();
+ map.put("deploy", "/v1/kv/dcae-pmsh:");
+ return map;
+ }
+
+ private Map<String, Object> getClampClientEndPoints() {
+ final Map<String, Object> map = new TreeMap<>();
+ map.put("status", "/restservices/clds/v2/loop/getstatus/");
+ map.put("create", "/restservices/clds/v2/loop/create/%s?templateName=%s");
+ map.put("deploy", "/restservices/clds/v2/loop/deploy/");
+ map.put("stop", "/restservices/clds/v2/loop/stop/");
+ map.put("delete", "/restservices/clds/v2/loop/delete/");
+ map.put("undeploy", "/restservices/clds/v2/loop/undeploy/");
return map;
}
@@ -148,27 +163,6 @@ public class CommonTestData {
}
/**
- * Returns a property map for a databaseProviderParameters map for test cases.
- *
- * @param isEmpty boolean value to represent that object created should be empty or not
- * @return a property map suitable for constructing an object
- */
- public Map<String, Object> getDatabaseProviderParametersMap(final boolean isEmpty) {
- final Map<String, Object> map = new TreeMap<>();
- if (!isEmpty) {
- map.put("name", "PolicyProviderParameterGroup");
- map.put("implementation", "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl");
- map.put("databaseDriver", "org.h2.Driver");
- map.put("databaseUrl", "jdbc:h2:mem:testdb");
- map.put("databaseUser", "policy");
- map.put("databasePassword", "P01icY");
- map.put("persistenceUnit", "ToscaConceptTest");
- }
-
- return map;
- }
-
- /**
* Returns a property map for a intermediaryParameters map for test cases.
*
* @param isEmpty boolean value to represent that object created should be empty or not
@@ -229,58 +223,6 @@ public class CommonTestData {
}
/**
- * Gets the standard participant parameters.
- *
- * @param port port to be inserted into the parameters
- * @return the standard participant parameters
- * @throws ControlLoopRuntimeException on errors
- */
- public ParticipantDcaeParameters getParticipantParameterGroup(int port) {
- try {
- return coder.decode(getParticipantParameterGroupAsString(port), ParticipantDcaeParameters.class);
-
- } catch (CoderException e) {
- throw new ControlLoopRuntimeException(Response.Status.NOT_ACCEPTABLE, "cannot read participant parameters",
- e);
- }
- }
-
- /**
- * Gets the standard participant parameters, as a String.
- *
- * @param port port to be inserted into the parameters
- * @return the standard participant parameters
- * @throws ControlLoopRuntimeException on errors
- */
- public static String getParticipantParameterGroupAsString(int port) {
-
- try {
- File file = new File(getParamFile());
- String json = new String(Files.readAllBytes(file.toPath()), StandardCharsets.UTF_8);
-
- json = json.replace("${port}", String.valueOf(port));
- json = json.replace("${dbName}", "jdbc:h2:mem:testdb");
-
- return json;
-
- } catch (IOException e) {
- throw new ControlLoopRuntimeException(Response.Status.NOT_ACCEPTABLE, "cannot read participant parameters",
- e);
-
- }
- }
-
- /**
- * Gets the full path to the parameter file, which may vary depending on whether or
- * not this is an end-to-end test.
- *
- * @return the parameter file name
- */
- private static String getParamFile() {
- return "src/test/resources/parameters/TestParametersStd.json";
- }
-
- /**
* Nulls out a field within a JSON string.
*
* @param json JSON string
diff --git a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/ParticipantDcaeParametersTest.java b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/ParticipantDcaeParametersTest.java
new file mode 100644
index 000000000..b59cee756
--- /dev/null
+++ b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/ParticipantDcaeParametersTest.java
@@ -0,0 +1,163 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.controlloop.participant.dcae.main.parameters;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import javax.validation.Validation;
+import javax.validation.ValidatorFactory;
+import org.junit.jupiter.api.Test;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
+import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantIntermediaryParameters;
+
+/**
+ * Class to perform unit test of {@link ParticipantDcaeParameters}.
+ * It will be tested the "javax.validation.constraints"
+ *
+ */
+class ParticipantDcaeParametersTest {
+ private CommonTestData commonTestData = new CommonTestData();
+ private ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory();
+
+ @Test
+ void testParticipantDcaeParameters() {
+ final ParticipantDcaeParameters participantParameters = commonTestData.getParticipantDcaeParameters();
+ assertThat(validatorFactory.getValidator().validate(participantParameters)).isEmpty();
+ }
+
+ @Test
+ void testZeroCheckCount() {
+ final ParticipantDcaeParameters participantParameters = commonTestData.getParticipantDcaeParameters();
+ participantParameters.setCheckCount(0);
+ assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty();
+ }
+
+ @Test
+ void testNoClampClientEndPoints() {
+ final ParticipantDcaeParameters participantParameters = commonTestData.getParticipantDcaeParameters();
+ participantParameters.setClampClientEndPoints(null);
+ assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty();
+ }
+
+ @Test
+ void testNoClampClientEndPointCreate() {
+ final ParticipantDcaeParameters participantParameters = commonTestData.getParticipantDcaeParameters();
+ participantParameters.getClampClientEndPoints().setCreate(null);
+ assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty();
+ }
+
+ @Test
+ void testNoClampClientEndPointDelete() {
+ final ParticipantDcaeParameters participantParameters = commonTestData.getParticipantDcaeParameters();
+ participantParameters.getClampClientEndPoints().setDelete(null);
+ assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty();
+ }
+
+ @Test
+ void testNoClampClientEndPointDeploy() {
+ final ParticipantDcaeParameters participantParameters = commonTestData.getParticipantDcaeParameters();
+ participantParameters.getClampClientEndPoints().setDeploy(null);
+ assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty();
+ }
+
+ @Test
+ void testNoClampClientEndPointStatus() {
+ final ParticipantDcaeParameters participantParameters = commonTestData.getParticipantDcaeParameters();
+ participantParameters.getClampClientEndPoints().setStatus(null);
+ assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty();
+ }
+
+ @Test
+ void testNoClampClientEndPointStop() {
+ final ParticipantDcaeParameters participantParameters = commonTestData.getParticipantDcaeParameters();
+ participantParameters.getClampClientEndPoints().setStop(null);
+ assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty();
+ }
+
+ @Test
+ void testNoClampClientEndPointUndeploy() {
+ final ParticipantDcaeParameters participantParameters = commonTestData.getParticipantDcaeParameters();
+ participantParameters.getClampClientEndPoints().setUndeploy(null);
+ assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty();
+ }
+
+ @Test
+ void testNoClampClientParameters() {
+ final ParticipantDcaeParameters participantParameters = commonTestData.getParticipantDcaeParameters();
+ participantParameters.setClampClientParameters(null);
+ assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty();
+ }
+
+ @Test
+ void testNoHostname() {
+ final ParticipantDcaeParameters participantParameters = commonTestData.getParticipantDcaeParameters();
+ participantParameters.getClampClientParameters().setHostname(null);
+ assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty();
+ }
+
+ @Test
+ void testNoTopicSinks() throws ControlLoopException {
+ final ParticipantDcaeParameters participantParameters = commonTestData.getParticipantDcaeParameters();
+
+ ParticipantIntermediaryParameters intermediaryParameters = participantParameters.getIntermediaryParameters();
+ intermediaryParameters.getClampControlLoopTopics().setTopicSinks(null);
+
+ assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty();
+ }
+
+ @Test
+ void testNoTopicSources() throws ControlLoopException {
+ final ParticipantDcaeParameters participantParameters = commonTestData.getParticipantDcaeParameters();
+
+ ParticipantIntermediaryParameters intermediaryParameters = participantParameters.getIntermediaryParameters();
+ intermediaryParameters.getClampControlLoopTopics().setTopicSources(null);
+
+ assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty();
+ }
+
+ @Test
+ void testNoConsulClientParameters() {
+ final ParticipantDcaeParameters participantParameters = commonTestData.getParticipantDcaeParameters();
+ participantParameters.setConsulClientParameters(null);
+ assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty();
+ }
+
+ @Test
+ void testNoConsulHostname() {
+ final ParticipantDcaeParameters participantParameters = commonTestData.getParticipantDcaeParameters();
+ participantParameters.getConsulClientParameters().setHostname(null);
+ assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty();
+ }
+
+ @Test
+ void testNoIntermediaryParameters() {
+ final ParticipantDcaeParameters participantParameters = commonTestData.getParticipantDcaeParameters();
+ participantParameters.setIntermediaryParameters(null);
+ assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty();
+ }
+
+ @Test
+ void testNoParticipantId() {
+ final ParticipantDcaeParameters participantParameters = commonTestData.getParticipantDcaeParameters();
+ participantParameters.getIntermediaryParameters().setParticipantId(null);
+ assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty();
+ }
+}
diff --git a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/TestParticipantDcaeParameterHandler.java b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/TestParticipantDcaeParameterHandler.java
deleted file mode 100644
index 2eb833204..000000000
--- a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/TestParticipantDcaeParameterHandler.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.controlloop.participant.dcae.main.parameters;
-
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-
-import java.io.FileNotFoundException;
-import org.junit.jupiter.api.Test;
-import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
-import org.onap.policy.common.utils.coder.CoderException;
-
-
-/**
- * Class to perform unit test of {@link ParticipantParameterHandler}.
- *
- */
-class TestParticipantDcaeParameterHandler {
-
- @Test
- void testParameterHandlerNoParameterFile() throws ControlLoopException {
- final String path = "src/test/resources/parameters/NoParametersFile.json";
-
- assertThatThrownBy(() -> new ParticipantDcaeParameterHandler().toParticipantDcaeParameters(path))
- .hasCauseInstanceOf(CoderException.class)
- .hasRootCauseInstanceOf(FileNotFoundException.class);
- }
-
- @Test
- void testParameterHandlerInvalidParameters() throws ControlLoopException {
- final String path = "src/test/resources/parameters/InvalidParameters.json";
-
- assertThatThrownBy(() -> new ParticipantDcaeParameterHandler().toParticipantDcaeParameters(path))
- .hasMessageStartingWith("error reading parameters from")
- .hasCauseInstanceOf(CoderException.class);
- }
-
- @Test
- void testParticipantParameterGroup() throws ControlLoopException {
- final String path = "src/test/resources/parameters/TestParameters.json";
-
- final ParticipantDcaeParameters parGroup = new ParticipantDcaeParameterHandler()
- .toParticipantDcaeParameters(path);
- assertEquals(CommonTestData.PARTICIPANT_GROUP_NAME, parGroup.getName());
- }
-}
diff --git a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/TestParticipantDcaeParameters.java b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/TestParticipantDcaeParameters.java
deleted file mode 100644
index 2320ae07b..000000000
--- a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/TestParticipantDcaeParameters.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.controlloop.participant.dcae.main.parameters;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Map;
-import org.junit.jupiter.api.Test;
-import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantIntermediaryParameters;
-import org.onap.policy.common.endpoints.parameters.TopicParameterGroup;
-import org.onap.policy.common.parameters.ValidationResult;
-
-/**
- * Class to perform unit test of {@link ParticipantParameterGroup}.
- *
- */
-class TestParticipantDcaeParameters {
- CommonTestData commonTestData = new CommonTestData();
-
- @Test
- void testParticipantParameterGroup_Named() {
- final ParticipantDcaeParameters participantParameters = new ParticipantDcaeParameters("my-name");
- assertEquals("my-name", participantParameters.getName());
- }
-
- @Test
- void testParticipantParameterGroup() {
- final ParticipantDcaeParameters participantParameters = commonTestData.toObject(
- commonTestData.getParticipantParameterGroupMap(CommonTestData.PARTICIPANT_GROUP_NAME),
- ParticipantDcaeParameters.class);
- final ParticipantIntermediaryParameters participantIntermediaryParameters = participantParameters
- .getIntermediaryParameters();
- final TopicParameterGroup topicParameterGroup = participantParameters.getIntermediaryParameters()
- .getClampControlLoopTopics();
- final ValidationResult validationResult = participantParameters.validate();
- assertTrue(validationResult.isValid());
- assertEquals(CommonTestData.PARTICIPANT_GROUP_NAME, participantParameters.getName());
- assertEquals(CommonTestData.TIME_INTERVAL, participantIntermediaryParameters.getReportingTimeInterval());
- assertEquals(CommonTestData.DESCRIPTION, participantIntermediaryParameters.getDescription());
- assertEquals(CommonTestData.TOPIC_PARAMS, topicParameterGroup.getTopicSinks());
- assertEquals(CommonTestData.TOPIC_PARAMS, topicParameterGroup.getTopicSources());
- }
-
- @Test
- void testParticipantParameterGroup_EmptyParticipantIntermediaryParameters() {
- final Map<String, Object> map =
- commonTestData.getParticipantParameterGroupMap(CommonTestData.PARTICIPANT_GROUP_NAME);
- map.replace("intermediaryParameters", commonTestData.getIntermediaryParametersMap(true));
- final ParticipantDcaeParameters participantParameters =
- commonTestData.toObject(map, ParticipantDcaeParameters.class);
- final ValidationResult validationResult = participantParameters.validate();
- assertNull(validationResult.getResult());
- }
-
- @Test
- void testParticipantParameterGroup_EmptyTopicParameters() {
- final Map<String, Object> map =
- commonTestData.getParticipantParameterGroupMap(CommonTestData.PARTICIPANT_GROUP_NAME);
- final Map<String, Object> intermediaryParametersMap = commonTestData.getIntermediaryParametersMap(false);
- intermediaryParametersMap.put("clampControlLoopTopics", commonTestData.getTopicParametersMap(true));
- map.replace("intermediaryParameters", intermediaryParametersMap);
-
- final ParticipantDcaeParameters participantParameters =
- commonTestData.toObject(map, ParticipantDcaeParameters.class);
- final ValidationResult validationResult = participantParameters.validate();
- assertNull(validationResult.getResult());
- }
-}
diff --git a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/rest/TestListenerUtils.java b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/rest/TestListenerUtils.java
index f414b7a10..0b2712b7a 100644
--- a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/rest/TestListenerUtils.java
+++ b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/rest/TestListenerUtils.java
@@ -34,7 +34,6 @@ import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.Parti
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopUpdate;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantHealthCheck;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStateChange;
-import org.onap.policy.clamp.controlloop.participant.dcae.main.parameters.CommonTestData;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
@@ -49,7 +48,6 @@ public class TestListenerUtils {
private static final YamlJsonTranslator yamlTranslator = new YamlJsonTranslator();
private static final Coder CODER = new StandardCoder();
private static final String TOSCA_TEMPLATE_YAML = "examples/controlloop/PMSubscriptionHandling.yaml";
- static CommonTestData commonTestData = new CommonTestData();
/**
* Method to create a controlLoop from a yaml file.
diff --git a/participant/participant-impl/participant-impl-dcae/src/test/resources/application_test.properties b/participant/participant-impl/participant-impl-dcae/src/test/resources/application_test.properties
new file mode 100644
index 000000000..d585dd3c9
--- /dev/null
+++ b/participant/participant-impl/participant-impl-dcae/src/test/resources/application_test.properties
@@ -0,0 +1,41 @@
+spring.security.user.name=healthcheck
+spring.security.user.password=zb!XztG34
+
+server.servlet.context-path=/onap/participantsim
+server.error.path=/error
+
+participant.name=ControlLoopParticipant Dcae Test
+participant.clampClientParameters.clientName=Clamp
+participant.clampClientParameters.hostname=0.0.0.0
+participant.clampClientParameters.port=8443
+participant.clampClientParameters.userName=admin
+participant.clampClientParameters.password=password
+participant.clampClientParameters.https=true
+participant.clampClientParameters.aaf=false
+participant.consulClientParameters.clientName=Consul
+participant.consulClientParameters.hostname=consul
+participant.consulClientParameters.port=31321
+participant.consulClientParameters.userName=admin
+participant.consulClientParameters.password=password
+participant.consulClientParameters.https=false
+participant.consulClientParameters.aaf=false
+participant.intermediaryParameters.name=Participant parameters
+participant.intermediaryParameters.reportingTimeInterval=120000
+participant.intermediaryParameters.description=Participant Description
+participant.intermediaryParameters.participantId.name=DCAEParticipant0
+participant.intermediaryParameters.participantId.version=1.0.0
+participant.intermediaryParameters.participantType.name=org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant
+participant.intermediaryParameters.participantType.version=2.3.4
+participant.intermediaryParameters.clampControlLoopTopics.name=ControlLoop Topics
+participant.intermediaryParameters.clampControlLoopTopics.topicSources[0].topic=POLICY-CLRUNTIME-PARTICIPANT
+participant.intermediaryParameters.clampControlLoopTopics.topicSources[0].servers[0]=localhost
+participant.intermediaryParameters.clampControlLoopTopics.topicSources[0].topicCommInfrastructure=dmaap
+participant.intermediaryParameters.clampControlLoopTopics.topicSources[0].fetchTimeout=15000
+participant.intermediaryParameters.clampControlLoopTopics.topicSinks[0].topic=POLICY-CLRUNTIME-PARTICIPANT
+participant.intermediaryParameters.clampControlLoopTopics.topicSinks[0].servers[0]=localhost
+participant.intermediaryParameters.clampControlLoopTopics.topicSinks[0].topicCommInfrastructure=dmaap
+participant.intermediaryParameters.clampControlLoopTopics.topicSinks[1].topic=POLICY-NOTIFICATION
+participant.intermediaryParameters.clampControlLoopTopics.topicSinks[1].servers[0]=localhost
+participant.intermediaryParameters.clampControlLoopTopics.topicSinks[1].topicCommInfrastructure=dmaap
+
+participant.checkCount=10
diff --git a/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/InvalidParameters.json b/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/InvalidParameters.json
deleted file mode 100644
index 1035ccb67..000000000
--- a/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/InvalidParameters.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "name": "
-}
diff --git a/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/MinimumParametersH2.json b/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/MinimumParametersH2.json
deleted file mode 100644
index 1ee2955b9..000000000
--- a/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/MinimumParametersH2.json
+++ /dev/null
@@ -1,61 +0,0 @@
-{
- "name": "ControlLoopParticipantGroup",
- "restServerParameters": {
- "host": "0.0.0.0",
- "port": 6969,
- "userName": "healthcheck",
- "password": "zb!XztG34",
- "https": false,
- "aaf": false
- },
- "intermediaryParameters": {
- "name": "Participant parameters",
- "reportingTimeInterval": 120000,
- "description": "Participant Description",
- "participantId": {
- "name": "DCAEParticipant0",
- "version": "1.0.0"
- },
- "participantType": {
- "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant",
- "version": "2.3.4"
- },
- "clampControlLoopTopics": {
- "topicSources": [
- {
- "topic": "POLICY-CLRUNTIME-PARTICIPANT",
- "servers": [
- "localhost"
- ],
- "topicCommInfrastructure": "dmaap",
- "fetchTimeout": 15000
- }
- ],
- "topicSinks": [
- {
- "topic": "POLICY-CLRUNTIME-PARTICIPANT",
- "servers": [
- "localhost"
- ],
- "topicCommInfrastructure": "dmaap"
- },
- {
- "topic": "POLICY-NOTIFICATION",
- "servers": [
- "localhost"
- ],
- "topicCommInfrastructure": "dmaap"
- }
- ]
- }
- },
- "databaseProviderParameters": {
- "name": "PolicyProviderParameterGroup",
- "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
- "databaseDriver": "org.h2.Driver",
- "databaseUrl": "jdbc:h2:mem:testdb",
- "databaseUser": "policy",
- "databasePassword": "P01icY",
- "persistenceUnit": "ToscaConceptTest"
- }
-}
diff --git a/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/NoParameters.json b/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/NoParameters.json
deleted file mode 100644
index 7a73a41bf..000000000
--- a/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/NoParameters.json
+++ /dev/null
@@ -1,2 +0,0 @@
-{
-} \ No newline at end of file
diff --git a/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/TestParameters.json b/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/TestParameters.json
deleted file mode 100644
index 580eea734..000000000
--- a/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/TestParameters.json
+++ /dev/null
@@ -1,70 +0,0 @@
-{
- "name": "ControlLoopParticipantGroup",
- "clampClientParameters": {
- "clientName": "Clamp",
- "hostname": "0.0.0.0",
- "port": 8443,
- "userName": "admin",
- "password": "password",
- "useHttps": true,
- "allowSelfSignedCerts": false
- },
- "consulClientParameters": {
- "clientName": "Consul",
- "hostname": "consul",
- "port": 31321,
- "userName": "admin",
- "password": "password",
- "useHttps": false
- },
- "intermediaryParameters": {
- "name": "Participant parameters",
- "reportingTimeInterval": 120000,
- "description": "Participant Description",
- "participantId": {
- "name": "DCAEParticipant0",
- "version": "1.0.0"
- },
- "participantType": {
- "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant",
- "version": "2.3.4"
- },
- "clampControlLoopTopics": {
- "topicSources": [
- {
- "topic": "POLICY-CLRUNTIME-PARTICIPANT",
- "servers": [
- "localhost"
- ],
- "topicCommInfrastructure": "dmaap",
- "fetchTimeout": 15000
- }
- ],
- "topicSinks": [
- {
- "topic": "POLICY-CLRUNTIME-PARTICIPANT",
- "servers": [
- "localhost"
- ],
- "topicCommInfrastructure": "dmaap"
- },
- {
- "topic": "POLICY-NOTIFICATION",
- "servers": [
- "localhost"
- ],
- "topicCommInfrastructure": "dmaap"
- }
- ]
- }
- },
- "databaseProviderParameters": {
- "name": "PolicyProviderParameterGroup",
- "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
- "databaseDriver": "org.h2.Driver",
- "databaseUrl": "jdbc:h2:mem:testdb",
- "databaseUser": "policy",
- "databasePassword": "P01icY",
- "persistenceUnit": "ToscaConceptTest"
- }
-}
diff --git a/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/TestParametersStd.json b/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/TestParametersStd.json
deleted file mode 100644
index 789fc7bbd..000000000
--- a/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/TestParametersStd.json
+++ /dev/null
@@ -1,71 +0,0 @@
-{
- "name": "ControlLoopParticipantGroup",
- "clampClientParameters": {
- "name": "Clamp",
- "host": "0.0.0.0",
- "port": 8443,
- "userName": "admin",
- "password": "password",
- "https": true,
- "aaf": false
- },
- "consulClientParameters": {
- "name": "Clamp",
- "host": "consul",
- "port": 31321,
- "userName": "admin",
- "password": "password",
- "https": false,
- "aaf": false
- },
- "intermediaryParameters": {
- "name": "Participant parameters",
- "reportingTimeInterval": 120000,
- "description": "Participant Description",
- "participantId": {
- "name": "DCAEParticipant0",
- "version": "1.0.0"
- },
- "participantType": {
- "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant",
- "version": "2.3.4"
- },
- "clampControlLoopTopics": {
- "topicSources": [
- {
- "topic": "POLICY-CLRUNTIME-PARTICIPANT",
- "servers": [
- "localhost"
- ],
- "topicCommInfrastructure": "dmaap",
- "fetchTimeout": 15000
- }
- ],
- "topicSinks": [
- {
- "topic": "POLICY-CLRUNTIME-PARTICIPANT",
- "servers": [
- "localhost"
- ],
- "topicCommInfrastructure": "dmaap"
- },
- {
- "topic": "POLICY-NOTIFICATION",
- "servers": [
- "localhost"
- ],
- "topicCommInfrastructure": "dmaap"
- }
- ]
- }
- },
- "databaseProviderParameters": {
- "name": "PolicyProviderParameterGroup",
- "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
- "databaseDriver": "org.h2.Driver",
- "databaseUrl": "jdbc:h2:mem:testdb",
- "databaseUser": "policy",
- "databasePassword": "P01icY",
- "persistenceUnit": "ToscaConceptTest"
- }
-}
diff --git a/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/Unreadable.json b/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/Unreadable.json
deleted file mode 100644
index b918defe4..000000000
--- a/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/Unreadable.json
+++ /dev/null
@@ -1,61 +0,0 @@
-{
- "name": "ControlLoopRuntimeGroup",
- "restServerParameters": {
- "host": "0.0.0.0",
- "port": ${port},
- "userName": "healthcheck",
- "password": "zb!XztG34",
- "https": false,
- "aaf": false
- },
- "participantParameters": {
- "heartBeatMs": 120000,
- "updateParameters": {
- "maxRetryCount": 1,
- "maxWaitMs": 30000
- },
- "stateChangeParameters": {
- "maxRetryCount": 1,
- "maxWaitMs": 30000
- }
- },
- "databaseProviderParameters": {
- "name": "PolicyProviderParameterGroup",
- "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
- "databaseDriver": "org.h2.Driver",
- "databaseUrl": "${dbName}",
- "databaseUser": "policy",
- "databasePassword": "P01icY",
- "persistenceUnit": "ToscaConceptTest"
- },
- "topicParameterGroup": {
- "topicSources": [
- {
- "topic": "POLICY-CLRUNTIME-PARTICIPANT",
- "servers": [
- "localhost"
- ],
- "topicCommInfrastructure": "dmaap",
- "fetchTimeout": 15000
- }
- ],
- "topicSinks": [
- {
- "topic": "POLICY-CLRUNTIME-PARTICIPANT",
- "servers": [
- "localhost"
- ],
- "topicCommInfrastructure": "dmaap"
- },
- {
- "topic": "POLICY-NOTIFICATION",
- "servers": [
- "localhost"
- ],
- "topicCommInfrastructure": "dmaap"
- }
- ]
- }
-}
-
-
diff --git a/participant/participant-impl/participant-impl-kubernetes/pom.xml b/participant/participant-impl/participant-impl-kubernetes/pom.xml
index 48b56a0ee..f51e3653d 100644
--- a/participant/participant-impl/participant-impl-kubernetes/pom.xml
+++ b/participant/participant-impl/participant-impl-kubernetes/pom.xml
@@ -39,6 +39,10 @@
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-validation</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/Application.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/Application.java
index ffa0bceb9..37ecf4e6f 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/Application.java
+++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/Application.java
@@ -22,19 +22,21 @@ package org.onap.policy.clamp.controlloop.participant.kubernetes;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
/**
* Starter.
*
*/
@SpringBootApplication
+@ConfigurationPropertiesScan("org.onap.policy.clamp.controlloop.participant.kubernetes.parameters")
public class Application {
/**
* Main class.
+ *
* @param args args
*/
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
-
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/parameters/ParticipantK8sParameterHandler.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/parameters/ParticipantK8sParameterHandler.java
deleted file mode 100644
index 1a7dc35e8..000000000
--- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/parameters/ParticipantK8sParameterHandler.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.controlloop.participant.kubernetes.parameters;
-
-import java.io.File;
-import javax.ws.rs.core.Response;
-import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
-import org.onap.policy.common.parameters.BeanValidationResult;
-import org.onap.policy.common.utils.coder.Coder;
-import org.onap.policy.common.utils.coder.CoderException;
-import org.onap.policy.common.utils.coder.StandardCoder;
-
-/**
- * This class handles reading, parsing and validating of control loop participant parameters from JSON files.
- */
-public class ParticipantK8sParameterHandler {
- private static final Coder CODER = new StandardCoder();
-
- /**
- * Read the parameters from the path of the file.
- *
- * @param path path of the config file.
- * @return the parameters read from the configuration file
- * @throws ControlLoopException on parameter exceptions
- */
- public ParticipantK8sParameters toParticipantK8sParameters(String path) throws ControlLoopException {
- ParticipantK8sParameters parameters = null;
- // Read the parameters
- try {
- // Read the parameters from JSON
- var file = new File(path);
- parameters = CODER.decode(file, ParticipantK8sParameters.class);
- } catch (final CoderException e) {
- final String errorMessage =
- "error reading parameters from \"" + path + "\"\n" + "(" + e.getClass().getSimpleName() + ")";
- throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE, errorMessage, e);
- }
-
- // The JSON processing returns null if there is an empty file
- if (parameters == null) {
- final String errorMessage = "no parameters found in \"" + path + "\"";
- throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE, errorMessage);
- }
-
- // validate the parameters
- final BeanValidationResult validationResult = parameters.validate();
- if (!validationResult.isValid()) {
- String returnMessage =
- "validation error(s) on parameters from \"" + path + "\"\n" + validationResult.getResult();
- throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE, returnMessage);
- }
-
- return parameters;
- }
-}
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/parameters/ParticipantK8sParameters.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/parameters/ParticipantK8sParameters.java
index 65b32433c..54eb3b225 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/parameters/ParticipantK8sParameters.java
+++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/parameters/ParticipantK8sParameters.java
@@ -21,39 +21,31 @@
package org.onap.policy.clamp.controlloop.participant.kubernetes.parameters;
import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
import lombok.Getter;
+import lombok.Setter;
import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantIntermediaryParameters;
-import org.onap.policy.common.parameters.ParameterGroupImpl;
-import org.onap.policy.common.parameters.annotations.NotNull;
import org.onap.policy.common.parameters.annotations.Valid;
-import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.validation.annotation.Validated;
/**
* Class to hold all parameters needed for the kubernetes participant.
*
*/
-@NotNull
-@NotBlank
+@Validated
@Getter
-public class ParticipantK8sParameters extends ParameterGroupImpl {
- public static final String DEFAULT_LOCAL_CHART_DIR = "/var/helm-manager/local-charts";
- public static final String DEFAULT_INFO_FILE_NAME = "CHART_INFO.json";
+@Setter
+@ConfigurationProperties(prefix = "participant")
+public class ParticipantK8sParameters {
+ @NotNull
@Valid
private ParticipantIntermediaryParameters intermediaryParameters;
- @Valid
- private PolicyModelsProviderParameters databaseProviderParameters;
-
- private String localChartDirectory = DEFAULT_LOCAL_CHART_DIR;
- private String infoFileName = DEFAULT_INFO_FILE_NAME;
+ @NotBlank
+ private String localChartDirectory;
- /**
- * Create the kubernetes participant parameter group.
- *
- * @param name the parameter group name
- */
- public ParticipantK8sParameters(final String name) {
- super(name);
- }
+ @NotBlank
+ private String infoFileName;
}
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartStore.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartStore.java
index e7458a4cd..dcdff62f5 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartStore.java
+++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartStore.java
@@ -40,7 +40,6 @@ import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.FileSystemUtils;
import org.springframework.web.multipart.MultipartFile;
@@ -61,7 +60,7 @@ public class ChartStore {
/**
* Constructor method.
*/
- public ChartStore(@Autowired ParticipantK8sParameters participantK8sParameters) {
+ public ChartStore(ParticipantK8sParameters participantK8sParameters) {
this.participantK8sParameters = participantK8sParameters;
this.restoreFromLocalFileSystem();
}
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/KubernetesParticipantConfig.json b/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/KubernetesParticipantConfig.json
deleted file mode 100644
index e854a9375..000000000
--- a/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/KubernetesParticipantConfig.json
+++ /dev/null
@@ -1,56 +0,0 @@
-{
- "name": "ControlLoopParticipantK8s",
- "localChartDirectory": "/var/helm-manager/local-charts",
- "infoFileName": "CHART_INFO.json",
-
- "intermediaryParameters":{
- "name":"Participant parameters",
- "reportingTimeInterval":120000,
- "description":"Participant Description",
- "participantId":{
- "name":"K8sParticipant0",
- "version":"1.0.0"
- },
- "participantType":{
- "name":"org.onap.k8s.controlloop.K8SControlLoopParticipant",
- "version":"2.3.4"
- },
- "clampControlLoopTopics":{
- "topicSources":[
- {
- "topic":"POLICY-CLRUNTIME-PARTICIPANT",
- "servers":[
- "localhost"
- ],
- "topicCommInfrastructure":"dmaap",
- "fetchTimeout":15000
- }
- ],
- "topicSinks":[
- {
- "topic":"POLICY-CLRUNTIME-PARTICIPANT",
- "servers":[
- "localhost"
- ],
- "topicCommInfrastructure":"dmaap"
- },
- {
- "topic":"POLICY-NOTIFICATION",
- "servers":[
- "localhost"
- ],
- "topicCommInfrastructure":"dmaap"
- }
- ]
- }
- },
- "databaseProviderParameters":{
- "name":"PolicyProviderParameterGroup",
- "implementation":"org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
- "databaseDriver":"org.mariadb.jdbc.Driver",
- "databaseUrl":"jdbc:mariadb://localhost:3306/controlloop",
- "databaseUser":"policy",
- "databasePassword":"P01icY",
- "persistenceUnit":"ToscaConceptTest"
- }
-}
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/application.yaml b/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/application.yaml
index b4240036b..63ec8a295 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/application.yaml
+++ b/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/application.yaml
@@ -3,7 +3,32 @@ spring:
active: prod
participant:
- file: src/main/resources/config/KubernetesParticipantConfig.json
+ localChartDirectory: /var/helm-manager/local-charts
+ infoFileName: CHART_INFO.json
+ intermediaryParameters:
+ reportingTimeInterval: 120000
+ description: Participant Description
+ participantId:
+ name: K8sParticipant0
+ version: 1.0.0
+ participantType:
+ name: org.onap.k8s.controlloop.K8SControlLoopParticipant
+ version: 2.3.4
+ clampControlLoopTopics:
+ topicSources[0]:
+ topic: POLICY-CLRUNTIME-PARTICIPANT
+ servers[0]: ${topicServer:message-router}
+ topicCommInfrastructure: dmaap
+ fetchTimeout: 15000
+ topicSinks[0]:
+ topic: POLICY-CLRUNTIME-PARTICIPANT
+ servers[0]: ${topicServer:message-router}
+ topicCommInfrastructure: dmaap
+ topicSinks[1]:
+ topic: POLICY-NOTIFICATION
+ servers[0]: ${topicServer:message-router}
+ topicCommInfrastructure: dmaap
+
management:
endpoints:
web:
diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/config/ParametersConfig.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/config/ParametersConfig.java
deleted file mode 100644
index 9c65d029c..000000000
--- a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/config/ParametersConfig.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.controlloop.participant.policy.config;
-
-import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
-import org.onap.policy.clamp.controlloop.participant.policy.main.parameters.ParticipantPolicyParameterHandler;
-import org.onap.policy.clamp.controlloop.participant.policy.main.parameters.ParticipantPolicyParameters;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-@Configuration
-public class ParametersConfig {
-
- @Value("${participant.file}")
- private String file;
-
- @Bean
- public ParticipantPolicyParameters participantPolicyParameters() throws ControlLoopException {
- return new ParticipantPolicyParameterHandler().toParticipantDcaeParameters(file);
- }
-}
diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/ParticipantPolicyParameterHandler.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/ParticipantPolicyParameterHandler.java
deleted file mode 100644
index 0d8e70013..000000000
--- a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/ParticipantPolicyParameterHandler.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.controlloop.participant.policy.main.parameters;
-
-import java.io.File;
-import javax.ws.rs.core.Response;
-import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
-import org.onap.policy.common.parameters.BeanValidationResult;
-import org.onap.policy.common.utils.coder.Coder;
-import org.onap.policy.common.utils.coder.CoderException;
-import org.onap.policy.common.utils.coder.StandardCoder;
-
-/**
- * This class handles reading, parsing and validating of policy participant parameters from JSON files.
- */
-public class ParticipantPolicyParameterHandler {
-
- private static final Coder CODER = new StandardCoder();
-
- /**
- * Read the parameters from the parameter file.
- *
- * @param path the path passed to policy
- * @return the parameters read from the configuration file
- * @throws ControlLoopException on parameter exceptions
- */
- public ParticipantPolicyParameters toParticipantDcaeParameters(final String path) throws ControlLoopException {
- ParticipantPolicyParameters parameters = null;
-
- // Read the parameters
- try {
- // Read the parameters from JSON
- File file = new File(path);
- parameters = CODER.decode(file, ParticipantPolicyParameters.class);
- } catch (final CoderException e) {
- final String errorMessage =
- "error reading parameters from \"" + path + "\"\n" + "(" + e.getClass().getSimpleName() + ")";
- throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE, errorMessage, e);
- }
-
- // The JSON processing returns null if there is an empty file
- if (parameters == null) {
- throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE, "no parameters found in \"" + path + "\"");
- }
-
- // validate the parameters
- final BeanValidationResult validationResult = parameters.validate();
- if (!validationResult.isValid()) {
- final String returnMessage =
- "validation error(s) on parameters from \"" + path + "\"\n" + validationResult.getResult();
-
- throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE, returnMessage);
- }
-
- return parameters;
- }
-}
diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/ParticipantPolicyParameters.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/ParticipantPolicyParameters.java
index 490722a45..91f7ae47f 100644
--- a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/ParticipantPolicyParameters.java
+++ b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/ParticipantPolicyParameters.java
@@ -20,30 +20,32 @@
package org.onap.policy.clamp.controlloop.participant.policy.main.parameters;
-import javax.validation.constraints.NotBlank;
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
import lombok.Getter;
+import lombok.Setter;
import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantIntermediaryParameters;
-import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
-import org.onap.policy.common.parameters.ParameterGroupImpl;
-import org.onap.policy.common.parameters.annotations.NotNull;
+import org.onap.policy.common.endpoints.parameters.RestClientParameters;
+import org.onap.policy.common.parameters.validation.ParameterGroupConstraint;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.validation.annotation.Validated;
+
/**
* Class to hold all parameters needed for the policy participant.
*
*/
-@NotNull
-@NotBlank
+@Validated
@Getter
-public class ParticipantPolicyParameters extends ParameterGroupImpl {
+@Setter
+@ConfigurationProperties(prefix = "participant")
+public class ParticipantPolicyParameters {
+
+ @NotNull
+ @Valid
private ParticipantIntermediaryParameters intermediaryParameters;
- private BusTopicParams policyApiParameters;
- /**
- * Create the policy participant parameter group.
- *
- * @param name the parameter group name
- */
- public ParticipantPolicyParameters(final String name) {
- super(name);
- }
+ @NotNull
+ @ParameterGroupConstraint
+ private RestClientParameters policyApiParameters;
}
diff --git a/participant/participant-impl/participant-impl-policy/src/main/resources/config/PolicyParticipantConfig.json b/participant/participant-impl/participant-impl-policy/src/main/resources/config/PolicyParticipantConfig.json
deleted file mode 100644
index bf458fae9..000000000
--- a/participant/participant-impl/participant-impl-policy/src/main/resources/config/PolicyParticipantConfig.json
+++ /dev/null
@@ -1,53 +0,0 @@
-{
- "name": "ControlLoopParticipantGroup",
- "intermediaryParameters": {
- "name": "Participant parameters",
- "reportingTimeInterval": 120000,
- "description": "Participant Description",
- "participantType":{
- "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
- "version":"2.3.1"
- },
- "participantId": {
- "name": "org.onap.PM_Policy",
- "version": "1.0.0"
- },
- "clampControlLoopTopics": {
- "topicSources": [
- {
- "topic": "POLICY-CLRUNTIME-PARTICIPANT",
- "servers": [
- "message-router"
- ],
- "topicCommInfrastructure": "dmaap",
- "fetchTimeout": 15000
- }
- ],
- "topicSinks": [
- {
- "topic": "POLICY-CLRUNTIME-PARTICIPANT",
- "servers": [
- "message-router"
- ],
- "topicCommInfrastructure": "dmaap"
- },
- {
- "topic": "POLICY-NOTIFICATION",
- "servers": [
- "message-router"
- ],
- "topicCommInfrastructure": "dmaap"
- }
- ]
- }
- },
- "policyApiParameters": {
- "clientName": "api",
- "hostname": "policy-api",
- "port": "6969",
- "userName": "healthcheck",
- "password": "zb!XztG34",
- "https": true,
- "allowSelfSignedCerts": true
- }
-}
diff --git a/participant/participant-impl/participant-impl-policy/src/main/resources/config/application.yaml b/participant/participant-impl/participant-impl-policy/src/main/resources/config/application.yaml
index 79eca8f92..7bf4f623a 100644
--- a/participant/participant-impl/participant-impl-policy/src/main/resources/config/application.yaml
+++ b/participant/participant-impl/participant-impl-policy/src/main/resources/config/application.yaml
@@ -1,3 +1,33 @@
participant:
- file: src/main/resources/config/PolicyParticipantConfig.json
+ policyApiParameters:
+ clientName: api
+ hostname: policy-api
+ port: 6969
+ userName: healthcheck
+ password: zb!XztG34
+ https: true
+ allowSelfSignedCerts: true
+ intermediaryParameters:
+ reportingTimeInterval: 120000
+ description: Participant Description
+ participantId:
+ name: org.onap.PM_Policy
+ version: 1.0.0
+ participantType:
+ name: org.onap.policy.controlloop.PolicyControlLoopParticipant
+ version: 2.3.1
+ clampControlLoopTopics:
+ topicSources[0]:
+ topic: POLICY-CLRUNTIME-PARTICIPANT
+ servers[0]: ${topicServer:message-router}
+ topicCommInfrastructure: dmaap
+ fetchTimeout: 15000
+ topicSinks[0]:
+ topic: POLICY-CLRUNTIME-PARTICIPANT
+ servers[0]: ${topicServer:message-router}
+ topicCommInfrastructure: dmaap
+ topicSinks[1]:
+ topic: POLICY-NOTIFICATION
+ servers[0]: ${topicServer:message-router}
+ topicCommInfrastructure: dmaap
diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/endtoend/ParticipantPolicyTest.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/endtoend/ParticipantPolicyTest.java
index 2a6f4b005..d34a38103 100644
--- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/endtoend/ParticipantPolicyTest.java
+++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/endtoend/ParticipantPolicyTest.java
@@ -41,7 +41,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
-@TestPropertySource(properties = "participant.file=src/test/resources/parameters/TestParameters.json")
+@TestPropertySource(locations = {"classpath:application_test.properties"})
class ParticipantPolicyTest {
private static final Object lockit = new Object();
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 1acc2c838..38861472c 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
@@ -20,19 +20,11 @@
package org.onap.policy.clamp.controlloop.participant.policy.main.parameters;
-import java.io.File;
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
import java.util.Arrays;
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;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
@@ -47,23 +39,19 @@ public class CommonTestData {
public static final long TIME_INTERVAL = 2000;
public static final List<TopicParameters> TOPIC_PARAMS = Arrays.asList(getTopicParams());
- public static final Coder coder = new StandardCoder();
+ public static final Coder CODER = new StandardCoder();
/**
- * Converts the contents of a map to a parameter class.
+ * Get ParticipantPolicyParameters.
*
- * @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
+ * @return ParticipantPolicyParameters
*/
- public <T extends ParameterGroup> T toObject(final Map<String, Object> source, final Class<T> clazz) {
+ public ParticipantPolicyParameters getParticipantPolicyParameters() {
try {
- return coder.convert(source, clazz);
+ return CODER.convert(getParticipantPolicyParametersMap(PARTICIPANT_GROUP_NAME),
+ ParticipantPolicyParameters.class);
} catch (final CoderException e) {
- throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE,
- "cannot create " + clazz.getName() + " from map", e);
+ throw new RuntimeException("cannot create ParticipantPolicyParameters from map", e);
}
}
@@ -79,27 +67,24 @@ public class CommonTestData {
map.put("name", name);
map.put("intermediaryParameters", getIntermediaryParametersMap(false));
- map.put("databaseProviderParameters", getDatabaseProviderParametersMap(false));
+ map.put("policyApiParameters", getPolicyApiParametersMap());
return map;
}
/**
- * Returns a property map for a databaseProviderParameters map for test cases.
+ * Returns a property map for a policyApiParameters map for test cases.
*
- * @param isEmpty boolean value to represent that object created should be empty or not
* @return a property map suitable for constructing an object
*/
- public Map<String, Object> getDatabaseProviderParametersMap(final boolean isEmpty) {
+ public Map<String, Object> getPolicyApiParametersMap() {
final Map<String, Object> map = new TreeMap<>();
- if (!isEmpty) {
- map.put("name", "PolicyProviderParameterGroup");
- map.put("implementation", "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl");
- map.put("databaseDriver", "org.h2.Driver");
- map.put("databaseUrl", "jdbc:h2:mem:testdb");
- map.put("databaseUser", "policy");
- map.put("databasePassword", "P01icY");
- map.put("persistenceUnit", "ToscaConceptTest");
- }
+ map.put("clientName", "api");
+ map.put("hostname", "localhost");
+ map.put("port", 6969);
+ map.put("userName", "healthcheck");
+ map.put("password", "zb!XztG34");
+ map.put("https", false);
+ map.put("allowSelfSignedCerts", true);
return map;
}
@@ -163,59 +148,6 @@ public class CommonTestData {
}
/**
- * Gets the standard participant parameters.
- *
- * @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);
- }
- }
-
- /**
- * Gets the standard participant parameters, as a String.
- *
- * @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) {
-
- try {
- File file = new File(getParamFile());
- String json = new String(Files.readAllBytes(file.toPath()), StandardCharsets.UTF_8);
-
- json = json.replace("${port}", String.valueOf(port));
- json = json.replace("${dbName}", "jdbc:h2:mem:testdb");
-
- return json;
-
- } catch (IOException e) {
- throw new ControlLoopRuntimeException(Response.Status.NOT_ACCEPTABLE, "cannot read participant parameters",
- e);
-
- }
- }
-
- /**
- * Gets the full path to the parameter file, which may vary depending on whether or
- * not this is an end-to-end test.
- *
- * @return the parameter file name
- */
- private static String getParamFile() {
- String paramFile = "src/test/resources/parameters/TestParametersStd.json";
- return paramFile;
- }
-
- /**
* Nulls out a field within a JSON string.
*
* @param json JSON string
diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/ParticipantPolicyParametersTest.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/ParticipantPolicyParametersTest.java
new file mode 100644
index 000000000..74e7cb1bc
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/ParticipantPolicyParametersTest.java
@@ -0,0 +1,66 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.controlloop.participant.policy.main.parameters;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import javax.validation.Validation;
+import javax.validation.ValidatorFactory;
+import org.junit.jupiter.api.Test;
+
+class ParticipantPolicyParametersTest {
+ private CommonTestData commonTestData = new CommonTestData();
+ private ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory();
+
+ @Test
+ void testParticipantPolicyParameters() {
+ final ParticipantPolicyParameters participantParameters = commonTestData.getParticipantPolicyParameters();
+ assertThat(validatorFactory.getValidator().validate(participantParameters)).isEmpty();
+ }
+
+ @Test
+ void testParticipantPolicyParameters_NullTopicSinks() {
+ final ParticipantPolicyParameters participantParameters = commonTestData.getParticipantPolicyParameters();
+ participantParameters.getIntermediaryParameters().getClampControlLoopTopics().setTopicSinks(null);
+ assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty();
+ }
+
+ @Test
+ void testParticipantPolicyParameters_NullTopicSources() {
+ final ParticipantPolicyParameters participantParameters = commonTestData.getParticipantPolicyParameters();
+ participantParameters.getIntermediaryParameters().getClampControlLoopTopics().setTopicSources(null);
+ assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty();
+ }
+
+ @Test
+ void testParticipantPolicyParameters_NullPolicyApiParameters() {
+ final ParticipantPolicyParameters participantParameters = commonTestData.getParticipantPolicyParameters();
+ participantParameters.setPolicyApiParameters(null);
+ assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty();
+ }
+
+ @Test
+ void testParticipantPolicyParameters_NullHostname() {
+ final ParticipantPolicyParameters participantParameters = commonTestData.getParticipantPolicyParameters();
+ participantParameters.getPolicyApiParameters().setHostname(null);
+ assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty();
+ }
+}
diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/TestParticipantPolicyParameterHandler.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/TestParticipantPolicyParameterHandler.java
deleted file mode 100644
index 8c12a4038..000000000
--- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/TestParticipantPolicyParameterHandler.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.controlloop.participant.policy.main.parameters;
-
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-
-import java.io.FileNotFoundException;
-import org.junit.jupiter.api.Test;
-import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
-import org.onap.policy.common.utils.coder.CoderException;
-
-class TestParticipantPolicyParameterHandler {
-
- @Test
- void testParameterHandlerNoParameterFile() throws ControlLoopException {
- final String path = "src/test/resources/parameters/NoParametersFile.json";
-
- assertThatThrownBy(() -> new ParticipantPolicyParameterHandler().toParticipantDcaeParameters(path))
- .hasCauseInstanceOf(CoderException.class)
- .hasRootCauseInstanceOf(FileNotFoundException.class);
- }
-
- @Test
- void testParameterHandlerInvalidParameters() throws ControlLoopException {
- final String path = "src/test/resources/parameters/InvalidParameters.json";
-
- assertThatThrownBy(() -> new ParticipantPolicyParameterHandler().toParticipantDcaeParameters(path))
- .hasMessageStartingWith("error reading parameters from")
- .hasCauseInstanceOf(CoderException.class);
- }
-
- @Test
- void testParticipantParameterGroup() throws ControlLoopException {
- final String path = "src/test/resources/parameters/TestParameters.json";
- final ParticipantPolicyParameters parGroup = new ParticipantPolicyParameterHandler()
- .toParticipantDcaeParameters(path);
- assertEquals(CommonTestData.PARTICIPANT_GROUP_NAME, parGroup.getName());
- }
-}
diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/TestParticipantPolicyParameters.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/TestParticipantPolicyParameters.java
deleted file mode 100644
index 5ffe5101d..000000000
--- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/TestParticipantPolicyParameters.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.controlloop.participant.policy.main.parameters;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-
-import java.util.Map;
-import org.junit.Test;
-import org.onap.policy.common.parameters.ValidationResult;
-
-public class TestParticipantPolicyParameters {
- CommonTestData commonTestData = new CommonTestData();
-
- @Test
- public void testParticipantPolicyParameters_Named() {
- final ParticipantPolicyParameters participantParameters = new ParticipantPolicyParameters("my-name");
- assertEquals("my-name", participantParameters.getName());
- }
-
- @Test
- public void testParticipantPolicyParameters() {
- final ParticipantPolicyParameters participantParameters = commonTestData.toObject(
- commonTestData.getParticipantPolicyParametersMap(CommonTestData.PARTICIPANT_GROUP_NAME),
- ParticipantPolicyParameters.class);
- assertThat(participantParameters.validate().isValid()).isTrue();
- }
-
- @Test
- public void testParticipantPolicyParameters_NullName() {
- final ParticipantPolicyParameters participantParameters = commonTestData
- .toObject(commonTestData.getParticipantPolicyParametersMap(null),
- ParticipantPolicyParameters.class);
- final ValidationResult validationResult = participantParameters.validate();
- assertFalse(validationResult.isValid());
- assertEquals(null, participantParameters.getName());
- assertThat(validationResult.getResult()).contains("is null");
- }
-
- @Test
- public void testParticipantPolicyParameters_EmptyName() {
- final ParticipantPolicyParameters participantParameters = commonTestData
- .toObject(commonTestData.getParticipantPolicyParametersMap(""),
- ParticipantPolicyParameters.class);
- final ValidationResult validationResult = participantParameters.validate();
- assertFalse(validationResult.isValid());
- assertEquals("", participantParameters.getName());
- assertThat(validationResult.getResult()).contains(
- "item \"name\" value \"\" INVALID, " + "is blank");
- }
-
- @Test
- public void testParticipantPolicyParameters_SetName() {
- final ParticipantPolicyParameters participantParameters = commonTestData.toObject(
- commonTestData.getParticipantPolicyParametersMap(CommonTestData.PARTICIPANT_GROUP_NAME),
- ParticipantPolicyParameters.class);
- participantParameters.setName("ParticipantNewGroup");
- assertThat(participantParameters.validate().isValid()).isTrue();
- assertEquals("ParticipantNewGroup", participantParameters.getName());
- }
-
- @Test
- public void testParticipantPolicyParameters_EmptyParticipantIntermediaryParameters() {
- final Map<String, Object> map =
- commonTestData.getParticipantPolicyParametersMap(CommonTestData.PARTICIPANT_GROUP_NAME);
- map.replace("intermediaryParameters", commonTestData.getIntermediaryParametersMap(true));
- final ParticipantPolicyParameters participantParameters =
- commonTestData.toObject(map, ParticipantPolicyParameters.class);
- final ValidationResult validationResult = participantParameters.validate();
- assertNull(validationResult.getResult());
- }
-
- @Test
- public void testParticipantPolicyParametersp_EmptyTopicParameters() {
- final Map<String, Object> map =
- commonTestData.getParticipantPolicyParametersMap(CommonTestData.PARTICIPANT_GROUP_NAME);
- final Map<String, Object> intermediaryParametersMap = commonTestData.getIntermediaryParametersMap(false);
- intermediaryParametersMap.put("clampControlLoopTopics", commonTestData.getTopicParametersMap(true));
- map.replace("intermediaryParameters", intermediaryParametersMap);
-
- final ParticipantPolicyParameters participantParameters =
- commonTestData.toObject(map, ParticipantPolicyParameters.class);
- final ValidationResult validationResult = participantParameters.validate();
- assertNull(validationResult.getResult());
- }
-}
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/application_test.properties b/participant/participant-impl/participant-impl-policy/src/test/resources/application_test.properties
new file mode 100644
index 000000000..2f260825b
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/resources/application_test.properties
@@ -0,0 +1,27 @@
+server.servlet.context-path=/onap/participantsim
+server.error.path=/error
+
+participant.policyApiParameters.clientName=api
+participant.policyApiParameters.hostname=localhost
+participant.policyApiParameters.port=6969
+participant.policyApiParameters.userName=healthcheck
+participant.policyApiParameters.password=zb!XztG34
+participant.policyApiParameters.https=false
+participant.policyApiParameters.allowSelfSignedCerts=true
+participant.intermediaryParameters.reportingTimeInterval: 120000
+participant.intermediaryParameters.description: Participant Description
+participant.intermediaryParameters.participantId.name: org.onap.PM_Policy
+participant.intermediaryParameters.participantId.version: 1.0.0
+participant.intermediaryParameters.participantType.name: org.onap.policy.controlloop.PolicyControlLoopParticipant
+participant.intermediaryParameters.participantType.version: 2.3.1
+participant.intermediaryParameters.clampControlLoopTopics.name=ControlLoop Topics
+participant.intermediaryParameters.clampControlLoopTopics.topicSources[0].topic=POLICY-CLRUNTIME-PARTICIPANT
+participant.intermediaryParameters.clampControlLoopTopics.topicSources[0].servers[0]=localhost
+participant.intermediaryParameters.clampControlLoopTopics.topicSources[0].topicCommInfrastructure=dmaap
+participant.intermediaryParameters.clampControlLoopTopics.topicSources[0].fetchTimeout=15000
+participant.intermediaryParameters.clampControlLoopTopics.topicSinks[0].topic=POLICY-CLRUNTIME-PARTICIPANT
+participant.intermediaryParameters.clampControlLoopTopics.topicSinks[0].servers[0]=localhost
+participant.intermediaryParameters.clampControlLoopTopics.topicSinks[0].topicCommInfrastructure=dmaap
+participant.intermediaryParameters.clampControlLoopTopics.topicSinks[1].topic=POLICY-NOTIFICATION
+participant.intermediaryParameters.clampControlLoopTopics.topicSinks[1].servers[0]=localhost
+participant.intermediaryParameters.clampControlLoopTopics.topicSinks[1].topicCommInfrastructure=dmaap
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/InvalidParameters.json b/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/InvalidParameters.json
deleted file mode 100644
index 1035ccb67..000000000
--- a/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/InvalidParameters.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "name": "
-}
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/MinimumParametersH2.json b/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/MinimumParametersH2.json
deleted file mode 100644
index 30250be68..000000000
--- a/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/MinimumParametersH2.json
+++ /dev/null
@@ -1,53 +0,0 @@
-{
- "name": "ControlLoopParticipantGroup",
- "intermediaryParameters": {
- "name": "Participant parameters",
- "reportingTimeInterval": 120000,
- "description": "Participant Description",
- "participantType":{
- "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
- "version":"2.3.1"
- },
- "participantId": {
- "name": "org.onap.PM_Policy",
- "version": "1.0.0"
- },
- "clampControlLoopTopics": {
- "topicSources": [
- {
- "topic": "POLICY-CLRUNTIME-PARTICIPANT",
- "servers": [
- "localhost"
- ],
- "topicCommInfrastructure": "dmaap",
- "fetchTimeout": 15000
- }
- ],
- "topicSinks": [
- {
- "topic": "POLICY-CLRUNTIME-PARTICIPANT",
- "servers": [
- "localhost"
- ],
- "topicCommInfrastructure": "dmaap"
- },
- {
- "topic": "POLICY-NOTIFICATION",
- "servers": [
- "localhost"
- ],
- "topicCommInfrastructure": "dmaap"
- }
- ]
- }
- },
- "databaseProviderParameters": {
- "name": "PolicyProviderParameterGroup",
- "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
- "databaseDriver": "org.h2.Driver",
- "databaseUrl": "jdbc:h2:mem:testdb",
- "databaseUser": "policy",
- "databasePassword": "P01icY",
- "persistenceUnit": "ToscaConceptTest"
- }
-}
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/NoParameters.json b/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/NoParameters.json
deleted file mode 100644
index 7a73a41bf..000000000
--- a/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/NoParameters.json
+++ /dev/null
@@ -1,2 +0,0 @@
-{
-} \ No newline at end of file
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/TestParameters.json b/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/TestParameters.json
deleted file mode 100644
index 024f72d6d..000000000
--- a/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/TestParameters.json
+++ /dev/null
@@ -1,53 +0,0 @@
-{
- "name": "ControlLoopParticipantGroup",
- "intermediaryParameters": {
- "name": "Participant parameters",
- "reportingTimeInterval": 120000,
- "description": "Participant Description",
- "participantType":{
- "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
- "version":"2.3.1"
- },
- "participantId": {
- "name": "org.onap.PM_Policy",
- "version": "1.0.0"
- },
- "clampControlLoopTopics": {
- "topicSources": [
- {
- "topic": "POLICY-CLRUNTIME-PARTICIPANT",
- "servers": [
- "localhost"
- ],
- "topicCommInfrastructure": "dmaap",
- "fetchTimeout": 15000
- }
- ],
- "topicSinks": [
- {
- "topic": "POLICY-CLRUNTIME-PARTICIPANT",
- "servers": [
- "localhost"
- ],
- "topicCommInfrastructure": "dmaap"
- },
- {
- "topic": "POLICY-NOTIFICATION",
- "servers": [
- "localhost"
- ],
- "topicCommInfrastructure": "dmaap"
- }
- ]
- }
- },
- "policyApiParameters": {
- "clientName": "api",
- "hostname": "localhost",
- "port": "6969",
- "userName": "healthcheck",
- "password": "zb!XztG34",
- "https": false,
- "allowSelfSignedCerts": true
- }
-}
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/TestParametersStd.json b/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/TestParametersStd.json
deleted file mode 100644
index 79540631a..000000000
--- a/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/TestParametersStd.json
+++ /dev/null
@@ -1,53 +0,0 @@
-{
- "name": "ControlLoopParticipantGroup",
- "intermediaryParameters": {
- "name": "Participant parameters",
- "reportingTimeInterval": 120000,
- "description": "Participant Description",
- "participantType": {
- "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
- "version": "2.3.1"
- },
- "participantId": {
- "name": "org.onap.PM_Policy",
- "version": "1.0.0"
- },
- "clampControlLoopTopics": {
- "topicSources": [
- {
- "topic": "POLICY-CLRUNTIME-PARTICIPANT",
- "servers": [
- "localhost"
- ],
- "topicCommInfrastructure": "dmaap",
- "fetchTimeout": 15000
- }
- ],
- "topicSinks": [
- {
- "topic": "POLICY-CLRUNTIME-PARTICIPANT",
- "servers": [
- "localhost"
- ],
- "topicCommInfrastructure": "dmaap"
- },
- {
- "topic": "POLICY-NOTIFICATION",
- "servers": [
- "localhost"
- ],
- "topicCommInfrastructure": "dmaap"
- }
- ]
- }
- },
- "databaseProviderParameters": {
- "name": "PolicyProviderParameterGroup",
- "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
- "databaseDriver": "org.h2.Driver",
- "databaseUrl": "jdbc:h2:mem:testdb",
- "databaseUser": "policy",
- "databasePassword": "P01icY",
- "persistenceUnit": "ToscaConceptTest"
- }
-}
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/Unreadable.json b/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/Unreadable.json
deleted file mode 100644
index e33409f82..000000000
--- a/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/Unreadable.json
+++ /dev/null
@@ -1,53 +0,0 @@
-{
- "name": "ControlLoopRuntimeGroup",
- "participantParameters": {
- "heartBeatMs": 120000,
- "updateParameters": {
- "maxRetryCount": 1,
- "maxWaitMs": 30000
- },
- "stateChangeParameters": {
- "maxRetryCount": 1,
- "maxWaitMs": 30000
- }
- },
- "databaseProviderParameters": {
- "name": "PolicyProviderParameterGroup",
- "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
- "databaseDriver": "org.h2.Driver",
- "databaseUrl": "jdbc:h2:mem:testdb",
- "databaseUser": "policy",
- "databasePassword": "P01icY",
- "persistenceUnit": "ToscaConceptTest"
- },
- "topicParameterGroup": {
- "topicSources": [
- {
- "topic": "POLICY-CLRUNTIME-PARTICIPANT",
- "servers": [
- "localhost"
- ],
- "topicCommInfrastructure": "dmaap",
- "fetchTimeout": 15000
- }
- ],
- "topicSinks": [
- {
- "topic": "POLICY-CLRUNTIME-PARTICIPANT",
- "servers": [
- "localhost"
- ],
- "topicCommInfrastructure": "dmaap"
- },
- {
- "topic": "POLICY-NOTIFICATION",
- "servers": [
- "localhost"
- ],
- "topicCommInfrastructure": "dmaap"
- }
- ]
- }
-}
-
-
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/ParticipantSimulatorApplication.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/ParticipantSimulatorApplication.java
index 3aa1c36db..9f6e4aa4b 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/ParticipantSimulatorApplication.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/ParticipantSimulatorApplication.java
@@ -22,12 +22,14 @@ package org.onap.policy.clamp.controlloop.participant.simulator;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
/**
* Starter.
*
*/
@SpringBootApplication
+@ConfigurationPropertiesScan("org.onap.policy.clamp.controlloop.participant.simulator.main.parameters")
public class ParticipantSimulatorApplication {
public static void main(String[] args) {
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/ParametersConfig.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/ParametersConfig.java
deleted file mode 100644
index 936df2c57..000000000
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/ParametersConfig.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.controlloop.participant.simulator.config;
-
-import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
-import org.onap.policy.clamp.controlloop.participant.simulator.main.parameters.ParticipantSimulatorParameterHandler;
-import org.onap.policy.clamp.controlloop.participant.simulator.main.parameters.ParticipantSimulatorParameters;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-@Configuration
-public class ParametersConfig {
-
- @Value("${participant.file}")
- private String file;
-
- @Bean
- public ParticipantSimulatorParameters participantSimulatorParameters() throws ControlLoopException {
- return new ParticipantSimulatorParameterHandler().toParticipantSimulatorParameters(file);
- }
-}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/ParticipantSimulatorParameterHandler.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/ParticipantSimulatorParameterHandler.java
deleted file mode 100644
index 178d08794..000000000
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/ParticipantSimulatorParameterHandler.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.controlloop.participant.simulator.main.parameters;
-
-import java.io.File;
-import javax.ws.rs.core.Response;
-import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
-import org.onap.policy.common.parameters.BeanValidationResult;
-import org.onap.policy.common.utils.coder.Coder;
-import org.onap.policy.common.utils.coder.CoderException;
-import org.onap.policy.common.utils.coder.StandardCoder;
-
-/**
- * This class handles reading, parsing and validating of participant simulator parameters from JSON files.
- */
-public class ParticipantSimulatorParameterHandler {
-
- private static final Coder CODER = new StandardCoder();
-
- /**
- * Read the parameters from the path of the file.
- *
- * @param path path of the config file.
- * @return the parameters read from the configuration file
- * @throws ControlLoopException on parameter exceptions
- */
- public ParticipantSimulatorParameters toParticipantSimulatorParameters(String path) throws ControlLoopException {
- ParticipantSimulatorParameters parameters = null;
- // Read the parameters
- try {
- // Read the parameters from JSON
- File file = new File(path);
- parameters = CODER.decode(file, ParticipantSimulatorParameters.class);
- } catch (final CoderException e) {
- final String errorMessage = "error reading parameters from \"" + path + "\"" + System.lineSeparator() + "("
- + e.getClass().getSimpleName() + ")";
- throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE, errorMessage, e);
- }
-
- // The JSON processing returns null if there is an empty file
- if (parameters == null) {
- final String errorMessage = "no parameters found in \"" + path + "\"";
- throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE, errorMessage);
- }
-
- // validate the parameters
- final BeanValidationResult validationResult = parameters.validate();
- if (!validationResult.isValid()) {
- final String returnMessage = "validation error(s) on parameters from \"" + path + "\""
- + System.lineSeparator() + validationResult.getResult();
-
- throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE, returnMessage);
- }
-
- return parameters;
- }
-
-}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/ParticipantSimulatorParameters.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/ParticipantSimulatorParameters.java
index a4e62b446..5110ac6a6 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/ParticipantSimulatorParameters.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/ParticipantSimulatorParameters.java
@@ -20,32 +20,31 @@
package org.onap.policy.clamp.controlloop.participant.simulator.main.parameters;
-import javax.validation.constraints.NotBlank;
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
import lombok.Getter;
+import lombok.Setter;
import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantIntermediaryParameters;
-import org.onap.policy.common.endpoints.parameters.RestServerParameters;
-import org.onap.policy.common.parameters.ParameterGroupImpl;
-import org.onap.policy.common.parameters.annotations.NotNull;
+import org.onap.policy.common.parameters.validation.ParameterGroupConstraint;
import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.validation.annotation.Validated;
/**
* Class to hold all parameters needed for the participant simulator.
*
*/
-@NotNull
-@NotBlank
+@Validated
@Getter
-public class ParticipantSimulatorParameters extends ParameterGroupImpl {
- private RestServerParameters restServerParameters;
+@Setter
+@ConfigurationProperties(prefix = "participant")
+public class ParticipantSimulatorParameters {
+
+ @NotNull
+ @Valid
private ParticipantIntermediaryParameters intermediaryParameters;
- private PolicyModelsProviderParameters databaseProviderParameters;
- /**
- * Create the participant simulator parameter group.
- *
- * @param name the parameter group name
- */
- public ParticipantSimulatorParameters(final String name) {
- super(name);
- }
+ @NotNull
+ @ParameterGroupConstraint
+ private PolicyModelsProviderParameters databaseProviderParameters;
}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/ParticipantErrorController.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/ParticipantErrorController.java
index 82c1ac602..d4429b879 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/ParticipantErrorController.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/ParticipantErrorController.java
@@ -94,8 +94,4 @@ public class ParticipantErrorController implements ErrorController {
return ResponseEntity.status(getStatus(request)).body(resp);
}
-
- public String getErrorPath() {
- return path;
- }
}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/resources/config/CDSParticipantConfig.json b/participant/participant-impl/participant-impl-simulator/src/main/resources/config/CDSParticipantConfig.json
deleted file mode 100644
index 544edb1ff..000000000
--- a/participant/participant-impl/participant-impl-simulator/src/main/resources/config/CDSParticipantConfig.json
+++ /dev/null
@@ -1,61 +0,0 @@
-{
- "name": "ControlLoopParticipantGroup",
- "restServerParameters": {
- "host": "0.0.0.0",
- "port": 6969,
- "userName": "healthcheck",
- "password": "zb!XztG34",
- "https": false,
- "aaf": false
- },
- "intermediaryParameters": {
- "name": "Participant parameters",
- "reportingTimeInterval": 120000,
- "description": "Participant Description",
- "participantId": {
- "name": "org.onap.PM_CDS_Blueprint",
- "version": "1.0.0"
- },
- "participantType": {
- "name": "org.onap.PM_CDS_Blueprint",
- "version": "1.0.0"
- },
- "clampControlLoopTopics": {
- "topicSources": [
- {
- "topic": "POLICY-CLRUNTIME-PARTICIPANT",
- "servers": [
- "message-router"
- ],
- "topicCommInfrastructure": "dmaap",
- "fetchTimeout": 15000
- }
- ],
- "topicSinks": [
- {
- "topic": "POLICY-CLRUNTIME-PARTICIPANT",
- "servers": [
- "message-router"
- ],
- "topicCommInfrastructure": "dmaap"
- },
- {
- "topic": "POLICY-NOTIFICATION",
- "servers": [
- "message-router"
- ],
- "topicCommInfrastructure": "dmaap"
- }
- ]
- }
- },
- "databaseProviderParameters": {
- "name": "PolicyProviderParameterGroup",
- "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
- "databaseDriver": "org.mariadb.jdbc.Driver",
- "databaseUrl": "jdbc:mariadb://mariadb:3306/cdsparticipantsim",
- "databaseUser": "policy",
- "databasePassword": "P01icY",
- "persistenceUnit": "ToscaConceptTest"
- }
-}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/resources/config/DCAEParticipantConfig.json b/participant/participant-impl/participant-impl-simulator/src/main/resources/config/DCAEParticipantConfig.json
deleted file mode 100644
index e80570f93..000000000
--- a/participant/participant-impl/participant-impl-simulator/src/main/resources/config/DCAEParticipantConfig.json
+++ /dev/null
@@ -1,31 +0,0 @@
-{
- "name":"ParticipantParameterGroup",
- "participantStatusParameters":{
- "timeIntervalMs": 10000,
- "description":"Participant Status",
- "participantType":{
- "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant",
- "version":"2.3.4"
- },
- "participantId":{
- "name": "DCAEParticipant0",
- "version":"1.0.0"
- },
- "participantDefinition":{
- "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant",
- "version":"2.3.4"
- }
- },
- "topicParameterGroup": {
- "topicSources" : [{
- "topic" : "POLICY-CLRUNTIME-PARTICIPANT",
- "servers" : [ "127.0.0.1:3904" ],
- "topicCommInfrastructure" : "dmaap"
- }],
- "topicSinks" : [{
- "topic" : "POLICY-CLRUNTIME-PARTICIPANT",
- "servers" : [ "127.0.0.1:3904" ],
- "topicCommInfrastructure" : "dmaap"
- }]
- }
-}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/resources/config/PolicyParticipantConfig.json b/participant/participant-impl/participant-impl-simulator/src/main/resources/config/PolicyParticipantConfig.json
deleted file mode 100644
index 8c8fa33cb..000000000
--- a/participant/participant-impl/participant-impl-simulator/src/main/resources/config/PolicyParticipantConfig.json
+++ /dev/null
@@ -1,31 +0,0 @@
-{
- "name":"ParticipantParameterGroup",
- "participantStatusParameters":{
- "timeIntervalMs":10000,
- "description":"Participant Status",
- "participantType":{
- "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
- "version":"2.3.1"
- },
- "participantId":{
- "name": "PolicyParticipant0",
- "version":"1.0.0"
- },
- "participantDefinition":{
- "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
- "version":"2.3.1"
- }
- },
- "topicParameterGroup": {
- "topicSources" : [{
- "topic" : "POLICY-CLRUNTIME-PARTICIPANT",
- "servers" : [ "127.0.0.1:3904" ],
- "topicCommInfrastructure" : "dmaap"
- }],
- "topicSinks" : [{
- "topic" : "POLICY-CLRUNTIME-PARTICIPANT",
- "servers" : [ "127.0.0.1:3904" ],
- "topicCommInfrastructure" : "dmaap"
- }]
- }
-}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/resources/config/application.yaml b/participant/participant-impl/participant-impl-simulator/src/main/resources/config/application.yaml
index b1fc135a5..a45636b34 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/resources/config/application.yaml
+++ b/participant/participant-impl/participant-impl-simulator/src/main/resources/config/application.yaml
@@ -12,4 +12,34 @@ server:
path: /error
participant:
- file: src/main/resources/config/CDSParticipantConfig.json
+ intermediaryParameters:
+ reportingTimeInterval: 120000
+ description: Participant Description
+ participantId:
+ name: org.onap.PM_CDS_Blueprint
+ version: 1.0.0
+ participantType:
+ name: org.onap.PM_CDS_Blueprint
+ version: 1.0.0
+ clampControlLoopTopics:
+ topicSources[0]:
+ topic: POLICY-CLRUNTIME-PARTICIPANT
+ servers[0]: ${topicServer:message-router}
+ topicCommInfrastructure: dmaap
+ fetchTimeout: 15000
+ topicSinks[0]:
+ topic: POLICY-CLRUNTIME-PARTICIPANT
+ servers[0]: ${topicServer:message-router}
+ topicCommInfrastructure: dmaap
+ topicSinks[1]:
+ topic: POLICY-NOTIFICATION
+ servers[0]: ${topicServer:message-router}
+ topicCommInfrastructure: dmaap
+ databaseProviderParameters:
+ name: PolicyProviderParameterGroup
+ implementation: org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl
+ databaseDriver: org.mariadb.jdbc.Driver
+ databaseUrl: jdbc:mariadb://mariadb:3306/cdsparticipantsim
+ databaseUser: policy
+ databasePassword: P01icY
+ persistenceUnit: ToscaConceptTest
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/CommonTestData.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/CommonTestData.java
index 2c9b1ccd2..c53410b28 100644
--- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/CommonTestData.java
+++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/CommonTestData.java
@@ -20,19 +20,11 @@
package org.onap.policy.clamp.controlloop.participant.simulator.main.parameters;
-import java.io.File;
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
import java.util.Arrays;
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;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
@@ -46,30 +38,20 @@ public class CommonTestData {
public static final String DESCRIPTION = "Participant description";
public static final long TIME_INTERVAL = 2000;
public static final List<TopicParameters> TOPIC_PARAMS = Arrays.asList(getTopicParams());
- private static final String REST_SERVER_PASSWORD = "zb!XztG34";
- private static final String REST_SERVER_USER = "healthcheck";
- private static final int REST_SERVER_PORT = 6969;
- public static final String REST_SERVER_HOST = "0.0.0.0";
- private static final boolean REST_SERVER_HTTPS = true;
- private static final boolean REST_SERVER_AAF = false;
- public static final Coder coder = new StandardCoder();
+ public static final Coder CODER = new StandardCoder();
/**
- * Converts the contents of a map to a parameter class.
+ * Get ParticipantSimulatorParameters.
*
- * @param <T> the specific parameter group type to convert
- * @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 parameter parsing errors
+ * @return ParticipantSimulatorParameters
*/
- public <T extends ParameterGroup> T toObject(final Map<String, Object> source, final Class<T> clazz) {
+ public ParticipantSimulatorParameters getParticipantSimulatorParameters() {
try {
- return coder.convert(source, clazz);
+ return CODER.convert(getParticipantParameterGroupMap(PARTICIPANT_GROUP_NAME),
+ ParticipantSimulatorParameters.class);
} catch (final CoderException e) {
- throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE,
- "cannot create " + clazz.getName() + " from map", e);
+ throw new RuntimeException("cannot create ParticipantSimulatorParameters from map", e);
}
}
@@ -84,34 +66,12 @@ public class CommonTestData {
final Map<String, Object> map = new TreeMap<>();
map.put("name", name);
- map.put("restServerParameters", getRestServerParametersMap(false));
map.put("intermediaryParameters", getIntermediaryParametersMap(false));
map.put("databaseProviderParameters", getDatabaseProviderParametersMap(false));
return map;
}
/**
- * Returns a property map for a RestServerParameters map for test cases.
- *
- * @param isEmpty boolean value to represent that object created should be empty or not
- * @return a property map suitable for constructing an object
- */
- public Map<String, Object> getRestServerParametersMap(final boolean isEmpty) {
- final Map<String, Object> map = new TreeMap<>();
- map.put("https", REST_SERVER_HTTPS);
- map.put("aaf", REST_SERVER_AAF);
-
- if (!isEmpty) {
- map.put("host", REST_SERVER_HOST);
- map.put("port", REST_SERVER_PORT);
- map.put("userName", REST_SERVER_USER);
- map.put("password", REST_SERVER_PASSWORD);
- }
-
- return map;
- }
-
- /**
* Returns a property map for a databaseProviderParameters map for test cases.
*
* @param isEmpty boolean value to represent that object created should be empty or not
@@ -191,58 +151,6 @@ public class CommonTestData {
}
/**
- * Gets the standard participant parameters.
- *
- * @param port port to be inserted into the parameters
- * @return the standard participant parameters
- * @throws ControlLoopRuntimeException on parameter read errors
- */
- public ParticipantSimulatorParameters getParticipantParameterGroup(int port) {
- try {
- return coder.decode(getParticipantParameterGroupAsString(port), ParticipantSimulatorParameters.class);
-
- } catch (CoderException e) {
- throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, "cannot read participant parameters", e);
- }
- }
-
- /**
- * Gets the standard participant parameters, as a String.
- *
- * @param port port to be inserted into the parameters
- * @return the standard participant parameters
- * @throws ControlLoopRuntimeException on parameter read errors
- */
- public static String getParticipantParameterGroupAsString(int port) {
-
- try {
- File file = new File(getParamFile());
- String json = new String(Files.readAllBytes(file.toPath()), StandardCharsets.UTF_8);
-
- json = json.replace("${port}", String.valueOf(port));
- json = json.replace("${dbName}", "jdbc:h2:mem:testdb");
-
- return json;
-
- } catch (IOException e) {
- throw new ControlLoopRuntimeException(Response.Status.NOT_ACCEPTABLE, "cannot read participant parameters",
- e);
-
- }
- }
-
- /**
- * Gets the full path to the parameter file, which may vary depending on whether or
- * not this is an end-to-end test.
- *
- * @return the parameter file name
- */
- private static String getParamFile() {
- String paramFile = "src/test/resources/parameters/TestParametersStd.json";
- return paramFile;
- }
-
- /**
* Nulls out a field within a JSON string.
*
* @param json JSON string
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/TestParticipantSimulatorParameterHandler.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/TestParticipantSimulatorParameterHandler.java
deleted file mode 100644
index 44b49f355..000000000
--- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/TestParticipantSimulatorParameterHandler.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.controlloop.participant.simulator.main.parameters;
-
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-
-import java.io.FileNotFoundException;
-import org.apache.commons.io.DirectoryWalker.CancelException;
-import org.junit.jupiter.api.Test;
-import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
-import org.onap.policy.common.utils.coder.CoderException;
-
-/**
- * Class to perform unit test of {@link ParticipantParameterHandler}.
- */
-class TestParticipantSimulatorParameterHandler {
-
- @Test
- void testParameterHandlerNoParameterFile() throws ControlLoopException {
- final String path = "src/test/resources/parameters/NoParametersFile.json";
-
- assertThatThrownBy(() -> new ParticipantSimulatorParameterHandler().toParticipantSimulatorParameters(path))
- .hasCauseInstanceOf(CoderException.class)
- .hasRootCauseInstanceOf(FileNotFoundException.class);
- }
-
- @Test
- void testParameterHandlerInvalidParameters() throws ControlLoopException {
- final String path = "src/test/resources/parameters/InvalidParameters.json";
-
- assertThatThrownBy(() -> new ParticipantSimulatorParameterHandler().toParticipantSimulatorParameters(path))
- .hasMessageStartingWith("error reading parameters from")
- .hasCauseInstanceOf(CoderException.class);
- }
-
- @Test
- void testParameterHandlerNoParameters() throws CancelException, ControlLoopException {
- final String path = "src/test/resources/parameters/EmptyParameters.json";
-
- assertThatThrownBy(() -> new ParticipantSimulatorParameterHandler().toParticipantSimulatorParameters(path))
- .hasMessageContaining("no parameters found");
- }
-
- @Test
- void testParticipantParameterGroup() throws ControlLoopException {
- final String path = "src/test/resources/parameters/TestParameters.json";
-
- final ParticipantSimulatorParameters parGroup = new ParticipantSimulatorParameterHandler()
- .toParticipantSimulatorParameters(path);
- assertEquals(CommonTestData.PARTICIPANT_GROUP_NAME, parGroup.getName());
- }
-}
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/TestParticipantSimulatorParameters.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/TestParticipantSimulatorParameters.java
index 41c5b09b0..e5c7b5e30 100644
--- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/TestParticipantSimulatorParameters.java
+++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/TestParticipantSimulatorParameters.java
@@ -21,90 +21,49 @@
package org.onap.policy.clamp.controlloop.participant.simulator.main.parameters;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import java.util.Map;
+import javax.validation.Validation;
+import javax.validation.ValidatorFactory;
import org.junit.jupiter.api.Test;
-import org.onap.policy.common.parameters.ValidationResult;
/**
* Class to perform unit test of {@link ParticipantParameterGroup}.
*/
class TestParticipantSimulatorParameters {
- CommonTestData commonTestData = new CommonTestData();
-
- @Test
- void testParticipantParameterGroup_Named() {
- final ParticipantSimulatorParameters participantParameters = new ParticipantSimulatorParameters("my-name");
- assertEquals("my-name", participantParameters.getName());
- }
+ private CommonTestData commonTestData = new CommonTestData();
+ private ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory();
@Test
void testParticipantParameterGroup() {
- final ParticipantSimulatorParameters participantParameters = commonTestData.toObject(
- commonTestData.getParticipantParameterGroupMap(CommonTestData.PARTICIPANT_GROUP_NAME),
- ParticipantSimulatorParameters.class);
- assertThat(participantParameters.validate().isValid()).isTrue();
- assertEquals(CommonTestData.PARTICIPANT_GROUP_NAME, participantParameters.getName());
+ final ParticipantSimulatorParameters participantParameters = commonTestData.getParticipantSimulatorParameters();
+ assertThat(validatorFactory.getValidator().validate(participantParameters)).isEmpty();
}
@Test
- void testParticipantParameterGroup_NullName() {
- final ParticipantSimulatorParameters participantParameters = commonTestData
- .toObject(commonTestData.getParticipantParameterGroupMap(null),
- ParticipantSimulatorParameters.class);
- final ValidationResult validationResult = participantParameters.validate();
- assertFalse(validationResult.isValid());
- assertEquals(null, participantParameters.getName());
- assertThat(validationResult.getResult()).contains("is null");
- }
-
- @Test
- void testParticipantParameterGroup_EmptyName() {
- final ParticipantSimulatorParameters participantParameters = commonTestData
- .toObject(commonTestData.getParticipantParameterGroupMap(""),
- ParticipantSimulatorParameters.class);
- final ValidationResult validationResult = participantParameters.validate();
- assertFalse(validationResult.isValid());
- assertEquals("", participantParameters.getName());
- assertThat(validationResult.getResult()).contains(
- "item \"name\" value \"\" INVALID, " + "is blank");
+ void testParticipantParameterGroup_EmptyParticipantIntermediaryParameters() {
+ final ParticipantSimulatorParameters participantParameters = commonTestData.getParticipantSimulatorParameters();
+ participantParameters.setIntermediaryParameters(null);
+ assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty();
}
@Test
- void testParticipantParameterGroup_SetName() {
- final ParticipantSimulatorParameters participantParameters = commonTestData.toObject(
- commonTestData.getParticipantParameterGroupMap(CommonTestData.PARTICIPANT_GROUP_NAME),
- ParticipantSimulatorParameters.class);
- participantParameters.setName("ParticipantNewGroup");
- assertThat(participantParameters.validate().isValid()).isTrue();
- assertEquals("ParticipantNewGroup", participantParameters.getName());
+ void testParticipantParameterGroup_EmptyDatabaseProviderParameters() {
+ final ParticipantSimulatorParameters participantParameters = commonTestData.getParticipantSimulatorParameters();
+ participantParameters.setDatabaseProviderParameters(null);
+ assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty();
}
@Test
- void testParticipantParameterGroup_EmptyParticipantIntermediaryParameters() {
- final Map<String, Object> map =
- commonTestData.getParticipantParameterGroupMap(CommonTestData.PARTICIPANT_GROUP_NAME);
- map.replace("intermediaryParameters", commonTestData.getIntermediaryParametersMap(true));
- final ParticipantSimulatorParameters participantParameters =
- commonTestData.toObject(map, ParticipantSimulatorParameters.class);
- final ValidationResult validationResult = participantParameters.validate();
- assertNull(validationResult.getResult());
+ void testParticipantPolicyParameters_NullTopicSinks() {
+ final ParticipantSimulatorParameters participantParameters = commonTestData.getParticipantSimulatorParameters();
+ participantParameters.getIntermediaryParameters().getClampControlLoopTopics().setTopicSinks(null);
+ assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty();
}
@Test
- void testParticipantParameterGroupp_EmptyTopicParameters() {
- final Map<String, Object> map =
- commonTestData.getParticipantParameterGroupMap(CommonTestData.PARTICIPANT_GROUP_NAME);
- final Map<String, Object> intermediaryParametersMap = commonTestData.getIntermediaryParametersMap(false);
- intermediaryParametersMap.put("clampControlLoopTopics", commonTestData.getTopicParametersMap(true));
- map.replace("intermediaryParameters", intermediaryParametersMap);
-
- final ParticipantSimulatorParameters participantParameters =
- commonTestData.toObject(map, ParticipantSimulatorParameters.class);
- final ValidationResult validationResult = participantParameters.validate();
- assertNull(validationResult.getResult());
+ void testParticipantPolicyParameters_NullTopicSources() {
+ final ParticipantSimulatorParameters participantParameters = commonTestData.getParticipantSimulatorParameters();
+ participantParameters.getIntermediaryParameters().getClampControlLoopTopics().setTopicSources(null);
+ assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty();
}
}
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/resources/application_test.properties b/participant/participant-impl/participant-impl-simulator/src/test/resources/application_test.properties
index c31bb9d6b..89c57bb12 100644
--- a/participant/participant-impl/participant-impl-simulator/src/test/resources/application_test.properties
+++ b/participant/participant-impl/participant-impl-simulator/src/test/resources/application_test.properties
@@ -4,4 +4,32 @@ spring.security.user.password=zb!XztG34
server.servlet.context-path=/onap/participantsim
server.error.path=/error
-participant.file=src/test/resources/parameters/TestParameters.json
+participant.restServerParameters.host=0.0.0.0
+participant.restServerParameters.port=6969
+participant.restServerParameters.userName=healthcheck
+participant.restServerParameters.password=zb!XztG34
+participant.restServerParameters.https=false
+participant.restServerParameters.aaf=false
+participant.intermediaryParameters.reportingTimeInterval=120000
+participant.intermediaryParameters.description=Participant Description
+participant.intermediaryParameters.participantId.name=org.onap.PM_CDS_Blueprint
+participant.intermediaryParameters.participantId.version=1.0.0
+participant.intermediaryParameters.participantType.name=org.onap.PM_CDS_Blueprint
+participant.intermediaryParameters.participantType.version=1.0.0
+participant.intermediaryParameters.clampControlLoopTopics.topicSources[0].topic=POLICY-CLRUNTIME-PARTICIPANT
+participant.intermediaryParameters.clampControlLoopTopics.topicSources[0].servers[0]=localhost
+participant.intermediaryParameters.clampControlLoopTopics.topicSources[0].topicCommInfrastructure=dmaap
+participant.intermediaryParameters.clampControlLoopTopics.topicSources[0].fetchTimeout=15000
+participant.intermediaryParameters.clampControlLoopTopics.topicSinks[0].topic=POLICY-CLRUNTIME-PARTICIPANT
+participant.intermediaryParameters.clampControlLoopTopics.topicSinks[0].servers[0]=localhost
+participant.intermediaryParameters.clampControlLoopTopics.topicSinks[0].topicCommInfrastructure=dmaap
+participant.intermediaryParameters.clampControlLoopTopics.topicSinks[1].topic=POLICY-NOTIFICATION
+participant.intermediaryParameters.clampControlLoopTopics.topicSinks[1].servers[0]=localhost
+participant.intermediaryParameters.clampControlLoopTopics.topicSinks[1].topicCommInfrastructure=dmaap
+participant.databaseProviderParameters.name=PolicyProviderParameterGroup
+participant.databaseProviderParameters.implementation=org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl
+participant.databaseProviderParameters.databaseDriver=org.h2.Driver
+participant.databaseProviderParameters.databaseUrl=jdbc:h2:mem:testdb
+participant.databaseProviderParameters.databaseUser=policy
+participant.databaseProviderParameters.databasePassword=P01icY
+participant.databaseProviderParameters.persistenceUnit=ToscaConceptTest
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/EmptyParameters.json b/participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/EmptyParameters.json
deleted file mode 100644
index e69de29bb..000000000
--- a/participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/EmptyParameters.json
+++ /dev/null
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/InvalidParameters.json b/participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/InvalidParameters.json
deleted file mode 100644
index 1035ccb67..000000000
--- a/participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/InvalidParameters.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "name": "
-}
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/NoParameters.json b/participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/NoParameters.json
deleted file mode 100644
index 7a73a41bf..000000000
--- a/participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/NoParameters.json
+++ /dev/null
@@ -1,2 +0,0 @@
-{
-} \ No newline at end of file
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/TestParameters.json b/participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/TestParameters.json
deleted file mode 100644
index 8c594044b..000000000
--- a/participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/TestParameters.json
+++ /dev/null
@@ -1,61 +0,0 @@
-{
- "name": "ControlLoopParticipantGroup",
- "restServerParameters": {
- "host": "0.0.0.0",
- "port": 6969,
- "userName": "healthcheck",
- "password": "zb!XztG34",
- "https": false,
- "aaf": false
- },
- "intermediaryParameters": {
- "name": "Participant parameters",
- "reportingTimeInterval": 120000,
- "description": "Participant Description",
- "participantId": {
- "name": "org.onap.PM_CDS_Blueprint",
- "version": "1.0.0"
- },
- "participantType": {
- "name": "org.onap.PM_CDS_Blueprint",
- "version": "1.0.0"
- },
- "clampControlLoopTopics": {
- "topicSources": [
- {
- "topic": "POLICY-CLRUNTIME-PARTICIPANT",
- "servers": [
- "localhost"
- ],
- "topicCommInfrastructure": "dmaap",
- "fetchTimeout": 15000
- }
- ],
- "topicSinks": [
- {
- "topic": "POLICY-CLRUNTIME-PARTICIPANT",
- "servers": [
- "localhost"
- ],
- "topicCommInfrastructure": "dmaap"
- },
- {
- "topic": "POLICY-NOTIFICATION",
- "servers": [
- "localhost"
- ],
- "topicCommInfrastructure": "dmaap"
- }
- ]
- }
- },
- "databaseProviderParameters": {
- "name": "PolicyProviderParameterGroup",
- "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
- "databaseDriver": "org.h2.Driver",
- "databaseUrl": "jdbc:h2:mem:testdb",
- "databaseUser": "policy",
- "databasePassword": "P01icY",
- "persistenceUnit": "ToscaConceptTest"
- }
-}
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/TestParametersStd.json b/participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/TestParametersStd.json
deleted file mode 100644
index 0295a8f91..000000000
--- a/participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/TestParametersStd.json
+++ /dev/null
@@ -1,61 +0,0 @@
-{
- "name": "ControlLoopParticipantGroup",
- "restServerParameters": {
- "host": "0.0.0.0",
- "port": ${port},
- "userName": "healthcheck",
- "password": "zb!XztG34",
- "https": false,
- "aaf": false
- },
- "intermediaryParameters": {
- "name": "Participant parameters",
- "reportingTimeInterval": 120000,
- "description": "Participant Description",
- "participantId": {
- "name": "org.onap.PM_CDS_Blueprint",
- "version": "1.0.0"
- },
- "participantType": {
- "name": "org.onap.PM_CDS_Blueprint",
- "version": "1.0.0"
- },
- "clampControlLoopTopics": {
- "topicSources": [
- {
- "topic": "POLICY-CLRUNTIME-PARTICIPANT",
- "servers": [
- "localhost"
- ],
- "topicCommInfrastructure": "dmaap",
- "fetchTimeout": 15000
- }
- ],
- "topicSinks": [
- {
- "topic": "POLICY-CLRUNTIME-PARTICIPANT",
- "servers": [
- "localhost"
- ],
- "topicCommInfrastructure": "dmaap"
- },
- {
- "topic": "POLICY-NOTIFICATION",
- "servers": [
- "localhost"
- ],
- "topicCommInfrastructure": "dmaap"
- }
- ]
- }
- },
- "databaseProviderParameters": {
- "name": "PolicyProviderParameterGroup",
- "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
- "databaseDriver": "org.h2.Driver",
- "databaseUrl": "jdbc:h2:mem:testdb",
- "databaseUser": "policy",
- "databasePassword": "P01icY",
- "persistenceUnit": "ToscaConceptTest"
- }
-}
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/Unreadable.json b/participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/Unreadable.json
deleted file mode 100644
index fc36b49e4..000000000
--- a/participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/Unreadable.json
+++ /dev/null
@@ -1,61 +0,0 @@
-{
- "name": "ControlLoopRuntimeGroup",
- "restServerParameters": {
- "host": "0.0.0.0",
- "port": 6969,
- "userName": "healthcheck",
- "password": "zb!XztG34",
- "https": false,
- "aaf": false
- },
- "participantParameters": {
- "heartBeatMs": 120000,
- "updateParameters": {
- "maxRetryCount": 1,
- "maxWaitMs": 30000
- },
- "stateChangeParameters": {
- "maxRetryCount": 1,
- "maxWaitMs": 30000
- }
- },
- "databaseProviderParameters": {
- "name": "PolicyProviderParameterGroup",
- "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
- "databaseDriver": "org.h2.Driver",
- "databaseUrl": "jdbc:h2:mem:testdb",
- "databaseUser": "policy",
- "databasePassword": "P01icY",
- "persistenceUnit": "ToscaConceptTest"
- },
- "topicParameterGroup": {
- "topicSources": [
- {
- "topic": "POLICY-CLRUNTIME-PARTICIPANT",
- "servers": [
- "localhost"
- ],
- "topicCommInfrastructure": "dmaap",
- "fetchTimeout": 15000
- }
- ],
- "topicSinks": [
- {
- "topic": "POLICY-CLRUNTIME-PARTICIPANT",
- "servers": [
- "localhost"
- ],
- "topicCommInfrastructure": "dmaap"
- },
- {
- "topic": "POLICY-NOTIFICATION",
- "servers": [
- "localhost"
- ],
- "topicCommInfrastructure": "dmaap"
- }
- ]
- }
-}
-
-
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java
index 18ee29f08..3eebd177f 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java
@@ -95,7 +95,7 @@ public class ControlLoopHandler implements Closeable {
* @return controlLoopElement the updated controlloop element
*/
public ControlLoopElement updateControlLoopElementState(UUID id, ControlLoopOrderedState orderedState,
- ControlLoopState newState) {
+ ControlLoopState newState) {
if (id == null) {
return null;
@@ -161,7 +161,7 @@ public class ControlLoopHandler implements Closeable {
* @param orderedState controlloop ordered state
*/
private void handleState(final ControlLoop controlLoop, final ParticipantResponseDetails response,
- ControlLoopOrderedState orderedState) {
+ ControlLoopOrderedState orderedState) {
switch (orderedState) {
case UNINITIALISED:
handleUninitialisedState(controlLoop, orderedState, response);
@@ -197,8 +197,8 @@ public class ControlLoopHandler implements Closeable {
// elements to existing ControlLoop has to be supported).
if (controlLoop != null) {
response.setResponseStatus(ParticipantResponseStatus.FAIL);
- response.setResponseMessage(
- "Control loop " + updateMsg.getControlLoopId() + " already defined on participant " + participantId);
+ response.setResponseMessage("Control loop " + updateMsg.getControlLoopId()
+ + " already defined on participant " + participantId);
messageSender.sendResponse(response);
return;
@@ -226,7 +226,7 @@ public class ControlLoopHandler implements Closeable {
response.setResponseStatus(ParticipantResponseStatus.SUCCESS);
response.setResponseMessage(
- "Control loop " + updateMsg.getControlLoopId() + " defined on participant " + participantId);
+ "Control loop " + updateMsg.getControlLoopId() + " defined on participant " + participantId);
messageSender.sendResponse(response);
}
@@ -239,7 +239,7 @@ public class ControlLoopHandler implements Closeable {
* @param response participant response
*/
private void handleUninitialisedState(final ControlLoop controlLoop, final ControlLoopOrderedState orderedState,
- final ParticipantResponseDetails response) {
+ final ParticipantResponseDetails response) {
handleStateChange(controlLoop, orderedState, ControlLoopState.UNINITIALISED, response);
controlLoopMap.remove(controlLoop.getKey().asIdentifier());
@@ -262,7 +262,7 @@ public class ControlLoopHandler implements Closeable {
* @param response participant response
*/
private void handlePassiveState(final ControlLoop controlLoop, final ControlLoopOrderedState orderedState,
- final ParticipantResponseDetails response) {
+ final ParticipantResponseDetails response) {
handleStateChange(controlLoop, orderedState, ControlLoopState.PASSIVE, response);
}
@@ -274,7 +274,7 @@ public class ControlLoopHandler implements Closeable {
* @param response participant response
*/
private void handleRunningState(final ControlLoop controlLoop, final ControlLoopOrderedState orderedState,
- final ParticipantResponseDetails response) {
+ final ParticipantResponseDetails response) {
handleStateChange(controlLoop, orderedState, ControlLoopState.RUNNING, response);
}
@@ -287,7 +287,7 @@ public class ControlLoopHandler implements Closeable {
* @param response the response to the state change request
*/
private void handleStateChange(ControlLoop controlLoop, final ControlLoopOrderedState orderedState,
- ControlLoopState newState, ParticipantResponseDetails response) {
+ ControlLoopState newState, ParticipantResponseDetails response) {
if (orderedState.equals(controlLoop.getOrderedState())) {
response.setResponseStatus(ParticipantResponseStatus.SUCCESS);
@@ -304,7 +304,7 @@ public class ControlLoopHandler implements Closeable {
response.setResponseStatus(ParticipantResponseStatus.SUCCESS);
response.setResponseMessage(
- "ControlLoop state changed from " + controlLoop.getOrderedState() + " to " + orderedState);
+ "ControlLoop state changed from " + controlLoop.getOrderedState() + " to " + orderedState);
controlLoop.setOrderedState(orderedState);
}
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java
index 913c050e3..5e414b175 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java
@@ -111,15 +111,14 @@ public class ParticipantHandler implements Closeable {
default:
LOGGER.debug("StateChange message has no state, state is null {}", stateChangeMsg.getParticipantId());
response.setResponseStatus(ParticipantResponseStatus.FAIL);
- response.setResponseMessage("StateChange message has invalid state for participantId "
- + stateChangeMsg.getParticipantId());
+ response.setResponseMessage(
+ "StateChange message has invalid state for participantId " + stateChangeMsg.getParticipantId());
break;
}
sender.sendResponse(response);
}
-
/**
* Method which handles a participant health check event from clamp.
*
@@ -196,8 +195,7 @@ public class ParticipantHandler implements Closeable {
* @param participantState participant state
* @return the participant
*/
- public Participant updateParticipantState(ToscaConceptIdentifier definition,
- ParticipantState participantState) {
+ public Participant updateParticipantState(ToscaConceptIdentifier definition, ParticipantState participantState) {
if (!Objects.equals(definition, participantId)) {
LOGGER.debug("No participant with this ID {}", definition.getName());
return null;
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/parameters/ParticipantIntermediaryParameters.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/parameters/ParticipantIntermediaryParameters.java
index 8e3440e42..5627abfe6 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/parameters/ParticipantIntermediaryParameters.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/parameters/ParticipantIntermediaryParameters.java
@@ -20,39 +20,39 @@
package org.onap.policy.clamp.controlloop.participant.intermediary.parameters;
+import javax.validation.Valid;
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
import lombok.Getter;
+import lombok.Setter;
import org.onap.policy.common.endpoints.parameters.TopicParameterGroup;
-import org.onap.policy.common.parameters.ParameterGroupImpl;
-import org.onap.policy.common.parameters.annotations.NotBlank;
-import org.onap.policy.common.parameters.annotations.NotNull;
+import org.onap.policy.common.parameters.validation.ParameterGroupConstraint;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
/**
* Class to hold all parameters needed for participant component.
*/
-@NotNull
-@NotBlank
@Getter
-public class ParticipantIntermediaryParameters extends ParameterGroupImpl {
+@Setter
+public class ParticipantIntermediaryParameters {
+
// The ID and description of this participant
+ @NotNull
+ @Valid
private ToscaConceptIdentifier participantId;
+
+ @NotBlank
private String description;
// The participant type of this participant
+ @NotNull
+ @Valid
private ToscaConceptIdentifier participantType;
// The time interval for periodic reporting of status to the CLAMP control loop server
private long reportingTimeInterval;
- // DMaaP topics for communicating with the CLAMP control loop server
+ @NotNull
+ @ParameterGroupConstraint
private TopicParameterGroup clampControlLoopTopics;
-
- /**
- * Create the participant parameter group.
- *
- * @param instanceId instance id of the event.
- */
- public ParticipantIntermediaryParameters(final String instanceId) {
- super(instanceId);
- }
}