aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2023-07-19 14:47:23 +0100
committerFrancesco Fiora <francesco.fiora@est.tech>2023-07-19 14:58:46 +0000
commita50ba1e7676ff0b535e9f443b50a66bbd44e5110 (patch)
treec1191b927168043d3141385d39c78eae6e01dd5f
parent7815def0c52559f8c64b70f5f4df9648c7b8f70d (diff)
Fix restart flag in ACM
Fix the missing message back from participant to ACM in restart scenario. Issue-ID: POLICY-4772 Change-Id: Ie0104a5f30a470b02994281aa50f047d33f5ef8d Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
-rwxr-xr-x[-rw-r--r--]participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionOutHandler.java2
-rwxr-xr-x[-rw-r--r--]participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionOutHandlerTest.java24
2 files changed, 25 insertions, 1 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 334d6a89d..bd5f1427e 100644..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
@@ -83,7 +83,7 @@ public class AutomationCompositionOutHandler {
return;
}
- if ((element.getRestarting() != null)
+ if ((element.getRestarting() == null)
&& ((deployState != null && lockState != null) || (deployState == null && lockState == null))) {
LOGGER.error("state error {} and {} cannot be handled", deployState, lockState);
return;
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 d7bc2e687..36c0c4b35 100644..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
@@ -20,6 +20,7 @@
package org.onap.policy.clamp.acm.participant.intermediary.handler;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
@@ -49,8 +50,10 @@ class AutomationCompositionOutHandlerTest {
assertDoesNotThrow(
() -> acOutHandler.updateAutomationCompositionElementState(null, null, null, null, null, null));
+
assertDoesNotThrow(() -> acOutHandler.updateAutomationCompositionElementState(UUID.randomUUID(),
UUID.randomUUID(), null, null, null, null));
+
assertDoesNotThrow(() -> acOutHandler.updateAutomationCompositionElementState(UUID.randomUUID(),
UUID.randomUUID(), DeployState.DEPLOYED, null, null, null));
@@ -59,6 +62,10 @@ class AutomationCompositionOutHandlerTest {
.thenReturn(automationComposition);
assertDoesNotThrow(() -> acOutHandler.updateAutomationCompositionElementState(
automationComposition.getInstanceId(), UUID.randomUUID(), DeployState.DEPLOYED, null, null, null));
+
+ var elementId = automationComposition.getElements().values().iterator().next().getId();
+ assertDoesNotThrow(() -> acOutHandler.updateAutomationCompositionElementState(
+ automationComposition.getInstanceId(), elementId, null, null, null, null));
}
@Test
@@ -92,6 +99,23 @@ class AutomationCompositionOutHandlerTest {
}
@Test
+ void updateAutomationCompositionElementStateRestartedTest() {
+ var publisher = mock(ParticipantMessagePublisher.class);
+ var cacheProvider = mock(CacheProvider.class);
+ var acOutHandler = new AutomationCompositionOutHandler(publisher, cacheProvider);
+
+ var automationComposition = CommonTestData.getTestAutomationCompositionMap().values().iterator().next();
+ when(cacheProvider.getAutomationComposition(automationComposition.getInstanceId()))
+ .thenReturn(automationComposition);
+ var element = automationComposition.getElements().values().iterator().next();
+ element.setRestarting(true);
+ acOutHandler.updateAutomationCompositionElementState(automationComposition.getInstanceId(), element.getId(),
+ DeployState.DEPLOYED, LockState.LOCKED, StateChangeResult.NO_ERROR, "Restarted");
+ verify(publisher).sendAutomationCompositionAck(any(AutomationCompositionDeployAck.class));
+ assertThat(element.getRestarting()).isNull();
+ }
+
+ @Test
void updateAutomationCompositionElementStateDeleteTest() {
var publisher = mock(ParticipantMessagePublisher.class);
var cacheProvider = mock(CacheProvider.class);