From: danielhanrahan Date: Wed, 24 Sep 2025 12:20:10 +0000 (+0100) Subject: Fix participant not sending ack X-Git-Tag: 8.2.1~7 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F13%2F142113%2F2;p=policy%2Fclamp.git Fix participant not sending ack After logging change, the code to send the ack was removed. This fixes recent CSIT failures. Also add unit tests. Issue-ID: POLICY-5452 Change-Id: I9ad595fca6082d9c34d0d63a109bfd7cdde99eb7 Signed-off-by: danielhanrahan --- 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 f520efc98..523b114d4 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 @@ -143,6 +143,7 @@ public class ParticipantMessagePublisher implements Publisher { description = "AUTOMATION_COMPOSITION_UPDATE_ACK/AUTOMATION_COMPOSITION_STATECHANGE_ACK messages published") public void sendAutomationCompositionAck(final AutomationCompositionDeployAck automationCompositionAck) { validate(); + topicSinkClient.send(automationCompositionAck); NetLoggerUtil.log(NetLoggerUtil.EventType.OUT, topicSinkClient.getSink().getTopicCommInfrastructure(), topicSinkClient.getTopic(), "Sent AutomationComposition Update/StateChange Ack to runtime - " + automationCompositionAck.toString()); 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 6b248fa10..63baef24d 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 @@ -27,6 +27,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; import java.util.Collections; import java.util.List; @@ -48,6 +49,9 @@ import org.onap.policy.clamp.models.acm.messages.kafka.participant.ParticipantSt import org.onap.policy.clamp.models.acm.messages.kafka.participant.ParticipantStatusReq; import org.onap.policy.common.message.bus.event.Topic; import org.onap.policy.common.message.bus.event.TopicSink; +import org.onap.policy.common.utils.coder.Coder; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.common.utils.coder.StandardCoderObject; class ParticipantCommTest { @@ -100,26 +104,35 @@ class ParticipantCommTest { } @Test - void participantMessagePublisherTest() { + void participantMessagePublisherTest() throws CoderException { + var coder = new StandardCoder(); + var mockTopicSink = mock(TopicSink.class); var publisher = new ParticipantMessagePublisher(); - publisher.active(Collections.singletonList(Mockito.mock(TopicSink.class))); + publisher.active(Collections.singletonList(mockTopicSink)); + var participantStatus = new ParticipantStatus(); assertDoesNotThrow(() -> publisher.sendParticipantStatus(participantStatus)); + verify(mockTopicSink).send(coder.encode(participantStatus)); var participantRegister = new ParticipantRegister(); assertDoesNotThrow(() -> publisher.sendParticipantRegister(participantRegister)); + verify(mockTopicSink).send(coder.encode(participantRegister)); var participantDeregister = new ParticipantDeregister(); assertDoesNotThrow(() -> publisher.sendParticipantDeregister(participantDeregister)); + verify(mockTopicSink).send(coder.encode(participantDeregister)); var participantPrimeAck = new ParticipantPrimeAck(); assertDoesNotThrow(() -> publisher.sendParticipantPrimeAck(participantPrimeAck)); + verify(mockTopicSink).send(coder.encode(participantPrimeAck)); - var automationCompositionAck = mock(AutomationCompositionDeployAck.class); + var automationCompositionAck = new AutomationCompositionDeployAck(ParticipantMessageType.AUTOMATION_COMPOSITION_DEPLOY); assertDoesNotThrow(() -> publisher.sendAutomationCompositionAck(automationCompositionAck)); + verify(mockTopicSink).send(coder.encode(automationCompositionAck)); - var participantReqSync = mock(ParticipantReqSync.class); + var participantReqSync = new ParticipantReqSync(); assertDoesNotThrow(() -> publisher.sendParticipantReqSync(participantReqSync)); + verify(mockTopicSink).send(coder.encode(participantReqSync)); } @Test