aboutsummaryrefslogtreecommitdiffstats
path: root/participant/participant-impl/participant-impl-dcae
diff options
context:
space:
mode:
Diffstat (limited to 'participant/participant-impl/participant-impl-dcae')
-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
3 files changed, 18 insertions, 31 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());
}
}