Fix for intermittent MsgExecutorTest failure 08/143308/2
authordanielhanrahan <daniel.hanrahan@est.tech>
Fri, 13 Feb 2026 10:13:30 +0000 (10:13 +0000)
committerDaniel Hanrahan <daniel.hanrahan@est.tech>
Fri, 13 Feb 2026 10:50:43 +0000 (10:50 +0000)
Use awaitility to wait until the messagesOnHold is empty.

Issue-ID: POLICY-5543
Change-Id: Iaa3f3c469dc3fae99bfcee7984d5434e218ca16d
Signed-off-by: danielhanrahan <daniel.hanrahan@est.tech>
participant/participant-intermediary/pom.xml
participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/MsgExecutorTest.java

index b0f99b9..c601a8f 100644 (file)
             <artifactId>spring-boot-starter-test</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.awaitility</groupId>
+            <artifactId>awaitility</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 </project>
index f8eeaf2..8e587c2 100644 (file)
@@ -21,6 +21,7 @@
 package org.onap.policy.clamp.acm.participant.intermediary.handler;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.awaitility.Awaitility.await;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.timeout;
@@ -28,6 +29,7 @@ import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 
 import java.util.UUID;
+import java.util.concurrent.TimeUnit;
 import org.junit.jupiter.api.Test;
 import org.onap.policy.clamp.acm.participant.intermediary.comm.ParticipantMessagePublisher;
 import org.onap.policy.clamp.acm.participant.intermediary.handler.cache.AutomationCompositionMsg;
@@ -80,7 +82,7 @@ class MsgExecutorTest {
         cacheProvider.addElementDefinition(compositionId, definitions, revisionIdComposition);
         msgExecutor.check();
         verify(automationCompositionHandler, timeout(200)).handleAutomationCompositionDeploy(updateMsg);
-        assertThat(cacheProvider.getMessagesOnHold()).isEmpty();
+        await().atMost(200, TimeUnit.MILLISECONDS).until(() -> cacheProvider.getMessagesOnHold().isEmpty());
     }
 
     @Test
@@ -120,7 +122,7 @@ class MsgExecutorTest {
         cacheProvider.initializeAutomationComposition(compositionId, automationComposition.getInstanceId(),
                 participantDeploy, acMsg.getRevisionIdInstance());
         msgExecutor.check();
-        verify(automationCompositionHandler, timeout(100)).handleAutomationCompositionStateChange(stateChangeMsg);
-        assertThat(cacheProvider.getMessagesOnHold()).isEmpty();
+        verify(automationCompositionHandler, timeout(200)).handleAutomationCompositionStateChange(stateChangeMsg);
+        await().atMost(200, TimeUnit.MILLISECONDS).until(() -> cacheProvider.getMessagesOnHold().isEmpty());
     }
 }