aboutsummaryrefslogtreecommitdiffstats
path: root/participant/participant-impl
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2021-06-21 16:45:27 +0100
committerFrancescoFioraEst <francesco.fiora@est.tech>2021-06-28 10:36:54 +0100
commit7f7f0c5790dc63e43a59c53154e796239ab34cbb (patch)
tree39a8682b04502e99bc8575ec636613de193ade03 /participant/participant-impl
parent077406d881b8b03456f76d246a4db44d13780999 (diff)
Convert Intermediary Participant to Spring and refactor Participants
Issue-ID: POLICY-3370 Change-Id: I1541fc47b35c91f9ec86ab768bc3cec2cd78647c Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'participant/participant-impl')
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/config/ParticipantConfig.java16
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/ParticipantDcaeParameters.java3
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/endtoend/PartecipantDcaeTest.java30
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/configurations/ParticipantIntermediaryConfig.java19
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/handler/ControlLoopElementHandler.java3
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/parameters/ParticipantK8sParameters.java3
-rw-r--r--participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/config/ParticipantConfig.java24
-rw-r--r--participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/ParticipantPolicyParameters.java4
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/endtoend/ParticipantPolicyTest.java28
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/ParticipantSimulatorApplication.java3
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/ParticipantConfig.java16
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/ParticipantSimulatorParameters.java11
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/resources/config/application.yaml8
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/endtoend/ParticipantSimulatorTest.java6
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/CommonTestData.java23
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/TestParticipantSimulatorParameters.java7
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/resources/application_test.properties7
17 files changed, 61 insertions, 150 deletions
diff --git a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/config/ParticipantConfig.java b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/config/ParticipantConfig.java
index ff828abab..965c3f143 100644
--- a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/config/ParticipantConfig.java
+++ b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/config/ParticipantConfig.java
@@ -21,29 +21,23 @@
package org.onap.policy.clamp.controlloop.participant.dcae.config;
import org.onap.policy.clamp.controlloop.participant.dcae.main.handler.ControlLoopElementHandler;
-import org.onap.policy.clamp.controlloop.participant.dcae.main.parameters.ParticipantDcaeParameters;
import org.onap.policy.clamp.controlloop.participant.intermediary.api.ParticipantIntermediaryApi;
-import org.onap.policy.clamp.controlloop.participant.intermediary.api.ParticipantIntermediaryFactory;
-import org.springframework.context.annotation.Bean;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
@Configuration
public class ParticipantConfig {
/**
- * Create ParticipantIntermediaryApi.
+ * Register ControlLoopElementListener.
*
- * @param parameters the Participant Dcae Parameters
+ * @param intermediaryApi the ParticipantIntermediaryApi
* @param clElementHandler the ControlLoop Element Handler
- * @return ParticipantIntermediaryApi
*/
- @Bean
- public ParticipantIntermediaryApi participantIntermediaryApi(ParticipantDcaeParameters parameters,
+ @Autowired
+ public void registerControlLoopElementListener(ParticipantIntermediaryApi intermediaryApi,
ControlLoopElementHandler clElementHandler) {
- ParticipantIntermediaryApi intermediaryApi = new ParticipantIntermediaryFactory().createApiImplementation();
- intermediaryApi.init(parameters.getIntermediaryParameters());
intermediaryApi.registerControlLoopElementListener(clElementHandler);
clElementHandler.setIntermediaryApi(intermediaryApi);
- return intermediaryApi;
}
}
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 798781177..1ef9e2fdd 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
@@ -27,6 +27,7 @@ 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.clamp.controlloop.participant.intermediary.parameters.ParticipantParameters;
import org.onap.policy.common.endpoints.parameters.RestClientParameters;
import org.onap.policy.common.parameters.validation.ParameterGroupConstraint;
import org.springframework.boot.context.properties.ConfigurationProperties;
@@ -40,7 +41,7 @@ import org.springframework.validation.annotation.Validated;
@Getter
@Setter
@ConfigurationProperties(prefix = "participant")
-public class ParticipantDcaeParameters {
+public class ParticipantDcaeParameters implements ParticipantParameters {
@NotNull
@Min(10)
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 46317729a..a96581e6c 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
@@ -35,9 +35,9 @@ 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.participant.dcae.main.parameters.CommonTestData;
import org.onap.policy.clamp.controlloop.participant.dcae.main.rest.TestListenerUtils;
-import org.onap.policy.clamp.controlloop.participant.intermediary.api.ParticipantIntermediaryApi;
import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ControlLoopStateChangeListener;
import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ControlLoopUpdateListener;
+import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.utils.coder.CoderException;
import org.springframework.beans.factory.annotation.Autowired;
@@ -61,7 +61,7 @@ class PartecipantDcaeTest {
private static ClientAndServer mockConsulServer;
@Autowired
- private ParticipantIntermediaryApi participantIntermediaryApi;
+ private ParticipantHandler participantHandler;
/**
* start Servers.
@@ -107,8 +107,7 @@ class PartecipantDcaeTest {
TestListenerUtils.createControlLoopStateChangeMsg(ControlLoopOrderedState.UNINITIALISED);
participantControlLoopStateChangeMsg.setOrderedState(ControlLoopOrderedState.PASSIVE);
- ControlLoopStateChangeListener clStateChangeListener =
- new ControlLoopStateChangeListener(participantIntermediaryApi.getParticipantHandler());
+ ControlLoopStateChangeListener clStateChangeListener = new ControlLoopStateChangeListener(participantHandler);
clStateChangeListener.onTopicEvent(INFRA, TOPIC, null, participantControlLoopStateChangeMsg);
assertEquals(ControlLoopOrderedState.PASSIVE, participantControlLoopStateChangeMsg.getOrderedState());
@@ -128,13 +127,12 @@ class PartecipantDcaeTest {
participantControlLoopUpdateMsg.getParticipantId().setName("DummyName");
participantControlLoopUpdateMsg.getControlLoop().setOrderedState(ControlLoopOrderedState.PASSIVE);
- ControlLoopUpdateListener clUpdateListener =
- new ControlLoopUpdateListener(participantIntermediaryApi.getParticipantHandler());
+ ControlLoopUpdateListener clUpdateListener = new ControlLoopUpdateListener(participantHandler);
clUpdateListener.onTopicEvent(INFRA, TOPIC, null, participantControlLoopUpdateMsg);
// Verify the content in participantHandler
assertNotEquals(participantControlLoopUpdateMsg.getParticipantId().getName(),
- participantIntermediaryApi.getParticipantHandler().getParticipantId().getName());
+ participantHandler.getParticipantId().getName());
}
@Test
@@ -142,15 +140,12 @@ class PartecipantDcaeTest {
ParticipantControlLoopUpdate participantControlLoopUpdateMsg = TestListenerUtils.createControlLoopUpdateMsg();
participantControlLoopUpdateMsg.getControlLoop().setOrderedState(ControlLoopOrderedState.PASSIVE);
- ControlLoopUpdateListener clUpdateListener =
- new ControlLoopUpdateListener(participantIntermediaryApi.getParticipantHandler());
+ ControlLoopUpdateListener clUpdateListener = new ControlLoopUpdateListener(participantHandler);
clUpdateListener.onTopicEvent(INFRA, TOPIC, null, participantControlLoopUpdateMsg);
// Verify the content in participantHandler
- assertEquals(participantIntermediaryApi.getParticipantHandler().getParticipantId(),
- participantControlLoopUpdateMsg.getParticipantId());
- assertEquals(1, participantIntermediaryApi.getParticipantHandler().getControlLoopHandler().getControlLoops()
- .getControlLoopList().size());
+ assertEquals(participantHandler.getParticipantId(), participantControlLoopUpdateMsg.getParticipantId());
+ assertEquals(1, participantHandler.getControlLoopHandler().getControlLoops().getControlLoopList().size());
}
@Test
@@ -158,14 +153,11 @@ class PartecipantDcaeTest {
ParticipantControlLoopUpdate participantControlLoopUpdateMsg = TestListenerUtils.createControlLoopUpdateMsg();
participantControlLoopUpdateMsg.getControlLoop().setOrderedState(ControlLoopOrderedState.UNINITIALISED);
- ControlLoopUpdateListener clUpdateListener =
- new ControlLoopUpdateListener(participantIntermediaryApi.getParticipantHandler());
+ ControlLoopUpdateListener clUpdateListener = new ControlLoopUpdateListener(participantHandler);
clUpdateListener.onTopicEvent(INFRA, TOPIC, null, participantControlLoopUpdateMsg);
// Verify the content in participantHandler
- assertEquals(participantIntermediaryApi.getParticipantHandler().getParticipantId(),
- participantControlLoopUpdateMsg.getParticipantId());
- assertEquals(1, participantIntermediaryApi.getParticipantHandler().getControlLoopHandler().getControlLoops()
- .getControlLoopList().size());
+ assertEquals(participantHandler.getParticipantId(), participantControlLoopUpdateMsg.getParticipantId());
+ assertEquals(1, participantHandler.getControlLoopHandler().getControlLoops().getControlLoopList().size());
}
}
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/configurations/ParticipantIntermediaryConfig.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/configurations/ParticipantIntermediaryConfig.java
index d8c39925b..bfbed66b7 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/configurations/ParticipantIntermediaryConfig.java
+++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/configurations/ParticipantIntermediaryConfig.java
@@ -21,28 +21,23 @@
package org.onap.policy.clamp.controlloop.participant.kubernetes.configurations;
import org.onap.policy.clamp.controlloop.participant.intermediary.api.ParticipantIntermediaryApi;
-import org.onap.policy.clamp.controlloop.participant.intermediary.api.ParticipantIntermediaryFactory;
import org.onap.policy.clamp.controlloop.participant.kubernetes.handler.ControlLoopElementHandler;
-import org.onap.policy.clamp.controlloop.participant.kubernetes.parameters.ParticipantK8sParameters;
-import org.springframework.context.annotation.Bean;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
@Configuration
public class ParticipantIntermediaryConfig {
/**
- * Create ParticipantIntermediaryApi.
+ * Register ControlLoopElementListener.
*
- * @param parameters the K8s Participant Parameters
+ * @param intermediaryApi the ParticipantIntermediaryApi
* @param clElementHandler the ControlLoop Element Handler
- * @return ParticipantIntermediaryApi
*/
- @Bean
- public ParticipantIntermediaryApi participantIntermediaryApi(ParticipantK8sParameters parameters,
- ControlLoopElementHandler clElementHandler) {
- ParticipantIntermediaryApi intermediaryApi = new ParticipantIntermediaryFactory().createApiImplementation();
- intermediaryApi.init(parameters.getIntermediaryParameters());
+ @Autowired
+ public void registerControlLoopElementListener(ParticipantIntermediaryApi intermediaryApi,
+ ControlLoopElementHandler clElementHandler) {
intermediaryApi.registerControlLoopElementListener(clElementHandler);
- return intermediaryApi;
+ clElementHandler.setIntermediaryApi(intermediaryApi);
}
}
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/handler/ControlLoopElementHandler.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/handler/ControlLoopElementHandler.java
index 5f1dcb8d4..6257c3d19 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/handler/ControlLoopElementHandler.java
+++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/handler/ControlLoopElementHandler.java
@@ -26,6 +26,7 @@ import java.lang.invoke.MethodHandles;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
+import lombok.Setter;
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;
@@ -52,7 +53,7 @@ public class ControlLoopElementHandler implements ControlLoopElementListener {
@Autowired
private ChartService chartService;
- @Autowired
+ @Setter
private ParticipantIntermediaryApi intermediaryApi;
// Map of CLElement Id and installed Helm charts
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 54eb3b225..a5731da74 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
@@ -25,6 +25,7 @@ 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.clamp.controlloop.participant.intermediary.parameters.ParticipantParameters;
import org.onap.policy.common.parameters.annotations.Valid;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.validation.annotation.Validated;
@@ -37,7 +38,7 @@ import org.springframework.validation.annotation.Validated;
@Getter
@Setter
@ConfigurationProperties(prefix = "participant")
-public class ParticipantK8sParameters {
+public class ParticipantK8sParameters implements ParticipantParameters {
@NotNull
@Valid
diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/config/ParticipantConfig.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/config/ParticipantConfig.java
index 3b8324151..7b49a9a6b 100644
--- a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/config/ParticipantConfig.java
+++ b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/config/ParticipantConfig.java
@@ -21,29 +21,23 @@
package org.onap.policy.clamp.controlloop.participant.policy.config;
import org.onap.policy.clamp.controlloop.participant.intermediary.api.ParticipantIntermediaryApi;
-import org.onap.policy.clamp.controlloop.participant.intermediary.api.ParticipantIntermediaryFactory;
import org.onap.policy.clamp.controlloop.participant.policy.main.handler.ControlLoopElementHandler;
-import org.onap.policy.clamp.controlloop.participant.policy.main.parameters.ParticipantPolicyParameters;
-import org.springframework.context.annotation.Bean;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
@Configuration
public class ParticipantConfig {
/**
- * Create ParticipantIntermediaryApi.
+ * Register ControlLoopElementListener.
*
- * @param parameters the Participant Policy Parameters
- * @param controlLoopElementHandler the ControlLoop Element Handler
- * @return ParticipantIntermediaryApi
+ * @param intermediaryApi the ParticipantIntermediaryApi
+ * @param clElementHandler the ControlLoop Element Handler
*/
- @Bean
- public ParticipantIntermediaryApi participantIntermediaryApi(ParticipantPolicyParameters parameters,
- ControlLoopElementHandler controlLoopElementHandler) {
- ParticipantIntermediaryApi intermediaryApi = new ParticipantIntermediaryFactory().createApiImplementation();
- intermediaryApi.init(parameters.getIntermediaryParameters());
- intermediaryApi.registerControlLoopElementListener(controlLoopElementHandler);
- controlLoopElementHandler.setIntermediaryApi(intermediaryApi);
- return intermediaryApi;
+ @Autowired
+ public void registerControlLoopElementListener(ParticipantIntermediaryApi intermediaryApi,
+ ControlLoopElementHandler clElementHandler) {
+ intermediaryApi.registerControlLoopElementListener(clElementHandler);
+ clElementHandler.setIntermediaryApi(intermediaryApi);
}
}
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 91f7ae47f..ced9d1bd0 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
@@ -25,12 +25,12 @@ 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.clamp.controlloop.participant.intermediary.parameters.ParticipantParameters;
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.
*
@@ -39,7 +39,7 @@ import org.springframework.validation.annotation.Validated;
@Getter
@Setter
@ConfigurationProperties(prefix = "participant")
-public class ParticipantPolicyParameters {
+public class ParticipantPolicyParameters implements ParticipantParameters {
@NotNull
@Valid
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 d34a38103..6b8323971 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
@@ -28,9 +28,9 @@ import org.junit.jupiter.api.extension.ExtendWith;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopStateChange;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopUpdate;
-import org.onap.policy.clamp.controlloop.participant.intermediary.api.ParticipantIntermediaryApi;
import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ControlLoopStateChangeListener;
import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ControlLoopUpdateListener;
+import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler;
import org.onap.policy.clamp.controlloop.participant.policy.main.utils.TestListenerUtils;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.springframework.beans.factory.annotation.Autowired;
@@ -49,7 +49,7 @@ class ParticipantPolicyTest {
private static final String TOPIC = "my-topic";
@Autowired
- private ParticipantIntermediaryApi participantIntermediaryApi;
+ private ParticipantHandler participantHandler;
@Test
void testUpdatePolicyTypes() {
@@ -60,14 +60,12 @@ class ParticipantPolicyTest {
assertNotNull(participantControlLoopUpdateMsg.getControlLoopDefinition().getPolicyTypes());
synchronized (lockit) {
- ControlLoopUpdateListener clUpdateListener =
- new ControlLoopUpdateListener(participantIntermediaryApi.getParticipantHandler());
+ ControlLoopUpdateListener clUpdateListener = new ControlLoopUpdateListener(participantHandler);
clUpdateListener.onTopicEvent(INFRA, TOPIC, null, participantControlLoopUpdateMsg);
}
// Verify the result of GET participants with what is stored
- assertEquals("org.onap.PM_Policy",
- participantIntermediaryApi.getParticipantHandler().getParticipantId().getName());
+ assertEquals("org.onap.PM_Policy", participantHandler.getParticipantId().getName());
}
@Test
@@ -83,14 +81,12 @@ class ParticipantPolicyTest {
participantControlLoopUpdateMsg.getControlLoopDefinition().getToscaTopologyTemplate().getPolicies());
synchronized (lockit) {
- ControlLoopUpdateListener clUpdateListener =
- new ControlLoopUpdateListener(participantIntermediaryApi.getParticipantHandler());
+ ControlLoopUpdateListener clUpdateListener = new ControlLoopUpdateListener(participantHandler);
clUpdateListener.onTopicEvent(INFRA, TOPIC, null, participantControlLoopUpdateMsg);
}
// Verify the result of GET participants with what is stored
- assertEquals("org.onap.PM_Policy",
- participantIntermediaryApi.getParticipantHandler().getParticipantId().getName());
+ assertEquals("org.onap.PM_Policy", participantHandler.getParticipantId().getName());
}
@Test
@@ -106,24 +102,20 @@ class ParticipantPolicyTest {
participantControlLoopUpdateMsg.getControlLoopDefinition().getToscaTopologyTemplate().getPolicies());
synchronized (lockit) {
- ControlLoopUpdateListener clUpdateListener =
- new ControlLoopUpdateListener(participantIntermediaryApi.getParticipantHandler());
+ ControlLoopUpdateListener clUpdateListener = new ControlLoopUpdateListener(participantHandler);
clUpdateListener.onTopicEvent(INFRA, TOPIC, null, participantControlLoopUpdateMsg);
}
// Verify the result of GET participants with what is stored
- assertEquals("org.onap.PM_Policy",
- participantIntermediaryApi.getParticipantHandler().getParticipantId().getName());
+ assertEquals("org.onap.PM_Policy", participantHandler.getParticipantId().getName());
- ControlLoopStateChangeListener clStateChangeListener =
- new ControlLoopStateChangeListener(participantIntermediaryApi.getParticipantHandler());
+ ControlLoopStateChangeListener clStateChangeListener = new ControlLoopStateChangeListener(participantHandler);
ParticipantControlLoopStateChange participantControlLoopStateChangeMsg =
TestListenerUtils.createControlLoopStateChangeMsg(ControlLoopOrderedState.UNINITIALISED);
participantControlLoopStateChangeMsg.setOrderedState(ControlLoopOrderedState.UNINITIALISED);
clStateChangeListener.onTopicEvent(INFRA, TOPIC, null, participantControlLoopStateChangeMsg);
// Verify the result of GET participants with what is stored
- assertEquals("org.onap.PM_Policy",
- participantIntermediaryApi.getParticipantHandler().getParticipantId().getName());
+ assertEquals("org.onap.PM_Policy", participantHandler.getParticipantId().getName());
}
}
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 9f6e4aa4b..8267df477 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
@@ -23,6 +23,7 @@ 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;
+import org.springframework.context.annotation.ComponentScan;
/**
* Starter.
@@ -30,6 +31,8 @@ import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
*/
@SpringBootApplication
@ConfigurationPropertiesScan("org.onap.policy.clamp.controlloop.participant.simulator.main.parameters")
+@ComponentScan({"org.onap.policy.clamp.controlloop.participant.simulator",
+ "org.onap.policy.clamp.controlloop.participant.intermediary"})
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/ParticipantConfig.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/ParticipantConfig.java
index f4e6791ec..c890ec247 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/ParticipantConfig.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/ParticipantConfig.java
@@ -20,9 +20,6 @@
package org.onap.policy.clamp.controlloop.participant.simulator.config;
-import org.onap.policy.clamp.controlloop.participant.intermediary.api.ParticipantIntermediaryApi;
-import org.onap.policy.clamp.controlloop.participant.intermediary.api.ParticipantIntermediaryFactory;
-import org.onap.policy.clamp.controlloop.participant.simulator.main.parameters.ParticipantSimulatorParameters;
import org.onap.policy.clamp.controlloop.participant.simulator.main.rest.RequestResponseLoggingFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
@@ -32,19 +29,6 @@ import org.springframework.context.annotation.Configuration;
public class ParticipantConfig {
/**
- * Create ParticipantIntermediaryApi.
- *
- * @param parameters the Participant Dcae Parameters
- * @return ParticipantIntermediaryApi
- */
- @Bean
- public ParticipantIntermediaryApi participantIntermediaryApi(ParticipantSimulatorParameters parameters) {
- ParticipantIntermediaryApi intermediaryApi = new ParticipantIntermediaryFactory().createApiImplementation();
- intermediaryApi.init(parameters.getIntermediaryParameters());
- return intermediaryApi;
- }
-
- /**
* logging Filter configuration.
*
* @return FilterRegistrationBean
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 5110ac6a6..99579006c 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
@@ -25,8 +25,7 @@ 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.validation.ParameterGroupConstraint;
-import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantParameters;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.validation.annotation.Validated;
@@ -38,13 +37,9 @@ import org.springframework.validation.annotation.Validated;
@Getter
@Setter
@ConfigurationProperties(prefix = "participant")
-public class ParticipantSimulatorParameters {
+public class ParticipantSimulatorParameters implements ParticipantParameters {
- @NotNull
@Valid
- private ParticipantIntermediaryParameters intermediaryParameters;
-
@NotNull
- @ParameterGroupConstraint
- private PolicyModelsProviderParameters databaseProviderParameters;
+ private ParticipantIntermediaryParameters intermediaryParameters;
}
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 a45636b34..82e3b89f1 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
@@ -35,11 +35,3 @@ participant:
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/endtoend/ParticipantSimulatorTest.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/endtoend/ParticipantSimulatorTest.java
index 46495f7c3..0b63c395a 100644
--- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/endtoend/ParticipantSimulatorTest.java
+++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/endtoend/ParticipantSimulatorTest.java
@@ -40,6 +40,7 @@ import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.Parti
import org.onap.policy.clamp.controlloop.models.messages.rest.TypedSimpleResponse;
import org.onap.policy.clamp.controlloop.participant.intermediary.api.ParticipantIntermediaryApi;
import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ControlLoopUpdateListener;
+import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler;
import org.onap.policy.clamp.controlloop.participant.simulator.main.parameters.CommonTestData;
import org.onap.policy.clamp.controlloop.participant.simulator.main.rest.AbstractRestController;
import org.onap.policy.clamp.controlloop.participant.simulator.main.rest.TestListenerUtils;
@@ -89,6 +90,9 @@ class ParticipantSimulatorTest {
@Autowired
private ParticipantIntermediaryApi participantIntermediaryApi;
+ @Autowired
+ private ParticipantHandler participantHandler;
+
private static final Object lockit = new Object();
private boolean check = false;
@@ -97,7 +101,7 @@ class ParticipantSimulatorTest {
if (!check) {
check = true;
ControlLoopUpdateListener clUpdateListener =
- new ControlLoopUpdateListener(participantIntermediaryApi.getParticipantHandler());
+ new ControlLoopUpdateListener(participantHandler);
ParticipantControlLoopUpdate participantControlLoopUpdateMsg =
TestListenerUtils.createControlLoopUpdateMsg();
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 c53410b28..e85b3ebbe 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
@@ -65,30 +65,7 @@ public class CommonTestData {
public Map<String, Object> getParticipantParameterGroupMap(final String name) {
final Map<String, Object> map = new TreeMap<>();
- map.put("name", name);
map.put("intermediaryParameters", getIntermediaryParametersMap(false));
- map.put("databaseProviderParameters", getDatabaseProviderParametersMap(false));
- 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
- * @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;
}
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 e5c7b5e30..3c1d1c2a3 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
@@ -47,13 +47,6 @@ class TestParticipantSimulatorParameters {
}
@Test
- void testParticipantParameterGroup_EmptyDatabaseProviderParameters() {
- final ParticipantSimulatorParameters participantParameters = commonTestData.getParticipantSimulatorParameters();
- participantParameters.setDatabaseProviderParameters(null);
- assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty();
- }
-
- @Test
void testParticipantPolicyParameters_NullTopicSinks() {
final ParticipantSimulatorParameters participantParameters = commonTestData.getParticipantSimulatorParameters();
participantParameters.getIntermediaryParameters().getClampControlLoopTopics().setTopicSinks(null);
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 89c57bb12..2b30c4ffd 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
@@ -26,10 +26,3 @@ participant.intermediaryParameters.clampControlLoopTopics.topicSinks[0].topicCom
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