summaryrefslogtreecommitdiffstats
path: root/participant/participant-intermediary/src/test/java
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2023-06-14 13:57:07 +0100
committerAdheli Tavares <adheli.tavares@est.tech>2023-06-15 15:01:34 +0000
commita2320d29b9373041db88395d9fdda7ea84d38807 (patch)
tree4088c3e0941bcf4d2988a503471c55db4085986d /participant/participant-intermediary/src/test/java
parentdd44112fcda0951dc76861cacfdabbffc9fe8579 (diff)
Add support for Prime Deprime Failure Handling in Intermediary
Issue-ID: POLICY-4715 Change-Id: Iab48e6c32c7aedcef9773614a61436398b059a49 Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'participant/participant-intermediary/src/test/java')
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandlerTest.java23
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionOutHandlerTest.java16
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandlerTest.java15
3 files changed, 45 insertions, 9 deletions
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 7e0c3da7f..b4397b49f 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
@@ -27,6 +27,7 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.junit.jupiter.api.Test;
@@ -35,6 +36,7 @@ import org.onap.policy.clamp.acm.participant.intermediary.api.AutomationComposit
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.AcElementDeploy;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDefinition;
import org.onap.policy.clamp.models.acm.concepts.ParticipantDeploy;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionDeploy;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionDeployAck;
@@ -196,4 +198,25 @@ class AutomationCompositionHandlerTest {
ach.handleAutomationCompositionDeploy(deployMsg);
verify(listener, times(automationComposition.getElements().size())).deploy(any(), any(), any());
}
+
+ @Test
+ void handleComposiotPrimeTest() throws PfModelException {
+ var listener = mock(AutomationCompositionElementListener.class);
+ var ach = new AutomationCompositionHandler(mock(CacheProvider.class), mock(ParticipantMessagePublisher.class),
+ listener);
+ var compositionId = UUID.randomUUID();
+ var list = List.of(new AutomationCompositionElementDefinition());
+ ach.prime(compositionId, list);
+ verify(listener).prime(compositionId, list);
+ }
+
+ @Test
+ void handleComposiotDeprimeTest() throws PfModelException {
+ var listener = mock(AutomationCompositionElementListener.class);
+ var ach = new AutomationCompositionHandler(mock(CacheProvider.class), mock(ParticipantMessagePublisher.class),
+ listener);
+ var compositionId = UUID.randomUUID();
+ ach.deprime(compositionId);
+ verify(listener).deprime(compositionId);
+ }
}
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 3f022dcf2..d7bc2e687 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
@@ -32,10 +32,12 @@ import java.util.UUID;
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.AcTypeState;
import org.onap.policy.clamp.models.acm.concepts.DeployState;
import org.onap.policy.clamp.models.acm.concepts.LockState;
import org.onap.policy.clamp.models.acm.concepts.StateChangeResult;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionDeployAck;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantPrimeAck;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantStatus;
class AutomationCompositionOutHandlerTest {
@@ -135,8 +137,18 @@ class AutomationCompositionOutHandlerTest {
when(cacheProvider.getAutomationComposition(automationComposition.getInstanceId()))
.thenReturn(automationComposition);
var elementId = automationComposition.getElements().values().iterator().next().getId();
- acOutHandler.sendAcElementInfo(automationComposition.getInstanceId(),
- elementId, "", "", Map.of());
+ acOutHandler.sendAcElementInfo(automationComposition.getInstanceId(), elementId, "", "", Map.of());
verify(publisher).sendParticipantStatus(any(ParticipantStatus.class));
}
+
+ @Test
+ void updateCompositionStateTest() {
+ var cacheProvider = mock(CacheProvider.class);
+ when(cacheProvider.getParticipantId()).thenReturn(UUID.randomUUID());
+ var publisher = mock(ParticipantMessagePublisher.class);
+ var acOutHandler = new AutomationCompositionOutHandler(publisher, cacheProvider);
+ acOutHandler.updateCompositionState(UUID.randomUUID(), AcTypeState.PRIMED, StateChangeResult.NO_ERROR,
+ "Primed");
+ verify(publisher).sendParticipantPrimeAck(any(ParticipantPrimeAck.class));
+ }
}
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 6cad99fa1..895d4ed59 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
@@ -43,7 +43,6 @@ import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDe
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.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;
@@ -160,15 +159,16 @@ class ParticipantHandlerTest {
var cacheProvider = mock(CacheProvider.class);
when(cacheProvider.getParticipantId()).thenReturn(CommonTestData.getParticipantId());
var publisher = mock(ParticipantMessagePublisher.class);
- var participantHandler = new ParticipantHandler(mock(AutomationCompositionHandler.class),
- mock(AutomationCompositionOutHandler.class), publisher, cacheProvider);
+ var acHandler = mock(AutomationCompositionHandler.class);
+ var participantHandler = new ParticipantHandler(acHandler, mock(AutomationCompositionOutHandler.class),
+ publisher, cacheProvider);
var participantPrime = new ParticipantPrime();
participantPrime.setCompositionId(UUID.randomUUID());
participantPrime.setParticipantDefinitionUpdates(List.of(createParticipantDefinition()));
participantHandler.handleParticipantPrime(participantPrime);
verify(cacheProvider).addElementDefinition(any(), any());
- verify(publisher).sendParticipantPrimeAck(any(ParticipantPrimeAck.class));
+ verify(acHandler).prime(any(), any());
}
@Test
@@ -176,14 +176,15 @@ class ParticipantHandlerTest {
var cacheProvider = mock(CacheProvider.class);
when(cacheProvider.getParticipantId()).thenReturn(CommonTestData.getParticipantId());
var publisher = mock(ParticipantMessagePublisher.class);
- var participantHandler = new ParticipantHandler(mock(AutomationCompositionHandler.class),
- mock(AutomationCompositionOutHandler.class), publisher, cacheProvider);
+ var acHandler = mock(AutomationCompositionHandler.class);
+ var participantHandler = new ParticipantHandler(acHandler, mock(AutomationCompositionOutHandler.class),
+ publisher, cacheProvider);
var participantPrime = new ParticipantPrime();
var compositionId = UUID.randomUUID();
participantPrime.setCompositionId(compositionId);
participantHandler.handleParticipantPrime(participantPrime);
verify(cacheProvider).removeElementDefinition(compositionId);
- verify(publisher).sendParticipantPrimeAck(any(ParticipantPrimeAck.class));
+ verify(acHandler).deprime(compositionId);
}
@Test