summaryrefslogtreecommitdiffstats
path: root/participant
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2021-08-09 16:27:25 +0100
committerFrancescoFioraEst <francesco.fiora@est.tech>2021-08-11 16:16:31 +0100
commit20e2a1787c703a7957728e0c9a190a556b0ae536 (patch)
treeb3cd7221cb234e8ff6deb7394e200ce7aa5421a3 /participant
parent8a2f14ae90528454c4aa2351f8f4c1e04eaed2b6 (diff)
Fix serialization of messages in Control Loop and Participants
Issue-ID: POLICY-3536 Change-Id: I72207ba8b3894238412bf19c32b799b661a23c21 Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'participant')
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/endtoend/ParticipantMessagesTest.java6
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/utils/TestListenerUtils.java21
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java13
3 files changed, 17 insertions, 23 deletions
diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/endtoend/ParticipantMessagesTest.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/endtoend/ParticipantMessagesTest.java
index aed03556a..08e7154bb 100644
--- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/endtoend/ParticipantMessagesTest.java
+++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/endtoend/ParticipantMessagesTest.java
@@ -156,12 +156,12 @@ class ParticipantMessagesTest {
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) {
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 b91cff22c..f87714e0e 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
@@ -34,7 +34,6 @@ import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop
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;
@@ -181,7 +180,7 @@ public class TestListenerUtils {
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());
@@ -200,10 +199,10 @@ public class TestListenerUtils {
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;
@@ -217,10 +216,8 @@ public class TestListenerUtils {
* @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;
}
@@ -254,7 +251,7 @@ public class TestListenerUtils {
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());
@@ -291,7 +288,7 @@ public class TestListenerUtils {
String policiesString = ResourceUtils.getResourceAsString(policiesFilePath);
ToscaServiceTemplate foundPoliciesSt =
- yamlTranslator.fromYaml(policiesString, ToscaServiceTemplate.class);
+ yamlTranslator.fromYaml(policiesString, ToscaServiceTemplate.class);
toscaServiceTemplate.getToscaTopologyTemplate().setPolicies(
foundPoliciesSt.getToscaTopologyTemplate().getPolicies());
}
@@ -305,7 +302,7 @@ public class TestListenerUtils {
}
ToscaServiceTemplate serviceTemplate = yamlTranslator.fromYaml(
- controlLoopString, ToscaServiceTemplate.class);
+ controlLoopString, ToscaServiceTemplate.class);
return serviceTemplate;
} catch (FileNotFoundException e) {
LOGGER.error("cannot find YAML file", controlLoopFilePath);
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 6a0e758dd..7aa89be51 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
@@ -32,16 +32,13 @@ import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant
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;
@@ -205,7 +202,7 @@ public class ParticipantHandler implements Closeable {
*/
public void handleParticipantRegisterAck(ParticipantRegisterAck participantRegisterAckMsg) {
LOGGER.debug("ParticipantRegisterAck message received as responseTo {}",
- participantRegisterAckMsg.getResponseTo());
+ participantRegisterAckMsg.getResponseTo());
}
/**
@@ -226,7 +223,7 @@ public class ParticipantHandler implements Closeable {
*/
public void handleParticipantDeregisterAck(ParticipantDeregisterAck participantDeregisterAckMsg) {
LOGGER.debug("ParticipantDeregisterAck message received as responseTo {}",
- participantDeregisterAckMsg.getResponseTo());
+ participantDeregisterAckMsg.getResponseTo());
}
/**
@@ -236,14 +233,14 @@ public class ParticipantHandler implements Closeable {
*/
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);