diff options
author | 2024-05-30 09:24:44 +0100 | |
---|---|---|
committer | 2024-05-31 08:11:13 +0000 | |
commit | 66cfd4c9006b84ce1f3751da3b9dae2b4fff78e8 (patch) | |
tree | b8335a608d7d22557a0663943dd3b09e2b163577 /participant/participant-intermediary/src/test/java | |
parent | 6d8ebc3dfe0ee496e009eec4db39babcde51a289 (diff) |
Fix participant registration issue
Issue-ID: POLICY-5039
Change-Id: Ic83a1feba3749f7a496749cbce174d7342d0cdcf
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'participant/participant-intermediary/src/test/java')
3 files changed, 18 insertions, 9 deletions
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 754fc6522..10f9d4586 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 @@ -93,8 +93,6 @@ class ParticipantCommTest { var participantStatus = new ParticipantStatus(); assertDoesNotThrow(() -> publisher.sendParticipantStatus(participantStatus)); - assertDoesNotThrow(() -> publisher.sendHeartbeat(participantStatus)); - var participantRegister = new ParticipantRegister(); assertDoesNotThrow(() -> publisher.sendParticipantRegister(participantRegister)); @@ -115,7 +113,6 @@ class ParticipantCommTest { var participantStatus = new ParticipantStatus(); assertThrows(AutomationCompositionRuntimeException.class, () -> publisher.sendParticipantStatus(participantStatus)); - assertThrows(AutomationCompositionRuntimeException.class, () -> publisher.sendHeartbeat(participantStatus)); var participantRegister = new ParticipantRegister(); assertThrows(AutomationCompositionRuntimeException.class, diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionOutHandlerTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionOutHandlerTest.java index 76fbd068f..eed5319f8 100644 --- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionOutHandlerTest.java +++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionOutHandlerTest.java @@ -206,16 +206,16 @@ class AutomationCompositionOutHandlerTest { var acOutHandler = new AutomationCompositionOutHandler(publisher, cacheProvider); acOutHandler.sendAcDefinitionInfo(null, null, Map.of()); - verify(publisher, times(0)).sendHeartbeat(any(ParticipantStatus.class)); + verify(publisher, times(0)).sendParticipantStatus(any(ParticipantStatus.class)); acOutHandler.sendAcDefinitionInfo(UUID.randomUUID(), null, Map.of()); - verify(publisher, times(0)).sendHeartbeat(any(ParticipantStatus.class)); + verify(publisher, times(0)).sendParticipantStatus(any(ParticipantStatus.class)); acOutHandler.sendAcDefinitionInfo(compositionId, new ToscaConceptIdentifier("wrong", "1.0.0"), Map.of()); - verify(publisher, times(0)).sendHeartbeat(any(ParticipantStatus.class)); + verify(publisher, times(0)).sendParticipantStatus(any(ParticipantStatus.class)); acOutHandler.sendAcDefinitionInfo(compositionId, elementId, Map.of()); - verify(publisher).sendHeartbeat(any(ParticipantStatus.class)); + verify(publisher).sendParticipantStatus(any(ParticipantStatus.class)); } @Test 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 8aac93138..cd28d41fb 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 @@ -24,6 +24,7 @@ import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.clearInvocations; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -58,10 +59,16 @@ class ParticipantHandlerTest { @Test void handleParticipantStatusReqTest() { var publisher = mock(ParticipantMessagePublisher.class); + when(publisher.isActive()).thenReturn(true); var cacheProvider = mock(CacheProvider.class); var participantHandler = new ParticipantHandler(mock(AutomationCompositionHandler.class), mock(AcLockHandler.class), mock(AcDefinitionHandler.class), publisher, cacheProvider); participantHandler.handleParticipantStatusReq(new ParticipantStatusReq()); + verify(publisher).sendParticipantRegister(any(ParticipantRegister.class)); + + when(cacheProvider.isRegistered()).thenReturn(true); + clearInvocations(publisher); + participantHandler.handleParticipantStatusReq(new ParticipantStatusReq()); verify(publisher).sendParticipantStatus(any(ParticipantStatus.class)); } @@ -213,6 +220,7 @@ class ParticipantHandlerTest { void sendHeartbeatTest() { var cacheProvider = mock(CacheProvider.class); when(cacheProvider.getParticipantId()).thenReturn(CommonTestData.getParticipantId()); + when(cacheProvider.isRegistered()).thenReturn(false); when(cacheProvider.getAutomationCompositions()).thenReturn(CommonTestData.getTestAutomationCompositionMap()); var publisher = mock(ParticipantMessagePublisher.class); when(publisher.isActive()).thenReturn(true); @@ -220,7 +228,11 @@ class ParticipantHandlerTest { var participantHandler = new ParticipantHandler(mock(AutomationCompositionHandler.class), mock(AcLockHandler.class), acHandler, publisher, cacheProvider); participantHandler.sendHeartbeat(); - verify(publisher).sendHeartbeat(any(ParticipantStatus.class)); - } + verify(publisher).sendParticipantRegister(any(ParticipantRegister.class)); + when(cacheProvider.isRegistered()).thenReturn(true); + clearInvocations(publisher); + participantHandler.sendHeartbeat(); + verify(publisher).sendParticipantStatus(any(ParticipantStatus.class)); + } } |