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/concepts/AutomationComposition.java6
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessageType.java6
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantPrime.java (renamed from models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdate.java)14
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantPrimeAck.java (renamed from models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdateAck.java)14
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java11
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java12
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java50
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantPrimeAckTest.java (renamed from models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdateAckTest.java)16
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantPrimeTest.java (renamed from models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdateTest.java)10
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionTest.java9
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java23
-rw-r--r--models/src/test/resources/providers/TestAutomationCompositions.json72
-rw-r--r--models/src/test/resources/providers/TestParticipant.json4
-rw-r--r--models/src/test/resources/providers/UpdateAutomationCompositions.json36
14 files changed, 133 insertions, 150 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 18a62ae94..363668619 100644
--- 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
@@ -53,13 +53,10 @@ public class AutomationComposition extends ToscaEntity implements Comparable<Aut
private DeployState deployState = DeployState.UNDEPLOYED;
@NonNull
- private LockState lockState = LockState.LOCKED;
+ private LockState lockState = LockState.NONE;
private Map<UUID, AutomationCompositionElement> elements;
- @NonNull
- private Boolean primed = false;
-
/**
* Copy contructor, does a deep copy.
*
@@ -74,7 +71,6 @@ public class AutomationComposition extends ToscaEntity implements Comparable<Aut
this.deployState = otherAutomationComposition.deployState;
this.lockState = otherAutomationComposition.lockState;
this.elements = PfUtils.mapMap(otherAutomationComposition.elements, AutomationCompositionElement::new);
- this.primed = otherAutomationComposition.primed;
}
@Override
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 502896188..474bcd36f 100644
--- 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
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-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.
@@ -77,13 +77,13 @@ public enum ParticipantMessageType {
/**
* Used by automation composition runtime to send ToscaServiceTemplate to participant.
*/
- PARTICIPANT_UPDATE,
+ PARTICIPANT_PRIME,
/**
* Used by participant to acknowledge the receipt of PARTICIPANT_UPDATE message
* from automation composition runtime.
*/
- PARTICIPANT_UPDATE_ACK,
+ PARTICIPANT_PRIME_ACK,
/**
* Used by participant to acknowledge the receipt of AUTOMATION_COMPOSITION_DEPLOY message
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdate.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantPrime.java
index 36842a8cf..b9d82a5c8 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdate.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantPrime.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2023 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -30,23 +30,23 @@ import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition;
import org.onap.policy.models.base.PfUtils;
/**
- * Class to represent the PARTICIPANT_UPDATE message that the ACM runtime sends to a participant.
+ * Class to represent the PARTICIPANT_PRIME message that the ACM runtime sends to a participant.
* the ACM Runtime sends automation composition element Definitions and Common Parameter Values to Participants.
*/
@Getter
@Setter
@ToString(callSuper = true)
-public class ParticipantUpdate extends ParticipantMessage {
+public class ParticipantPrime extends ParticipantMessage {
// A list of updates to ParticipantDefinitions
private List<ParticipantDefinition> participantDefinitionUpdates = new ArrayList<>();
/**
- * Constructor for instantiating ParticipantUpdate class with message name.
+ * Constructor for instantiating ParticipantPrime class with message name.
*
*/
- public ParticipantUpdate() {
- super(ParticipantMessageType.PARTICIPANT_UPDATE);
+ public ParticipantPrime() {
+ super(ParticipantMessageType.PARTICIPANT_PRIME);
}
/**
@@ -54,7 +54,7 @@ public class ParticipantUpdate extends ParticipantMessage {
*
* @param source source from which to copy
*/
- public ParticipantUpdate(ParticipantUpdate source) {
+ public ParticipantPrime(ParticipantPrime source) {
super(source);
this.participantDefinitionUpdates = PfUtils.mapList(source.participantDefinitionUpdates,
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdateAck.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantPrimeAck.java
index 2c3a68e22..156fe919c 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdateAck.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantPrimeAck.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2023 Nordix Foundation.
* ================================================================================
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -27,19 +27,19 @@ import lombok.Setter;
import lombok.ToString;
/**
- * Class to represent the PARTICIPANT_UPDATE_ACK message that registered participant sends to the ACM runtime.
+ * Class to represent the PARTICIPANT_PRIME_ACK message that registered participant sends to the ACM runtime.
*/
@Getter
@Setter
@ToString(callSuper = true)
-public class ParticipantUpdateAck extends ParticipantAckMessage {
+public class ParticipantPrimeAck extends ParticipantAckMessage {
/**
- * Constructor for instantiating ParticipantUpdateAck class with message name.
+ * Constructor for instantiating ParticipantPrimeAck class with message name.
*
*/
- public ParticipantUpdateAck() {
- super(ParticipantMessageType.PARTICIPANT_UPDATE_ACK);
+ public ParticipantPrimeAck() {
+ super(ParticipantMessageType.PARTICIPANT_PRIME_ACK);
}
/**
@@ -47,7 +47,7 @@ public class ParticipantUpdateAck extends ParticipantAckMessage {
*
* @param source source from which to copy
*/
- public ParticipantUpdateAck(final ParticipantUpdateAck source) {
+ public ParticipantPrimeAck(final ParticipantPrimeAck source) {
super(source);
}
}
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 00f83122d..2aacc74b6 100644
--- 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
@@ -100,9 +100,6 @@ public class JpaAutomationComposition extends Validated
@Column
private String description;
- @Column(columnDefinition = "TINYINT DEFAULT 1")
- private Boolean primed;
-
@NotNull
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JoinColumn(name = "instanceId", foreignKey = @ForeignKey(name = "ac_element_fk"))
@@ -155,7 +152,6 @@ public class JpaAutomationComposition extends Validated
this.lockState = copyConcept.lockState;
this.description = copyConcept.description;
this.elements = PfUtils.mapList(copyConcept.elements, JpaAutomationCompositionElement::new);
- this.primed = copyConcept.primed;
}
/**
@@ -180,7 +176,6 @@ public class JpaAutomationComposition extends Validated
automationComposition.setDeployState(deployState);
automationComposition.setLockState(lockState);
automationComposition.setDescription(description);
- automationComposition.setPrimed(primed);
automationComposition.setElements(new LinkedHashMap<>(this.elements.size()));
for (var element : this.elements) {
automationComposition.getElements().put(UUID.fromString(element.getElementId()), element.toAuthorative());
@@ -200,7 +195,6 @@ public class JpaAutomationComposition extends Validated
this.deployState = automationComposition.getDeployState();
this.lockState = automationComposition.getLockState();
this.description = automationComposition.getDescription();
- this.primed = automationComposition.getPrimed();
this.elements = new ArrayList<>(automationComposition.getElements().size());
for (var elementEntry : automationComposition.getElements().entrySet()) {
@@ -264,11 +258,6 @@ public class JpaAutomationComposition extends Validated
if (result != 0) {
return result;
}
-
- result = ObjectUtils.compare(primed, other.primed);
- if (result != 0) {
- return result;
- }
return PfUtils.compareObjects(elements, other.elements);
}
}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java
index 21efc66d3..197955d3a 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022 Nordix Foundation.
+ * Copyright (C) 2021-2023 Nordix Foundation.
* ================================================================================
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -30,8 +30,11 @@ import javax.ws.rs.core.Response.Status;
import lombok.AllArgsConstructor;
import lombok.NonNull;
import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
+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.persistence.concepts.JpaAutomationComposition;
import org.onap.policy.clamp.models.acm.persistence.repository.AutomationCompositionRepository;
+import org.onap.policy.clamp.models.acm.utils.AcmUtils;
import org.onap.policy.models.base.PfModelRuntimeException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.springframework.data.domain.Example;
@@ -97,6 +100,7 @@ public class AutomationCompositionProvider {
*/
public AutomationComposition createAutomationComposition(final AutomationComposition automationComposition) {
automationComposition.setInstanceId(UUID.randomUUID());
+ AcmUtils.setCascadedState(automationComposition, DeployState.UNDEPLOYED, LockState.NONE);
var result = automationCompositionRepository.save(ProviderUtils.getJpaAndValidate(automationComposition,
JpaAutomationComposition::new, "automation composition"));
@@ -110,7 +114,9 @@ public class AutomationCompositionProvider {
* @param automationComposition the automation composition to update
* @return the updated automation composition
*/
- public AutomationComposition updateAutomationComposition(final AutomationComposition automationComposition) {
+ public AutomationComposition updateAutomationComposition(
+ @NonNull final AutomationComposition automationComposition) {
+ AcmUtils.setCascadedState(automationComposition, DeployState.UNDEPLOYED, LockState.NONE);
var result = automationCompositionRepository.save(ProviderUtils.getJpaAndValidate(automationComposition,
JpaAutomationComposition::new, "automation composition"));
@@ -154,6 +160,8 @@ public class AutomationCompositionProvider {
example.setInstanceId(null);
example.setElements(null);
example.setState(null);
+ example.setDeployState(null);
+ example.setLockState(null);
return Example.of(example);
}
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 7d1e80f54..af29deb3f 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
@@ -39,6 +39,8 @@ import org.onap.policy.clamp.models.acm.concepts.AcTypeState;
import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDefinition;
+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;
@@ -97,25 +99,23 @@ public final class AcmUtils {
}
/**
- * Set the Policy information in the service template for the automation composition element.
+ * Get the Policy information in the service template for the deploy message to participants.
*
- * @param acElement automation composition element
* @param toscaServiceTemplate ToscaServiceTemplate
*/
- public static void setAcPolicyInfo(AutomationCompositionElement acElement,
- ToscaServiceTemplate toscaServiceTemplate) {
+ public static ToscaServiceTemplate getToscaServiceTemplateFragment(ToscaServiceTemplate toscaServiceTemplate) {
// Pass respective PolicyTypes or Policies as part of toscaServiceTemplateFragment
if (toscaServiceTemplate.getPolicyTypes() == null
&& toscaServiceTemplate.getToscaTopologyTemplate().getPolicies() == null) {
- return;
+ return new ToscaServiceTemplate();
}
- ToscaServiceTemplate toscaServiceTemplateFragment = new ToscaServiceTemplate();
+ var toscaServiceTemplateFragment = new ToscaServiceTemplate();
toscaServiceTemplateFragment.setPolicyTypes(toscaServiceTemplate.getPolicyTypes());
- ToscaTopologyTemplate toscaTopologyTemplate = new ToscaTopologyTemplate();
+ var toscaTopologyTemplate = new ToscaTopologyTemplate();
toscaTopologyTemplate.setPolicies(toscaServiceTemplate.getToscaTopologyTemplate().getPolicies());
toscaServiceTemplateFragment.setToscaTopologyTemplate(toscaTopologyTemplate);
toscaServiceTemplateFragment.setDataTypes(toscaServiceTemplate.getDataTypes());
- acElement.setToscaServiceTemplateFragment(toscaServiceTemplateFragment);
+ return toscaServiceTemplateFragment;
}
/**
@@ -196,7 +196,7 @@ public final class AcmUtils {
public static List<Entry<String, ToscaNodeTemplate>> extractAcElementsFromServiceTemplate(
ToscaServiceTemplate serviceTemplate) {
return serviceTemplate.getToscaTopologyTemplate().getNodeTemplates().entrySet().stream().filter(
- nodeTemplateEntry -> checkIfNodeTemplateIsAutomationCompositionElement(nodeTemplateEntry.getValue(),
+ nodeTemplateEntry -> checkIfNodeTemplateIsAutomationCompositionElement(nodeTemplateEntry.getValue(),
serviceTemplate))
.collect(Collectors.toList());
}
@@ -308,4 +308,36 @@ public final class AcmUtils {
.collect(Collectors.toList());
// @formatter:on
}
+
+
+ /**
+ * Return true if DeployState and LockState are in a Transitional State.
+ *
+ * @return true if DeployState and LockState are in a Transitional State
+ */
+ 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);
+ }
+
+ /**
+ * 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
+ */
+ public static void setCascadedState(final AutomationComposition automationComposition,
+ final DeployState deployState, final LockState lockState) {
+ automationComposition.setDeployState(deployState);
+ automationComposition.setLockState(lockState);
+
+ if (MapUtils.isEmpty(automationComposition.getElements())) {
+ return;
+ }
+
+ for (var element : automationComposition.getElements().values()) {
+ element.setDeployState(deployState);
+ element.setLockState(lockState);
+ }
+ }
}
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdateAckTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantPrimeAckTest.java
index e2c3454a4..e4684b8d0 100644
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdateAckTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantPrimeAckTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022 Nordix Foundation.
+ * Copyright (C) 2021-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.
@@ -30,30 +30,30 @@ import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-class ParticipantUpdateAckTest {
+class ParticipantPrimeAckTest {
@Test
void testCopyConstructor() throws CoderException {
- assertThatThrownBy(() -> new ParticipantUpdateAck(null)).isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(() -> new ParticipantPrimeAck(null)).isInstanceOf(NullPointerException.class);
- final ParticipantUpdateAck orig = new ParticipantUpdateAck();
+ final ParticipantPrimeAck orig = new ParticipantPrimeAck();
// verify with null values
assertEquals(removeVariableFields(orig.toString()),
- removeVariableFields(new ParticipantUpdateAck(orig).toString()));
+ removeVariableFields(new ParticipantPrimeAck(orig).toString()));
// verify with all values
ToscaConceptIdentifier id = new ToscaConceptIdentifier();
id.setName("id");
id.setVersion("1.2.3");
orig.setResponseTo(UUID.randomUUID());
- orig.setMessageType(ParticipantMessageType.PARTICIPANT_UPDATE_ACK);
+ orig.setMessageType(ParticipantMessageType.PARTICIPANT_PRIME_ACK);
orig.setResult(true);
orig.setMessage("Successfully processed message");
assertEquals(removeVariableFields(orig.toString()),
- removeVariableFields(new ParticipantUpdateAck(orig).toString()));
+ removeVariableFields(new ParticipantPrimeAck(orig).toString()));
- assertSerializable(orig, ParticipantUpdateAck.class);
+ assertSerializable(orig, ParticipantPrimeAck.class);
}
}
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdateTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantPrimeTest.java
index ffbd63f1a..890fc55ae 100644
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdateTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantPrimeTest.java
@@ -40,12 +40,12 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
/**
* Test the copy constructor.
*/
-class ParticipantUpdateTest {
+class ParticipantPrimeTest {
@Test
void testCopyConstructor() throws CoderException {
- assertThatThrownBy(() -> new ParticipantUpdate(null)).isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(() -> new ParticipantPrime(null)).isInstanceOf(NullPointerException.class);
- var orig = new ParticipantUpdate();
+ var orig = new ParticipantPrime();
// verify with all values
orig.setAutomationCompositionId(UUID.randomUUID());
orig.setParticipantId(CommonTestData.getParticipantId());
@@ -70,11 +70,11 @@ class ParticipantUpdateTest {
participantDefinitionUpdate.setAutomationCompositionElementDefinitionList(List.of(acDefinition));
orig.setParticipantDefinitionUpdates(List.of(participantDefinitionUpdate));
- var other = new ParticipantUpdate(orig);
+ var other = new ParticipantPrime(orig);
assertEquals(removeVariableFields(orig.toString()), removeVariableFields(other.toString()));
- assertSerializable(orig, ParticipantUpdate.class);
+ assertSerializable(orig, ParticipantPrime.class);
}
private AutomationCompositionElementDefinition getAcElementDefinition(ToscaConceptIdentifier id) {
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 30e225995..0f10c8c03 100644
--- 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
@@ -60,6 +60,10 @@ class JpaAutomationCompositionTest {
}).hasMessageMatching("copyConcept is marked .*ull but is null");
assertThatThrownBy(() -> {
+ new JpaAutomationComposition((AutomationComposition) null);
+ }).hasMessageMatching("authorativeConcept is marked .*ull but is null");
+
+ assertThatThrownBy(() -> {
new JpaAutomationComposition(null, null, null, null, null, null, null);
}).hasMessageMatching(NULL_INSTANCE_ID_ERROR);
@@ -211,11 +215,6 @@ class JpaAutomationCompositionTest {
testJpaAutomationComposition.setDescription(null);
assertEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition));
- testJpaAutomationComposition.setPrimed(true);
- assertNotEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition));
- testJpaAutomationComposition.setPrimed(false);
- assertEquals(0, testJpaAutomationComposition.compareTo(otherJpaAutomationComposition));
-
assertEquals(testJpaAutomationComposition, new JpaAutomationComposition(testJpaAutomationComposition));
}
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 413139999..c16beaf87 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
@@ -39,6 +39,8 @@ import java.util.UUID;
import org.junit.jupiter.api.Test;
import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
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.ParticipantDeploy;
import org.onap.policy.clamp.models.acm.document.concepts.DocToscaServiceTemplate;
import org.onap.policy.common.utils.coder.StandardCoder;
@@ -58,6 +60,15 @@ class AcmUtilsTest {
private static final String TOSCA_TEMPLATE_YAML = "clamp/acm/pmsh/funtional-pmsh-usecase.yaml";
@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();
+ }
+
+ @Test
void testCommonUtilsParticipantUpdate() {
var acElement = new AutomationCompositionElement();
List<ParticipantDeploy> participantUpdates = new ArrayList<>();
@@ -111,10 +122,9 @@ class AcmUtilsTest {
@Test
void testCommonUtilsServiceTemplate() {
- var acElement = new AutomationCompositionElement();
var toscaServiceTemplate = getDummyToscaServiceTemplate();
- AcmUtils.setAcPolicyInfo(acElement, toscaServiceTemplate);
- assertEquals(getDummyToscaDataTypeMap(), acElement.getToscaServiceTemplateFragment().getDataTypes());
+ var toscaServiceTemplateFragment = AcmUtils.getToscaServiceTemplateFragment(toscaServiceTemplate);
+ assertEquals(getDummyToscaDataTypeMap(), toscaServiceTemplateFragment.getDataTypes());
}
@Test
@@ -122,9 +132,10 @@ class AcmUtilsTest {
var toscaServiceTemplate = getDummyToscaServiceTemplate();
toscaServiceTemplate.setPolicyTypes(null);
toscaServiceTemplate.getToscaTopologyTemplate().setPolicies(null);
- AutomationCompositionElement acElement = new AutomationCompositionElement();
- AcmUtils.setAcPolicyInfo(new AutomationCompositionElement(), toscaServiceTemplate);
- assertNull(acElement.getToscaServiceTemplateFragment());
+ var toscaServiceTemplateFragment = AcmUtils.getToscaServiceTemplateFragment(toscaServiceTemplate);
+ assertNull(toscaServiceTemplateFragment.getPolicyTypes());
+ assertNull(toscaServiceTemplateFragment.getToscaTopologyTemplate());
+ assertNull(toscaServiceTemplateFragment.getDataTypes());
}
@Test
diff --git a/models/src/test/resources/providers/TestAutomationCompositions.json b/models/src/test/resources/providers/TestAutomationCompositions.json
index bf1d76fbc..24f5a4870 100644
--- a/models/src/test/resources/providers/TestAutomationCompositions.json
+++ b/models/src/test/resources/providers/TestAutomationCompositions.json
@@ -3,8 +3,8 @@
{
"compositionId": "709c62b3-8918-41b9-a747-e21eb79c6c40",
"instanceId": "809c62b3-8918-41b9-a748-e21eb79c6c89",
- "state": "UNINITIALISED",
- "orderedState": "UNINITIALISED",
+ "deployState": "UNDEPLOYED",
+ "lockState": "NONE",
"elements": {
"709c62b3-8918-41b9-a747-e21eb79c6c20": {
"id": "709c62b3-8918-41b9-a747-e21eb79c6c20",
@@ -12,12 +12,8 @@
"name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice",
"version": "1.2.3"
},
- "participantType": {
- "name": "org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant",
- "version": "2.3.4"
- },
- "state": "UNINITIALISED",
- "orderedState": "UNINITIALISED",
+ "deployState": "UNDEPLOYED",
+ "lockState": "NONE",
"description": "DCAE automation composition element for the PMSH instance 0 automation composition"
},
"709c62b3-8918-41b9-a747-e21eb79c6c21": {
@@ -26,12 +22,8 @@
"name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement",
"version": "1.2.3"
},
- "participantType": {
- "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant",
- "version": "2.3.1"
- },
- "state": "UNINITIALISED",
- "orderedState": "UNINITIALISED",
+ "deployState": "UNDEPLOYED",
+ "lockState": "NONE",
"description": "Monitoring Policy element for the PMSH instance 0 automation composition"
},
"709c62b3-8918-41b9-a747-e21eb79c6c22": {
@@ -40,12 +32,8 @@
"name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement",
"version": "1.2.3"
},
- "participantType": {
- "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant",
- "version": "2.3.1"
- },
- "state": "UNINITIALISED",
- "orderedState": "UNINITIALISED",
+ "deployState": "UNDEPLOYED",
+ "lockState": "NONE",
"description": "Operational Policy element for the PMSH instance 0 automation composition"
},
"709c62b3-8918-41b9-a747-e21eb79c6c23": {
@@ -54,12 +42,8 @@
"name": "org.onap.domain.pmsh.PMSH_CDS_AutomationCompositionElement",
"version": "1.2.3"
},
- "participantType": {
- "name": "org.onap.ccsdk.cds.acm.CdsAutomationCompositionParticipant",
- "version": "2.2.1"
- },
- "state": "UNINITIALISED",
- "orderedState": "UNINITIALISED",
+ "deployState": "UNDEPLOYED",
+ "lockState": "NONE",
"description": "CDS automation composition element for the PMSH instance 0 automation composition"
}
},
@@ -70,8 +54,8 @@
{
"compositionId": "709c62b3-8918-41b9-a747-e21eb79c6c40",
"instanceId": "809c62b3-8918-41b9-a748-e21eb79c6c90",
- "state": "UNINITIALISED",
- "orderedState": "UNINITIALISED",
+ "deployState": "UNDEPLOYED",
+ "lockState": "NONE",
"elements": {
"709c62b3-8918-41b9-a747-e21eb79c6c24": {
"id": "709c62b3-8918-41b9-a747-e21eb79c6c24",
@@ -79,12 +63,8 @@
"name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice",
"version": "1.2.3"
},
- "participantType": {
- "name": "org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant",
- "version": "2.3.4"
- },
- "state": "UNINITIALISED",
- "orderedState": "UNINITIALISED",
+ "deployState": "UNDEPLOYED",
+ "lockState": "NONE",
"description": "DCAE automation composition element for the PMSH instance 1 automation composition"
},
"709c62b3-8918-41b9-a747-e21eb79c6c25": {
@@ -93,12 +73,8 @@
"name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement",
"version": "1.2.3"
},
- "participantType": {
- "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant",
- "version": "2.3.1"
- },
- "state": "UNINITIALISED",
- "orderedState": "UNINITIALISED",
+ "deployState": "UNDEPLOYED",
+ "lockState": "NONE",
"description": "Monitoring Policy element for the PMSH instance 1 automation composition"
},
"709c62b3-8918-41b9-a747-e21eb79c6c26": {
@@ -107,12 +83,8 @@
"name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement",
"version": "1.2.3"
},
- "participantType": {
- "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant",
- "version": "2.3.1"
- },
- "state": "UNINITIALISED",
- "orderedState": "UNINITIALISED",
+ "deployState": "UNDEPLOYED",
+ "lockState": "NONE",
"description": "Operational Policy element for the PMSH instance 1 automation composition"
},
"709c62b3-8918-41b9-a747-e21eb79c6c27": {
@@ -121,12 +93,8 @@
"name": "org.onap.domain.pmsh.PMSH_CDS_AutomationCompositionElement",
"version": "1.2.3"
},
- "participantType": {
- "name": "org.onap.ccsdk.cds.acm.CdsAutomationCompositionParticipant",
- "version": "2.2.1"
- },
- "state": "UNINITIALISED",
- "orderedState": "UNINITIALISED",
+ "deployState": "UNDEPLOYED",
+ "lockState": "NONE",
"description": "CDS element for the PMSH instance 1 automation composition"
}
},
diff --git a/models/src/test/resources/providers/TestParticipant.json b/models/src/test/resources/providers/TestParticipant.json
index 2f4f910f1..689c6a2b2 100644
--- a/models/src/test/resources/providers/TestParticipant.json
+++ b/models/src/test/resources/providers/TestParticipant.json
@@ -8,10 +8,6 @@
"participantState": "ON_LINE",
"description": "A dummy PMSH participant1",
"participantId": "82fd8ef9-1d1e-4343-9b28-7f9564ee3de6",
- "participantType":{
- "name": "org.onap.domain.pmsh.PolicyAutomationCompositionDefinition",
- "version": "1.0.0"
- },
"participantSupportedElementTypes": {
"68fe8c61-7629-4be7-99d8-18bc6a92d178": {
"id": "68fe8c61-7629-4be7-99d8-18bc6a92d178",
diff --git a/models/src/test/resources/providers/UpdateAutomationCompositions.json b/models/src/test/resources/providers/UpdateAutomationCompositions.json
index f118ea799..9681ef247 100644
--- a/models/src/test/resources/providers/UpdateAutomationCompositions.json
+++ b/models/src/test/resources/providers/UpdateAutomationCompositions.json
@@ -7,8 +7,8 @@
"name": "org.onap.domain.pmsh.PMSHAutomationCompositionDefinition",
"version": "1.0.0"
},
- "state": "RUNNING",
- "orderedState": "RUNNING",
+ "deployState": "UNDEPLOYED",
+ "lockState": "NONE",
"description": "PMSH automation composition instance 0",
"elements": {
"709c62b3-8918-41b9-a747-d21eb79c6c20": {
@@ -17,12 +17,8 @@
"name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice",
"version": "1.2.3"
},
- "participantType": {
- "name": "org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant",
- "version": "2.3.4"
- },
- "state": "RUNNING",
- "orderedState": "RUNNING",
+ "deployState": "UNDEPLOYED",
+ "lockState": "NONE",
"description": "DCAE element for the PMSH instance 0 automation composition"
},
"709c62b3-8918-41b9-a747-d21eb79c6c21": {
@@ -31,12 +27,8 @@
"name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement",
"version": "1.2.3"
},
- "participantType": {
- "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant",
- "version": "2.3.1"
- },
- "state": "RUNNING",
- "orderedState": "RUNNING",
+ "deployState": "UNDEPLOYED",
+ "lockState": "NONE",
"description": "Monitoring Policy element for the PMSH instance 0 automation composition"
},
"709c62b3-8918-41b9-a747-d21eb79c6c22": {
@@ -45,12 +37,8 @@
"name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement",
"version": "2.3.1"
},
- "participantType": {
- "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant",
- "version": "1.0.0"
- },
- "state": "RUNNING",
- "orderedState": "RUNNING",
+ "deployState": "UNDEPLOYED",
+ "lockState": "NONE",
"description": "Operational Policy element for the PMSH instance 0 automation composition"
},
"709c62b3-8918-41b9-a747-d21eb79c6c23": {
@@ -59,12 +47,8 @@
"name": "org.onap.domain.pmsh.PMSH_CDS_AutomationCompositionElement",
"version": "1.2.3"
},
- "participantType": {
- "name": "org.onap.ccsdk.cds.acm.CdsAutomationCompositionParticipant",
- "version": "2.2.1"
- },
- "state": "RUNNING",
- "orderedState": "RUNNING",
+ "deployState": "UNDEPLOYED",
+ "lockState": "NONE",
"description": "CDS element for the PMSH instance 0 automation composition"
}
}