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.
// 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>>
+ private Map<String, Map<UUID, ControlLoopElementDefinition>>
participantDefinitionUpdateMap = new LinkedHashMap<>();
// Map of ControlLoopInfo types indexed by ControlLoopId, one entry for each control loop
- private Map<ToscaConceptIdentifier, ControlLoopInfo> controlLoopInfoMap;
+ private Map<String, ControlLoopInfo> controlLoopInfoMap;
/**
* Constructor for instantiating ParticipantStatus class with message name.
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.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElementDefinition;
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.
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>>
+ private Map<String, Map<UUID, ControlLoopElementDefinition>>
participantDefinitionUpdateMap = new LinkedHashMap<>();
/**
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 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;
/**
class ControlLoopStateChangeTest {
@Test
- void testCopyConstructor() {
+ void testCopyConstructor() throws CoderException {
assertThatThrownBy(() -> new ControlLoopStateChange(null)).isInstanceOf(NullPointerException.class);
ControlLoopStateChange orig = new ControlLoopStateChange();
assertEquals(removeVariableFields(orig.toString()),
removeVariableFields(new ControlLoopStateChange(orig).toString()));
+
+ assertSerializable(orig, ControlLoopStateChange.class);
}
}
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);
newmsg = new ParticipantAckMessage(message);
newmsg.setResponseTo(message.getResponseTo());
assertEquals(message.toString(), newmsg.toString());
+
+ assertSerializable(message, ParticipantAckMessage.class);
}
private ParticipantAckMessage makeMessage() {
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();
assertEquals(removeVariableFields(orig.toString()),
removeVariableFields(new ParticipantDeregisterAck(orig).toString()));
+
+ assertSerializable(orig, ParticipantDeregisterAck.class);
}
}
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();
assertEquals(removeVariableFields(orig.toString()),
removeVariableFields(new ParticipantDeregister(orig).toString()));
+
+ assertSerializable(orig, ParticipantDeregister.class);
}
}
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);
newmsg.setMessageId(message.getMessageId());
newmsg.setTimestamp(message.getTimestamp());
assertEquals(message.toString(), newmsg.toString());
+
+ assertSerializable(message, ParticipantMessage.class);
}
@Test
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.
*/
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()));
+ }
}
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();
assertEquals(removeVariableFields(orig.toString()),
removeVariableFields(new ParticipantRegisterAck(orig).toString()));
+
+ assertSerializable(orig, ParticipantRegisterAck.class);
}
}
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();
assertEquals(removeVariableFields(orig.toString()),
removeVariableFields(new ParticipantRegister(orig).toString()));
+
+ assertSerializable(orig, ParticipantRegister.class);
}
}
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 ParticipantStatusReqTest {
@Test
- void testCopyConstructor() {
+ void testCopyConstructor() throws CoderException {
assertThatThrownBy(() -> new ParticipantStatusReq(null)).isInstanceOf(NullPointerException.class);
ParticipantStatusReq orig = new ParticipantStatusReq();
ParticipantStatusReq other = new ParticipantStatusReq(orig);
assertEquals(removeVariableFields(orig.toString()), removeVariableFields(other.toString()));
+
+ assertSerializable(orig, ParticipantStatusReq.class);
}
}
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 org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopStatistics;
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;
class ParticipantStatusTest {
@Test
- void testCopyConstructor() {
+ void testCopyConstructor() throws CoderException {
assertThatThrownBy(() -> new ParticipantStatus(null)).isInstanceOf(NullPointerException.class);
final ParticipantStatus orig = new ParticipantStatus();
orig.setTimestamp(Instant.ofEpochMilli(3000));
ControlLoopInfo clInfo = getControlLoopInfo(id);
- orig.setControlLoopInfoMap(Map.of(id, clInfo));
+ orig.setControlLoopInfoMap(Map.of(id.toString(), clInfo));
ControlLoopElementDefinition clDefinition = getClElementDefinition();
Map<UUID, ControlLoopElementDefinition> clElementDefinitionMap = Map.of(UUID.randomUUID(), clDefinition);
- Map<ToscaConceptIdentifier, Map<UUID, ControlLoopElementDefinition>>
- participantDefinitionUpdateMap = Map.of(id, clElementDefinitionMap);
+ Map<String, Map<UUID, ControlLoopElementDefinition>>
+ participantDefinitionUpdateMap = Map.of(id.toString(), clElementDefinitionMap);
orig.setParticipantDefinitionUpdateMap(participantDefinitionUpdateMap);
assertEquals(removeVariableFields(orig.toString()),
removeVariableFields(new ParticipantStatus(orig).toString()));
+
+ assertSerializable(orig, ParticipantStatus.class);
}
private ControlLoopInfo getControlLoopInfo(ToscaConceptIdentifier id) {
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();
assertEquals(removeVariableFields(orig.toString()),
removeVariableFields(new ParticipantUpdateAck(orig).toString()));
+
+ assertSerializable(orig, ParticipantUpdateAck.class);
}
}
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.clamp.controlloop.models.controlloop.concepts.ControlLoopElementDefinition;
+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;
*/
class ParticipantUpdateTest {
@Test
- void testCopyConstructor() {
+ void testCopyConstructor() throws CoderException {
assertThatThrownBy(() -> new ParticipantUpdate(null)).isInstanceOf(NullPointerException.class);
ParticipantUpdate orig = new ParticipantUpdate();
Map<UUID, ControlLoopElementDefinition> clElementDefinitionMap = Map.of(UUID.randomUUID(), clDefinition);
- Map<ToscaConceptIdentifier, Map<UUID, ControlLoopElementDefinition>>
- participantDefinitionUpdateMap = Map.of(id, clElementDefinitionMap);
+ Map<String, Map<UUID, ControlLoopElementDefinition>> participantDefinitionUpdateMap =
+ Map.of(id.toString(), clElementDefinitionMap);
orig.setParticipantDefinitionUpdateMap(participantDefinitionUpdateMap);
ParticipantUpdate other = new ParticipantUpdate(orig);
assertEquals(removeVariableFields(orig.toString()), removeVariableFields(other.toString()));
+
+ assertSerializable(orig, ParticipantUpdate.class);
}
}
final ParticipantStatus heartbeat = new ParticipantStatus();
heartbeat.setParticipantId(getParticipantId());
ControlLoopInfo clInfo = getControlLoopInfo(getControlLoopId());
- heartbeat.setControlLoopInfoMap(Map.of(getControlLoopId(), clInfo));
+ heartbeat.setControlLoopInfoMap(Map.of(getControlLoopId().toString(), clInfo));
ControlLoopElementDefinition clDefinition = getClElementDefinition();
Map<UUID, ControlLoopElementDefinition> clElementDefinitionMap = Map.of(UUID.randomUUID(), clDefinition);
- Map<ToscaConceptIdentifier, Map<UUID, ControlLoopElementDefinition>>
- participantDefinitionUpdateMap = Map.of(getParticipantId(), clElementDefinitionMap);
+ Map<String, Map<UUID, ControlLoopElementDefinition>>
+ participantDefinitionUpdateMap = Map.of(getParticipantId().toString(), clElementDefinitionMap);
heartbeat.setParticipantDefinitionUpdateMap(participantDefinitionUpdateMap);
synchronized (lockit) {
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.ParticipantState;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopStateChange;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopUpdate;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdate;
final ParticipantUpdate participantUpdateMsg = new ParticipantUpdate();
ToscaConceptIdentifier participantId = new ToscaConceptIdentifier("org.onap.PM_Policy", "1.0.0");
ToscaConceptIdentifier participantType = new ToscaConceptIdentifier(
- "org.onap.policy.controlloop.PolicyControlLoopParticipant", "2.3.1");
+ "org.onap.policy.controlloop.PolicyControlLoopParticipant", "2.3.1");
participantUpdateMsg.setParticipantId(participantId);
participantUpdateMsg.setTimestamp(Instant.now());
clDefinition.setCommonPropertiesMap(commonPropertiesMap);
Map<UUID, ControlLoopElementDefinition> controlLoopElementDefinitionMap =
- Map.of(UUID.randomUUID(), clDefinition);
+ Map.of(UUID.randomUUID(), clDefinition);
- Map<ToscaConceptIdentifier, Map<UUID, ControlLoopElementDefinition>>
- participantDefinitionUpdateMap = Map.of(participantId, controlLoopElementDefinitionMap);
+ Map<String, Map<UUID, ControlLoopElementDefinition>> participantDefinitionUpdateMap =
+ Map.of(participantId.toString(), controlLoopElementDefinitionMap);
participantUpdateMsg.setParticipantDefinitionUpdateMap(participantDefinitionUpdateMap);
return participantUpdateMsg;
* @return ControlLoopUpdate message
* @throws CoderException exception while reading the file to object
*/
- public static ControlLoopUpdate createParticipantClUpdateMsgFromJson(String jsonFilePath)
- throws CoderException {
- ControlLoopUpdate controlLoopUpdateMsg =
- CODER.decode(new File(jsonFilePath), ControlLoopUpdate.class);
+ public static ControlLoopUpdate createParticipantClUpdateMsgFromJson(String jsonFilePath) throws CoderException {
+ ControlLoopUpdate controlLoopUpdateMsg = CODER.decode(new File(jsonFilePath), ControlLoopUpdate.class);
return controlLoopUpdateMsg;
}
String policyTypeString = ResourceUtils.getResourceAsString(policyTypeFilePath);
ToscaServiceTemplate foundPolicyTypeSt =
- yamlTranslator.fromYaml(policyTypeString, ToscaServiceTemplate.class);
+ yamlTranslator.fromYaml(policyTypeString, ToscaServiceTemplate.class);
toscaServiceTemplate.setDerivedFrom(foundPolicyTypeSt.getDerivedFrom());
toscaServiceTemplate.setDescription(foundPolicyTypeSt.getDescription());
String policiesString = ResourceUtils.getResourceAsString(policiesFilePath);
ToscaServiceTemplate foundPoliciesSt =
- yamlTranslator.fromYaml(policiesString, ToscaServiceTemplate.class);
+ yamlTranslator.fromYaml(policiesString, ToscaServiceTemplate.class);
toscaServiceTemplate.getToscaTopologyTemplate().setPolicies(
foundPoliciesSt.getToscaTopologyTemplate().getPolicies());
}
}
ToscaServiceTemplate serviceTemplate = yamlTranslator.fromYaml(
- controlLoopString, ToscaServiceTemplate.class);
+ controlLoopString, ToscaServiceTemplate.class);
return serviceTemplate;
} catch (FileNotFoundException e) {
LOGGER.error("cannot find YAML file", controlLoopFilePath);
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.clamp.controlloop.models.messages.dmaap.participant.ControlLoopAck;
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.ParticipantDeregister;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantDeregisterAck;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessage;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantRegister;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantRegisterAck;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantResponseStatus;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStatus;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStatusReq;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdate;
*/
public void handleParticipantRegisterAck(ParticipantRegisterAck participantRegisterAckMsg) {
LOGGER.debug("ParticipantRegisterAck message received as responseTo {}",
- participantRegisterAckMsg.getResponseTo());
+ participantRegisterAckMsg.getResponseTo());
}
/**
*/
public void handleParticipantDeregisterAck(ParticipantDeregisterAck participantDeregisterAckMsg) {
LOGGER.debug("ParticipantDeregisterAck message received as responseTo {}",
- participantDeregisterAckMsg.getResponseTo());
+ participantDeregisterAckMsg.getResponseTo());
}
/**
*/
public void handleParticipantUpdate(ParticipantUpdate participantUpdateMsg) {
LOGGER.debug("ParticipantUpdate message received for participantId {}",
- participantUpdateMsg.getParticipantId());
+ participantUpdateMsg.getParticipantId());
if (!participantUpdateMsg.appliesTo(participantType, participantId)) {
return;
}
- Map<UUID, ControlLoopElementDefinition> clDefinitionMap =
- participantUpdateMsg.getParticipantDefinitionUpdateMap().get(participantUpdateMsg.getParticipantId());
+ Map<UUID, ControlLoopElementDefinition> clDefinitionMap = participantUpdateMsg
+ .getParticipantDefinitionUpdateMap().get(participantUpdateMsg.getParticipantId().toString());
for (ControlLoopElementDefinition element : clDefinitionMap.values()) {
clElementDefsOnThisParticipant.put(element.getId(), element);
import org.apache.commons.collections4.CollectionUtils;
import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
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.ControlLoopInfo;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant;
private void superviseControlLoops(ParticipantStatus participantStatusMessage)
throws PfModelException, ControlLoopException {
- for (Map.Entry<ToscaConceptIdentifier, ControlLoopInfo> clEntry :
- participantStatusMessage.getControlLoopInfoMap().entrySet()) {
- var dbControlLoop = controlLoopProvider.getControlLoop(new ToscaConceptIdentifier(
- clEntry.getKey().getName(), clEntry.getKey().getVersion()));
- if (dbControlLoop == null) {
- exceptionOccured(Response.Status.NOT_FOUND,
- "PARTICIPANT_STATUS control loop not found in database: " + clEntry.getKey());
+ if (participantStatusMessage.getControlLoopInfoMap() != null) {
+ for (Map.Entry<String, ControlLoopInfo> clEntry : participantStatusMessage.getControlLoopInfoMap()
+ .entrySet()) {
+ String[] key = clEntry.getKey().split(" ");
+ var dbControlLoop = controlLoopProvider.getControlLoop(
+ new ToscaConceptIdentifier(key[0], key[1]));
+ if (dbControlLoop == null) {
+ exceptionOccured(Response.Status.NOT_FOUND,
+ "PARTICIPANT_STATUS control loop not found in database: " + clEntry.getKey());
+ }
+ dbControlLoop.setState(clEntry.getValue().getState());
+ monitoringProvider.createClElementStatistics(clEntry.getValue().getControlLoopStatistics()
+ .getClElementStatisticsList().getClElementStatistics());
}
- dbControlLoop.setState(clEntry.getValue().getState());
- monitoringProvider.createClElementStatistics(clEntry.getValue()
- .getControlLoopStatistics().getClElementStatisticsList().getClElementStatistics());
}
}
Map<UUID, ControlLoopElementDefinition> controlLoopElementDefinitionMap = new LinkedHashMap<>();
controlLoopElementDefinitionMap.put(UUID.randomUUID(), clDefinition);
- Map<ToscaConceptIdentifier, Map<UUID, ControlLoopElementDefinition>> participantDefinitionUpdateMap =
- new LinkedHashMap<>();
- participantDefinitionUpdateMap.put(participantId, controlLoopElementDefinitionMap);
+ Map<String, Map<UUID, ControlLoopElementDefinition>> participantDefinitionUpdateMap = new LinkedHashMap<>();
+ participantDefinitionUpdateMap.put(participantId.toString(), controlLoopElementDefinitionMap);
message.setParticipantDefinitionUpdateMap(participantDefinitionUpdateMap);
LOGGER.debug("Participant Update sent {}", message);
public static void setupDbProviderParameters() throws PfModelException {
ClRuntimeParameterGroup controlLoopParameters = CommonTestData.geParameterGroup("instantproviderdb");
- modelsProvider =
- CommonTestData.getPolicyModelsProvider(controlLoopParameters.getDatabaseProviderParameters());
+ modelsProvider = CommonTestData.getPolicyModelsProvider(controlLoopParameters.getDatabaseProviderParameters());
clProvider = new ControlLoopProvider(controlLoopParameters.getDatabaseProviderParameters());
var participantStatisticsProvider =
new ParticipantStatisticsProvider(controlLoopParameters.getDatabaseProviderParameters());
var participantDeregisterAckPublisher = Mockito.mock(ParticipantDeregisterAckPublisher.class);
var participantUpdatePublisher = Mockito.mock(ParticipantUpdatePublisher.class);
supervisionHandler = new SupervisionHandler(clProvider, participantProvider, monitoringProvider,
- controlLoopUpdatePublisher, controlLoopStateChangePublisher,
- participantRegisterAckPublisher, participantDeregisterAckPublisher, participantUpdatePublisher);
+ controlLoopUpdatePublisher, controlLoopStateChangePublisher, participantRegisterAckPublisher,
+ participantDeregisterAckPublisher, participantUpdatePublisher);
}
@AfterAll
synchronized (lockit) {
ParticipantRegisterListener participantRegisterListener =
new ParticipantRegisterListener(supervisionHandler);
- ToscaServiceTemplate serviceTemplate = yamlTranslator
- .fromYaml(ResourceUtils.getResourceAsString(TOSCA_SERVICE_TEMPLATE_YAML), ToscaServiceTemplate.class);
+ ToscaServiceTemplate serviceTemplate = yamlTranslator.fromYaml(
+ ResourceUtils.getResourceAsString(TOSCA_SERVICE_TEMPLATE_YAML), ToscaServiceTemplate.class);
List<ToscaNodeTemplate> listOfTemplates = commissioningProvider.getControlLoopDefinitions(null, null);
commissioningProvider.createControlLoopDefinitions(serviceTemplate);
clDefinition.setCommonPropertiesMap(commonPropertiesMap);
Map<UUID, ControlLoopElementDefinition> controlLoopElementDefinitionMap =
- Map.of(UUID.randomUUID(), clDefinition);
+ Map.of(UUID.randomUUID(), clDefinition);
- Map<ToscaConceptIdentifier, Map<UUID, ControlLoopElementDefinition>>
- participantDefinitionUpdateMap = Map.of(getParticipantId(), controlLoopElementDefinitionMap);
+ Map<String, Map<UUID, ControlLoopElementDefinition>> participantDefinitionUpdateMap =
+ Map.of(getParticipantId().toString(), controlLoopElementDefinitionMap);
participantUpdateMsg.setParticipantDefinitionUpdateMap(participantDefinitionUpdateMap);
synchronized (lockit) {