aboutsummaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
Diffstat (limited to 'models')
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcInstanceStateResolver.java153
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java28
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AcInstanceStateResolverTest.java74
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java19
4 files changed, 197 insertions, 77 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcInstanceStateResolver.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcInstanceStateResolver.java
index ace246c5d..fd8b63582 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcInstanceStateResolver.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcInstanceStateResolver.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2023 Nordix Foundation.
+ * Copyright (C) 2023-2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,8 +23,10 @@ package org.onap.policy.clamp.models.acm.persistence.provider;
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.concepts.SubState;
import org.onap.policy.clamp.models.acm.messages.rest.instantiation.DeployOrder;
import org.onap.policy.clamp.models.acm.messages.rest.instantiation.LockOrder;
+import org.onap.policy.clamp.models.acm.messages.rest.instantiation.SubOrder;
import org.onap.policy.clamp.models.acm.utils.StateDefinition;
import org.springframework.stereotype.Component;
@@ -39,6 +41,10 @@ public class AcInstanceStateResolver {
private static final String UPDATING = DeployState.UPDATING.name();
private static final String DELETING = DeployState.DELETING.name();
private static final String MIGRATING = DeployState.MIGRATING.name();
+ private static final String MIGRATION_PRECHECKING = SubState.MIGRATION_PRECHECKING.name();
+ private static final String PREPARING = SubState.PREPARING.name();
+ private static final String REVIEWING = SubState.REVIEWING.name();
+ private static final String SUB_STATE_NONE = SubState.NONE.name();
private static final String LOCKED = LockState.LOCKED.name();
private static final String LOCKING = LockState.LOCKING.name();
@@ -48,6 +54,7 @@ public class AcInstanceStateResolver {
private static final String DEPLOY_NONE = DeployOrder.NONE.name();
private static final String LOCK_NONE = LockOrder.NONE.name();
+ private static final String SUB_NONE = SubOrder.NONE.name();
private static final String NO_ERROR = StateChangeResult.NO_ERROR.name();
private static final String FAILED = StateChangeResult.FAILED.name();
@@ -60,55 +67,105 @@ public class AcInstanceStateResolver {
public static final String LOCK = LockOrder.LOCK.name();
public static final String UNLOCK = LockOrder.UNLOCK.name();
public static final String MIGRATE = DeployOrder.MIGRATE.name();
+ public static final String MIGRATE_PRECHECK = SubOrder.MIGRATE_PRECHECK.name();
+ public static final String PREPARE = SubOrder.PREPARE.name();
+ public static final String REVIEW = SubOrder.REVIEW.name();
+ public static final String UPDATE = DeployOrder.UPDATE.name();
public static final String NONE = "NONE";
/**
* Construct.
*/
public AcInstanceStateResolver() {
- this.graph = new StateDefinition<>(5, NONE);
-
- // no error
- this.graph.put(new String[] {DEPLOY, LOCK_NONE, UNDEPLOYED, STATE_LOCKED_NONE, NO_ERROR}, DEPLOY);
- this.graph.put(new String[] {UNDEPLOY, LOCK_NONE, DEPLOYED, LOCKED, NO_ERROR}, UNDEPLOY);
- this.graph.put(new String[] {DELETE, LOCK_NONE, UNDEPLOYED, LOCK_NONE, NO_ERROR}, DELETE);
- this.graph.put(new String[] {DEPLOY_NONE, UNLOCK, DEPLOYED, LOCKED, NO_ERROR}, UNLOCK);
- this.graph.put(new String[] {DEPLOY_NONE, LOCK, DEPLOYED, UNLOCKED, NO_ERROR}, LOCK);
- this.graph.put(new String[] {MIGRATE, LOCK_NONE, DEPLOYED, LOCKED, NO_ERROR}, MIGRATE);
-
- // failed
- this.graph.put(new String[] {DEPLOY, LOCK_NONE, UNDEPLOYING, STATE_LOCKED_NONE, FAILED}, DEPLOY);
- this.graph.put(new String[] {DEPLOY, LOCK_NONE, DEPLOYING, STATE_LOCKED_NONE, FAILED}, DEPLOY);
-
- this.graph.put(new String[] {UNDEPLOY, LOCK_NONE, UNDEPLOYING, STATE_LOCKED_NONE, FAILED}, UNDEPLOY);
- this.graph.put(new String[] {UNDEPLOY, LOCK_NONE, UPDATING, LOCKED, FAILED}, UNDEPLOY);
- this.graph.put(new String[] {UNDEPLOY, LOCK_NONE, MIGRATING, LOCKED, FAILED}, UNDEPLOY);
- this.graph.put(new String[] {UNDEPLOY, LOCK_NONE, DEPLOYING, STATE_LOCKED_NONE, FAILED}, UNDEPLOY);
-
- this.graph.put(new String[] {DELETE, LOCK_NONE, DELETING, LOCK_NONE, FAILED}, DELETE);
-
- this.graph.put(new String[] {DEPLOY_NONE, UNLOCK, DEPLOYED, LOCKING, FAILED}, UNLOCK);
- this.graph.put(new String[] {DEPLOY_NONE, UNLOCK, DEPLOYED, UNLOCKING, FAILED}, UNLOCK);
-
- this.graph.put(new String[] {DEPLOY_NONE, LOCK, DEPLOYED, LOCKING, FAILED}, LOCK);
- this.graph.put(new String[] {DEPLOY_NONE, LOCK, DEPLOYED, UNLOCKING, FAILED}, LOCK);
+ this.graph = new StateDefinition<>(7, NONE);
+
+ // make an order when there are no fails
+ this.graph.put(new String[] {DEPLOY, LOCK_NONE, SUB_NONE,
+ UNDEPLOYED, STATE_LOCKED_NONE, SUB_STATE_NONE, NO_ERROR}, DEPLOY);
+ this.graph.put(new String[] {UNDEPLOY, LOCK_NONE, SUB_NONE,
+ DEPLOYED, LOCKED, SUB_STATE_NONE, NO_ERROR}, UNDEPLOY);
+ this.graph.put(new String[] {DELETE, LOCK_NONE, SUB_NONE,
+ UNDEPLOYED, LOCK_NONE, SUB_STATE_NONE, NO_ERROR}, DELETE);
+ this.graph.put(new String[] {DEPLOY_NONE, UNLOCK, SUB_NONE,
+ DEPLOYED, LOCKED, SUB_STATE_NONE, NO_ERROR}, UNLOCK);
+ this.graph.put(new String[] {DEPLOY_NONE, LOCK, SUB_NONE,
+ DEPLOYED, UNLOCKED, SUB_STATE_NONE, NO_ERROR}, LOCK);
+ this.graph.put(new String[] {MIGRATE, LOCK_NONE, SUB_NONE,
+ DEPLOYED, LOCKED, SUB_STATE_NONE, NO_ERROR}, MIGRATE);
+ this.graph.put(new String[] {UPDATE, LOCK_NONE, SUB_NONE,
+ DEPLOYED, LOCKED, SUB_STATE_NONE, NO_ERROR}, UPDATE);
+ this.graph.put(new String[] {DEPLOY_NONE, LOCK_NONE, REVIEW,
+ DEPLOYED, LOCKED, SUB_STATE_NONE, NO_ERROR}, REVIEW);
+ this.graph.put(new String[] {DEPLOY_NONE, LOCK_NONE, PREPARE,
+ UNDEPLOYED, STATE_LOCKED_NONE, SUB_STATE_NONE, NO_ERROR}, PREPARE);
+ this.graph.put(new String[] {DEPLOY_NONE, LOCK_NONE, MIGRATE_PRECHECK,
+ DEPLOYED, LOCKED, SUB_STATE_NONE, NO_ERROR}, MIGRATE_PRECHECK);
+
+ // make an order in a failed scenario
+ this.graph.put(new String[] {DEPLOY, LOCK_NONE, SUB_NONE,
+ UNDEPLOYING, STATE_LOCKED_NONE, SUB_STATE_NONE, FAILED}, DEPLOY);
+ this.graph.put(new String[] {DEPLOY, LOCK_NONE, SUB_NONE,
+ DEPLOYING, STATE_LOCKED_NONE, SUB_STATE_NONE, FAILED}, DEPLOY);
+
+ this.graph.put(new String[] {UNDEPLOY, LOCK_NONE, SUB_NONE,
+ UNDEPLOYING, STATE_LOCKED_NONE, SUB_STATE_NONE, FAILED}, UNDEPLOY);
+ this.graph.put(new String[] {UNDEPLOY, LOCK_NONE, SUB_NONE,
+ UPDATING, LOCKED, SUB_STATE_NONE, FAILED}, UNDEPLOY);
+ this.graph.put(new String[] {UNDEPLOY, LOCK_NONE, SUB_NONE,
+ MIGRATING, LOCKED, SUB_STATE_NONE, FAILED}, UNDEPLOY);
+ this.graph.put(new String[] {UNDEPLOY, LOCK_NONE, SUB_NONE,
+ DEPLOYING, STATE_LOCKED_NONE, SUB_STATE_NONE, FAILED}, UNDEPLOY);
+
+ this.graph.put(new String[] {DELETE, LOCK_NONE, SUB_NONE,
+ DELETING, LOCK_NONE, SUB_STATE_NONE, FAILED}, DELETE);
+
+ this.graph.put(new String[] {DEPLOY_NONE, UNLOCK, SUB_NONE,
+ DEPLOYED, LOCKING, SUB_STATE_NONE, FAILED}, UNLOCK);
+ this.graph.put(new String[] {DEPLOY_NONE, UNLOCK, SUB_NONE,
+ DEPLOYED, UNLOCKING, SUB_STATE_NONE, FAILED}, UNLOCK);
+
+ this.graph.put(new String[] {DEPLOY_NONE, LOCK, SUB_NONE, DEPLOYED, LOCKING, SUB_STATE_NONE, FAILED}, LOCK);
+ this.graph.put(new String[] {DEPLOY_NONE, LOCK, SUB_NONE, DEPLOYED, UNLOCKING, SUB_STATE_NONE, FAILED}, LOCK);
+
+ this.graph.put(new String[] {UPDATE, LOCK_NONE, SUB_NONE, UPDATING, LOCKED, SUB_STATE_NONE, FAILED}, UPDATE);
+
+ this.graph.put(new String[] {DEPLOY_NONE, LOCK_NONE, MIGRATE_PRECHECK,
+ DEPLOYED, LOCKED, MIGRATION_PRECHECKING, FAILED}, MIGRATE_PRECHECK);
// timeout
- this.graph.put(new String[] {DEPLOY, LOCK_NONE, UNDEPLOYING, STATE_LOCKED_NONE, TIMEOUT}, DEPLOY);
- this.graph.put(new String[] {DEPLOY, LOCK_NONE, DEPLOYING, STATE_LOCKED_NONE, TIMEOUT}, DEPLOY);
-
- this.graph.put(new String[] {UNDEPLOY, LOCK_NONE, UNDEPLOYING, STATE_LOCKED_NONE, TIMEOUT}, UNDEPLOY);
- this.graph.put(new String[] {UNDEPLOY, LOCK_NONE, UPDATING, LOCKED, TIMEOUT}, UNDEPLOY);
- this.graph.put(new String[] {UNDEPLOY, LOCK_NONE, MIGRATING, LOCKED, TIMEOUT}, UNDEPLOY);
- this.graph.put(new String[] {UNDEPLOY, LOCK_NONE, DEPLOYING, STATE_LOCKED_NONE, TIMEOUT}, UNDEPLOY);
-
- this.graph.put(new String[] {DELETE, LOCK_NONE, DELETING, LOCK_NONE, TIMEOUT}, DELETE);
-
- this.graph.put(new String[] {DEPLOY_NONE, UNLOCK, DEPLOYED, LOCKING, TIMEOUT}, UNLOCK);
- this.graph.put(new String[] {DEPLOY_NONE, LOCK, DEPLOYED, LOCKING, TIMEOUT}, LOCK);
-
- this.graph.put(new String[] {DEPLOY_NONE, LOCK, DEPLOYED, UNLOCKING, TIMEOUT}, LOCK);
- this.graph.put(new String[] {DEPLOY_NONE, UNLOCK, DEPLOYED, UNLOCKING, TIMEOUT}, UNLOCK);
+ this.graph.put(new String[] {DEPLOY, LOCK_NONE, SUB_NONE,
+ UNDEPLOYING, STATE_LOCKED_NONE, SUB_STATE_NONE, TIMEOUT}, DEPLOY);
+ this.graph.put(new String[] {DEPLOY, LOCK_NONE, SUB_NONE,
+ DEPLOYING, STATE_LOCKED_NONE, SUB_STATE_NONE, TIMEOUT}, DEPLOY);
+
+ this.graph.put(new String[] {UNDEPLOY, LOCK_NONE, SUB_NONE,
+ UNDEPLOYING, STATE_LOCKED_NONE, SUB_STATE_NONE, TIMEOUT}, UNDEPLOY);
+ this.graph.put(new String[] {UNDEPLOY, LOCK_NONE, SUB_NONE,
+ UPDATING, LOCKED, SUB_STATE_NONE, TIMEOUT}, UNDEPLOY);
+ this.graph.put(new String[] {UNDEPLOY, LOCK_NONE, SUB_NONE,
+ MIGRATING, LOCKED, SUB_STATE_NONE, TIMEOUT}, UNDEPLOY);
+ this.graph.put(new String[] {UNDEPLOY, LOCK_NONE, SUB_NONE,
+ MIGRATION_PRECHECKING, LOCKED, SUB_STATE_NONE, TIMEOUT}, UNDEPLOY);
+ this.graph.put(new String[] {UNDEPLOY, LOCK_NONE, SUB_NONE,
+ DEPLOYING, STATE_LOCKED_NONE, SUB_STATE_NONE, TIMEOUT}, UNDEPLOY);
+
+ this.graph.put(new String[] {DELETE, LOCK_NONE, SUB_NONE,
+ DELETING, LOCK_NONE, SUB_STATE_NONE, TIMEOUT}, DELETE);
+
+ this.graph.put(new String[] {DEPLOY_NONE, UNLOCK, SUB_NONE,
+ DEPLOYED, LOCKING, SUB_STATE_NONE, TIMEOUT}, UNLOCK);
+ this.graph.put(new String[] {DEPLOY_NONE, LOCK, SUB_NONE,
+ DEPLOYED, LOCKING, SUB_STATE_NONE, TIMEOUT}, LOCK);
+
+ this.graph.put(new String[] {DEPLOY_NONE, LOCK, SUB_NONE,
+ DEPLOYED, UNLOCKING, SUB_STATE_NONE, TIMEOUT}, LOCK);
+ this.graph.put(new String[] {DEPLOY_NONE, UNLOCK, SUB_NONE,
+ DEPLOYED, UNLOCKING, SUB_STATE_NONE, TIMEOUT}, UNLOCK);
+
+ this.graph.put(new String[] {UPDATE, LOCK_NONE, SUB_NONE, UPDATING, LOCKED, SUB_STATE_NONE, TIMEOUT}, UPDATE);
+
+ this.graph.put(new String[] {DEPLOY_NONE, LOCK_NONE, MIGRATE_PRECHECK,
+ DEPLOYED, LOCKED, MIGRATION_PRECHECKING, TIMEOUT}, MIGRATE_PRECHECK);
}
/**
@@ -116,20 +173,24 @@ public class AcInstanceStateResolver {
*
* @param acDeployOrder the Deploy Ordered
* @param acLockOrder the Lock Ordered
+ * @param acSubOrder the Sub Ordered
* @param acDeployState then current Deploy State
* @param acLockState the current Lock State
+ * @param acSubState the current Sub State
* @param acStateChangeResult the current Result of the State Change
* @return the order (DEPLOY/UNDEPLOY/LOCK/UNLOCK) to send to participant or NONE if order is not consistent
*/
- public String resolve(DeployOrder acDeployOrder, LockOrder acLockOrder, DeployState acDeployState,
- LockState acLockState, StateChangeResult acStateChangeResult) {
+ public String resolve(DeployOrder acDeployOrder, LockOrder acLockOrder, SubOrder acSubOrder,
+ DeployState acDeployState, LockState acLockState, SubState acSubState, StateChangeResult acStateChangeResult) {
var deployOrder = acDeployOrder != null ? acDeployOrder : DeployOrder.NONE;
var lockOrder = acLockOrder != null ? acLockOrder : LockOrder.NONE;
+ var subOrder = acSubOrder != null ? acSubOrder : SubOrder.NONE;
var stateChangeResult = acStateChangeResult != null ? acStateChangeResult : StateChangeResult.NO_ERROR;
var deployState = acDeployState != null ? acDeployState : DeployState.UNDEPLOYED;
var lockState = acLockState != null ? acLockState : LockState.NONE;
- return this.graph.get(new String[] {deployOrder.name(), lockOrder.name(), deployState.name(), lockState.name(),
- stateChangeResult.name()});
+ var subState = acSubState != null ? acSubState : SubState.NONE;
+ return this.graph.get(new String[] {deployOrder.name(), lockOrder.name(), subOrder.name(),
+ deployState.name(), lockState.name(), subState.name(), stateChangeResult.name()});
}
}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java b/models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java
index f90e5a807..50b8d14ad 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java
@@ -51,6 +51,7 @@ import org.onap.policy.clamp.models.acm.concepts.NodeTemplateState;
import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition;
import org.onap.policy.clamp.models.acm.concepts.ParticipantDeploy;
import org.onap.policy.clamp.models.acm.concepts.ParticipantRestartAc;
+import org.onap.policy.clamp.models.acm.concepts.SubState;
import org.onap.policy.clamp.models.acm.messages.rest.instantiation.DeployOrder;
import org.onap.policy.clamp.models.acm.messages.rest.instantiation.LockOrder;
import org.onap.policy.clamp.models.acm.persistence.concepts.StringToMapConverter;
@@ -288,16 +289,20 @@ public final class AcmUtils {
// @formatter:on
}
+
/**
- * Return true if DeployState and LockState are in a Transitional State.
+ * Return true if DeployState, LockState and SubState are in a Transitional State.
*
- * @return true if DeployState and LockState are in a Transitional State
+ * @param deployState the DeployState
+ * @param lockState the LockState
+ * @param subState the SubState
+ * @return true if there is a state in a Transitional State
*/
- public static boolean isInTransitionalState(DeployState deployState, LockState lockState) {
+ public static boolean isInTransitionalState(DeployState deployState, LockState lockState, SubState subState) {
return DeployState.DEPLOYING.equals(deployState) || DeployState.UNDEPLOYING.equals(deployState)
|| LockState.LOCKING.equals(lockState) || LockState.UNLOCKING.equals(lockState)
|| DeployState.DELETING.equals(deployState) || DeployState.UPDATING.equals(deployState)
- || DeployState.MIGRATING.equals(deployState);
+ || DeployState.MIGRATING.equals(deployState) || !SubState.NONE.equals(subState);
}
/**
@@ -381,9 +386,23 @@ public final class AcmUtils {
*/
public static void setCascadedState(final AutomationComposition automationComposition,
final DeployState deployState, final LockState lockState) {
+ setCascadedState(automationComposition, deployState, lockState, SubState.NONE);
+ }
+
+ /**
+ /**
+ * Set the states on the automation composition and on all its automation composition elements.
+ *
+ * @param deployState the DeployState we want the automation composition to transition to
+ * @param lockState the LockState we want the automation composition to transition to
+ * @param subState the SubState we want the automation composition to transition to
+ */
+ public static void setCascadedState(final AutomationComposition automationComposition,
+ final DeployState deployState, final LockState lockState, final SubState subState) {
automationComposition.setDeployState(deployState);
automationComposition.setLockState(lockState);
automationComposition.setLastMsg(TimestampHelper.now());
+ automationComposition.setSubState(subState);
if (MapUtils.isEmpty(automationComposition.getElements())) {
return;
@@ -392,6 +411,7 @@ public final class AcmUtils {
for (var element : automationComposition.getElements().values()) {
element.setDeployState(deployState);
element.setLockState(lockState);
+ element.setSubState(subState);
element.setMessage(null);
}
}
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AcInstanceStateResolverTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AcInstanceStateResolverTest.java
index 7f6cb2f0c..a807a1179 100644
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AcInstanceStateResolverTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AcInstanceStateResolverTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2023 Nordix Foundation.
+ * Copyright (C) 2023-2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,42 +26,78 @@ import org.junit.jupiter.api.Test;
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.concepts.SubState;
import org.onap.policy.clamp.models.acm.messages.rest.instantiation.DeployOrder;
import org.onap.policy.clamp.models.acm.messages.rest.instantiation.LockOrder;
+import org.onap.policy.clamp.models.acm.messages.rest.instantiation.SubOrder;
class AcInstanceStateResolverTest {
@Test
void testResolve() {
var acTypeStateResolver = new AcInstanceStateResolver();
- var result = acTypeStateResolver.resolve(DeployOrder.DEPLOY, LockOrder.NONE, DeployState.UNDEPLOYED,
- LockState.NONE, StateChangeResult.NO_ERROR);
+ // deploy
+ var result = acTypeStateResolver.resolve(DeployOrder.DEPLOY, LockOrder.NONE, SubOrder.NONE,
+ DeployState.UNDEPLOYED, LockState.NONE, SubState.NONE, StateChangeResult.NO_ERROR);
assertThat(result).isEqualTo(AcInstanceStateResolver.DEPLOY);
- result = acTypeStateResolver.resolve(DeployOrder.UNDEPLOY, LockOrder.NONE, DeployState.DEPLOYED,
- LockState.LOCKED, StateChangeResult.NO_ERROR);
+
+ // undeploy
+ result = acTypeStateResolver.resolve(DeployOrder.UNDEPLOY, LockOrder.NONE, SubOrder.NONE,
+ DeployState.DEPLOYED, LockState.LOCKED, SubState.NONE, StateChangeResult.NO_ERROR);
assertThat(result).isEqualTo(AcInstanceStateResolver.UNDEPLOY);
- result = acTypeStateResolver.resolve(DeployOrder.NONE, LockOrder.UNLOCK, DeployState.DEPLOYED, LockState.LOCKED,
- StateChangeResult.NO_ERROR);
+
+ // unlock
+ result = acTypeStateResolver.resolve(DeployOrder.NONE, LockOrder.UNLOCK, SubOrder.NONE,
+ DeployState.DEPLOYED, LockState.LOCKED, SubState.NONE, StateChangeResult.NO_ERROR);
assertThat(result).isEqualTo(AcInstanceStateResolver.UNLOCK);
- result = acTypeStateResolver.resolve(DeployOrder.NONE, LockOrder.LOCK, DeployState.DEPLOYED, LockState.UNLOCKED,
- StateChangeResult.NO_ERROR);
+
+ // lock
+ result = acTypeStateResolver.resolve(DeployOrder.NONE, LockOrder.LOCK, SubOrder.NONE,
+ DeployState.DEPLOYED, LockState.UNLOCKED, SubState.NONE, StateChangeResult.NO_ERROR);
assertThat(result).isEqualTo(AcInstanceStateResolver.LOCK);
- result = acTypeStateResolver.resolve(DeployOrder.NONE, LockOrder.NONE, DeployState.UNDEPLOYED, LockState.NONE,
- StateChangeResult.NO_ERROR);
+ // migrate
+ result = acTypeStateResolver.resolve(DeployOrder.MIGRATE, LockOrder.NONE, SubOrder.NONE,
+ DeployState.DEPLOYED, LockState.LOCKED, SubState.NONE, StateChangeResult.NO_ERROR);
+ assertThat(result).isEqualTo(AcInstanceStateResolver.MIGRATE);
+
+ // migrate-precheck
+ result = acTypeStateResolver.resolve(DeployOrder.NONE, LockOrder.NONE, SubOrder.MIGRATE_PRECHECK,
+ DeployState.DEPLOYED, LockState.LOCKED, SubState.NONE, StateChangeResult.NO_ERROR);
+ assertThat(result).isEqualTo(AcInstanceStateResolver.MIGRATE_PRECHECK);
+
+ // prepare
+ result = acTypeStateResolver.resolve(DeployOrder.NONE, LockOrder.NONE, SubOrder.PREPARE,
+ DeployState.UNDEPLOYED, LockState.NONE, SubState.NONE, StateChangeResult.NO_ERROR);
+ assertThat(result).isEqualTo(AcInstanceStateResolver.PREPARE);
+
+ // review
+ result = acTypeStateResolver.resolve(DeployOrder.NONE, LockOrder.NONE, SubOrder.REVIEW,
+ DeployState.DEPLOYED, LockState.LOCKED, SubState.NONE, StateChangeResult.NO_ERROR);
+ assertThat(result).isEqualTo(AcInstanceStateResolver.REVIEW);
+ }
+
+ @Test
+ void testResolveWrongOrder() {
+ var acTypeStateResolver = new AcInstanceStateResolver();
+
+ var result = acTypeStateResolver.resolve(DeployOrder.NONE, LockOrder.NONE, SubOrder.NONE,
+ DeployState.UNDEPLOYED, LockState.NONE, SubState.NONE, StateChangeResult.NO_ERROR);
assertThat(result).isEqualTo(AcInstanceStateResolver.NONE);
- result = acTypeStateResolver.resolve(DeployOrder.UNDEPLOY, LockOrder.UNLOCK, DeployState.DEPLOYED,
- LockState.LOCKED, StateChangeResult.NO_ERROR);
+
+ result = acTypeStateResolver.resolve(DeployOrder.UNDEPLOY, LockOrder.UNLOCK, SubOrder.NONE,
+ DeployState.DEPLOYED, LockState.LOCKED, SubState.NONE, StateChangeResult.NO_ERROR);
assertThat(result).isEqualTo(AcInstanceStateResolver.NONE);
- result = acTypeStateResolver.resolve(DeployOrder.NONE, LockOrder.UNLOCK, DeployState.UNDEPLOYED, LockState.NONE,
- StateChangeResult.NO_ERROR);
+
+ result = acTypeStateResolver.resolve(DeployOrder.NONE, LockOrder.UNLOCK, SubOrder.NONE,
+ DeployState.UNDEPLOYED, LockState.NONE, SubState.NONE, StateChangeResult.NO_ERROR);
assertThat(result).isEqualTo(AcInstanceStateResolver.NONE);
- result = acTypeStateResolver.resolve(DeployOrder.UNDEPLOY, LockOrder.NONE, DeployState.DEPLOYING,
- LockState.NONE, StateChangeResult.NO_ERROR);
+
+ result = acTypeStateResolver.resolve(DeployOrder.UNDEPLOY, LockOrder.NONE, SubOrder.NONE,
+ DeployState.DEPLOYING, LockState.NONE, SubState.NONE, StateChangeResult.NO_ERROR);
assertThat(result).isEqualTo(AcInstanceStateResolver.NONE);
- result = acTypeStateResolver.resolve(null, null, null, null, null);
+ result = acTypeStateResolver.resolve(null, null, null, null, null, null, null);
assertThat(result).isEqualTo(AcInstanceStateResolver.NONE);
}
-
}
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java
index f17eff398..5d0a7d95a 100644
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java
@@ -43,6 +43,7 @@ import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionDefinition
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement;
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.SubState;
import org.onap.policy.clamp.models.acm.document.concepts.DocToscaServiceTemplate;
import org.onap.policy.clamp.models.acm.messages.rest.instantiation.DeployOrder;
import org.onap.policy.clamp.models.acm.messages.rest.instantiation.LockOrder;
@@ -68,14 +69,16 @@ class AcmUtilsTest {
@Test
void testIsInTransitionalState() {
- assertThat(AcmUtils.isInTransitionalState(DeployState.DEPLOYED, LockState.LOCKED)).isFalse();
- assertThat(AcmUtils.isInTransitionalState(DeployState.DEPLOYING, LockState.NONE)).isTrue();
- assertThat(AcmUtils.isInTransitionalState(DeployState.UNDEPLOYING, LockState.NONE)).isTrue();
- assertThat(AcmUtils.isInTransitionalState(DeployState.DEPLOYED, LockState.LOCKING)).isTrue();
- assertThat(AcmUtils.isInTransitionalState(DeployState.DEPLOYED, LockState.UNLOCKING)).isTrue();
- assertThat(AcmUtils.isInTransitionalState(DeployState.DELETING, LockState.NONE)).isTrue();
- assertThat(AcmUtils.isInTransitionalState(DeployState.UPDATING, LockState.LOCKED)).isTrue();
- assertThat(AcmUtils.isInTransitionalState(DeployState.MIGRATING, LockState.LOCKED)).isTrue();
+ assertThat(AcmUtils.isInTransitionalState(DeployState.DEPLOYED, LockState.LOCKED, SubState.NONE)).isFalse();
+ assertThat(AcmUtils.isInTransitionalState(DeployState.DEPLOYING, LockState.NONE, SubState.NONE)).isTrue();
+ assertThat(AcmUtils.isInTransitionalState(DeployState.UNDEPLOYING, LockState.NONE, SubState.NONE)).isTrue();
+ assertThat(AcmUtils.isInTransitionalState(DeployState.DEPLOYED, LockState.LOCKING, SubState.NONE)).isTrue();
+ assertThat(AcmUtils.isInTransitionalState(DeployState.DEPLOYED, LockState.UNLOCKING, SubState.NONE)).isTrue();
+ assertThat(AcmUtils.isInTransitionalState(DeployState.DELETING, LockState.NONE, SubState.NONE)).isTrue();
+ assertThat(AcmUtils.isInTransitionalState(DeployState.UPDATING, LockState.LOCKED, SubState.NONE)).isTrue();
+ assertThat(AcmUtils.isInTransitionalState(DeployState.MIGRATING, LockState.LOCKED, SubState.NONE)).isTrue();
+ assertThat(AcmUtils.isInTransitionalState(DeployState.DEPLOYED, LockState.LOCKED,
+ SubState.MIGRATION_PRECHECKING)).isTrue();
}
@Test