aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElement.java9
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopAck.java85
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopStateChange.java3
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdate.java18
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageType.java19
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusReq.java51
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopAckTest.java62
-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.java41
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantPojosTest.java2
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusReqTest.java52
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateTest.java11
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/rest/TestListenerUtils.java1
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/endtoend/ParticipantPolicyTest.java20
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/utils/TestListenerUtils.java9
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/TestListenerUtils.java1
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java7
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java2
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopUpdatePublisher.java13
19 files changed, 336 insertions, 76 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElement.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElement.java
index 83f062c74..b99759eb3 100644
--- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElement.java
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElement.java
@@ -20,12 +20,16 @@
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.NoArgsConstructor;
import lombok.NonNull;
import lombok.ToString;
import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfUtils;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
/**
@@ -57,6 +61,10 @@ public class ControlLoopElement {
private ClElementStatistics clElementStatistics;
+ // 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.
+ private Map<String, String> commonPropertiesMap = new LinkedHashMap<>();
+
/**
* Copy constructor, does a deep copy but as all fields here are immutable, it's just a regular copy.
*
@@ -71,5 +79,6 @@ public class ControlLoopElement {
this.orderedState = otherElement.orderedState;
this.description = otherElement.description;
this.clElementStatistics = otherElement.clElementStatistics;
+ this.commonPropertiesMap = PfUtils.mapMap(otherElement.commonPropertiesMap, UnaryOperator.identity());
}
}
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
new file mode 100644
index 000000000..6a72ec1f2
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopAck.java
@@ -0,0 +1,85 @@
+/*-
+ * ============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.messages.dmaap.participant;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.UUID;
+import java.util.function.UnaryOperator;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+import org.apache.commons.lang3.tuple.Pair;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElementDefinition;
+import org.onap.policy.models.base.PfUtils;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+/**
+ * Class to represent the CONTROLLOOP_ACK message that a participant sends
+ * to control loop runtime as an acknowledgement to either ControlLoopUpdate
+ * or ControlLoopStateChange message.
+ */
+@Getter
+@Setter
+@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
+ // ControlLoopElement.
+ private Map<UUID, Map<UUID, Boolean>> controlLoopResultMap = new LinkedHashMap<>();
+
+ /**
+ * Constructor for instantiating ParticipantRegisterAck class with message name.
+ *
+ */
+ public ControlLoopAck(final ParticipantMessageType messageType) {
+ super(messageType);
+ }
+
+ /**
+ * Constructs the object, making a deep copy.
+ *
+ * @param source source from which to copy
+ */
+ 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,
+ clElementResultMap -> PfUtils.mapMap(clElementResultMap, UnaryOperator.identity()));
+ }
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopStateChange.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopStateChange.java
index 180d99439..e6955b90b 100644
--- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopStateChange.java
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopStateChange.java
@@ -24,6 +24,7 @@ import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState;
/**
* Class to represent the CONTROL_LOOP_STATE_CHANGE message that the control loop runtime will send to
@@ -34,6 +35,7 @@ import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop
@ToString(callSuper = true)
public class ControlLoopStateChange extends ParticipantMessage {
private ControlLoopOrderedState orderedState;
+ private ControlLoopState currentState;
/**
* Constructor for instantiating ControlLoopStateChange class with message name.
@@ -52,5 +54,6 @@ public class ControlLoopStateChange extends ParticipantMessage {
super(source);
this.orderedState = source.orderedState;
+ this.currentState = source.currentState;
}
}
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 876c370b4..865264f6d 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,11 +20,16 @@
package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.UUID;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement;
+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.
@@ -35,11 +40,13 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
@Setter
@ToString(callSuper = true)
public class ControlLoopUpdate extends ParticipantMessage {
+
// The control loop
private ControlLoop controlLoop;
- // A service template containing a complete definition of the control loop
- private ToscaServiceTemplate controlLoopDefinition;
+ // A map with Participant ID as its key, and a map of ControlLoopElements as value.
+ private Map<ToscaConceptIdentifier, Map<UUID, ControlLoopElement>>
+ participantUpdateMap = new LinkedHashMap<>();
/**
* Constructor for instantiating ControlLoopUpdate class with message name.
@@ -57,7 +64,8 @@ public class ControlLoopUpdate extends ParticipantMessage {
public ControlLoopUpdate(ControlLoopUpdate source) {
super(source);
- this.controlLoop = new ControlLoop(source.controlLoop);
- this.controlLoopDefinition = new ToscaServiceTemplate(source.controlLoopDefinition);
+ this.controlLoop = source.controlLoop;
+ this.participantUpdateMap = PfUtils.mapMap(source.participantUpdateMap,
+ clElementMap -> PfUtils.mapMap(clElementMap, ControlLoopElement::new));
}
}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageType.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageType.java
index 0c39392e0..62b8d20b0 100644
--- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageType.java
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageType.java
@@ -83,5 +83,22 @@ public enum ParticipantMessageType {
* Used by participant to acknowledge the receipt of Participant_Update message
* from control loop runtime.
*/
- PARTICIPANT_UPDATE_ACK
+ PARTICIPANT_UPDATE_ACK,
+
+ /**
+ * Used by participant to acknowledge the receipt of ControlLoop_Update message
+ * from control loop runtime.
+ */
+ CONTROLLOOP_UPDATE_ACK,
+
+ /**
+ * Used by participant to acknowledge the receipt of ControlLoop_StateChange message
+ * from control loop runtime.
+ */
+ CONTROLLOOP_STATECHANGE_ACK,
+
+ /**
+ * Used by control loop runtime to request for ParticipantStatus message immediately.
+ */
+ PARTICIPANT_STATUS_REQ
}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusReq.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusReq.java
new file mode 100644
index 000000000..9242cea02
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusReq.java
@@ -0,0 +1,51 @@
+/*-
+ * ============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.messages.dmaap.participant;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+/**
+ * Class to represent the PARTICIPANT_STATUS_REQ message that controlloop runtime
+ * sends to participants for an immediate ParticipantStatus from participants.
+ */
+@Getter
+@Setter
+@ToString(callSuper = true)
+public class ParticipantStatusReq extends ParticipantMessage {
+
+ /**
+ * Constructor for instantiating a participant status request class.
+ */
+ public ParticipantStatusReq() {
+ super(ParticipantMessageType.PARTICIPANT_STATUS_REQ);
+ }
+
+ /**
+ * Constructs the object, making a deep copy.
+ *
+ * @param source source from which to copy
+ */
+ public ParticipantStatusReq(final ParticipantStatusReq source) {
+ super(source);
+ }
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopAckTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopAckTest.java
new file mode 100644
index 000000000..8734a435c
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopAckTest.java
@@ -0,0 +1,62 @@
+/*-
+ * ============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.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.removeVariableFields;
+
+import java.util.Map;
+import java.util.UUID;
+import org.junit.jupiter.api.Test;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+class ControlLoopAckTest {
+
+ @Test
+ void testCopyConstructor() {
+ assertThatThrownBy(() -> new ControlLoopAck((ControlLoopAck) null))
+ .isInstanceOf(NullPointerException.class);
+
+ final ControlLoopAck orig = new ControlLoopAck(ParticipantMessageType.CONTROL_LOOP_UPDATE);
+
+ // verify with null values
+ assertEquals(removeVariableFields(orig.toString()),
+ removeVariableFields(new ControlLoopAck(orig).toString()));
+
+ // verify with all values
+ ToscaConceptIdentifier id = new ToscaConceptIdentifier("id", "1.2.3");
+ orig.setControlLoopId(id);
+ orig.setParticipantId(id);
+ orig.setParticipantType(id);
+
+ Map<UUID, Boolean> clElementResult = Map.of(UUID.randomUUID(), true);
+ final Map<UUID, Map<UUID, Boolean>> controlLoopResultMap = Map.of(UUID.randomUUID(), clElementResult);
+ orig.setControlLoopResultMap(controlLoopResultMap);
+
+ orig.setResponseTo(UUID.randomUUID());
+ orig.setResult(true);
+ orig.setMessage("Successfully processed ControlLoopUpdate message");
+
+ assertEquals(removeVariableFields(orig.toString()),
+ removeVariableFields(new ControlLoopAck(orig).toString()));
+ }
+}
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 5b7fda0c4..dd6a814a7 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
@@ -28,6 +28,7 @@ import java.time.Instant;
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.models.tosca.authorative.concepts.ToscaConceptIdentifier;
/**
@@ -46,13 +47,12 @@ class ControlLoopStateChangeTest {
removeVariableFields(new ControlLoopStateChange(orig).toString()));
// 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.setMessageId(UUID.randomUUID());
orig.setOrderedState(ControlLoopOrderedState.RUNNING);
+ orig.setCurrentState(ControlLoopState.PASSIVE);
orig.setTimestamp(Instant.ofEpochMilli(3000));
assertEquals(removeVariableFields(orig.toString()),
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 ac164e32b..0ac4f5331 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
@@ -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.junit.Assert.assertNotSame;
import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields;
import java.time.Instant;
+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.ControlLoopOrderedState;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
/**
* Test the copy constructor.
@@ -42,30 +44,37 @@ class ControlLoopUpdateTest {
ControlLoopUpdate orig = new ControlLoopUpdate();
// 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.setParticipantId(null);
orig.setMessageId(UUID.randomUUID());
orig.setTimestamp(Instant.ofEpochMilli(3000));
+ ControlLoopElement clElement = new ControlLoopElement();
+ clElement.setId(UUID.randomUUID());
+ clElement.setDefinition(id);
+ clElement.setDescription("Description");
+ clElement.setOrderedState(ControlLoopOrderedState.PASSIVE);
+ clElement.setState(ControlLoopState.PASSIVE);
+ clElement.setParticipantId(id);
+ clElement.setParticipantType(id);
+
ControlLoop controlLoop = new ControlLoop();
controlLoop.setName("controlLoop");
- ToscaServiceTemplate toscaServiceTemplate = new ToscaServiceTemplate();
- toscaServiceTemplate.setName("serviceTemplate");
- toscaServiceTemplate.setDerivedFrom("parentServiceTemplate");
- toscaServiceTemplate.setDescription("Description of serviceTemplate");
- toscaServiceTemplate.setVersion("1.2.3");
- orig.setControlLoopDefinition(toscaServiceTemplate);
+ 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);
+
ControlLoopUpdate other = new ControlLoopUpdate(orig);
assertEquals(removeVariableFields(orig.toString()), removeVariableFields(other.toString()));
-
- // ensure list and items are not the same object
- assertNotSame(other.getControlLoop(), controlLoop);
- assertNotSame(other.getControlLoopDefinition(), toscaServiceTemplate);
}
}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantPojosTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantPojosTest.java
index 1a56a3979..e67fbc143 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantPojosTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantPojosTest.java
@@ -46,6 +46,8 @@ class ParticipantPojosTest {
pojoClasses.remove(PojoClassFactory.getPojoClass(ParticipantMessageTest.class));
pojoClasses.remove(PojoClassFactory.getPojoClass(ParticipantAckMessage.class));
pojoClasses.remove(PojoClassFactory.getPojoClass(ParticipantAckMessageTest.class));
+ pojoClasses.remove(PojoClassFactory.getPojoClass(ControlLoopAck.class));
+ pojoClasses.remove(PojoClassFactory.getPojoClass(ControlLoopAckTest.class));
// @formatter:off
final Validator validator = ValidatorBuilder
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
new file mode 100644
index 000000000..b391aa2cf
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusReqTest.java
@@ -0,0 +1,52 @@
+/*-
+ * ============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.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.removeVariableFields;
+
+import java.time.Instant;
+import java.util.UUID;
+import org.junit.jupiter.api.Test;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+/**
+ * Test the copy constructor.
+ */
+class ParticipantStatusReqTest {
+ @Test
+ void testCopyConstructor() {
+ assertThatThrownBy(() -> new ParticipantStatusReq(null)).isInstanceOf(NullPointerException.class);
+
+ ParticipantStatusReq orig = new ParticipantStatusReq();
+ // verify with all values
+ ToscaConceptIdentifier id = new ToscaConceptIdentifier("id", "1.2.3");
+ orig.setParticipantId(id);
+ orig.setControlLoopId(null);
+ orig.setParticipantType(null);
+ orig.setMessageId(UUID.randomUUID());
+ orig.setTimestamp(Instant.ofEpochMilli(3000));
+
+ ParticipantStatusReq other = new ParticipantStatusReq(orig);
+ assertEquals(removeVariableFields(orig.toString()), removeVariableFields(other.toString()));
+ }
+}
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 4f8b42b3a..094431233 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,11 +22,9 @@ 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.junit.Assert.assertNotSame;
import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields;
import java.time.Instant;
-import java.util.LinkedHashMap;
import java.util.Map;
import java.util.UUID;
import org.junit.jupiter.api.Test;
@@ -62,16 +60,13 @@ class ParticipantUpdateTest {
ControlLoopElementDefinition clDefinition = new ControlLoopElementDefinition();
clDefinition.setId(UUID.randomUUID());
clDefinition.setControlLoopElementToscaServiceTemplate(toscaServiceTemplate);
- Map<String, String> commonPropertiesMap = new LinkedHashMap<>();
- commonPropertiesMap.put("Prop1", "PropValue");
+ Map<String, String> commonPropertiesMap = Map.of("Prop1", "PropValue");
clDefinition.setCommonPropertiesMap(commonPropertiesMap);
- Map<UUID, ControlLoopElementDefinition> controlLoopElementDefinitionMap = new LinkedHashMap<>();
- controlLoopElementDefinitionMap.put(UUID.randomUUID(), clDefinition);
+ Map<UUID, ControlLoopElementDefinition> clElementDefinitionMap = Map.of(UUID.randomUUID(), clDefinition);
Map<ToscaConceptIdentifier, Map<UUID, ControlLoopElementDefinition>>
- participantDefinitionUpdateMap = new LinkedHashMap<>();
- participantDefinitionUpdateMap.put(id, controlLoopElementDefinitionMap);
+ participantDefinitionUpdateMap = Map.of(id, clElementDefinitionMap);
orig.setParticipantDefinitionUpdateMap(participantDefinitionUpdateMap);
ParticipantUpdate other = new ParticipantUpdate(orig);
diff --git a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/rest/TestListenerUtils.java b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/rest/TestListenerUtils.java
index ddcc05ca4..bb1021db6 100644
--- a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/rest/TestListenerUtils.java
+++ b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/rest/TestListenerUtils.java
@@ -156,7 +156,6 @@ public class TestListenerUtils {
controlLoop.setVersion("1.0.0");
controlLoop.setDefinition(controlLoopId);
clUpdateMsg.setControlLoop(controlLoop);
- clUpdateMsg.setControlLoopDefinition(toscaServiceTemplate);
return clUpdateMsg;
}
diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/endtoend/ParticipantPolicyTest.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/endtoend/ParticipantPolicyTest.java
index c0bd89696..10563cde2 100644
--- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/endtoend/ParticipantPolicyTest.java
+++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/endtoend/ParticipantPolicyTest.java
@@ -21,17 +21,14 @@
package org.onap.policy.clamp.controlloop.participant.policy.endtoend;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopStateChange;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopUpdate;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdate;
import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ControlLoopStateChangeListener;
import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ControlLoopUpdateListener;
-import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ParticipantUpdateListener;
import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler;
import org.onap.policy.clamp.controlloop.participant.policy.main.utils.TestListenerUtils;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
@@ -58,9 +55,6 @@ class ParticipantPolicyTest {
ControlLoopUpdate controlLoopUpdateMsg = TestListenerUtils.createControlLoopUpdateMsg();
controlLoopUpdateMsg.getControlLoop().setOrderedState(ControlLoopOrderedState.PASSIVE);
- // Verify that the ToscaServicetemplate has policy_types
- assertNotNull(controlLoopUpdateMsg.getControlLoopDefinition().getPolicyTypes());
-
synchronized (lockit) {
ControlLoopUpdateListener clUpdateListener = new ControlLoopUpdateListener(participantHandler);
@@ -75,13 +69,6 @@ class ParticipantPolicyTest {
ControlLoopUpdate controlLoopUpdateMsg = TestListenerUtils.createControlLoopUpdateMsg();
controlLoopUpdateMsg.getControlLoop().setOrderedState(ControlLoopOrderedState.PASSIVE);
- // Add policies to the toscaServiceTemplate
- TestListenerUtils.addPoliciesToToscaServiceTemplate(controlLoopUpdateMsg.getControlLoopDefinition());
-
- // Verify that the ToscaServicetemplate has policies
- assertNotNull(
- controlLoopUpdateMsg.getControlLoopDefinition().getToscaTopologyTemplate().getPolicies());
-
synchronized (lockit) {
ControlLoopUpdateListener clUpdateListener = new ControlLoopUpdateListener(participantHandler);
@@ -96,13 +83,6 @@ class ParticipantPolicyTest {
ControlLoopUpdate controlLoopUpdateMsg = TestListenerUtils.createControlLoopUpdateMsg();
controlLoopUpdateMsg.getControlLoop().setOrderedState(ControlLoopOrderedState.PASSIVE);
- // Add policies to the toscaServiceTemplate
- TestListenerUtils.addPoliciesToToscaServiceTemplate(controlLoopUpdateMsg.getControlLoopDefinition());
-
- // Verify that the ToscaServicetemplate has policies
- assertNotNull(
- controlLoopUpdateMsg.getControlLoopDefinition().getToscaTopologyTemplate().getPolicies());
-
synchronized (lockit) {
ControlLoopUpdateListener clUpdateListener = new ControlLoopUpdateListener(participantHandler);
diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/utils/TestListenerUtils.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/utils/TestListenerUtils.java
index 6f1e00143..fe7e17fd7 100644
--- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/utils/TestListenerUtils.java
+++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/utils/TestListenerUtils.java
@@ -168,7 +168,6 @@ public class TestListenerUtils {
controlLoop.setVersion("1.0.0");
controlLoop.setDefinition(controlLoopId);
clUpdateMsg.setControlLoop(controlLoop);
- clUpdateMsg.setControlLoopDefinition(toscaServiceTemplate);
return clUpdateMsg;
}
@@ -190,11 +189,9 @@ public class TestListenerUtils {
participantUpdateMsg.setTimestamp(Instant.ofEpochMilli(3000));
participantUpdateMsg.setMessageId(UUID.randomUUID());
- ToscaServiceTemplate toscaServiceTemplate = new ToscaServiceTemplate();
- toscaServiceTemplate.setName("serviceTemplate");
- toscaServiceTemplate.setDerivedFrom("parentServiceTemplate");
- toscaServiceTemplate.setDescription("Description of serviceTemplate");
- toscaServiceTemplate.setVersion("1.2.3");
+ ToscaServiceTemplate toscaServiceTemplate = testControlLoopRead();
+ // Add policies to the toscaServiceTemplate
+ TestListenerUtils.addPoliciesToToscaServiceTemplate(toscaServiceTemplate);
ControlLoopElementDefinition clDefinition = new ControlLoopElementDefinition();
clDefinition.setId(UUID.randomUUID());
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/TestListenerUtils.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/TestListenerUtils.java
index 81af821d6..999feb1e1 100644
--- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/TestListenerUtils.java
+++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/TestListenerUtils.java
@@ -158,7 +158,6 @@ public class TestListenerUtils {
controlLoop.setVersion("1.0.0");
controlLoop.setDefinition(controlLoopId);
clUpdateMsg.setControlLoop(controlLoop);
- clUpdateMsg.setControlLoopDefinition(toscaServiceTemplate);
return clUpdateMsg;
}
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java
index e1a7e7fdf..c9da1279d 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java
@@ -31,6 +31,7 @@ import org.apache.commons.collections4.CollectionUtils;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics;
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.ControlLoops;
@@ -177,7 +178,8 @@ public class ControlLoopHandler {
*
* @param updateMsg the update message
*/
- public void handleControlLoopUpdate(ControlLoopUpdate updateMsg) {
+ public void handleControlLoopUpdate(ControlLoopUpdate updateMsg,
+ Map<UUID, ControlLoopElementDefinition> clElementDefinitions) {
if (!updateMsg.appliesTo(participantType, participantId)) {
return;
@@ -211,7 +213,8 @@ public class ControlLoopHandler {
for (ControlLoopElementListener clElementListener : listeners) {
try {
for (ControlLoopElement element : updateMsg.getControlLoop().getElements().values()) {
- clElementListener.controlLoopElementUpdate(element, updateMsg.getControlLoopDefinition());
+ clElementListener.controlLoopElementUpdate(element,
+ clElementDefinitions.get(element.getId()).getControlLoopElementToscaServiceTemplate());
}
} catch (PfModelException e) {
LOGGER.debug("Control loop element update failed {}", updateMsg.getControlLoopId());
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java
index ed1da5819..9daff7239 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java
@@ -115,7 +115,7 @@ public class ParticipantHandler implements Closeable {
* @param updateMsg the update message
*/
public void handleControlLoopUpdate(ControlLoopUpdate updateMsg) {
- controlLoopHandler.handleControlLoopUpdate(updateMsg);
+ controlLoopHandler.handleControlLoopUpdate(updateMsg, clElementDefsOnThisParticipant);
}
/**
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopUpdatePublisher.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopUpdatePublisher.java
index e366ba49a..448662cfe 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopUpdatePublisher.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopUpdatePublisher.java
@@ -23,8 +23,6 @@ package org.onap.policy.clamp.controlloop.runtime.supervision.comm;
import lombok.AllArgsConstructor;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopUpdate;
-import org.onap.policy.clamp.controlloop.runtime.commissioning.CommissioningProvider;
-import org.onap.policy.models.base.PfModelException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@@ -38,8 +36,6 @@ public class ControlLoopUpdatePublisher extends AbstractParticipantPublisher<Con
private static final Logger LOGGER = LoggerFactory.getLogger(ControlLoopUpdatePublisher.class);
- private final CommissioningProvider commissioningProvider;
-
/**
* Send ControlLoopUpdate to Participant.
*
@@ -49,14 +45,7 @@ public class ControlLoopUpdatePublisher extends AbstractParticipantPublisher<Con
var controlLoopUpdateMsg = new ControlLoopUpdate();
controlLoopUpdateMsg.setControlLoopId(controlLoop.getKey().asIdentifier());
controlLoopUpdateMsg.setControlLoop(controlLoop);
- // TODO: We should look up the correct TOSCA node template here for the control loop
- // Tiny hack implemented to return the tosca service template entry from the database and be passed onto dmaap
- try {
- controlLoopUpdateMsg.setControlLoopDefinition(commissioningProvider.getToscaServiceTemplate(null, null));
- } catch (PfModelException pfme) {
- LOGGER.warn("Get of tosca service template failed, cannot send ParticipantControlLoopUpdate", pfme);
- return;
- }
+ LOGGER.debug("ControlLoopUpdate message sent", controlLoopUpdateMsg);
super.send(controlLoopUpdateMsg);
}
}