summaryrefslogtreecommitdiffstats
path: root/participant/participant-impl
diff options
context:
space:
mode:
authorSirisha_Manchikanti <sirisha.manchikanti@est.tech>2021-08-03 17:49:00 +0100
committerSirisha_Manchikanti <sirisha.manchikanti@est.tech>2021-08-04 14:35:55 +0100
commit2c094b95c86f3315e359d971fbfa0ad60d173053 (patch)
treebd4b33f1e28ad3fad8769b3a36a51e4f89a63dea /participant/participant-impl
parent055fa4ad38a11bb5890b6e0ea280e9b96a1b2a39 (diff)
Update controlloop messages
Updated controlloop messages according to https://wiki.onap.org/display/DW/The+CLAMP+Control+Loop+Participant+Protocol Issue-ID: POLICY-3417 Signed-off-by: Sirisha_Manchikanti <sirisha.manchikanti@est.tech> Change-Id: Ied32ea5bb63a6b69286d03f1a7b2b86e3acad7a7
Diffstat (limited to 'participant/participant-impl')
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/rest/TestListenerUtils.java24
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/endtoend/ParticipantMessagesTest.java65
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/utils/TestListenerUtils.java25
3 files changed, 62 insertions, 52 deletions
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 bb1021db6..136d0e500 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
@@ -32,7 +32,6 @@ import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopStateChange;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopUpdate;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantHealthCheck;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
@@ -170,29 +169,6 @@ public class TestListenerUtils {
}
/**
- * Method to create ParticipantHealthCheck message.
- *
- * @return ParticipantHealthCheck message
- */
- public static ParticipantHealthCheck createParticipantHealthCheckMsg() {
- ToscaConceptIdentifier participantId = new ToscaConceptIdentifier();
- participantId.setName("DCAEParticipant0");
- participantId.setVersion("1.0.0");
-
- ToscaConceptIdentifier controlLoopId = new ToscaConceptIdentifier();
- controlLoopId.setName("PMSHInstance0");
- controlLoopId.setVersion("1.0.0");
-
- final ParticipantHealthCheck participantHealthCheckMsg = new ParticipantHealthCheck();
- participantHealthCheckMsg.setParticipantId(participantId);
- participantHealthCheckMsg.setControlLoopId(controlLoopId);
- participantHealthCheckMsg.setTimestamp(Instant.now());
- participantHealthCheckMsg.setState(ParticipantState.PASSIVE);
-
- return participantHealthCheckMsg;
- }
-
- /**
* Method to create ControlLoopUpdate using the arguments passed.
*
* @param jsonFilePath the path of the controlloop content
diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/endtoend/ParticipantMessagesTest.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/endtoend/ParticipantMessagesTest.java
index 093ac190c..aed03556a 100644
--- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/endtoend/ParticipantMessagesTest.java
+++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/endtoend/ParticipantMessagesTest.java
@@ -24,15 +24,22 @@ import static org.assertj.core.api.Assertions.assertThatCode;
import java.time.Instant;
import java.util.Collections;
+import java.util.List;
+import java.util.Map;
import java.util.UUID;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mockito;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatisticsList;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElementDefinition;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopInfo;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopStatistics;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantDeregister;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantDeregisterAck;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantRegister;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantRegisterAck;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantResponseDetails;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStatus;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdate;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdateAck;
@@ -45,6 +52,7 @@ import org.onap.policy.clamp.controlloop.participant.policy.main.utils.TestListe
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
@@ -146,9 +154,16 @@ class ParticipantMessagesTest {
@Test
void testParticipantStatusHeartbeat() throws Exception {
final ParticipantStatus heartbeat = new ParticipantStatus();
- heartbeat.setMessage("ParticipantStatus message");
- heartbeat.setResponse(new ParticipantResponseDetails());
heartbeat.setParticipantId(getParticipantId());
+ ControlLoopInfo clInfo = getControlLoopInfo(getControlLoopId());
+ heartbeat.setControlLoopInfoMap(Map.of(getControlLoopId(), clInfo));
+
+ ControlLoopElementDefinition clDefinition = getClElementDefinition();
+ Map<UUID, ControlLoopElementDefinition> clElementDefinitionMap = Map.of(UUID.randomUUID(), clDefinition);
+ Map<ToscaConceptIdentifier, Map<UUID, ControlLoopElementDefinition>>
+ participantDefinitionUpdateMap = Map.of(getParticipantId(), clElementDefinitionMap);
+ heartbeat.setParticipantDefinitionUpdateMap(participantDefinitionUpdateMap);
+
synchronized (lockit) {
ParticipantMessagePublisher publisher =
new ParticipantMessagePublisher(Collections.singletonList(Mockito.mock(TopicSink.class)));
@@ -156,7 +171,6 @@ class ParticipantMessagesTest {
}
}
-
private ToscaConceptIdentifier getParticipantId() {
return new ToscaConceptIdentifier("org.onap.PM_Policy", "1.0.0");
}
@@ -164,4 +178,47 @@ class ParticipantMessagesTest {
private ToscaConceptIdentifier getParticipantType() {
return new ToscaConceptIdentifier("org.onap.policy.controlloop.PolicyControlLoopParticipant", "2.3.1");
}
+
+ private ToscaConceptIdentifier getControlLoopId() {
+ return new ToscaConceptIdentifier("PMSHInstance0", "1.0.0");
+ }
+
+ private ControlLoopInfo getControlLoopInfo(ToscaConceptIdentifier id) {
+ ControlLoopInfo clInfo = new ControlLoopInfo();
+ clInfo.setState(ControlLoopState.PASSIVE2RUNNING);
+
+ ControlLoopStatistics clStatistics = new ControlLoopStatistics();
+ clStatistics.setControlLoopId(id);
+ clStatistics.setAverageExecutionTime(12345);
+ clStatistics.setEventCount(12345);
+ clStatistics.setLastEnterTime(12345);
+ clStatistics.setLastExecutionTime(12345);
+ clStatistics.setLastStart(12345);
+ clStatistics.setTimeStamp(Instant.ofEpochMilli(3000));
+ clStatistics.setUpTime(12345);
+ ClElementStatisticsList clElementStatisticsList = new ClElementStatisticsList();
+ ClElementStatistics clElementStatistics = new ClElementStatistics();
+ clElementStatistics.setParticipantId(new ToscaConceptIdentifier("defName", "0.0.1"));
+ clElementStatistics.setTimeStamp(Instant.now());
+ clElementStatisticsList.setClElementStatistics(List.of(clElementStatistics));
+ clStatistics.setClElementStatisticsList(clElementStatisticsList);
+
+ clInfo.setControlLoopStatistics(clStatistics);
+ return clInfo;
+ }
+
+ private ControlLoopElementDefinition getClElementDefinition() {
+ ToscaServiceTemplate toscaServiceTemplate = new ToscaServiceTemplate();
+ toscaServiceTemplate.setName("serviceTemplate");
+ toscaServiceTemplate.setDerivedFrom("parentServiceTemplate");
+ toscaServiceTemplate.setDescription("Description of serviceTemplate");
+ toscaServiceTemplate.setVersion("1.2.3");
+
+ ControlLoopElementDefinition clDefinition = new ControlLoopElementDefinition();
+ clDefinition.setId(UUID.randomUUID());
+ clDefinition.setControlLoopElementToscaServiceTemplate(toscaServiceTemplate);
+ Map<String, String> commonPropertiesMap = Map.of("Prop1", "PropValue");
+ clDefinition.setCommonPropertiesMap(commonPropertiesMap);
+ return clDefinition;
+ }
}
diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/utils/TestListenerUtils.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/utils/TestListenerUtils.java
index fe7e17fd7..b91cff22c 100644
--- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/utils/TestListenerUtils.java
+++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/utils/TestListenerUtils.java
@@ -37,7 +37,6 @@ import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopStateChange;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopUpdate;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantHealthCheck;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdate;
import org.onap.policy.clamp.controlloop.participant.policy.main.parameters.CommonTestData;
import org.onap.policy.common.utils.coder.Coder;
@@ -156,6 +155,7 @@ public class TestListenerUtils {
clElementParticipantId.setName(toscaInputEntry.getKey());
clElementParticipantId.setVersion(toscaInputEntry.getValue().getVersion());
clElement.setParticipantId(clElementParticipantId);
+ clElement.setParticipantType(clElementParticipantId);
clElement.setDefinition(clElementParticipantId);
clElement.setState(ControlLoopState.UNINITIALISED);
@@ -210,29 +210,6 @@ public class TestListenerUtils {
}
/**
- * Method to create ParticipantHealthCheck message.
- *
- * @return ParticipantHealthCheck message
- */
- public static ParticipantHealthCheck createParticipantHealthCheckMsg() {
- ToscaConceptIdentifier participantId = new ToscaConceptIdentifier();
- participantId.setName("org.onap.PM_Policy");
- participantId.setVersion("0.0.0");
-
- ToscaConceptIdentifier controlLoopId = new ToscaConceptIdentifier();
- controlLoopId.setName("PMSHInstance0");
- controlLoopId.setVersion("1.0.0");
-
- final ParticipantHealthCheck participantHealthCheckMsg = new ParticipantHealthCheck();
- participantHealthCheckMsg.setParticipantId(participantId);
- participantHealthCheckMsg.setControlLoopId(controlLoopId);
- participantHealthCheckMsg.setTimestamp(Instant.now());
- participantHealthCheckMsg.setState(ParticipantState.PASSIVE);
-
- return participantHealthCheckMsg;
- }
-
- /**
* Method to create ControlLoopUpdate using the arguments passed.
*
* @param jsonFilePath the path of the controlloop content