summaryrefslogtreecommitdiffstats
path: root/models/src
diff options
context:
space:
mode:
Diffstat (limited to 'models/src')
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementDefinition.java18
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopInfo.java4
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoops.java2
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantDefinition.java56
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantUpdates.java56
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopAck.java15
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdate.java22
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregister.java4
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterAck.java4
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatus.java26
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdate.java24
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopStateChangeTest.java6
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdateTest.java19
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantAckMessageTest.java6
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregisterAckTest.java6
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregisterTest.java6
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageTest.java6
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageUtils.java20
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterAckTest.java6
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterTest.java6
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusReqTest.java6
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusTest.java38
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateAckTest.java6
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateTest.java48
24 files changed, 283 insertions, 127 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 c3e630681..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,19 +20,17 @@
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;
import org.onap.policy.models.base.PfUtils;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
/**
* Class to represent the PARTICIPANT_STATUS message that all the participants send to the control loop runtime.
@@ -46,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<ToscaConceptIdentifier, 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<ToscaConceptIdentifier, 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.
@@ -76,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 5fd00e278..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,30 +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.function.UnaryOperator;
+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.ToscaConceptIdentifier;
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<ToscaConceptIdentifier, 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.
@@ -61,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/ControlLoopStateChangeTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopStateChangeTest.java
index dd6a814a7..1bf155e9a 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopStateChangeTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopStateChangeTest.java
@@ -22,6 +22,7 @@ package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
+import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable;
import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields;
import java.time.Instant;
@@ -29,6 +30,7 @@ import java.util.UUID;
import org.junit.jupiter.api.Test;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState;
+import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
/**
@@ -37,7 +39,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
class ControlLoopStateChangeTest {
@Test
- void testCopyConstructor() {
+ void testCopyConstructor() throws CoderException {
assertThatThrownBy(() -> new ControlLoopStateChange(null)).isInstanceOf(NullPointerException.class);
ControlLoopStateChange orig = new ControlLoopStateChange();
@@ -57,5 +59,7 @@ class ControlLoopStateChangeTest {
assertEquals(removeVariableFields(orig.toString()),
removeVariableFields(new ControlLoopStateChange(orig).toString()));
+
+ assertSerializable(orig, ControlLoopStateChange.class);
}
}
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/ParticipantAckMessageTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantAckMessageTest.java
index 82ba5d186..b9c1053f3 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantAckMessageTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantAckMessageTest.java
@@ -22,15 +22,17 @@ package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
+import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable;
import java.util.UUID;
import org.junit.jupiter.api.Test;
+import org.onap.policy.common.utils.coder.CoderException;
class ParticipantAckMessageTest {
private ParticipantAckMessage message;
@Test
- void testCopyConstructor() {
+ void testCopyConstructor() throws CoderException {
assertThatThrownBy(() -> new ParticipantAckMessage((ParticipantAckMessage) null))
.isInstanceOf(NullPointerException.class);
@@ -45,6 +47,8 @@ class ParticipantAckMessageTest {
newmsg = new ParticipantAckMessage(message);
newmsg.setResponseTo(message.getResponseTo());
assertEquals(message.toString(), newmsg.toString());
+
+ assertSerializable(message, ParticipantAckMessage.class);
}
private ParticipantAckMessage makeMessage() {
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregisterAckTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregisterAckTest.java
index cfb891e2a..f1ae5f709 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregisterAckTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregisterAckTest.java
@@ -22,16 +22,18 @@ package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
+import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable;
import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields;
import java.util.UUID;
import org.junit.jupiter.api.Test;
+import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
class ParticipantDeregisterAckTest {
@Test
- void testCopyConstructor() {
+ void testCopyConstructor() throws CoderException {
assertThatThrownBy(() -> new ParticipantDeregisterAck(null)).isInstanceOf(NullPointerException.class);
final ParticipantDeregisterAck orig = new ParticipantDeregisterAck();
@@ -51,5 +53,7 @@ class ParticipantDeregisterAckTest {
assertEquals(removeVariableFields(orig.toString()),
removeVariableFields(new ParticipantDeregisterAck(orig).toString()));
+
+ assertSerializable(orig, ParticipantDeregisterAck.class);
}
}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregisterTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregisterTest.java
index 2daefb6cc..89546890a 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregisterTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregisterTest.java
@@ -22,17 +22,19 @@ package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
+import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable;
import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields;
import java.time.Instant;
import java.util.UUID;
import org.junit.jupiter.api.Test;
+import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
class ParticipantDeregisterTest {
@Test
- void testCopyConstructor() {
+ void testCopyConstructor() throws CoderException {
assertThatThrownBy(() -> new ParticipantDeregister(null)).isInstanceOf(NullPointerException.class);
final ParticipantDeregister orig = new ParticipantDeregister();
@@ -53,5 +55,7 @@ class ParticipantDeregisterTest {
assertEquals(removeVariableFields(orig.toString()),
removeVariableFields(new ParticipantDeregister(orig).toString()));
+
+ assertSerializable(orig, ParticipantDeregister.class);
}
}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageTest.java
index 8d644f1f1..924ad8fa8 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageTest.java
@@ -24,17 +24,19 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable;
import java.time.Instant;
import java.util.UUID;
import org.junit.jupiter.api.Test;
+import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
class ParticipantMessageTest {
private ParticipantMessage message;
@Test
- void testCopyConstructor() {
+ void testCopyConstructor() throws CoderException {
assertThatThrownBy(() -> new ParticipantMessage((ParticipantMessage) null))
.isInstanceOf(NullPointerException.class);
@@ -51,6 +53,8 @@ class ParticipantMessageTest {
newmsg.setMessageId(message.getMessageId());
newmsg.setTimestamp(message.getTimestamp());
assertEquals(message.toString(), newmsg.toString());
+
+ assertSerializable(message, ParticipantMessage.class);
}
@Test
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageUtils.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageUtils.java
index dfbc25d1b..78c278f98 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageUtils.java
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageUtils.java
@@ -20,6 +20,11 @@
package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant;
+import static org.junit.Assert.assertEquals;
+
+import org.onap.policy.common.utils.coder.CoderException;
+import org.onap.policy.common.utils.coder.StandardCoder;
+
/**
* Utility class for tests of ParticipantMessage subclasses.
*/
@@ -32,4 +37,19 @@ public class ParticipantMessageUtils {
public static String removeVariableFields(String text) {
return text.replaceAll("messageId=[^,]*", "messageId=xxx").replaceAll("timestamp=[^,]*", "timestamp=nnn");
}
+
+ /**
+ * Check if object is Serializable.
+ *
+ * @param object the Object
+ * @param clazz the class of the Object
+ * @throws CoderException if object is not Serializable
+ */
+ public static <T> void assertSerializable(Object object, Class<T> clazz) throws CoderException {
+ var standardCoder = new StandardCoder();
+ var json = standardCoder.encode(object);
+ var other = standardCoder.decode(json, clazz);
+
+ assertEquals(removeVariableFields(object.toString()), removeVariableFields(other.toString()));
+ }
}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterAckTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterAckTest.java
index f0c721186..886933aba 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterAckTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterAckTest.java
@@ -22,16 +22,18 @@ package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
+import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable;
import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields;
import java.util.UUID;
import org.junit.jupiter.api.Test;
+import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
class ParticipantRegisterAckTest {
@Test
- void testCopyConstructor() {
+ void testCopyConstructor() throws CoderException {
assertThatThrownBy(() -> new ParticipantRegisterAck(null)).isInstanceOf(NullPointerException.class);
final ParticipantRegisterAck orig = new ParticipantRegisterAck();
@@ -51,5 +53,7 @@ class ParticipantRegisterAckTest {
assertEquals(removeVariableFields(orig.toString()),
removeVariableFields(new ParticipantRegisterAck(orig).toString()));
+
+ assertSerializable(orig, ParticipantRegisterAck.class);
}
}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterTest.java
index d7ce5bf38..e86d9e885 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterTest.java
@@ -22,17 +22,19 @@ package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
+import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable;
import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields;
import java.time.Instant;
import java.util.UUID;
import org.junit.jupiter.api.Test;
+import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
class ParticipantRegisterTest {
@Test
- void testCopyConstructor() {
+ void testCopyConstructor() throws CoderException {
assertThatThrownBy(() -> new ParticipantRegister(null)).isInstanceOf(NullPointerException.class);
final ParticipantRegister orig = new ParticipantRegister();
@@ -53,5 +55,7 @@ class ParticipantRegisterTest {
assertEquals(removeVariableFields(orig.toString()),
removeVariableFields(new ParticipantRegister(orig).toString()));
+
+ assertSerializable(orig, ParticipantRegister.class);
}
}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusReqTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusReqTest.java
index b391aa2cf..98c127107 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusReqTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusReqTest.java
@@ -22,11 +22,13 @@ package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
+import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable;
import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields;
import java.time.Instant;
import java.util.UUID;
import org.junit.jupiter.api.Test;
+import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
/**
@@ -34,7 +36,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
*/
class ParticipantStatusReqTest {
@Test
- void testCopyConstructor() {
+ void testCopyConstructor() throws CoderException {
assertThatThrownBy(() -> new ParticipantStatusReq(null)).isInstanceOf(NullPointerException.class);
ParticipantStatusReq orig = new ParticipantStatusReq();
@@ -48,5 +50,7 @@ class ParticipantStatusReqTest {
ParticipantStatusReq other = new ParticipantStatusReq(orig);
assertEquals(removeVariableFields(orig.toString()), removeVariableFields(other.toString()));
+
+ assertSerializable(orig, ParticipantStatusReq.class);
}
}
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 05cfdd78b..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
@@ -22,6 +22,7 @@ package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
+import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable;
import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields;
import java.time.Instant;
@@ -35,15 +36,17 @@ 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 {
@Test
- void testCopyConstructor() {
+ void testCopyConstructor() throws CoderException {
assertThatThrownBy(() -> new ParticipantStatus(null)).isInstanceOf(NullPointerException.class);
final ParticipantStatus orig = new ParticipantStatus();
@@ -63,21 +66,24 @@ class ParticipantStatusTest {
orig.setTimestamp(Instant.ofEpochMilli(3000));
ControlLoopInfo clInfo = getControlLoopInfo(id);
- orig.setControlLoopInfoMap(Map.of(id, clInfo));
+ orig.setControlLoopInfoList(List.of(clInfo));
- ControlLoopElementDefinition clDefinition = getClElementDefinition();
- Map<UUID, ControlLoopElementDefinition> clElementDefinitionMap = Map.of(UUID.randomUUID(), clDefinition);
- Map<ToscaConceptIdentifier, Map<UUID, ControlLoopElementDefinition>>
- participantDefinitionUpdateMap = Map.of(id, 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()));
+
+ assertSerializable(orig, ParticipantStatus.class);
}
private ControlLoopInfo getControlLoopInfo(ToscaConceptIdentifier id) {
ControlLoopInfo clInfo = new ControlLoopInfo();
clInfo.setState(ControlLoopState.PASSIVE2RUNNING);
+ clInfo.setControlLoopId(id);
ControlLoopStatistics clStatistics = new ControlLoopStatistics();
clStatistics.setControlLoopId(id);
@@ -99,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/ParticipantUpdateAckTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateAckTest.java
index 868147637..d2a191018 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateAckTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateAckTest.java
@@ -22,16 +22,18 @@ package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
+import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable;
import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields;
import java.util.UUID;
import org.junit.jupiter.api.Test;
+import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
class ParticipantUpdateAckTest {
@Test
- void testCopyConstructor() {
+ void testCopyConstructor() throws CoderException {
assertThatThrownBy(() -> new ParticipantUpdateAck(null)).isInstanceOf(NullPointerException.class);
final ParticipantUpdateAck orig = new ParticipantUpdateAck();
@@ -51,5 +53,7 @@ class ParticipantUpdateAckTest {
assertEquals(removeVariableFields(orig.toString()),
removeVariableFields(new ParticipantUpdateAck(orig).toString()));
+
+ assertSerializable(orig, ParticipantUpdateAck.class);
}
}
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 094431233..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
@@ -22,14 +22,19 @@ package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
+import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable;
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;
/**
@@ -37,14 +42,12 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
*/
class ParticipantUpdateTest {
@Test
- void testCopyConstructor() {
+ void testCopyConstructor() throws CoderException {
assertThatThrownBy(() -> new ParticipantUpdate(null)).isInstanceOf(NullPointerException.class);
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);
@@ -57,20 +60,37 @@ 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<ToscaConceptIdentifier, Map<UUID, ControlLoopElementDefinition>>
- participantDefinitionUpdateMap = Map.of(id, 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);
assertEquals(removeVariableFields(orig.toString()), removeVariableFields(other.toString()));
+
+ 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;
}
}