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 | |
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')
14 files changed, 209 insertions, 113 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementDefinition.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementDefinition.java index 7daf8974c..b9f4d6904 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementDefinition.java +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementDefinition.java @@ -22,28 +22,28 @@ package org.onap.policy.clamp.controlloop.models.controlloop.concepts; import java.util.LinkedHashMap; import java.util.Map; -import java.util.UUID; import java.util.function.UnaryOperator; import lombok.Data; +import lombok.Getter; import lombok.NoArgsConstructor; -import lombok.NonNull; import lombok.ToString; import org.onap.policy.models.base.PfUtils; -import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; /** * Class to represent a control loop element definition instance. */ +@Getter @NoArgsConstructor @Data @ToString public class ControlLoopElementDefinition { - @NonNull - private UUID id = UUID.randomUUID(); + private ToscaConceptIdentifier clElementDefinitionId; // The definition of the Control Loop Element in TOSCA - private ToscaServiceTemplate controlLoopElementToscaServiceTemplate; + private ToscaNodeTemplate controlLoopElementToscaNodeTemplate; // A map indexed by the property name. Each map entry is the serialized value of the property, // which can be deserialized into an instance of the type of the property. @@ -55,9 +55,9 @@ public class ControlLoopElementDefinition { * @param clElementDefinition the controlloop element definition to copy from */ public ControlLoopElementDefinition(final ControlLoopElementDefinition clElementDefinition) { - this.id = clElementDefinition.id; - this.controlLoopElementToscaServiceTemplate = - new ToscaServiceTemplate(clElementDefinition.controlLoopElementToscaServiceTemplate); + this.clElementDefinitionId = clElementDefinition.clElementDefinitionId; + this.controlLoopElementToscaNodeTemplate = + new ToscaNodeTemplate(clElementDefinition.controlLoopElementToscaNodeTemplate); this.commonPropertiesMap = PfUtils.mapMap(clElementDefinition.commonPropertiesMap, UnaryOperator.identity()); } } diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopInfo.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopInfo.java index bdf894125..0c33606db 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopInfo.java +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopInfo.java @@ -23,6 +23,7 @@ package org.onap.policy.clamp.controlloop.models.controlloop.concepts; import lombok.Data; import lombok.NoArgsConstructor; import lombok.ToString; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; /** * Class to represent a control loop info instance. @@ -32,6 +33,8 @@ import lombok.ToString; @ToString public class ControlLoopInfo { + private ToscaConceptIdentifier controlLoopId; + private ControlLoopState state = ControlLoopState.UNINITIALISED; private ControlLoopStatistics controlLoopStatistics; @@ -42,6 +45,7 @@ public class ControlLoopInfo { * @param otherElement the other element to copy from */ public ControlLoopInfo(final ControlLoopInfo otherElement) { + this.controlLoopId = otherElement.controlLoopId; this.state = otherElement.state; this.controlLoopStatistics = otherElement.controlLoopStatistics; } diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoops.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoops.java index 8edcc3c11..691ce95db 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoops.java +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoops.java @@ -37,7 +37,7 @@ public class ControlLoops { private List<ControlLoop> controlLoopList; /** - * Copy contructor, does a deep copy. + * Copy constructor, does a deep copy. * * @param otherControlLoops the other element to copy from */ diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantDefinition.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantDefinition.java new file mode 100644 index 000000000..bf93c074e --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantDefinition.java @@ -0,0 +1,56 @@ +/*- + * ============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.models.controlloop.concepts; + +import java.util.ArrayList; +import java.util.List; +import lombok.Data; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.ToString; +import org.onap.policy.models.base.PfUtils; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +/** + * Class to represent a participant definition update instance. + */ +@Getter +@NoArgsConstructor +@Data +@ToString +public class ParticipantDefinition { + + private ToscaConceptIdentifier participantId; + + // List of ControlLoopElementDefinition values for a particular participant + private List<ControlLoopElementDefinition> controlLoopElementDefinitionList = new ArrayList<>(); + + /** + * Copy constructor, does a deep copy but as all fields here are immutable, it's just a regular copy. + * + * @param participantDefinition the participant definition to copy from + */ + public ParticipantDefinition(final ParticipantDefinition participantDefinition) { + this.participantId = participantDefinition.participantId; + this.controlLoopElementDefinitionList = PfUtils.mapList( + participantDefinition.controlLoopElementDefinitionList, ControlLoopElementDefinition::new); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantUpdates.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantUpdates.java new file mode 100644 index 000000000..ea851b8c5 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantUpdates.java @@ -0,0 +1,56 @@ +/*- + * ============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.models.controlloop.concepts; + +import java.util.ArrayList; +import java.util.List; +import lombok.Data; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.ToString; +import org.onap.policy.models.base.PfUtils; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +/** + * Class to represent a participant definition update instance. + */ +@Getter +@NoArgsConstructor +@Data +@ToString +public class ParticipantUpdates { + + private ToscaConceptIdentifier participantId; + + // List of ControlLoopElement values for a particular participant + private List<ControlLoopElement> controlLoopElementList = new ArrayList<>(); + + /** + * Copy constructor, does a deep copy but as all fields here are immutable, it's just a regular copy. + * + * @param participantUpdates the participant with updates to copy from + */ + public ParticipantUpdates(final ParticipantUpdates participantUpdates) { + this.participantId = participantUpdates.participantId; + this.controlLoopElementList = PfUtils.mapList( + participantUpdates.controlLoopElementList, ControlLoopElement::new); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopAck.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopAck.java index 3411a0369..55ba7faf5 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopAck.java +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopAck.java @@ -41,19 +41,6 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; @ToString(callSuper = true) public class ControlLoopAck extends ParticipantAckMessage { - /** - * Participant ID, or {@code null} for messages from participants. - */ - private ToscaConceptIdentifier participantId; - - /** - * Participant Type, or {@code null} for messages from participants. - */ - private ToscaConceptIdentifier participantType; - - /** - * Control loop ID, or {@code null} for messages to participants. - */ private ToscaConceptIdentifier controlLoopId; // A map with ControlLoopElementID as its key, and a pair of result and message as value per @@ -75,8 +62,6 @@ public class ControlLoopAck extends ParticipantAckMessage { */ public ControlLoopAck(final ControlLoopAck source) { super(source); - this.participantId = source.participantId; - this.participantType = source.participantType; this.controlLoopId = source.controlLoopId; this.controlLoopResultMap = PfUtils.mapMap(source.controlLoopResultMap, UnaryOperator.identity()); } diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdate.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdate.java index 865264f6d..42b9712e2 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdate.java +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdate.java @@ -20,16 +20,13 @@ package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.UUID; +import java.util.ArrayList; +import java.util.List; import lombok.Getter; import lombok.Setter; import lombok.ToString; -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.ParticipantUpdates; import org.onap.policy.models.base.PfUtils; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; /** * Class to represent the CONTROL_LOOP_UPDATE message that the control loop runtime sends to a participant. @@ -41,12 +38,8 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; @ToString(callSuper = true) public class ControlLoopUpdate extends ParticipantMessage { - // The control loop - private ControlLoop controlLoop; - - // A map with Participant ID as its key, and a map of ControlLoopElements as value. - private Map<ToscaConceptIdentifier, Map<UUID, ControlLoopElement>> - participantUpdateMap = new LinkedHashMap<>(); + // A list of ParticipantUpdates instances which carries details of an updated participant. + private List<ParticipantUpdates> participantUpdatesList = new ArrayList<>(); /** * Constructor for instantiating ControlLoopUpdate class with message name. @@ -64,8 +57,7 @@ public class ControlLoopUpdate extends ParticipantMessage { public ControlLoopUpdate(ControlLoopUpdate source) { super(source); - this.controlLoop = source.controlLoop; - this.participantUpdateMap = PfUtils.mapMap(source.participantUpdateMap, - clElementMap -> PfUtils.mapMap(clElementMap, ControlLoopElement::new)); + this.participantUpdatesList = PfUtils.mapList(source.participantUpdatesList, + ParticipantUpdates::new); } } diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregister.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregister.java index e8759b302..7705e3d0c 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregister.java +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregister.java @@ -23,10 +23,6 @@ package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; import lombok.Getter; import lombok.Setter; import lombok.ToString; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantHealthStatus; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics; /** * Class to represent the PARTICIPANT_DEREGISTER message that all the participants send to control loop runtime. diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterAck.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterAck.java index 3d55c3690..28d51be93 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterAck.java +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterAck.java @@ -23,10 +23,6 @@ package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; import lombok.Getter; import lombok.Setter; import lombok.ToString; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantHealthStatus; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics; /** * Class to represent the PARTICIPANT_REGISTER_ACK message that control loop runtime sends to registered participant. diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatus.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatus.java index a8b268b4d..8600b4b5b 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatus.java +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatus.java @@ -20,14 +20,13 @@ package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.UUID; +import java.util.ArrayList; +import java.util.List; import lombok.Getter; import lombok.Setter; import lombok.ToString; -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.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.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics; @@ -45,16 +44,13 @@ public class ParticipantStatus extends ParticipantMessage { private ParticipantState state; private ParticipantHealthStatus healthStatus; - // Participant statistics private ParticipantStatistics participantStatistics; - // A map with Participant ID as its key, and a map of ControlLoopElements as value. - // Returned in response to ParticipantStatusReq only - private Map<String, Map<UUID, ControlLoopElementDefinition>> - participantDefinitionUpdateMap = new LinkedHashMap<>(); + // A list of ParticipantDefinition updates, returned in response to ParticipantStatusReq only + private List<ParticipantDefinition> participantDefinitionUpdates = new ArrayList<>(); - // Map of ControlLoopInfo types indexed by ControlLoopId, one entry for each control loop - private Map<String, ControlLoopInfo> controlLoopInfoMap; + // List of ControlLoopInfo types with ControlLoopId, its state and statistics + private List<ControlLoopInfo> controlLoopInfoList = new ArrayList<>(); /** * Constructor for instantiating ParticipantStatus class with message name. @@ -75,9 +71,8 @@ public class ParticipantStatus extends ParticipantMessage { this.state = source.state; this.healthStatus = source.healthStatus; this.participantStatistics = (source.participantStatistics == null ? null : new ParticipantStatistics()); - this.participantDefinitionUpdateMap = PfUtils.mapMap(source.participantDefinitionUpdateMap, - clElementDefinitionMap -> PfUtils.mapMap(clElementDefinitionMap, - ControlLoopElementDefinition::new)); - this.controlLoopInfoMap = PfUtils.mapMap(source.controlLoopInfoMap, ControlLoopInfo::new); + this.participantDefinitionUpdates = PfUtils.mapList(source.participantDefinitionUpdates, + ParticipantDefinition::new); + this.controlLoopInfoList = PfUtils.mapList(source.controlLoopInfoList, ControlLoopInfo::new); } } diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdate.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdate.java index 2733de474..5c1b67905 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdate.java +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdate.java @@ -20,27 +20,28 @@ package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.UUID; +import java.util.ArrayList; +import java.util.List; import lombok.Getter; import lombok.Setter; import lombok.ToString; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElementDefinition; +import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantDefinition; import org.onap.policy.models.base.PfUtils; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; /** * Class to represent the PARTICIPANT_UPDATE message that the control loop runtime sends to a participant. - * CLAMP Runtime sends Control Loop Element Definitions and Common Parameter Values to Participants. + * ControlLoop Runtime sends Control Loop Element Definitions and Common Parameter Values to Participants. */ @Getter @Setter @ToString(callSuper = true) public class ParticipantUpdate extends ParticipantMessage { - // A map with Participant ID as its key, and a map of ControlLoopElements as value. - private Map<String, Map<UUID, ControlLoopElementDefinition>> - participantDefinitionUpdateMap = new LinkedHashMap<>(); + // A list of updates to ParticipantDefinitions + private List<ParticipantDefinition> participantDefinitionUpdates = new ArrayList<>(); + + private ToscaServiceTemplate toscaServiceTemplate = new ToscaServiceTemplate(); /** * Constructor for instantiating ParticipantUpdate class with message name. @@ -58,8 +59,8 @@ public class ParticipantUpdate extends ParticipantMessage { public ParticipantUpdate(ParticipantUpdate source) { super(source); - this.participantDefinitionUpdateMap = PfUtils.mapMap(source.participantDefinitionUpdateMap, - clElementDefinitionMap -> PfUtils.mapMap(clElementDefinitionMap, - ControlLoopElementDefinition::new)); + this.participantDefinitionUpdates = PfUtils.mapList(source.participantDefinitionUpdates, + ParticipantDefinition::new); + this.toscaServiceTemplate = source.toscaServiceTemplate; } } 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; + } } |