diff options
author | Sirisha_Manchikanti <sirisha.manchikanti@est.tech> | 2021-08-10 21:51:48 +0100 |
---|---|---|
committer | Sirisha_Manchikanti <sirisha.manchikanti@est.tech> | 2021-08-18 14:58:42 +0100 |
commit | d0a1bcee60c43a736a0526d49c07c564632c4f02 (patch) | |
tree | 32d46f33307a9bb65215a1f52eb626ae7db3d1ee /models/src/test | |
parent | a37bd982693785af5fc791df0baaa49dda039846 (diff) |
Updated ControlLoop component messages
Updated controlloop messages (ParticipantUpdate, ControlLoopUpdate,
ParticipantStatus) according to the following Wiki and added
implementation for the corresponding updates in runtime-controlloop and
participant components
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: I80d96a7553a89ca47de2aa35e09df5a5c792acfa
Diffstat (limited to 'models/src/test')
3 files changed, 54 insertions, 39 deletions
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdateTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdateTest.java index 0ac4f5331..d1b749e82 100644 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdateTest.java +++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdateTest.java @@ -25,13 +25,16 @@ import static org.junit.Assert.assertEquals; import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields; import java.time.Instant; +import java.util.List; import java.util.Map; import java.util.UUID; import org.junit.jupiter.api.Test; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop; import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement; +import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElementDefinition; 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.models.controlloop.concepts.ParticipantDefinition; +import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantUpdates; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; /** @@ -59,19 +62,13 @@ class ControlLoopUpdateTest { clElement.setParticipantId(id); clElement.setParticipantType(id); - ControlLoop controlLoop = new ControlLoop(); - controlLoop.setName("controlLoop"); - Map<UUID, ControlLoopElement> elements = Map.of(clElement.getId(), clElement); - controlLoop.setElements(elements); - orig.setControlLoop(controlLoop); - Map<String, String> commonPropertiesMap = Map.of("Prop1", "PropValue"); clElement.setCommonPropertiesMap(commonPropertiesMap); - Map<UUID, ControlLoopElement> controlLoopElementMap = Map.of(UUID.randomUUID(), clElement); - Map<ToscaConceptIdentifier, Map<UUID, ControlLoopElement>> - participantUpdateMap = Map.of(id, controlLoopElementMap); - orig.setParticipantUpdateMap(participantUpdateMap); + ParticipantUpdates participantUpdates = new ParticipantUpdates(); + participantUpdates.setParticipantId(id); + participantUpdates.setControlLoopElementList(List.of(clElement)); + orig.setParticipantUpdatesList(List.of(participantUpdates)); ControlLoopUpdate other = new ControlLoopUpdate(orig); diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusTest.java index 14252cd95..7c163870e 100644 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusTest.java +++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusTest.java @@ -36,11 +36,12 @@ import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop 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.controlloop.concepts.ParticipantDefinition; import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantHealthStatus; import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; class ParticipantStatusTest { @@ -65,13 +66,13 @@ class ParticipantStatusTest { orig.setTimestamp(Instant.ofEpochMilli(3000)); ControlLoopInfo clInfo = getControlLoopInfo(id); - orig.setControlLoopInfoMap(Map.of(id.toString(), clInfo)); + orig.setControlLoopInfoList(List.of(clInfo)); - ControlLoopElementDefinition clDefinition = getClElementDefinition(); - Map<UUID, ControlLoopElementDefinition> clElementDefinitionMap = Map.of(UUID.randomUUID(), clDefinition); - Map<String, Map<UUID, ControlLoopElementDefinition>> - participantDefinitionUpdateMap = Map.of(id.toString(), clElementDefinitionMap); - orig.setParticipantDefinitionUpdateMap(participantDefinitionUpdateMap); + ParticipantDefinition participantDefinitionUpdate = new ParticipantDefinition(); + participantDefinitionUpdate.setParticipantId(id); + ControlLoopElementDefinition clDefinition = getClElementDefinition(id); + participantDefinitionUpdate.setControlLoopElementDefinitionList(List.of(clDefinition)); + orig.setParticipantDefinitionUpdates(List.of(participantDefinitionUpdate)); assertEquals(removeVariableFields(orig.toString()), removeVariableFields(new ParticipantStatus(orig).toString())); @@ -82,6 +83,7 @@ class ParticipantStatusTest { private ControlLoopInfo getControlLoopInfo(ToscaConceptIdentifier id) { ControlLoopInfo clInfo = new ControlLoopInfo(); clInfo.setState(ControlLoopState.PASSIVE2RUNNING); + clInfo.setControlLoopId(id); ControlLoopStatistics clStatistics = new ControlLoopStatistics(); clStatistics.setControlLoopId(id); @@ -103,16 +105,16 @@ class ParticipantStatusTest { 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"); + private ControlLoopElementDefinition getClElementDefinition(ToscaConceptIdentifier id) { + ToscaNodeTemplate toscaNodeTemplate = new ToscaNodeTemplate(); + toscaNodeTemplate.setName("nodeTemplate"); + toscaNodeTemplate.setDerivedFrom("parentNodeTemplate"); + toscaNodeTemplate.setDescription("Description of nodeTemplate"); + toscaNodeTemplate.setVersion("1.2.3"); ControlLoopElementDefinition clDefinition = new ControlLoopElementDefinition(); - clDefinition.setId(UUID.randomUUID()); - clDefinition.setControlLoopElementToscaServiceTemplate(toscaServiceTemplate); + clDefinition.setClElementDefinitionId(id); + clDefinition.setControlLoopElementToscaNodeTemplate(toscaNodeTemplate); Map<String, String> commonPropertiesMap = Map.of("Prop1", "PropValue"); clDefinition.setCommonPropertiesMap(commonPropertiesMap); return clDefinition; diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateTest.java index 6ccdd20ec..06141de2b 100644 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateTest.java +++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateTest.java @@ -26,12 +26,15 @@ import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participan import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields; import java.time.Instant; +import java.util.List; import java.util.Map; import java.util.UUID; import org.junit.jupiter.api.Test; import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElementDefinition; +import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantDefinition; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; /** @@ -44,9 +47,7 @@ class ParticipantUpdateTest { ParticipantUpdate orig = new ParticipantUpdate(); // verify with all values - ToscaConceptIdentifier id = new ToscaConceptIdentifier(); - id.setName("id"); - id.setVersion("1.2.3"); + ToscaConceptIdentifier id = new ToscaConceptIdentifier("id", "1.2.3"); orig.setControlLoopId(id); orig.setParticipantId(id); orig.setParticipantType(id); @@ -59,17 +60,17 @@ class ParticipantUpdateTest { 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); + ToscaNodeTemplate toscaNodeTemplate = new ToscaNodeTemplate(); + toscaNodeTemplate.setName("nodeTemplate"); + toscaNodeTemplate.setDerivedFrom("parentNodeTemplate"); + toscaNodeTemplate.setDescription("Description of nodeTemplate"); + toscaNodeTemplate.setVersion("1.2.3"); - Map<UUID, ControlLoopElementDefinition> clElementDefinitionMap = Map.of(UUID.randomUUID(), clDefinition); - - Map<String, Map<UUID, ControlLoopElementDefinition>> participantDefinitionUpdateMap = - Map.of(id.toString(), clElementDefinitionMap); - orig.setParticipantDefinitionUpdateMap(participantDefinitionUpdateMap); + ParticipantDefinition participantDefinitionUpdate = new ParticipantDefinition(); + participantDefinitionUpdate.setParticipantId(id); + ControlLoopElementDefinition clDefinition = getClElementDefinition(id); + participantDefinitionUpdate.setControlLoopElementDefinitionList(List.of(clDefinition)); + orig.setParticipantDefinitionUpdates(List.of(participantDefinitionUpdate)); ParticipantUpdate other = new ParticipantUpdate(orig); @@ -77,4 +78,19 @@ class ParticipantUpdateTest { assertSerializable(orig, ParticipantUpdate.class); } + + private ControlLoopElementDefinition getClElementDefinition(ToscaConceptIdentifier id) { + ToscaNodeTemplate toscaNodeTemplate = new ToscaNodeTemplate(); + toscaNodeTemplate.setName("nodeTemplate"); + toscaNodeTemplate.setDerivedFrom("parentNodeTemplate"); + toscaNodeTemplate.setDescription("Description of nodeTemplate"); + toscaNodeTemplate.setVersion("1.2.3"); + + ControlLoopElementDefinition clDefinition = new ControlLoopElementDefinition(); + clDefinition.setClElementDefinitionId(id); + clDefinition.setControlLoopElementToscaNodeTemplate(toscaNodeTemplate); + Map<String, String> commonPropertiesMap = Map.of("Prop1", "PropValue"); + clDefinition.setCommonPropertiesMap(commonPropertiesMap); + return clDefinition; + } } |