aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionOutHandler.java14
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionOutHandlerTest.java24
2 files changed, 34 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 7cf83db9d..d9f2b7acd 100644
--- 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
@@ -162,10 +162,10 @@ public class AutomationCompositionOutHandler {
LOGGER.warn("SubState has always NO_ERROR result!");
}
} else if (deployState != null) {
- handleDeployState(automationComposition, element, deployState);
+ handleDeployState(automationComposition, element, deployState, stateChangeResult);
}
if (lockState != null) {
- handleLockState(automationComposition, element, lockState);
+ handleLockState(automationComposition, element, lockState, stateChangeResult);
}
var automationCompositionStateChangeAck =
@@ -186,9 +186,12 @@ public class AutomationCompositionOutHandler {
}
private void handleDeployState(AutomationComposition automationComposition, AutomationCompositionElement element,
- DeployState deployState) {
+ DeployState deployState, StateChangeResult stateChangeResult) {
element.setDeployState(deployState);
element.setLockState(DeployState.DEPLOYED.equals(element.getDeployState()) ? LockState.LOCKED : LockState.NONE);
+ if (StateChangeResult.FAILED.equals(stateChangeResult)) {
+ return;
+ }
var checkOpt = automationComposition.getElements().values().stream()
.filter(acElement -> !deployState.equals(acElement.getDeployState())).findAny();
if (checkOpt.isEmpty()) {
@@ -209,8 +212,11 @@ public class AutomationCompositionOutHandler {
}
private void handleLockState(AutomationComposition automationComposition, AutomationCompositionElement element,
- LockState lockState) {
+ LockState lockState, StateChangeResult stateChangeResult) {
element.setLockState(lockState);
+ if (StateChangeResult.FAILED.equals(stateChangeResult)) {
+ return;
+ }
var checkOpt = automationComposition.getElements().values().stream()
.filter(acElement -> !lockState.equals(acElement.getLockState())).findAny();
if (checkOpt.isEmpty()) {
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 202f25c6f..ce62fcb6d 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
@@ -311,4 +311,28 @@ class AutomationCompositionOutHandlerTest {
.sendAutomationCompositionAck(any(AutomationCompositionDeployAck.class));
assertEquals(compositionTarget, automationComposition.getCompositionId());
}
+
+ @Test
+ void updateFailMigrationTest() {
+ var cacheProvider = mock(CacheProvider.class);
+ when(cacheProvider.getParticipantId()).thenReturn(UUID.randomUUID());
+ var publisher = mock(ParticipantMessagePublisher.class);
+ var acOutHandler = new AutomationCompositionOutHandler(publisher, cacheProvider);
+
+ var automationComposition = CommonTestData.getTestAutomationCompositionMap().values().iterator().next();
+ when(cacheProvider.getAutomationComposition(automationComposition.getInstanceId()))
+ .thenReturn(automationComposition);
+
+ automationComposition.setCompositionTargetId(UUID.randomUUID());
+ automationComposition.setDeployState(DeployState.MIGRATING);
+ var compositionId = automationComposition.getCompositionId();
+ for (var element : automationComposition.getElements().values()) {
+ element.setDeployState(DeployState.MIGRATING);
+ acOutHandler.updateAutomationCompositionElementState(automationComposition.getInstanceId(),
+ element.getId(), DeployState.DEPLOYED, null, StateChangeResult.FAILED, "");
+ }
+ verify(publisher, times(automationComposition.getElements().size()))
+ .sendAutomationCompositionAck(any(AutomationCompositionDeployAck.class));
+ assertEquals(compositionId, automationComposition.getCompositionId());
+ }
}