diff options
author | FrancescoFioraEst <francesco.fiora@est.tech> | 2022-12-19 14:43:11 +0000 |
---|---|---|
committer | FrancescoFioraEst <francesco.fiora@est.tech> | 2022-12-20 10:35:32 +0000 |
commit | c71863696d729286502f951a64c3d2193c6641e7 (patch) | |
tree | 024363ddde071c3f59d7468bdc9ddfd011d3701e /participant/participant-intermediary/src/test/java/org | |
parent | 66208f7d9ec65d859803ed347c3fdecd2d99022f (diff) |
Add compositionId into Messages between ACM and Participants
Issue-ID: POLICY-4489
Change-Id: I1fb8c04eacee040d5c944c522ca59a2a9a50376b
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'participant/participant-intermediary/src/test/java/org')
4 files changed, 2 insertions, 75 deletions
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java index 4458f0bfa..bc5db8571 100644 --- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java +++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java @@ -20,10 +20,7 @@ package org.onap.policy.clamp.acm.participant.intermediary.api.impl; -import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotNull; import java.util.UUID; import org.junit.jupiter.api.Test; @@ -32,7 +29,6 @@ import org.onap.policy.clamp.acm.participant.intermediary.api.AutomationComposit import org.onap.policy.clamp.acm.participant.intermediary.main.parameters.CommonTestData; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; -import org.onap.policy.clamp.models.acm.concepts.ParticipantState; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; @@ -43,38 +39,15 @@ class ParticipantIntermediaryApiImplTest { private static final String ID_NAME = "org.onap.PM_CDS_Blueprint"; private static final String ID_VERSION = "1.0.1"; - private static final String ID_NAME_E = "PMSHInstance1"; - private static final String ID_VERSION_E = "1.0.1"; - - private static final String ID_NAME_TYPE = "org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant"; - private static final String ID_VERSION_TYPE = "2.3.4"; - @Test void mockParticipantIntermediaryApiImplTest() throws CoderException { var uuid = UUID.randomUUID(); var id = new ToscaConceptIdentifier(ID_NAME, ID_VERSION); - var participantHandler = commonTestData.getParticipantHandlerAutomationCompositions(); var automationComposiitonHandler = commonTestData.setTestAutomationCompositionHandler(id, uuid); - var apiImpl = new ParticipantIntermediaryApiImpl(participantHandler, automationComposiitonHandler); + var apiImpl = new ParticipantIntermediaryApiImpl(automationComposiitonHandler); var acElementListener = Mockito.mock(AutomationCompositionElementListener.class); apiImpl.registerAutomationCompositionElementListener(acElementListener); - assertNotNull(apiImpl.getAutomationCompositions(id.getName(), id.getVersion())); - assertThat(apiImpl.getAcElementDefinitionCommonProperties(id)).isEmpty(); - - var participants = apiImpl.getParticipants(id.getName(), id.getVersion()); - assertEquals(ParticipantState.UNKNOWN, participants.get(0).getParticipantState()); - - var participant = apiImpl.updateParticipantState(id, ParticipantState.TERMINATED); - assertEquals(ParticipantState.TERMINATED, participant.getParticipantState()); - - var elements = apiImpl.getAutomationCompositionElements(ID_NAME_E, ID_VERSION_E); - assertFalse(elements.containsKey(uuid)); - - var element = apiImpl.getAutomationCompositionElement(elements.keySet().iterator().next()); - var idType = new ToscaConceptIdentifier(ID_NAME_TYPE, ID_VERSION_TYPE); - assertEquals(idType, element.getParticipantType()); - var acElement = apiImpl.updateAutomationCompositionElementState(UUID.randomUUID(), uuid, AutomationCompositionOrderedState.UNINITIALISED, AutomationCompositionState.PASSIVE, ParticipantMessageType.AUTOMATION_COMPOSITION_STATECHANGE_ACK); diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandlerTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandlerTest.java index 06700fcce..8b52c1cfe 100644 --- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandlerTest.java +++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandlerTest.java @@ -54,8 +54,6 @@ class AutomationCompositionHandlerTest { @Test void automationCompositionHandlerTest() { var ach = commonTestData.getMockAutomationCompositionHandler(); - assertNotNull(ach.getAutomationCompositions()); - assertNotNull(ach.getAutomationCompositionMap()); assertNotNull(ach.getElementsOnThisParticipant()); 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 fd0b54f5e..f6988b0e8 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,7 +24,6 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; import java.time.Instant; @@ -35,12 +34,9 @@ import org.junit.jupiter.api.Test; import org.onap.policy.clamp.acm.participant.intermediary.comm.ParticipantMessagePublisher; import org.onap.policy.clamp.acm.participant.intermediary.main.parameters.CommonTestData; import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition; -import org.onap.policy.clamp.models.acm.concepts.ParticipantHealthStatus; -import org.onap.policy.clamp.models.acm.concepts.ParticipantState; 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.ParticipantRegisterAck; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdate; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; @@ -52,19 +48,6 @@ class ParticipantHandlerTest { private static final String ID_VERSION = "1.0.1"; @Test - void mockParticipantHandlerTest() { - var participantHandler = commonTestData.getMockParticipantHandler(); - assertNull(participantHandler.getParticipant(null, null)); - assertEquals("org.onap.PM_CDS_Blueprint 1.0.1", participantHandler.getParticipantId().toString()); - - var id = new ToscaConceptIdentifier(ID_NAME, ID_VERSION); - assertEquals(id, participantHandler.getParticipantId()); - assertEquals(id, participantHandler.getParticipantType()); - assertThat(participantHandler.getAcElementDefinitionCommonProperties(id)).isEmpty(); - - } - - @Test void handleUpdateTest() { var parameters = CommonTestData.getParticipantParameters(); var automationCompositionHander = commonTestData.getMockAutomationCompositionHandler(); @@ -81,6 +64,7 @@ class ParticipantHandlerTest { var id = new ToscaConceptIdentifier(ID_NAME, ID_VERSION); participantUpdateMsg.setAutomationCompositionId(CommonTestData.AC_ID_1); + participantUpdateMsg.setCompositionId(CommonTestData.AC_ID_1); participantUpdateMsg.setParticipantId(id); participantUpdateMsg.setParticipantType(id); participantUpdateMsg.setMessageId(UUID.randomUUID()); @@ -91,7 +75,6 @@ class ParticipantHandlerTest { assertThat(heartbeatF.getAutomationCompositionInfoList()).isEmpty(); participantHandler.handleParticipantUpdate(participantUpdateMsg); - assertThat(participantHandler.getAcElementDefinitionCommonProperties(id)).isEmpty(); var heartbeatT = participantHandler.makeHeartbeat(true); assertEquals(id, heartbeatT.getParticipantId()); @@ -116,31 +99,6 @@ class ParticipantHandlerTest { } @Test - void handleParticipantTest() { - var participantHandler = commonTestData.getMockParticipantHandler(); - var id = new ToscaConceptIdentifier(ID_NAME, ID_VERSION); - var p = participantHandler.getParticipant(id.getName(), id.getVersion()); - assertEquals(ParticipantState.UNKNOWN, p.getParticipantState()); - - participantHandler.updateParticipantState(id, ParticipantState.PASSIVE); - var p2 = participantHandler.getParticipant(id.getName(), id.getVersion()); - assertEquals(ParticipantState.PASSIVE, p2.getParticipantState()); - - var participantRegisterAckMsg = new ParticipantRegisterAck(); - participantRegisterAckMsg.setState(ParticipantState.TERMINATED); - participantHandler.handleParticipantRegisterAck(participantRegisterAckMsg); - assertEquals(ParticipantHealthStatus.HEALTHY, participantHandler.makeHeartbeat(false).getHealthStatus()); - - var emptyid = new ToscaConceptIdentifier("", ID_VERSION); - assertNull(participantHandler.updateParticipantState(emptyid, ParticipantState.PASSIVE)); - - var sameid = new ToscaConceptIdentifier(ID_NAME, ID_VERSION); - var participant = participantHandler.updateParticipantState(sameid, ParticipantState.PASSIVE); - assertEquals(participant.getDefinition(), sameid); - - } - - @Test void checkAppliesTo() { var participantHandler = commonTestData.getMockParticipantHandler(); var participantAckMsg = diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java index 01a8f3c28..10c438f93 100644 --- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java +++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java @@ -196,8 +196,6 @@ public class CommonTestData { */ public ParticipantHandler getParticipantHandlerAutomationCompositions() throws CoderException { var automationCompositionHandler = Mockito.mock(AutomationCompositionHandler.class); - Mockito.doReturn(getTestAutomationCompositions()).when(automationCompositionHandler) - .getAutomationCompositions(); Mockito.doReturn(getTestAutomationCompositionMap()).when(automationCompositionHandler) .getAutomationCompositionMap(); var publisher = new ParticipantMessagePublisher(); |