summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2023-09-26 14:31:58 +0100
committerFrancesco Fiora <francesco.fiora@est.tech>2023-09-26 13:34:28 +0000
commit54155ebf6232417d264159acf9fbfcdc08c11244 (patch)
tree60bbe3a27a5468a8d69b9ebe99f0534e05f66ff6
parent4407ea6948a060734a4f2836b11bd2d5c6ea6194 (diff)
Add migration message support
Issue-ID: POLICY-4822 Change-Id: Ibde7c14424c63a96c64378d8897e8887935d6c79 Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
-rwxr-xr-x[-rw-r--r--]models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationComposition.java3
-rwxr-xr-x[-rw-r--r--]models/src/main/java/org/onap/policy/clamp/models/acm/concepts/DeployState.java3
-rwxr-xr-xmodels/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionMigration.java43
-rwxr-xr-x[-rw-r--r--]models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessageType.java8
-rwxr-xr-x[-rw-r--r--]models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/DeployOrder.java3
-rwxr-xr-xmodels/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java22
-rwxr-xr-x[-rw-r--r--]models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcInstanceStateResolver.java14
-rwxr-xr-xmodels/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java76
-rwxr-xr-x[-rw-r--r--]models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionTest.java160
-rwxr-xr-x[-rw-r--r--]models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java17
10 files changed, 223 insertions, 126 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationComposition.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationComposition.java
index b92b03fba..0cf1f99ec 100644..100755
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationComposition.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationComposition.java
@@ -42,6 +42,8 @@ public class AutomationComposition extends ToscaEntity implements Comparable<Aut
@NonNull
private UUID compositionId;
+ private UUID compositionTargetId;
+
private Boolean restarting;
@NonNull
@@ -63,6 +65,7 @@ public class AutomationComposition extends ToscaEntity implements Comparable<Aut
super(otherAutomationComposition);
this.instanceId = otherAutomationComposition.instanceId;
this.compositionId = otherAutomationComposition.compositionId;
+ this.compositionTargetId = otherAutomationComposition.compositionTargetId;
this.restarting = otherAutomationComposition.restarting;
this.deployState = otherAutomationComposition.deployState;
this.lockState = otherAutomationComposition.lockState;
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/DeployState.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/DeployState.java
index 9dde703b6..57669fe77 100644..100755
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/DeployState.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/DeployState.java
@@ -27,5 +27,6 @@ public enum DeployState {
UNDEPLOYING,
DELETING,
DELETED,
- UPDATING
+ UPDATING,
+ MIGRATING
}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionMigration.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionMigration.java
new file mode 100755
index 000000000..dd5e528c5
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionMigration.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.models.acm.messages.dmaap.participant;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantDeploy;
+
+@Getter
+@Setter
+@ToString(callSuper = true)
+public class AutomationCompositionMigration extends ParticipantMessage {
+
+ private UUID compositionTargetId;
+ // A list of updates to AC element properties
+ private List<ParticipantDeploy> participantUpdatesList = new ArrayList<>();
+
+ public AutomationCompositionMigration() {
+ super(ParticipantMessageType.AUTOMATION_COMPOSITION_MIGRATION);
+ }
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessageType.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessageType.java
index c42778aae..7609accee 100644..100755
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessageType.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessageType.java
@@ -104,5 +104,11 @@ public enum ParticipantMessageType {
/**
* Used by runtime to send composition and instances to a restarted participant.
*/
- PARTICIPANT_RESTART
+ PARTICIPANT_RESTART,
+
+ /**
+ * Used by acm runtime to migrate from a composition to another one in participants, triggers a
+ * AUTOMATION_COMPOSITION_MIGRATION message with result of AUTOMATION_COMPOSITION_STATE_CHANGE operation.
+ */
+ AUTOMATION_COMPOSITION_MIGRATION
}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/DeployOrder.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/DeployOrder.java
index 24197f1ab..758a5057f 100644..100755
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/DeployOrder.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/DeployOrder.java
@@ -26,5 +26,6 @@ public enum DeployOrder {
DEPLOY,
DELETE,
UPDATE,
- RESTARTING
+ RESTARTING,
+ MIGRATE
}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java
index 104792143..5e27fde53 100755
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java
@@ -81,6 +81,9 @@ public class JpaAutomationComposition extends Validated
private String compositionId;
@Column
+ private String compositionTargetId;
+
+ @Column
private Boolean restarting;
@Column
@@ -106,8 +109,8 @@ public class JpaAutomationComposition extends Validated
* The Default Constructor creates a {@link JpaAutomationComposition} object with a null key.
*/
public JpaAutomationComposition() {
- this(UUID.randomUUID().toString(), new PfConceptKey(), UUID.randomUUID().toString(),
- new ArrayList<>(), DeployState.UNDEPLOYED, LockState.NONE);
+ this(UUID.randomUUID().toString(), new PfConceptKey(), UUID.randomUUID().toString(), new ArrayList<>(),
+ DeployState.UNDEPLOYED, LockState.NONE);
}
/**
@@ -121,8 +124,7 @@ public class JpaAutomationComposition extends Validated
* @param lockState the Lock State
*/
public JpaAutomationComposition(@NonNull final String instanceId, @NonNull final PfConceptKey key,
- @NonNull final String compositionId,
- @NonNull final List<JpaAutomationCompositionElement> elements,
+ @NonNull final String compositionId, @NonNull final List<JpaAutomationCompositionElement> elements,
@NonNull final DeployState deployState, @NonNull final LockState lockState) {
this.instanceId = instanceId;
this.name = key.getName();
@@ -143,6 +145,7 @@ public class JpaAutomationComposition extends Validated
this.name = copyConcept.name;
this.version = copyConcept.version;
this.compositionId = copyConcept.compositionId;
+ this.compositionTargetId = copyConcept.compositionTargetId;
this.restarting = copyConcept.restarting;
this.deployState = copyConcept.deployState;
this.lockState = copyConcept.lockState;
@@ -168,6 +171,9 @@ public class JpaAutomationComposition extends Validated
automationComposition.setName(name);
automationComposition.setVersion(version);
automationComposition.setCompositionId(UUID.fromString(compositionId));
+ if (compositionTargetId != null) {
+ automationComposition.setCompositionTargetId(UUID.fromString(compositionTargetId));
+ }
automationComposition.setRestarting(restarting);
automationComposition.setDeployState(deployState);
automationComposition.setLockState(lockState);
@@ -187,6 +193,9 @@ public class JpaAutomationComposition extends Validated
this.name = automationComposition.getName();
this.version = automationComposition.getVersion();
this.compositionId = automationComposition.getCompositionId().toString();
+ if (automationComposition.getCompositionTargetId() != null) {
+ this.compositionTargetId = automationComposition.getCompositionTargetId().toString();
+ }
this.restarting = automationComposition.getRestarting();
this.deployState = automationComposition.getDeployState();
this.lockState = automationComposition.getLockState();
@@ -230,6 +239,11 @@ public class JpaAutomationComposition extends Validated
return result;
}
+ result = ObjectUtils.compare(compositionTargetId, other.compositionTargetId);
+ if (result != 0) {
+ return result;
+ }
+
result = ObjectUtils.compare(restarting, other.restarting);
if (result != 0) {
return result;
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 e2f4fdf9b..7fed8a756 100644..100755
--- 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
@@ -38,6 +38,7 @@ public class AcInstanceStateResolver {
private static final String UNDEPLOYING = DeployState.UNDEPLOYING.name();
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 LOCKED = LockState.LOCKED.name();
private static final String LOCKING = LockState.LOCKING.name();
@@ -58,6 +59,7 @@ public class AcInstanceStateResolver {
public static final String DELETE = DeployOrder.DELETE.name();
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 NONE = "NONE";
/**
@@ -72,22 +74,24 @@ public class AcInstanceStateResolver {
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[] {UNDEPLOY, LOCK_NONE, UNDEPLOYING, STATE_LOCKED_NONE, FAILED}, UNDEPLOY);
- this.graph.put(new String[] {UNDEPLOY, LOCK_NONE, UPDATING, STATE_LOCKED_NONE, FAILED}, UNDEPLOY);
-
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, LOCK, DEPLOYED, LOCKING, FAILED}, LOCK);
+ 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.put(new String[] {DEPLOY_NONE, UNLOCK, DEPLOYED, UNLOCKING, FAILED}, UNLOCK);
// timeout
this.graph.put(new String[] {DEPLOY, LOCK_NONE, UNDEPLOYING, STATE_LOCKED_NONE, TIMEOUT}, DEPLOY);
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 258c6dc93..fe44050d5 100755
--- 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
@@ -45,6 +45,7 @@ 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.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.messages.rest.instantiation.DeployOrder;
import org.onap.policy.clamp.models.acm.messages.rest.instantiation.LockOrder;
import org.onap.policy.common.parameters.BeanValidationResult;
@@ -289,7 +290,8 @@ public final class AcmUtils {
public static boolean isInTransitionalState(DeployState deployState, LockState lockState) {
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.DELETING.equals(deployState) || DeployState.UPDATING.equals(deployState)
+ || DeployState.MIGRATING.equals(deployState);
}
/**
@@ -299,24 +301,12 @@ public final class AcmUtils {
* @return the DeployOrder
*/
public static DeployOrder stateDeployToOrder(DeployState deployState) {
- DeployOrder result = null;
- switch (deployState) {
- case DEPLOYING:
- result = DeployOrder.DEPLOY;
- break;
-
- case UNDEPLOYING:
- result = DeployOrder.UNDEPLOY;
- break;
-
- case DELETING:
- result = DeployOrder.DELETE;
- break;
-
- default:
- result = DeployOrder.NONE;
- }
- return result;
+ return switch (deployState) {
+ case DEPLOYING -> DeployOrder.DEPLOY;
+ case UNDEPLOYING -> DeployOrder.UNDEPLOY;
+ case DELETING -> DeployOrder.DELETE;
+ default -> DeployOrder.NONE;
+ };
}
/**
@@ -341,24 +331,12 @@ public final class AcmUtils {
* @return the DeployState
*/
public static DeployState deployCompleted(DeployState deployState) {
- DeployState result = null;
- switch (deployState) {
- case UPDATING, DEPLOYING:
- result = DeployState.DEPLOYED;
- break;
-
- case UNDEPLOYING:
- result = DeployState.UNDEPLOYED;
- break;
-
- case DELETING:
- result = DeployState.DELETED;
- break;
-
- default:
- return deployState;
- }
- return result;
+ return switch (deployState) {
+ case MIGRATING, UPDATING, DEPLOYING -> DeployState.DEPLOYED;
+ case UNDEPLOYING -> DeployState.UNDEPLOYED;
+ case DELETING -> DeployState.DELETED;
+ default -> deployState;
+ };
}
/**
@@ -427,6 +405,30 @@ public final class AcmUtils {
}
/**
+ * Create a list of AcElementDeploy for update/migrate message.
+ *
+ * @param automationComposition the AutomationComposition
+ * @param deployOrder the DeployOrder
+ */
+ public static List<ParticipantDeploy> createParticipantDeployList(AutomationComposition automationComposition,
+ DeployOrder deployOrder) {
+ Map<UUID, List<AcElementDeploy>> map = new HashMap<>();
+ for (var element : automationComposition.getElements().values()) {
+ var acElementDeploy = createAcElementDeploy(element, deployOrder);
+ map.putIfAbsent(element.getParticipantId(), new ArrayList<>());
+ map.get(element.getParticipantId()).add(acElementDeploy);
+ }
+ List<ParticipantDeploy> participantDeploys = new ArrayList<>();
+ for (var entry : map.entrySet()) {
+ var participantDeploy = new ParticipantDeploy();
+ participantDeploy.setParticipantId(entry.getKey());
+ participantDeploy.setAcElementList(entry.getValue());
+ participantDeploys.add(participantDeploy);
+ }
+ return participantDeploys;
+ }
+
+ /**
* Create a new AcElementRestart from an AutomationCompositionElement.
*
* @param element the AutomationCompositionElement
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionTest.java
index 04a874419..697b4e148 100644..100755
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionTest.java
@@ -62,28 +62,28 @@ class JpaAutomationCompositionTest {
}).hasMessageMatching(NULL_INSTANCE_ID_ERROR);
assertThatThrownBy(() -> {
- new JpaAutomationComposition(INSTANCE_ID, null, null, new ArrayList<>(),
- DeployState.UNDEPLOYED, LockState.LOCKED);
+ new JpaAutomationComposition(INSTANCE_ID, null, null, new ArrayList<>(), DeployState.UNDEPLOYED,
+ LockState.LOCKED);
}).hasMessageMatching("key" + NULL_TEXT_ERROR);
assertThatThrownBy(() -> {
- new JpaAutomationComposition(INSTANCE_ID, new PfConceptKey(), null,
- new ArrayList<>(), DeployState.UNDEPLOYED, LockState.LOCKED);
+ new JpaAutomationComposition(INSTANCE_ID, new PfConceptKey(), null, new ArrayList<>(),
+ DeployState.UNDEPLOYED, LockState.LOCKED);
}).hasMessageMatching("compositionId" + NULL_TEXT_ERROR);
assertThatThrownBy(() -> {
- new JpaAutomationComposition(INSTANCE_ID, new PfConceptKey(), COMPOSITION_ID.toString(),
- null, DeployState.UNDEPLOYED, LockState.LOCKED);
+ new JpaAutomationComposition(INSTANCE_ID, new PfConceptKey(), COMPOSITION_ID.toString(), null,
+ DeployState.UNDEPLOYED, LockState.LOCKED);
}).hasMessageMatching("elements" + NULL_TEXT_ERROR);
assertThatThrownBy(() -> {
- new JpaAutomationComposition(INSTANCE_ID, new PfConceptKey(), COMPOSITION_ID.toString(),
- new ArrayList<>(), null, LockState.LOCKED);
+ new JpaAutomationComposition(INSTANCE_ID, new PfConceptKey(), COMPOSITION_ID.toString(), new ArrayList<>(),
+ null, LockState.LOCKED);
}).hasMessageMatching("deployState" + NULL_TEXT_ERROR);
assertThatThrownBy(() -> {
- new JpaAutomationComposition(INSTANCE_ID, new PfConceptKey(), COMPOSITION_ID.toString(),
- new ArrayList<>(), DeployState.UNDEPLOYED, null);
+ new JpaAutomationComposition(INSTANCE_ID, new PfConceptKey(), COMPOSITION_ID.toString(), new ArrayList<>(),
+ DeployState.UNDEPLOYED, null);
}).hasMessageMatching("lockState" + NULL_TEXT_ERROR);
assertNotNull(new JpaAutomationComposition());
@@ -93,29 +93,34 @@ class JpaAutomationCompositionTest {
@Test
void testJpaAutomationComposition() {
- var testJpaAutomationComposition = createJpaAutomationCompositionInstance();
+ var jpaAutomationComposition = createJpaAutomationCompositionInstance();
+
+ var automationComposition = createAutomationCompositionInstance();
+ assertEquals(automationComposition, jpaAutomationComposition.toAuthorative());
- var participant = createAutomationCompositionInstance();
- assertEquals(participant, testJpaAutomationComposition.toAuthorative());
+ var target = UUID.randomUUID();
+ jpaAutomationComposition.setCompositionTargetId(target.toString());
+ automationComposition.setCompositionTargetId(target);
+ assertEquals(automationComposition, jpaAutomationComposition.toAuthorative());
assertThatThrownBy(() -> {
- testJpaAutomationComposition.fromAuthorative(null);
+ jpaAutomationComposition.fromAuthorative(null);
}).hasMessageMatching("automationComposition is marked .*ull but is null");
assertThatThrownBy(() -> new JpaAutomationComposition((JpaAutomationComposition) null))
.isInstanceOf(NullPointerException.class);
- var testJpaAutomationCompositionFa = new JpaAutomationComposition();
- testJpaAutomationCompositionFa.setInstanceId(null);
- testJpaAutomationCompositionFa.fromAuthorative(participant);
- assertEquals(testJpaAutomationComposition, testJpaAutomationCompositionFa);
+ var jpaAutomationCompositionFa = new JpaAutomationComposition();
+ jpaAutomationCompositionFa.setInstanceId(null);
+ jpaAutomationCompositionFa.fromAuthorative(automationComposition);
+ assertEquals(jpaAutomationComposition, jpaAutomationCompositionFa);
- assertEquals("automation-composition", testJpaAutomationComposition.getName());
+ assertEquals("automation-composition", jpaAutomationComposition.getName());
assertEquals("automation-composition",
new JpaAutomationComposition(createAutomationCompositionInstance()).getName());
- var testJpaAutomationComposition2 = new JpaAutomationComposition(testJpaAutomationComposition);
- assertEquals(testJpaAutomationComposition, testJpaAutomationComposition2);
+ var jpaAutomationComposition2 = new JpaAutomationComposition(jpaAutomationComposition);
+ assertEquals(jpaAutomationComposition, jpaAutomationComposition2);
}
@Test
@@ -130,60 +135,65 @@ class JpaAutomationCompositionTest {
@Test
void testJpaAutomationCompositionCompareTo() {
- var testJpaAutomationComposition = createJpaAutomationCompositionInstance();
-
- var otherJpaAutomationComposition = new JpaAutomationComposition(testJpaAutomationComposition);
- assertEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition));
- assertEquals(-1, testJpaAutomationComposition.compareTo(null));
- assertEquals(0, testJpaAutomationComposition.compareTo(testJpaAutomationComposition));
- assertNotEquals(0, testJpaAutomationComposition.compareTo(new DummyJpaAutomationCompositionChild()));
-
- testJpaAutomationComposition.setInstanceId("BadValue");
- assertNotEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition));
- testJpaAutomationComposition.setInstanceId(INSTANCE_ID);
- assertEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition));
-
- testJpaAutomationComposition.setCompositionId(UUID.randomUUID().toString());
- assertNotEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition));
- testJpaAutomationComposition.setCompositionId(COMPOSITION_ID);
- assertEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition));
-
- testJpaAutomationComposition.setName("BadValue");
- assertNotEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition));
- testJpaAutomationComposition.setName("automation-composition");
- assertEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition));
-
- testJpaAutomationComposition.setVersion("0.0.0");
- assertNotEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition));
- testJpaAutomationComposition.setVersion("0.0.1");
- assertEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition));
-
- testJpaAutomationComposition.setDeployState(DeployState.DEPLOYED);
- assertNotEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition));
- testJpaAutomationComposition.setDeployState(DeployState.UNDEPLOYED);
- assertEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition));
-
- testJpaAutomationComposition.setLockState(LockState.UNLOCKED);
- assertNotEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition));
- testJpaAutomationComposition.setLockState(LockState.NONE);
- assertEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition));
-
- testJpaAutomationComposition.setDescription("A description");
- assertNotEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition));
- testJpaAutomationComposition.setDescription(null);
- assertEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition));
-
- testJpaAutomationComposition.setRestarting(true);
- assertNotEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition));
- testJpaAutomationComposition.setRestarting(null);
- assertEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition));
-
- testJpaAutomationComposition.setStateChangeResult(StateChangeResult.NO_ERROR);
- assertNotEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition));
- testJpaAutomationComposition.setStateChangeResult(null);
- assertEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition));
-
- assertEquals(testJpaAutomationComposition, new JpaAutomationComposition(testJpaAutomationComposition));
+ var jpaAutomationComposition = createJpaAutomationCompositionInstance();
+
+ var otherJpaAutomationComposition = new JpaAutomationComposition(jpaAutomationComposition);
+ assertEquals(0, jpaAutomationComposition.compareTo(otherJpaAutomationComposition));
+ assertEquals(-1, jpaAutomationComposition.compareTo(null));
+ assertEquals(0, jpaAutomationComposition.compareTo(jpaAutomationComposition));
+ assertNotEquals(0, jpaAutomationComposition.compareTo(new DummyJpaAutomationCompositionChild()));
+
+ jpaAutomationComposition.setInstanceId("BadValue");
+ assertNotEquals(0, jpaAutomationComposition.compareTo(otherJpaAutomationComposition));
+ jpaAutomationComposition.setInstanceId(INSTANCE_ID);
+ assertEquals(0, jpaAutomationComposition.compareTo(otherJpaAutomationComposition));
+
+ jpaAutomationComposition.setCompositionId(UUID.randomUUID().toString());
+ assertNotEquals(0, jpaAutomationComposition.compareTo(otherJpaAutomationComposition));
+ jpaAutomationComposition.setCompositionId(COMPOSITION_ID);
+ assertEquals(0, jpaAutomationComposition.compareTo(otherJpaAutomationComposition));
+
+ jpaAutomationComposition.setCompositionTargetId(UUID.randomUUID().toString());
+ assertNotEquals(0, jpaAutomationComposition.compareTo(otherJpaAutomationComposition));
+ jpaAutomationComposition.setCompositionTargetId(null);
+ assertEquals(0, jpaAutomationComposition.compareTo(otherJpaAutomationComposition));
+
+ jpaAutomationComposition.setName("BadValue");
+ assertNotEquals(0, jpaAutomationComposition.compareTo(otherJpaAutomationComposition));
+ jpaAutomationComposition.setName("automation-composition");
+ assertEquals(0, jpaAutomationComposition.compareTo(otherJpaAutomationComposition));
+
+ jpaAutomationComposition.setVersion("0.0.0");
+ assertNotEquals(0, jpaAutomationComposition.compareTo(otherJpaAutomationComposition));
+ jpaAutomationComposition.setVersion("0.0.1");
+ assertEquals(0, jpaAutomationComposition.compareTo(otherJpaAutomationComposition));
+
+ jpaAutomationComposition.setDeployState(DeployState.DEPLOYED);
+ assertNotEquals(0, jpaAutomationComposition.compareTo(otherJpaAutomationComposition));
+ jpaAutomationComposition.setDeployState(DeployState.UNDEPLOYED);
+ assertEquals(0, jpaAutomationComposition.compareTo(otherJpaAutomationComposition));
+
+ jpaAutomationComposition.setLockState(LockState.UNLOCKED);
+ assertNotEquals(0, jpaAutomationComposition.compareTo(otherJpaAutomationComposition));
+ jpaAutomationComposition.setLockState(LockState.NONE);
+ assertEquals(0, jpaAutomationComposition.compareTo(otherJpaAutomationComposition));
+
+ jpaAutomationComposition.setDescription("A description");
+ assertNotEquals(0, jpaAutomationComposition.compareTo(otherJpaAutomationComposition));
+ jpaAutomationComposition.setDescription(null);
+ assertEquals(0, jpaAutomationComposition.compareTo(otherJpaAutomationComposition));
+
+ jpaAutomationComposition.setRestarting(true);
+ assertNotEquals(0, jpaAutomationComposition.compareTo(otherJpaAutomationComposition));
+ jpaAutomationComposition.setRestarting(null);
+ assertEquals(0, jpaAutomationComposition.compareTo(otherJpaAutomationComposition));
+
+ jpaAutomationComposition.setStateChangeResult(StateChangeResult.NO_ERROR);
+ assertNotEquals(0, jpaAutomationComposition.compareTo(otherJpaAutomationComposition));
+ jpaAutomationComposition.setStateChangeResult(null);
+ assertEquals(0, jpaAutomationComposition.compareTo(otherJpaAutomationComposition));
+
+ assertEquals(jpaAutomationComposition, new JpaAutomationComposition(jpaAutomationComposition));
}
@Test
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 a9bd25f81..e0e5a2edc 100644..100755
--- 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
@@ -68,6 +68,7 @@ class AcmUtilsTest {
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();
}
@Test
@@ -195,6 +196,18 @@ class AcmUtilsTest {
}
@Test
+ void testCreateAcElementDeployList() {
+ var automationComposition = getDummyAutomationComposition();
+ var result = AcmUtils.createParticipantDeployList(automationComposition, DeployOrder.DEPLOY);
+ assertThat(result).hasSameSizeAs(automationComposition.getElements().values());
+ for (var participantDeploy : result) {
+ for (var element : participantDeploy.getAcElementList()) {
+ assertEquals(DeployOrder.DEPLOY, element.getOrderedState());
+ }
+ }
+ }
+
+ @Test
void testCreateAcElementRestart() {
var element = getDummyAutomationComposition().getElements().values().iterator().next();
var result = AcmUtils.createAcElementRestart(element);
@@ -210,8 +223,8 @@ class AcmUtilsTest {
Map<UUID, AutomationCompositionElement> map = new LinkedHashMap<>();
try {
var element = new StandardCoder().decode(
- new File("src/test/resources/json/AutomationCompositionElementNoOrderedState.json"),
- AutomationCompositionElement.class);
+ new File("src/test/resources/json/AutomationCompositionElementNoOrderedState.json"),
+ AutomationCompositionElement.class);
map.put(UUID.randomUUID(), element);
} catch (Exception e) {
fail("Cannot read or decode " + e.getMessage());