diff options
author | Ramesh Murugan Iyer <ramesh.murugan.iyer@est.tech> | 2023-02-03 09:01:30 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2023-02-03 09:01:30 +0000 |
commit | 26814a2d839be880fa56c658f0d88940d957e872 (patch) | |
tree | 7835255e47bf1e76648889c1427a5b9604f90e5b /participant | |
parent | b77b1160c9391f7b0cf1a16ce7e203a45203fb6a (diff) | |
parent | 9659c99c9c8b4b7ce33d7f48e61df44a03090186 (diff) |
Merge "Refactor ParticipantUpdate to ParticipantPrime"
Diffstat (limited to 'participant')
7 files changed, 77 insertions, 77 deletions
diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/endtoend/ParticipantMessagesTest.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/endtoend/ParticipantMessagesTest.java index 555183227..5ba598cc8 100644 --- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/endtoend/ParticipantMessagesTest.java +++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/endtoend/ParticipantMessagesTest.java @@ -32,18 +32,18 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mockito; import org.onap.policy.clamp.acm.participant.intermediary.comm.ParticipantDeregisterAckListener; import org.onap.policy.clamp.acm.participant.intermediary.comm.ParticipantMessagePublisher; +import org.onap.policy.clamp.acm.participant.intermediary.comm.ParticipantPrimeListener; import org.onap.policy.clamp.acm.participant.intermediary.comm.ParticipantRegisterAckListener; -import org.onap.policy.clamp.acm.participant.intermediary.comm.ParticipantUpdateListener; import org.onap.policy.clamp.acm.participant.intermediary.handler.ParticipantHandler; import org.onap.policy.clamp.acm.participant.policy.main.parameters.CommonTestData; import org.onap.policy.clamp.acm.participant.policy.main.utils.TestListenerUtils; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDeregister; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDeregisterAck; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantPrime; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantPrimeAck; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantRegister; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantRegisterAck; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantStatus; -import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdate; -import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdateAck; import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; import org.onap.policy.common.endpoints.event.comm.TopicSink; import org.springframework.beans.factory.annotation.Autowired; @@ -126,11 +126,11 @@ class ParticipantMessagesTest { @Test void testReceiveParticipantUpdateMessage() { - ParticipantUpdate participantUpdateMsg = TestListenerUtils.createParticipantUpdateMsg(); + ParticipantPrime participantPrimeMsg = TestListenerUtils.createParticipantPrimeMsg(); synchronized (lockit) { - ParticipantUpdateListener participantUpdateListener = new ParticipantUpdateListener(participantHandler); - participantUpdateListener.onTopicEvent(INFRA, TOPIC, null, participantUpdateMsg); + ParticipantPrimeListener participantPrimeListener = new ParticipantPrimeListener(participantHandler); + participantPrimeListener.onTopicEvent(INFRA, TOPIC, null, participantPrimeMsg); } // Verify the result of GET participants with what is stored @@ -138,16 +138,16 @@ class ParticipantMessagesTest { } @Test - void testSendParticipantUpdateAckMessage() { - final ParticipantUpdateAck participantUpdateAckMsg = new ParticipantUpdateAck(); - participantUpdateAckMsg.setMessage("ParticipantUpdateAck message"); - participantUpdateAckMsg.setResponseTo(UUID.randomUUID()); - participantUpdateAckMsg.setResult(true); + void testSendParticipantPrimeAckMessage() { + final ParticipantPrimeAck participantPrimeAckMsg = new ParticipantPrimeAck(); + participantPrimeAckMsg.setMessage("ParticipantPrimeAck message"); + participantPrimeAckMsg.setResponseTo(UUID.randomUUID()); + participantPrimeAckMsg.setResult(true); synchronized (lockit) { ParticipantMessagePublisher participantMessagePublisher = new ParticipantMessagePublisher(); participantMessagePublisher.active(Collections.singletonList(Mockito.mock(TopicSink.class))); - assertThatCode(() -> participantMessagePublisher.sendParticipantUpdateAck(participantUpdateAckMsg)) + assertThatCode(() -> participantMessagePublisher.sendParticipantPrimeAck(participantPrimeAckMsg)) .doesNotThrowAnyException(); } } diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/TestListenerUtils.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/TestListenerUtils.java index b7058a84f..17d961880 100644 --- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/TestListenerUtils.java +++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/TestListenerUtils.java @@ -29,7 +29,7 @@ import java.util.UUID; import lombok.AccessLevel; import lombok.NoArgsConstructor; import org.onap.policy.clamp.acm.participant.policy.main.parameters.CommonTestData; -import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdate; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantPrime; import org.onap.policy.common.utils.coder.YamlJsonTranslator; import org.onap.policy.common.utils.resources.ResourceUtils; import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; @@ -45,23 +45,23 @@ public final class TestListenerUtils { /** * Method to create participantUpdateMsg. * - * @return ParticipantUpdate message + * @return ParticipantPrime message */ - public static ParticipantUpdate createParticipantUpdateMsg() { - final var participantUpdateMsg = new ParticipantUpdate(); + public static ParticipantPrime createParticipantPrimeMsg() { + final var participantPrimeMsg = new ParticipantPrime(); var participantId = CommonTestData.getParticipantId(); - participantUpdateMsg.setParticipantId(participantId); - participantUpdateMsg.setTimestamp(Instant.now()); - participantUpdateMsg.setTimestamp(Instant.ofEpochMilli(3000)); - participantUpdateMsg.setMessageId(UUID.randomUUID()); + participantPrimeMsg.setParticipantId(participantId); + participantPrimeMsg.setTimestamp(Instant.now()); + participantPrimeMsg.setTimestamp(Instant.ofEpochMilli(3000)); + participantPrimeMsg.setMessageId(UUID.randomUUID()); var toscaServiceTemplate = testAutomationCompositionRead(); // Add policies to the toscaServiceTemplate TestListenerUtils.addPoliciesToToscaServiceTemplate(toscaServiceTemplate); - participantUpdateMsg.setParticipantDefinitionUpdates(new ArrayList<>()); - return participantUpdateMsg; + participantPrimeMsg.setParticipantDefinitionUpdates(new ArrayList<>()); + return participantPrimeMsg; } private static ToscaServiceTemplate testAutomationCompositionRead() { diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantMessagePublisher.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantMessagePublisher.java index b18875813..4c885fa26 100644 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantMessagePublisher.java +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantMessagePublisher.java @@ -28,9 +28,9 @@ import org.onap.policy.clamp.acm.participant.intermediary.handler.Publisher; import org.onap.policy.clamp.common.acm.exception.AutomationCompositionRuntimeException; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionDeployAck; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDeregister; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantPrimeAck; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantRegister; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantStatus; -import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdateAck; import org.onap.policy.common.endpoints.event.comm.TopicSink; import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClient; import org.slf4j.Logger; @@ -100,15 +100,15 @@ public class ParticipantMessagePublisher implements Publisher { } /** - * Method to send Participant Update Ack message to runtime. + * Method to send Participant Prime Ack message to runtime. * - * @param participantUpdateAck the Participant Update Ack + * @param participantPrimeAck the Participant Prime Ack */ - @Timed(value = "publisher.participant_update_ack", description = "PARTICIPANT_UPDATE_ACK messages published") - public void sendParticipantUpdateAck(final ParticipantUpdateAck participantUpdateAck) { + @Timed(value = "publisher.participant_prime_ack", description = "PARTICIPANT_PRIME_ACK messages published") + public void sendParticipantPrimeAck(final ParticipantPrimeAck participantPrimeAck) { validate(); - topicSinkClient.send(participantUpdateAck); - LOGGER.debug("Sent Participant Update Ack message to CLAMP - {}", participantUpdateAck); + topicSinkClient.send(participantPrimeAck); + LOGGER.debug("Sent Participant Prime Ack message to CLAMP - {}", participantPrimeAck); } /** diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantUpdateListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantPrimeListener.java index 19eb5fb30..e114c74f9 100644 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantUpdateListener.java +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantPrimeListener.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. + * Copyright (C) 2021-2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,26 +22,26 @@ package org.onap.policy.clamp.acm.participant.intermediary.comm; import org.onap.policy.clamp.acm.participant.intermediary.handler.ParticipantHandler; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType; -import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdate; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantPrime; import org.springframework.stereotype.Component; /** - * Listener for Participant Update messages sent by runtime. + * Listener for Participant Prime messages sent by runtime. */ @Component -public class ParticipantUpdateListener extends ParticipantListener<ParticipantUpdate> { +public class ParticipantPrimeListener extends ParticipantListener<ParticipantPrime> { /** * Constructs the object. * * @param participantHandler the handler for managing the state of the participant */ - public ParticipantUpdateListener(final ParticipantHandler participantHandler) { - super(ParticipantUpdate.class, participantHandler, participantHandler::handleParticipantUpdate); + public ParticipantPrimeListener(final ParticipantHandler participantHandler) { + super(ParticipantPrime.class, participantHandler, participantHandler::handleParticipantPrime); } @Override public String getType() { - return ParticipantMessageType.PARTICIPANT_UPDATE.name(); + return ParticipantMessageType.PARTICIPANT_PRIME.name(); } } 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 050d66d0b..3aae2c41a 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 @@ -42,12 +42,12 @@ import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantAc import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDeregister; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDeregisterAck; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessage; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantPrime; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantPrimeAck; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantRegister; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantRegisterAck; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantStatus; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantStatusReq; -import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdate; -import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdateAck; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @@ -186,44 +186,44 @@ public class ParticipantHandler { } /** - * Handle a ParticipantUpdate message. + * Handle a ParticipantPrime message. * - * @param participantUpdateMsg the ParticipantUpdate message + * @param participantPrimeMsg the ParticipantPrime message */ - @Timed(value = "listener.participant_update", description = "PARTICIPANT_UPDATE messages received") - public void handleParticipantUpdate(ParticipantUpdate participantUpdateMsg) { - LOGGER.debug("ParticipantUpdate message received for participantId {}", - participantUpdateMsg.getParticipantId()); + @Timed(value = "listener.participant_prime", description = "PARTICIPANT_PRIME messages received") + public void handleParticipantPrime(ParticipantPrime participantPrimeMsg) { + LOGGER.debug("ParticipantPrime message received for participantId {}", + participantPrimeMsg.getParticipantId()); - acElementDefsMap.putIfAbsent(participantUpdateMsg.getCompositionId(), new ArrayList<>()); - if (!participantUpdateMsg.getParticipantDefinitionUpdates().isEmpty()) { + acElementDefsMap.putIfAbsent(participantPrimeMsg.getCompositionId(), new ArrayList<>()); + if (!participantPrimeMsg.getParticipantDefinitionUpdates().isEmpty()) { // This message is to commission the automation composition - for (var participantDefinition : participantUpdateMsg.getParticipantDefinitionUpdates()) { + for (var participantDefinition : participantPrimeMsg.getParticipantDefinitionUpdates()) { if (participantDefinition.getParticipantId().equals(participantId)) { - acElementDefsMap.get(participantUpdateMsg.getCompositionId()) + acElementDefsMap.get(participantPrimeMsg.getCompositionId()) .addAll(participantDefinition.getAutomationCompositionElementDefinitionList()); break; } } } else { // This message is to decommission the automation composition - acElementDefsMap.get(participantUpdateMsg.getCompositionId()).clear(); + acElementDefsMap.get(participantPrimeMsg.getCompositionId()).clear(); } - sendParticipantUpdateAck(participantUpdateMsg.getMessageId(), participantUpdateMsg.getCompositionId()); + sendParticipantPrimeAck(participantPrimeMsg.getMessageId(), participantPrimeMsg.getCompositionId()); } /** - * Method to send ParticipantUpdateAck message to automation composition runtime. + * Method to send ParticipantPrimeAck message to automation composition runtime. */ - public void sendParticipantUpdateAck(UUID messageId, UUID compositionId) { - var participantUpdateAck = new ParticipantUpdateAck(); - participantUpdateAck.setResponseTo(messageId); - participantUpdateAck.setCompositionId(compositionId); - participantUpdateAck.setMessage("Participant Update Ack message"); - participantUpdateAck.setResult(true); - participantUpdateAck.setParticipantId(participantId); - participantUpdateAck.setState(ParticipantState.ON_LINE); - publisher.sendParticipantUpdateAck(participantUpdateAck); + public void sendParticipantPrimeAck(UUID messageId, UUID compositionId) { + var participantPrimeAck = new ParticipantPrimeAck(); + participantPrimeAck.setResponseTo(messageId); + participantPrimeAck.setCompositionId(compositionId); + participantPrimeAck.setMessage("Participant Prime Ack message"); + participantPrimeAck.setResult(true); + participantPrimeAck.setParticipantId(participantId); + participantPrimeAck.setState(ParticipantState.ON_LINE); + publisher.sendParticipantPrimeAck(participantPrimeAck); } /** diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantCommTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantCommTest.java index d9d99da4e..1540d6e4c 100644 --- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantCommTest.java +++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantCommTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021-2022 Nordix Foundation. + * Copyright (C) 2021-2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,8 +56,8 @@ class ParticipantCommTest { assertEquals(ParticipantMessageType.PARTICIPANT_DEREGISTER_ACK.name(), participantDeregisterAckListener.getType()); - var participantUpdateListener = new ParticipantUpdateListener(participantHandler); - assertEquals(ParticipantMessageType.PARTICIPANT_UPDATE.name(), participantUpdateListener.getType()); + var participantPrimeListener = new ParticipantPrimeListener(participantHandler); + assertEquals(ParticipantMessageType.PARTICIPANT_PRIME.name(), participantPrimeListener.getType()); var automationCompositionUpdateListener = new AutomationCompositionDeployListener(participantHandler); assertEquals(ParticipantMessageType.AUTOMATION_COMPOSITION_DEPLOY.name(), diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandlerTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandlerTest.java index 9f1bf29be..7349ab9c0 100644 --- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandlerTest.java +++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandlerTest.java @@ -39,8 +39,8 @@ import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantAckMessage; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessage; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantPrime; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantRegisterAck; -import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdate; import org.onap.policy.common.utils.coder.CoderException; class ParticipantHandlerTest { @@ -54,43 +54,43 @@ class ParticipantHandlerTest { var publisher = new ParticipantMessagePublisher(); var emptyParticipantHandler = new ParticipantHandler(parameters, publisher, automationCompositionHander); - var participantUpdateMsg = new ParticipantUpdate(); + var participantPrimeMsg = new ParticipantPrime(); assertThatThrownBy(() -> - emptyParticipantHandler.handleParticipantUpdate(participantUpdateMsg)) + emptyParticipantHandler.handleParticipantPrime(participantPrimeMsg)) .isInstanceOf(RuntimeException.class); var participantHandler = commonTestData.getMockParticipantHandler(); var participantId = CommonTestData.getParticipantId(); - participantUpdateMsg.setAutomationCompositionId(CommonTestData.AC_ID_1); - participantUpdateMsg.setCompositionId(CommonTestData.AC_ID_1); - participantUpdateMsg.setParticipantId(participantId); - participantUpdateMsg.setMessageId(UUID.randomUUID()); - participantUpdateMsg.setTimestamp(Instant.ofEpochMilli(3000)); + participantPrimeMsg.setAutomationCompositionId(CommonTestData.AC_ID_1); + participantPrimeMsg.setCompositionId(CommonTestData.AC_ID_1); + participantPrimeMsg.setParticipantId(participantId); + participantPrimeMsg.setMessageId(UUID.randomUUID()); + participantPrimeMsg.setTimestamp(Instant.ofEpochMilli(3000)); var heartbeatF = participantHandler.makeHeartbeat(false); assertEquals(participantId, heartbeatF.getParticipantId()); assertThat(heartbeatF.getAutomationCompositionInfoList()).isEmpty(); - participantHandler.handleParticipantUpdate(participantUpdateMsg); + participantHandler.handleParticipantPrime(participantPrimeMsg); var heartbeatT = participantHandler.makeHeartbeat(true); assertEquals(participantId, heartbeatT.getParticipantId()); assertThat(heartbeatT.getParticipantDefinitionUpdates()).isNotEmpty(); assertEquals(participantId, heartbeatT.getParticipantDefinitionUpdates().get(0).getParticipantId()); - var pum = setListParticipantDefinition(participantUpdateMsg); - participantHandler.handleParticipantUpdate(pum); + var pum = setListParticipantDefinition(participantPrimeMsg); + participantHandler.handleParticipantPrime(pum); var heartbeatTAfterUpdate = participantHandler.makeHeartbeat(true); assertEquals(participantId, heartbeatTAfterUpdate.getParticipantId()); } - private ParticipantUpdate setListParticipantDefinition(ParticipantUpdate participantUpdateMsg) { + private ParticipantPrime setListParticipantDefinition(ParticipantPrime participantPrimeMsg) { var def = new ParticipantDefinition(); def.setParticipantId(CommonTestData.getParticipantId()); - participantUpdateMsg.setParticipantDefinitionUpdates(List.of(def)); - return participantUpdateMsg; + participantPrimeMsg.setParticipantDefinitionUpdates(List.of(def)); + return participantPrimeMsg; } @Test |