diff options
author | Ramesh Murugan Iyer <ramesh.murugan.iyer@est.tech> | 2023-02-27 08:58:49 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2023-02-27 08:58:49 +0000 |
commit | f12d441b34bee2e7f5c2488ed05c4abf0f86ba7a (patch) | |
tree | 17e40b1709c92075827a7028cced154df5ebafad | |
parent | 210646c4aa2f9edb50b6894fbe06f0a8d6ea4610 (diff) | |
parent | 660e20098d446046a27b03b44bccd069aae5408b (diff) |
Merge "Fix ClassCastException in ACM"
3 files changed, 22 insertions, 12 deletions
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java index ff967791d..5565e0bd0 100644 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java @@ -93,7 +93,6 @@ public class ParticipantHandler { @Timed(value = "listener.participant_status_req", description = "PARTICIPANT_STATUS_REQ messages received") public void handleParticipantStatusReq(final ParticipantStatusReq participantStatusReqMsg) { var participantStatus = makeHeartbeat(true); - participantStatus.setParticipantSupportedElementType(this.supportedAcElementTypes); publisher.sendParticipantStatus(participantStatus); } @@ -268,6 +267,7 @@ public class ParticipantHandler { heartbeat.setParticipantId(participantId); heartbeat.setState(ParticipantState.ON_LINE); heartbeat.setAutomationCompositionInfoList(getAutomationCompositionInfoList()); + heartbeat.setParticipantSupportedElementType(new ArrayList<>(this.supportedAcElementTypes)); if (responseToParticipantStatusReq) { List<ParticipantDefinition> participantDefinitionList = new ArrayList<>(acElementDefsMap.size()); diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java index 6cf75ccb6..c1bfcf07a 100644 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java @@ -62,7 +62,8 @@ public class SupervisionParticipantHandler { @Timed(value = "listener.participant_register", description = "PARTICIPANT_REGISTER messages received") public void handleParticipantMessage(ParticipantRegister participantRegisterMsg) { LOGGER.debug("Participant Register received {}", participantRegisterMsg); - saveParticipantStatus(participantRegisterMsg); + saveParticipantStatus(participantRegisterMsg, + listToMap(participantRegisterMsg.getParticipantSupportedElementType())); participantRegisterAckPublisher.send(participantRegisterMsg.getMessageId(), participantRegisterMsg.getParticipantId()); @@ -98,18 +99,18 @@ public class SupervisionParticipantHandler { @Timed(value = "listener.participant_status", description = "PARTICIPANT_STATUS messages received") public void handleParticipantMessage(ParticipantStatus participantStatusMsg) { LOGGER.debug("Participant Status received {}", participantStatusMsg); - saveParticipantStatus(participantStatusMsg); + saveParticipantStatus(participantStatusMsg, + listToMap(participantStatusMsg.getParticipantSupportedElementType())); } - private void saveParticipantStatus(ParticipantMessage participantMessage) { + private void saveParticipantStatus(ParticipantMessage participantMessage, + Map<UUID, ParticipantSupportedElementType> participantSupportedElementType) { var participantOpt = participantProvider.findParticipant(participantMessage.getParticipantId()); if (participantOpt.isEmpty()) { - ParticipantRegister registerMessage = (ParticipantRegister) participantMessage; var participant = new Participant(); participant.setParticipantId(participantMessage.getParticipantId()); - participant.setParticipantSupportedElementTypes(listToMap(registerMessage - .getParticipantSupportedElementType())); + participant.setParticipantSupportedElementTypes(participantSupportedElementType); participant.setParticipantState(ParticipantState.ON_LINE); participantProvider.saveParticipant(participant); diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java index 246ba7dc7..fb12e040a 100644 --- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java @@ -25,14 +25,16 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import java.util.ArrayList; +import java.util.List; import java.util.Optional; import java.util.UUID; import org.junit.jupiter.api.Test; import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantDeregisterAckPublisher; import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantRegisterAckPublisher; import org.onap.policy.clamp.acm.runtime.util.CommonTestData; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionInfo; import org.onap.policy.clamp.models.acm.concepts.ParticipantState; +import org.onap.policy.clamp.models.acm.concepts.ParticipantSupportedElementType; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDeregister; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantRegister; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantStatus; @@ -66,12 +68,15 @@ class SupervisionParticipantHandlerTest { var participantRegisterMessage = new ParticipantRegister(); participantRegisterMessage.setMessageId(UUID.randomUUID()); participantRegisterMessage.setParticipantId(CommonTestData.getParticipantId()); + var supportedElementType = new ParticipantSupportedElementType(); + supportedElementType.setTypeName("Type"); + supportedElementType.setTypeVersion("1.0.0"); + participantRegisterMessage.setParticipantSupportedElementType(List.of(supportedElementType)); + var participantProvider = mock(ParticipantProvider.class); var participantRegisterAckPublisher = mock(ParticipantRegisterAckPublisher.class); var handler = new SupervisionParticipantHandler(participantProvider, participantRegisterAckPublisher, - mock(ParticipantDeregisterAckPublisher.class)); - participantRegisterMessage.setParticipantSupportedElementType(new ArrayList<>()); - + mock(ParticipantDeregisterAckPublisher.class)); handler.handleParticipantMessage(participantRegisterMessage); verify(participantProvider).saveParticipant(any()); @@ -84,7 +89,11 @@ class SupervisionParticipantHandlerTest { var participantStatusMessage = new ParticipantStatus(); participantStatusMessage.setParticipantId(CommonTestData.getParticipantId()); participantStatusMessage.setState(ParticipantState.ON_LINE); - participantStatusMessage.setParticipantSupportedElementType(new ArrayList<>()); + var supportedElementType = new ParticipantSupportedElementType(); + supportedElementType.setTypeName("Type"); + supportedElementType.setTypeVersion("1.0.0"); + participantStatusMessage.setParticipantSupportedElementType(List.of(supportedElementType)); + participantStatusMessage.setAutomationCompositionInfoList(List.of(new AutomationCompositionInfo())); var participantProvider = mock(ParticipantProvider.class); var handler = new SupervisionParticipantHandler(participantProvider, |