summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2023-08-08 16:58:25 +0100
committerFrancesco Fiora <francesco.fiora@est.tech>2023-08-09 11:07:04 +0000
commitea5f81815a19d0b902e3c80f15d1b17c122bce76 (patch)
treebf5cdc880678b1e65007b67b335445d46b95f8f5
parent97ad8fec943b53cb669b1917b0fb175de6d8ddbd (diff)
Add composition outProperties support in Deprime
Issue-ID: POLICY-4784 Change-Id: I8d97d1cebc92c29b4b6842ad31f653664c09b0bf Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
-rwxr-xr-xparticipant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionOutHandler.java3
-rwxr-xr-xparticipant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java1
-rwxr-xr-xparticipant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionOutHandlerTest.java19
-rwxr-xr-xparticipant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandlerTest.java1
4 files changed, 20 insertions, 4 deletions
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionOutHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionOutHandler.java
index 3023cddda..7e4fedbf3 100755
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionOutHandler.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionOutHandler.java
@@ -225,6 +225,9 @@ public class AutomationCompositionOutHandler {
participantPrimeAck.setState(ParticipantState.ON_LINE);
publisher.sendParticipantPrimeAck(participantPrimeAck);
cacheProvider.getMsgIdentification().remove(compositionId);
+ if (AcTypeState.COMMISSIONED.equals(state) && StateChangeResult.NO_ERROR.equals(stateChangeResult)) {
+ cacheProvider.removeElementDefinition(compositionId);
+ }
}
/**
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java
index 6d7ff2ccd..8d906c07b 100755
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java
@@ -190,7 +190,6 @@ public class ParticipantHandler {
participantPrimeMsg.getCompositionId(), list);
} else {
// deprime
- cacheProvider.removeElementDefinition(participantPrimeMsg.getCompositionId());
automationCompositionHandler.deprime(participantPrimeMsg.getMessageId(),
participantPrimeMsg.getCompositionId());
}
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 e1b0b0891..c45be4e8b 100755
--- 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
@@ -168,14 +168,29 @@ class AutomationCompositionOutHandlerTest {
}
@Test
- void updateCompositionStateTest() {
+ void updateCompositionStatePrimedTest() {
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,
+ var compositionId = UUID.randomUUID();
+ acOutHandler.updateCompositionState(compositionId, AcTypeState.PRIMED, StateChangeResult.NO_ERROR,
"Primed");
verify(publisher).sendParticipantPrimeAck(any(ParticipantPrimeAck.class));
+ verify(cacheProvider, times(0)).removeElementDefinition(compositionId);
+ }
+
+ @Test
+ void updateCompositionStateDeprimingTest() {
+ var cacheProvider = mock(CacheProvider.class);
+ when(cacheProvider.getParticipantId()).thenReturn(UUID.randomUUID());
+ var publisher = mock(ParticipantMessagePublisher.class);
+ var acOutHandler = new AutomationCompositionOutHandler(publisher, cacheProvider);
+ var compositionId = UUID.randomUUID();
+ acOutHandler.updateCompositionState(compositionId, AcTypeState.COMMISSIONED, StateChangeResult.NO_ERROR,
+ "Deprimed");
+ verify(publisher).sendParticipantPrimeAck(any(ParticipantPrimeAck.class));
+ verify(cacheProvider).removeElementDefinition(compositionId);
}
@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 4e41d9740..c558e6668 100755
--- 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
@@ -208,7 +208,6 @@ class ParticipantHandlerTest {
var messageId = UUID.randomUUID();
participantPrime.setMessageId(messageId);
participantHandler.handleParticipantPrime(participantPrime);
- verify(cacheProvider).removeElementDefinition(compositionId);
verify(acHandler).deprime(messageId, compositionId);
}