summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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/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/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
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java123
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/InstantiationController.java6
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java19
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionDeployPublisher.java2
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProviderTest.java74
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/rest/InstantiationControllerTest.java140
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java12
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/CommonTestData.java5
-rw-r--r--runtime-acm/src/test/resources/rest/acm/AutomationComposition.json31
-rw-r--r--runtime-acm/src/test/resources/rest/acm/AutomationCompositionElementsNotFound.json37
-rw-r--r--runtime-acm/src/test/resources/rest/acm/AutomationCompositionNotFound.json36
-rw-r--r--runtime-acm/src/test/resources/rest/acm/AutomationCompositionSmoke.json31
-rw-r--r--runtime-acm/src/test/resources/rest/acm/AutomationCompositionUpdate.json31
22 files changed, 301 insertions, 469 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/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/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"
}
}
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java
index 4949c6612..5281cb537 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java
@@ -21,25 +21,20 @@
package org.onap.policy.clamp.acm.runtime.instantiation;
-import java.util.List;
import java.util.UUID;
-import java.util.function.Function;
-import java.util.stream.Collectors;
+import javax.validation.Valid;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import lombok.AllArgsConstructor;
-import org.onap.policy.clamp.acm.runtime.supervision.SupervisionHandler;
-import org.onap.policy.clamp.common.acm.exception.AutomationCompositionException;
-import org.onap.policy.clamp.common.acm.exception.AutomationCompositionRuntimeException;
+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.AutomationCompositionState;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositions;
-import org.onap.policy.clamp.models.acm.concepts.Participant;
-import org.onap.policy.clamp.models.acm.messages.rest.instantiation.InstantiationCommand;
+import org.onap.policy.clamp.models.acm.messages.rest.instantiation.AcInstanceStateUpdate;
import org.onap.policy.clamp.models.acm.messages.rest.instantiation.InstantiationResponse;
import org.onap.policy.clamp.models.acm.persistence.provider.AcDefinitionProvider;
+import org.onap.policy.clamp.models.acm.persistence.provider.AcInstanceStateResolver;
import org.onap.policy.clamp.models.acm.persistence.provider.AutomationCompositionProvider;
-import org.onap.policy.clamp.models.acm.persistence.provider.ParticipantProvider;
import org.onap.policy.clamp.models.acm.utils.AcmUtils;
import org.onap.policy.common.parameters.BeanValidationResult;
import org.onap.policy.common.parameters.ObjectValidationResult;
@@ -55,14 +50,11 @@ import org.springframework.transaction.annotation.Transactional;
@Transactional
@AllArgsConstructor
public class AutomationCompositionInstantiationProvider {
- private static final String AUTOMATION_COMPOSITION_NODE_ELEMENT_TYPE = "AutomationCompositionElement";
private static final String DO_NOT_MATCH = " do not match with ";
private final AutomationCompositionProvider automationCompositionProvider;
- private final SupervisionHandler supervisionHandler;
- private final ParticipantProvider participantProvider;
private final AcDefinitionProvider acDefinitionProvider;
- private static final String ENTRY = "entry ";
+ private final AcInstanceStateResolver acInstanceStateResolver;
/**
* Create automation composition.
@@ -142,10 +134,24 @@ public class AutomationCompositionInstantiationProvider {
if (acDefinitionOpt.isEmpty()) {
result.addResult(new ObjectValidationResult("ServiceTemplate", "", ValidationStatus.INVALID,
"Commissioned automation composition definition not found"));
- } else {
- result.addResult(AcmUtils.validateAutomationComposition(automationComposition,
- acDefinitionOpt.get().getServiceTemplate()));
+ return result;
}
+ if (!AcTypeState.PRIMED.equals(acDefinitionOpt.get().getState())) {
+ result.addResult(new ObjectValidationResult("ServiceTemplate", "", ValidationStatus.INVALID,
+ "Commissioned automation composition definition not primed"));
+ return result;
+ }
+ result.addResult(AcmUtils.validateAutomationComposition(automationComposition,
+ acDefinitionOpt.get().getServiceTemplate()));
+
+ if (result.isValid()) {
+ for (var element : automationComposition.getElements().values()) {
+ var name = element.getDefinition().getName();
+ var participantId = acDefinitionOpt.get().getElementStateMap().get(name).getParticipantId();
+ element.setParticipantId(participantId);
+ }
+ }
+
return result;
}
@@ -208,61 +214,42 @@ public class AutomationCompositionInstantiationProvider {
}
/**
- * Issue a command to automation compositions, setting their ordered state.
+ * Handle Composition Instance State.
*
- * @param automationComposition the AutomationComposition
- * @param command the command to issue to automation compositions
+ * @param compositionId the compositionId
+ * @param instanceId the instanceId
+ * @param acInstanceStateUpdate the AcInstanceStateUpdate
*/
- public void issueAutomationCompositionCommand(AutomationComposition automationComposition,
- InstantiationCommand command) {
-
- if (command.getOrderedState() == null) {
- throw new AutomationCompositionRuntimeException(Status.BAD_REQUEST,
- "ordered state invalid or not specified on command");
- }
-
- var participants = participantProvider.getParticipants();
- if (participants.isEmpty()) {
- throw new AutomationCompositionRuntimeException(Status.BAD_REQUEST, "No participants registered");
- }
- var validationResult = validateIssueAutomationComposition(automationComposition, participants);
- if (!validationResult.isValid()) {
- throw new AutomationCompositionRuntimeException(Response.Status.BAD_REQUEST, validationResult.getResult());
- }
-
- automationComposition.setCascadedOrderedState(command.getOrderedState());
- try {
- supervisionHandler.triggerAutomationCompositionSupervision(automationComposition);
- } catch (AutomationCompositionException e) {
- throw new AutomationCompositionRuntimeException(Response.Status.BAD_REQUEST, e.getMessage());
+ public void compositionInstanceState(UUID compositionId, UUID instanceId,
+ @Valid AcInstanceStateUpdate acInstanceStateUpdate) {
+ var automationComposition = automationCompositionProvider.getAutomationComposition(instanceId);
+ if (!compositionId.equals(automationComposition.getCompositionId())) {
+ throw new PfModelRuntimeException(Response.Status.BAD_REQUEST,
+ automationComposition.getCompositionId() + DO_NOT_MATCH + compositionId);
}
- automationCompositionProvider.updateAutomationComposition(automationComposition);
- }
-
- private BeanValidationResult validateIssueAutomationComposition(AutomationComposition automationComposition,
- List<Participant> participants) {
- var result = new BeanValidationResult("AutomationComposition", automationComposition);
-
- var participantMap = participants.stream()
- .collect(Collectors.toMap(participant -> participant.getParticipantId(), Function.identity()));
-
- for (var element : automationComposition.getElements().values()) {
-
- var subResult = new BeanValidationResult(ENTRY + element.getDefinition().getName(), element);
- var p = participantMap.get(element.getParticipantId());
- if (p == null) {
- subResult.addResult(new ObjectValidationResult(AUTOMATION_COMPOSITION_NODE_ELEMENT_TYPE,
- element.getDefinition().getName(), ValidationStatus.INVALID,
- "Participant with ID " + element.getParticipantId() + " is not registered"));
- } else if (!p.getParticipantId().equals(element.getParticipantId())) {
- subResult.addResult(new ObjectValidationResult(AUTOMATION_COMPOSITION_NODE_ELEMENT_TYPE,
- element.getDefinition().getName(), ValidationStatus.INVALID,
- "Participant with ID " + " - " + element.getParticipantId()
- + " is not registered"));
- }
- result.addResult(subResult);
+ var acDefinition = acDefinitionProvider.getAcDefinition(automationComposition.getCompositionId());
+ var result = acInstanceStateResolver.resolve(acInstanceStateUpdate.getDeployOrder(),
+ acInstanceStateUpdate.getLockOrder(), automationComposition.getDeployState(),
+ automationComposition.getLockState());
+ switch (result) {
+ case "DEPLOY":
+ //
+ break;
+
+ case "UNDEPLOY":
+ //
+ break;
+
+ case "LOCK":
+ //
+ break;
+
+ case "UNLOCK":
+ //
+ break;
+
+ default:
+ throw new PfModelRuntimeException(Status.BAD_REQUEST, "Not valid " + acInstanceStateUpdate);
}
-
- return result;
}
}
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/InstantiationController.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/InstantiationController.java
index 94c111e00..afe09314f 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/InstantiationController.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/InstantiationController.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.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -116,7 +116,7 @@ public class InstantiationController extends AbstractRestController implements A
@Override
public ResponseEntity<Void> compositionInstanceState(UUID compositionId, UUID instanceId,
@Valid AcInstanceStateUpdate body, UUID requestId) {
- // TODO Auto-generated method stub
- return null;
+ provider.compositionInstanceState(compositionId, instanceId, body);
+ return ResponseEntity.accepted().build();
}
}
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java
index b31a95b18..db726e09d 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java
@@ -141,7 +141,6 @@ public class SupervisionHandler {
if (automationComposition.isPresent()) {
var updated = updateState(automationComposition.get(),
automationCompositionAckMessage.getAutomationCompositionResultMap().entrySet());
- updated |= setPrimed(automationComposition.get());
if (updated) {
automationCompositionProvider.updateAutomationComposition(automationComposition.get());
}
@@ -165,24 +164,6 @@ public class SupervisionHandler {
return updated;
}
- private boolean setPrimed(AutomationComposition automationComposition) {
- var acElements = automationComposition.getElements().values();
- if (acElements != null) {
- Boolean primedFlag = true;
- var checkOpt = automationComposition.getElements().values().stream()
- .filter(acElement -> (!acElement.getState().equals(AutomationCompositionState.PASSIVE)
- || !acElement.getState().equals(AutomationCompositionState.RUNNING)))
- .findAny();
- if (checkOpt.isEmpty()) {
- primedFlag = false;
- }
- automationComposition.setPrimed(primedFlag);
- return true;
- }
-
- return false;
- }
-
/**
* Supervise a automation composition, performing whatever actions need to be performed on the automation
* composition.
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionDeployPublisher.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionDeployPublisher.java
index 4a0abc180..0811a5a44 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionDeployPublisher.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionDeployPublisher.java
@@ -78,7 +78,7 @@ public class AutomationCompositionDeployPublisher extends AbstractParticipantPub
List<ParticipantDeploy> participantDeploys = new ArrayList<>();
for (var element : automationComposition.getElements().values()) {
- AcmUtils.setAcPolicyInfo(element, toscaServiceTemplate);
+ element.setToscaServiceTemplateFragment(AcmUtils.getToscaServiceTemplateFragment(toscaServiceTemplate));
AcmUtils.prepareParticipantUpdate(element, participantDeploys);
}
acDeployMsg.setParticipantUpdatesList(participantDeploys);
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProviderTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProviderTest.java
index 0a46bc6b8..019d53c0b 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProviderTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProviderTest.java
@@ -33,17 +33,13 @@ import java.util.Optional;
import java.util.UUID;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
-import org.mockito.Mockito;
-import org.onap.policy.clamp.acm.runtime.supervision.SupervisionHandler;
import org.onap.policy.clamp.acm.runtime.util.CommonTestData;
import org.onap.policy.clamp.common.acm.exception.AutomationCompositionException;
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.AutomationCompositionState;
-import org.onap.policy.clamp.models.acm.messages.rest.instantiation.InstantiationCommand;
import org.onap.policy.clamp.models.acm.persistence.provider.AcDefinitionProvider;
import org.onap.policy.clamp.models.acm.persistence.provider.AutomationCompositionProvider;
-import org.onap.policy.clamp.models.acm.persistence.provider.ParticipantProvider;
import org.onap.policy.clamp.models.acm.persistence.provider.ProviderUtils;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate;
@@ -56,13 +52,13 @@ class AutomationCompositionInstantiationProviderTest {
private static final String AC_INSTANTIATION_CREATE_JSON = "src/test/resources/rest/acm/AutomationComposition.json";
private static final String AC_INSTANTIATION_UPDATE_JSON =
"src/test/resources/rest/acm/AutomationCompositionUpdate.json";
- private static final String AC_INSTANTIATION_CHANGE_STATE_JSON = "src/test/resources/rest/acm/PassiveCommand.json";
+
private static final String AC_INSTANTIATION_DEFINITION_NAME_NOT_FOUND_JSON =
"src/test/resources/rest/acm/AutomationCompositionElementsNotFound.json";
private static final String AC_INSTANTIATION_AC_DEFINITION_NOT_FOUND_JSON =
"src/test/resources/rest/acm/AutomationCompositionNotFound.json";
private static final String DELETE_BAD_REQUEST = "Automation composition state is still %s";
- private static final String ORDERED_STATE_INVALID = "ordered state invalid or not specified on command";
+
private static final String AC_ELEMENT_NAME_NOT_FOUND =
"\"AutomationComposition\" INVALID, item has status INVALID\n"
+ " \"entry PMSHInstance0AcElementNotFound\" INVALID, item has status INVALID\n"
@@ -86,18 +82,13 @@ class AutomationCompositionInstantiationProviderTest {
@Test
void testInstantiationCrud() throws AutomationCompositionException {
- var participantProvider = Mockito.mock(ParticipantProvider.class);
- var participants = CommonTestData.createParticipants();
- when(participantProvider.getParticipants()).thenReturn(participants);
-
var acDefinitionProvider = mock(AcDefinitionProvider.class);
var acDefinition = CommonTestData.createAcDefinition(serviceTemplate, AcTypeState.PRIMED);
var compositionId = acDefinition.getCompositionId();
when(acDefinitionProvider.findAcDefinition(compositionId)).thenReturn(Optional.of(acDefinition));
- var supervisionHandler = mock(SupervisionHandler.class);
var acProvider = mock(AutomationCompositionProvider.class);
- var instantiationProvider = new AutomationCompositionInstantiationProvider(acProvider, supervisionHandler,
- participantProvider, acDefinitionProvider);
+ var instantiationProvider =
+ new AutomationCompositionInstantiationProvider(acProvider, acDefinitionProvider, null);
var automationCompositionCreate =
InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Crud");
automationCompositionCreate.setCompositionId(compositionId);
@@ -132,15 +123,6 @@ class AutomationCompositionInstantiationProviderTest {
verify(acProvider).updateAutomationComposition(automationCompositionUpdate);
- var instantiationCommand =
- InstantiationUtils.getInstantiationCommandFromResource(AC_INSTANTIATION_CHANGE_STATE_JSON);
- instantiationProvider.issueAutomationCompositionCommand(automationCompositionUpdate,
- instantiationCommand);
- verify(supervisionHandler).triggerAutomationCompositionSupervision(automationCompositionUpdate);
-
- // in order to delete a automationComposition the state must be UNINITIALISED
- automationCompositionCreate.setState(AutomationCompositionState.UNINITIALISED);
-
when(acProvider.deleteAutomationComposition(automationCompositionUpdate.getInstanceId()))
.thenReturn(automationCompositionUpdate);
instantiationProvider.deleteAutomationComposition(automationCompositionCreate.getCompositionId(),
@@ -154,13 +136,11 @@ class AutomationCompositionInstantiationProviderTest {
var automationComposition =
InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Delete");
- var participantProvider = Mockito.mock(ParticipantProvider.class);
var acProvider = mock(AutomationCompositionProvider.class);
- var supervisionHandler = mock(SupervisionHandler.class);
var acDefinitionProvider = mock(AcDefinitionProvider.class);
- var instantiationProvider = new AutomationCompositionInstantiationProvider(acProvider, supervisionHandler,
- participantProvider, acDefinitionProvider);
+ var instantiationProvider = new AutomationCompositionInstantiationProvider(acProvider,
+ acDefinitionProvider, null);
when(acProvider.getAutomationComposition(automationComposition.getInstanceId()))
.thenReturn(automationComposition);
@@ -185,13 +165,11 @@ class AutomationCompositionInstantiationProviderTest {
private void assertThatDeleteThrownBy(AutomationComposition automationComposition,
AutomationCompositionState state) {
automationComposition.setState(state);
- var participantProvider = Mockito.mock(ParticipantProvider.class);
var acProvider = mock(AutomationCompositionProvider.class);
- var supervisionHandler = mock(SupervisionHandler.class);
var acDefinitionProvider = mock(AcDefinitionProvider.class);
- var instantiationProvider = new AutomationCompositionInstantiationProvider(acProvider, supervisionHandler,
- participantProvider, acDefinitionProvider);
+ var instantiationProvider = new AutomationCompositionInstantiationProvider(acProvider,
+ acDefinitionProvider, null);
when(acProvider.getAutomationComposition(automationComposition.getInstanceId()))
.thenReturn(automationComposition);
@@ -218,11 +196,8 @@ class AutomationCompositionInstantiationProviderTest {
when(acProvider.createAutomationComposition(automationCompositionCreate))
.thenReturn(automationCompositionCreate);
- var participantProvider = Mockito.mock(ParticipantProvider.class);
- var supervisionHandler = mock(SupervisionHandler.class);
-
- var instantiationProvider = new AutomationCompositionInstantiationProvider(acProvider, supervisionHandler,
- participantProvider, acDefinitionProvider);
+ var instantiationProvider = new AutomationCompositionInstantiationProvider(acProvider,
+ acDefinitionProvider, null);
var instantiationResponse = instantiationProvider.createAutomationComposition(
automationCompositionCreate.getCompositionId(), automationCompositionCreate);
@@ -247,10 +222,8 @@ class AutomationCompositionInstantiationProviderTest {
automationComposition.setCompositionId(compositionId);
var acProvider = mock(AutomationCompositionProvider.class);
- var participantProvider = mock(ParticipantProvider.class);
- var supervisionHandler = mock(SupervisionHandler.class);
- var provider = new AutomationCompositionInstantiationProvider(acProvider, supervisionHandler,
- participantProvider, acDefinitionProvider);
+ var provider = new AutomationCompositionInstantiationProvider(acProvider,
+ acDefinitionProvider, null);
assertThatThrownBy(() -> provider.createAutomationComposition(compositionId, automationComposition))
.hasMessageMatching(AC_ELEMENT_NAME_NOT_FOUND);
@@ -267,14 +240,12 @@ class AutomationCompositionInstantiationProviderTest {
var automationComposition = InstantiationUtils
.getAutomationCompositionFromResource(AC_INSTANTIATION_AC_DEFINITION_NOT_FOUND_JSON, "AcNotFound");
- var participantProvider = Mockito.mock(ParticipantProvider.class);
var acProvider = mock(AutomationCompositionProvider.class);
when(acProvider.getAutomationComposition(automationComposition.getInstanceId()))
.thenReturn(automationComposition);
- var supervisionHandler = mock(SupervisionHandler.class);
var acDefinitionProvider = mock(AcDefinitionProvider.class);
- var provider = new AutomationCompositionInstantiationProvider(acProvider, supervisionHandler,
- participantProvider, acDefinitionProvider);
+ var provider = new AutomationCompositionInstantiationProvider(acProvider,
+ acDefinitionProvider, null);
var compositionId = automationComposition.getCompositionId();
assertThatThrownBy(() -> provider.createAutomationComposition(compositionId, automationComposition))
@@ -290,21 +261,4 @@ class AutomationCompositionInstantiationProviderTest {
assertThatThrownBy(() -> provider.updateAutomationComposition(wrongCompositionId, automationComposition))
.hasMessageMatching(compositionId + DO_NOT_MATCH + wrongCompositionId);
}
-
- @Test
- void testIssueAutomationCompositionCommand_OrderedStateInvalid() {
- var participantProvider = Mockito.mock(ParticipantProvider.class);
- var acProvider = mock(AutomationCompositionProvider.class);
- var supervisionHandler = mock(SupervisionHandler.class);
- var acDefinitionProvider = mock(AcDefinitionProvider.class);
- var instantiationProvider = new AutomationCompositionInstantiationProvider(acProvider, supervisionHandler,
- participantProvider, acDefinitionProvider);
- var automationComposition = InstantiationUtils
- .getAutomationCompositionFromResource(AC_INSTANTIATION_AC_DEFINITION_NOT_FOUND_JSON, "AcNotFound");
- when(acProvider.getAutomationComposition(automationComposition.getInstanceId()))
- .thenReturn(automationComposition);
-
- assertThatThrownBy(() -> instantiationProvider.issueAutomationCompositionCommand(automationComposition,
- new InstantiationCommand())).hasMessageMatching(ORDERED_STATE_INVALID);
- }
}
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/rest/InstantiationControllerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/rest/InstantiationControllerTest.java
index 38db863c3..fe0a477f9 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/rest/InstantiationControllerTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/rest/InstantiationControllerTest.java
@@ -30,10 +30,8 @@ import static org.onap.policy.clamp.acm.runtime.util.CommonTestData.TOSCA_SERVIC
import java.util.UUID;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
-import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.onap.policy.clamp.acm.runtime.instantiation.AutomationCompositionInstantiationProvider;
@@ -41,14 +39,13 @@ import org.onap.policy.clamp.acm.runtime.instantiation.InstantiationUtils;
import org.onap.policy.clamp.acm.runtime.main.rest.InstantiationController;
import org.onap.policy.clamp.acm.runtime.util.CommonTestData;
import org.onap.policy.clamp.acm.runtime.util.rest.CommonRestController;
+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.AutomationCompositions;
import org.onap.policy.clamp.models.acm.messages.rest.instantiation.AcInstanceStateUpdate;
+import org.onap.policy.clamp.models.acm.messages.rest.instantiation.DeployOrder;
import org.onap.policy.clamp.models.acm.messages.rest.instantiation.InstantiationResponse;
import org.onap.policy.clamp.models.acm.persistence.provider.AcDefinitionProvider;
-import org.onap.policy.clamp.models.acm.persistence.provider.ParticipantProvider;
-import org.onap.policy.clamp.models.acm.persistence.repository.AutomationCompositionRepository;
-import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@@ -74,10 +71,6 @@ class InstantiationControllerTest extends CommonRestController {
private static final String INSTANTIATION_ENDPOINT = "compositions/%s/instances";
private static ToscaServiceTemplate serviceTemplate = new ToscaServiceTemplate();
- private UUID compositionId = UUID.randomUUID();
-
- @Autowired
- private AutomationCompositionRepository automationCompositionRepository;
@Autowired
private AcDefinitionProvider acDefinitionProvider;
@@ -85,9 +78,6 @@ class InstantiationControllerTest extends CommonRestController {
@Autowired
private AutomationCompositionInstantiationProvider instantiationProvider;
- @Autowired
- private ParticipantProvider participantProvider;
-
@LocalServerPort
private int randomServerPort;
@@ -97,25 +87,15 @@ class InstantiationControllerTest extends CommonRestController {
}
@BeforeEach
- public void populateDb() {
- createEntryInDB();
- }
-
- @BeforeEach
public void setUpPort() {
super.setHttpPrefix(randomServerPort);
}
- @AfterEach
- public void cleanDatabase() {
- deleteEntryInDB();
- }
-
- private String getInstanceEndPoint() {
+ private String getInstanceEndPoint(UUID compositionId) {
return String.format(INSTANTIATION_ENDPOINT, compositionId.toString());
}
- private String getInstanceEndPoint(UUID instanceId) {
+ private String getInstanceEndPoint(UUID compositionId, UUID instanceId) {
return String.format(INSTANTIATION_ENDPOINT, compositionId.toString()) + "/" + instanceId;
}
@@ -129,12 +109,12 @@ class InstantiationControllerTest extends CommonRestController {
var automationComposition =
InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Unauthorized");
- assertUnauthorizedPost(getInstanceEndPoint(), Entity.json(automationComposition));
+ assertUnauthorizedPost(getInstanceEndPoint(UUID.randomUUID()), Entity.json(automationComposition));
}
@Test
void testQuery_Unauthorized() {
- assertUnauthorizedGet(getInstanceEndPoint());
+ assertUnauthorizedGet(getInstanceEndPoint(UUID.randomUUID()));
}
@Test
@@ -142,42 +122,45 @@ class InstantiationControllerTest extends CommonRestController {
var automationComposition =
InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_UPDATE_JSON, "Unauthorized");
- assertUnauthorizedPut(getInstanceEndPoint(), Entity.json(automationComposition));
+ assertUnauthorizedPut(getInstanceEndPoint(UUID.randomUUID()), Entity.json(automationComposition));
}
@Test
void testDelete_Unauthorized() {
- assertUnauthorizedDelete(getInstanceEndPoint());
+ assertUnauthorizedDelete(getInstanceEndPoint(UUID.randomUUID()));
}
@Test
void testCreate() {
+ var compositionId = createAcDefinitionInDB("Create");
var automationCompositionFromRsc =
InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Create");
automationCompositionFromRsc.setCompositionId(compositionId);
- var invocationBuilder = super.sendRequest(getInstanceEndPoint());
+ var invocationBuilder = super.sendRequest(getInstanceEndPoint(compositionId));
var resp = invocationBuilder.post(Entity.json(automationCompositionFromRsc));
assertEquals(Response.Status.CREATED.getStatusCode(), resp.getStatus());
var instResponse = resp.readEntity(InstantiationResponse.class);
InstantiationUtils.assertInstantiationResponse(instResponse, automationCompositionFromRsc);
automationCompositionFromRsc.setInstanceId(instResponse.getInstanceId());
+ automationCompositionFromRsc.getElements().values()
+ .forEach(element -> element.setParticipantId(CommonTestData.getParticipantId()));
var automationCompositionFromDb =
instantiationProvider.getAutomationComposition(compositionId, instResponse.getInstanceId());
assertNotNull(automationCompositionFromDb);
assertEquals(automationCompositionFromRsc, automationCompositionFromDb);
-
}
@Test
void testCreateBadRequest() {
+ var compositionId = createAcDefinitionInDB("CreateBadRequest");
var automationCompositionFromRsc = InstantiationUtils
.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "CreateBadRequest");
automationCompositionFromRsc.setCompositionId(compositionId);
- var invocationBuilder = super.sendRequest(getInstanceEndPoint());
+ var invocationBuilder = super.sendRequest(getInstanceEndPoint(compositionId));
var resp = invocationBuilder.post(Entity.json(automationCompositionFromRsc));
assertEquals(Response.Status.CREATED.getStatusCode(), resp.getStatus());
@@ -191,7 +174,8 @@ class InstantiationControllerTest extends CommonRestController {
@Test
void testQuery_NoResultWithThisName() {
- var invocationBuilder = super.sendRequest(getInstanceEndPoint() + "?name=noResultWithThisName");
+ var invocationBuilder =
+ super.sendRequest(getInstanceEndPoint(UUID.randomUUID()) + "?name=noResultWithThisName");
var rawresp = invocationBuilder.buildGet().invoke();
assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus());
var resp = rawresp.readEntity(AutomationCompositions.class);
@@ -200,14 +184,15 @@ class InstantiationControllerTest extends CommonRestController {
@Test
void testQuery() {
+ var compositionId = createAcDefinitionInDB("Query");
var automationComposition =
InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Query");
automationComposition.setCompositionId(compositionId);
instantiationProvider.createAutomationComposition(compositionId, automationComposition);
- var invocationBuilder =
- super.sendRequest(getInstanceEndPoint() + "?name=" + automationComposition.getKey().getName());
+ var invocationBuilder = super.sendRequest(
+ getInstanceEndPoint(compositionId) + "?name=" + automationComposition.getKey().getName());
var rawresp = invocationBuilder.buildGet().invoke();
assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus());
var automationCompositionsQuery = rawresp.readEntity(AutomationCompositions.class);
@@ -217,7 +202,26 @@ class InstantiationControllerTest extends CommonRestController {
}
@Test
+ void testGet() {
+ var compositionId = createAcDefinitionInDB("Get");
+ var automationComposition =
+ InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Get");
+ automationComposition.setCompositionId(compositionId);
+
+ instantiationProvider.createAutomationComposition(compositionId, automationComposition);
+
+ var invocationBuilder = super.sendRequest(
+ getInstanceEndPoint(compositionId, automationComposition.getInstanceId()));
+ var rawresp = invocationBuilder.buildGet().invoke();
+ assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus());
+ var automationCompositionGet = rawresp.readEntity(AutomationComposition.class);
+ assertNotNull(automationCompositionGet);
+ assertEquals(automationComposition, automationCompositionGet);
+ }
+
+ @Test
void testUpdate() {
+ var compositionId = createAcDefinitionInDB("Update");
var automationCompositionCreate =
InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Update");
automationCompositionCreate.setCompositionId(compositionId);
@@ -228,7 +232,10 @@ class InstantiationControllerTest extends CommonRestController {
InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_UPDATE_JSON, "Update");
automationComposition.setCompositionId(compositionId);
automationComposition.setInstanceId(response.getInstanceId());
- var invocationBuilder = super.sendRequest(getInstanceEndPoint());
+ automationComposition.getElements().values()
+ .forEach(element -> element.setParticipantId(CommonTestData.getParticipantId()));
+
+ var invocationBuilder = super.sendRequest(getInstanceEndPoint(compositionId));
var resp = invocationBuilder.post(Entity.json(automationComposition));
assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus());
@@ -245,6 +252,7 @@ class InstantiationControllerTest extends CommonRestController {
@Test
void testDelete() {
+ var compositionId = createAcDefinitionInDB("Delete");
var automationCompositionFromRsc =
InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Delete");
automationCompositionFromRsc.setCompositionId(compositionId);
@@ -252,7 +260,7 @@ class InstantiationControllerTest extends CommonRestController {
var instResponse =
instantiationProvider.createAutomationComposition(compositionId, automationCompositionFromRsc);
- var invocationBuilder = super.sendRequest(getInstanceEndPoint(instResponse.getInstanceId()));
+ var invocationBuilder = super.sendRequest(getInstanceEndPoint(compositionId, instResponse.getInstanceId()));
var resp = invocationBuilder.delete();
assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus());
instResponse = resp.readEntity(InstantiationResponse.class);
@@ -265,30 +273,31 @@ class InstantiationControllerTest extends CommonRestController {
@Test
void testDeleteNotFound() {
+ var compositionId = createAcDefinitionInDB("DeleteNotFound");
var automationCompositionFromRsc =
InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "DelNotFound");
automationCompositionFromRsc.setCompositionId(compositionId);
instantiationProvider.createAutomationComposition(compositionId, automationCompositionFromRsc);
- var invocationBuilder = super.sendRequest(getInstanceEndPoint(UUID.randomUUID()));
+ var invocationBuilder = super.sendRequest(getInstanceEndPoint(compositionId, UUID.randomUUID()));
var resp = invocationBuilder.delete();
assertEquals(Response.Status.NOT_FOUND.getStatusCode(), resp.getStatus());
}
- @Disabled
@Test
- void testCommand_NotFound1() {
- var invocationBuilder = super.sendRequest(getInstanceEndPoint(UUID.randomUUID()));
- var resp = invocationBuilder.post(Entity.json(new AutomationComposition()));
+ void testDeploy_NotFound() {
+ var compositionId = createAcDefinitionInDB("Deploy_NotFound");
+ var invocationBuilder = super.sendRequest(getInstanceEndPoint(compositionId, UUID.randomUUID()));
+ var resp = invocationBuilder.put(Entity.json(new AcInstanceStateUpdate()));
assertEquals(Response.Status.NOT_FOUND.getStatusCode(), resp.getStatus());
}
- @Disabled
@Test
- void testCommand_NotFound2() {
+ void testDeploy_BadRequest() {
+ var compositionId = createAcDefinitionInDB("Deploy_BadRequest");
var acFromRsc =
- InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "DelNotFound");
+ InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "BadRequest");
acFromRsc.setCompositionId(compositionId);
var instResponse = instantiationProvider.createAutomationComposition(compositionId, acFromRsc);
@@ -297,50 +306,33 @@ class InstantiationControllerTest extends CommonRestController {
command.setDeployOrder(null);
command.setLockOrder(null);
- var invocationBuilder = super.sendRequest(getInstanceEndPoint(instResponse.getInstanceId()));
+ var invocationBuilder = super.sendRequest(getInstanceEndPoint(compositionId, instResponse.getInstanceId()));
var resp = invocationBuilder.put(Entity.json(command));
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), resp.getStatus());
}
- @Disabled
@Test
- void testCommand() throws PfModelException {
+ void testDeploy() {
+ var compositionId = createAcDefinitionInDB("Deploy");
var automationComposition =
InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Command");
automationComposition.setCompositionId(compositionId);
var instResponse = instantiationProvider.createAutomationComposition(compositionId, automationComposition);
- var participants = CommonTestData.createParticipants();
- for (var participant : participants) {
- participantProvider.saveParticipant(participant);
- }
-
var instantiationUpdate = new AcInstanceStateUpdate();
+ instantiationUpdate.setDeployOrder(DeployOrder.DEPLOY);
+ instantiationUpdate.setLockOrder(null);
- var invocationBuilder = super.sendRequest(getInstanceEndPoint(instResponse.getInstanceId()));
+ var invocationBuilder = super.sendRequest(getInstanceEndPoint(compositionId, instResponse.getInstanceId()));
var resp = invocationBuilder.put(Entity.json(instantiationUpdate));
- assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus());
- instResponse = resp.readEntity(InstantiationResponse.class);
- InstantiationUtils.assertInstantiationResponse(instResponse, automationComposition);
-
- // check passive state on DB
- var toscaConceptIdentifier = instResponse.getAffectedAutomationComposition();
- var automationCompositionsGet = instantiationProvider.getAutomationCompositions(compositionId,
- toscaConceptIdentifier.getName(), toscaConceptIdentifier.getVersion());
- assertThat(automationCompositionsGet.getAutomationCompositionList()).hasSize(1);
- }
-
- private synchronized void deleteEntryInDB() {
- automationCompositionRepository.deleteAll();
- var list = acDefinitionProvider.findAcDefinition(compositionId);
- if (!list.isEmpty()) {
- acDefinitionProvider.deleteAcDefintion(compositionId);
- }
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), resp.getStatus());
}
- private synchronized void createEntryInDB() {
- deleteEntryInDB();
- var acmDefinition = acDefinitionProvider.createAutomationCompositionDefinition(serviceTemplate);
- compositionId = acmDefinition.getCompositionId();
+ private UUID createAcDefinitionInDB(String name) {
+ var serviceTemplateCreate = new ToscaServiceTemplate(serviceTemplate);
+ serviceTemplateCreate.setName(name);
+ var acmDefinition = CommonTestData.createAcDefinition(serviceTemplate, AcTypeState.PRIMED);
+ acDefinitionProvider.updateAcDefinition(acmDefinition);
+ return acmDefinition.getCompositionId();
}
}
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java
index e54cfafa2..0fa15b62d 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java
@@ -40,11 +40,13 @@ import org.onap.policy.clamp.acm.runtime.supervision.comm.AutomationCompositionD
import org.onap.policy.clamp.acm.runtime.supervision.comm.AutomationCompositionStateChangePublisher;
import org.onap.policy.clamp.acm.runtime.util.CommonTestData;
import org.onap.policy.clamp.common.acm.exception.AutomationCompositionException;
+import org.onap.policy.clamp.models.acm.concepts.AcElementDeployAck;
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.AutomationCompositionDefinition;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
+import org.onap.policy.clamp.models.acm.concepts.DeployState;
import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionDeployAck;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType;
@@ -214,7 +216,10 @@ class SupervisionHandlerTest {
AutomationCompositionOrderedState.PASSIVE, AutomationCompositionState.UNINITIALISED);
var automationCompositionAckMessage =
new AutomationCompositionDeployAck(ParticipantMessageType.AUTOMATION_COMPOSITION_STATECHANGE_ACK);
- automationCompositionAckMessage.setAutomationCompositionResultMap(Map.of());
+ var acElementDeployAck =
+ new AcElementDeployAck(AutomationCompositionState.PASSIVE, DeployState.DEPLOYED, true, "");
+ automationCompositionAckMessage.setAutomationCompositionResultMap(
+ Map.of(UUID.fromString("709c62b3-8918-41b9-a747-d21eb79c6c20"), acElementDeployAck));
automationCompositionAckMessage.setAutomationCompositionId(IDENTIFIER);
handler.handleAutomationCompositionStateChangeAckMessage(automationCompositionAckMessage);
@@ -227,7 +232,10 @@ class SupervisionHandlerTest {
var automationCompositionAckMessage =
new AutomationCompositionDeployAck(ParticipantMessageType.AUTOMATION_COMPOSITION_DEPLOY_ACK);
automationCompositionAckMessage.setParticipantId(CommonTestData.getParticipantId());
- automationCompositionAckMessage.setAutomationCompositionResultMap(Map.of());
+ var acElementDeployAck =
+ new AcElementDeployAck(AutomationCompositionState.PASSIVE, DeployState.DEPLOYED, true, "");
+ automationCompositionAckMessage.setAutomationCompositionResultMap(
+ Map.of(UUID.fromString("709c62b3-8918-41b9-a747-d21eb79c6c20"), acElementDeployAck));
automationCompositionAckMessage.setAutomationCompositionId(IDENTIFIER);
var automationCompositionProvider = mock(AutomationCompositionProvider.class);
var handler = createSupervisionHandler(automationCompositionProvider,
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/CommonTestData.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/CommonTestData.java
index 702a93678..69c1302bc 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/CommonTestData.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/CommonTestData.java
@@ -114,6 +114,11 @@ public class CommonTestData {
acDefinition.setServiceTemplate(serviceTemplate);
var acElements = AcmUtils.extractAcElementsFromServiceTemplate(serviceTemplate);
acDefinition.setElementStateMap(AcmUtils.createElementStateMap(acElements, state));
+ if (AcTypeState.PRIMED.equals(state)) {
+ for (var element : acDefinition.getElementStateMap().values()) {
+ element.setParticipantId(getParticipantId());
+ }
+ }
return acDefinition;
}
diff --git a/runtime-acm/src/test/resources/rest/acm/AutomationComposition.json b/runtime-acm/src/test/resources/rest/acm/AutomationComposition.json
index 77078e6eb..0e6988d9b 100644
--- a/runtime-acm/src/test/resources/rest/acm/AutomationComposition.json
+++ b/runtime-acm/src/test/resources/rest/acm/AutomationComposition.json
@@ -2,8 +2,8 @@
"name": "PMSHInstance0",
"version": "1.0.1",
"compositionId": "709c62b3-8918-41b9-a747-d21eb79c6c40",
- "state": "UNINITIALISED",
- "orderedState": "UNINITIALISED",
+ "deployState": "UNDEPLOYED",
+ "lockState": "NONE",
"description": "PMSH automation composition instance 0",
"elements": {
"709c62b3-8918-41b9-a747-d21eb79c6c20": {
@@ -12,13 +12,8 @@
"name": "org.onap.domain.database.PMSH_K8SMicroserviceAutomationCompositionElement",
"version": "1.2.3"
},
- "participantId": "101c62b3-8918-41b9-a747-d21eb79c6c02",
- "participantType": {
- "name": "org.onap.policy.clamp.acm.KubernetesParticipant",
- "version": "2.3.4"
- },
- "state": "UNINITIALISED",
- "orderedState": "UNINITIALISED",
+ "deployState": "UNDEPLOYED",
+ "lockState": "NONE",
"description": "Automation composition element for the K8S microservice for PMSH"
},
"709c62b3-8918-41b9-a747-d21eb79c6c21": {
@@ -27,13 +22,8 @@
"name": "org.onap.domain.database.Http_PMSHMicroserviceAutomationCompositionElement",
"version": "1.2.3"
},
- "participantId": "101c62b3-8918-41b9-a747-d21eb79c6c01",
- "participantType": {
- "name": "org.onap.policy.clamp.acm.HttpParticipant",
- "version": "2.3.4"
- },
- "state": "UNINITIALISED",
- "orderedState": "UNINITIALISED",
+ "deployState": "UNDEPLOYED",
+ "lockState": "NONE",
"description": "Automation composition element for the http requests of PMSH microservice"
},
"709c62b3-8918-41b9-a747-d21eb79c6c22": {
@@ -42,13 +32,8 @@
"name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement",
"version": "1.2.3"
},
- "participantId": "101c62b3-8918-41b9-a747-d21eb79c6c03",
- "participantType": {
- "name": "org.onap.policy.clamp.acm.PolicyParticipant",
- "version": "2.3.1"
- },
- "state": "UNINITIALISED",
- "orderedState": "UNINITIALISED",
+ "deployState": "UNDEPLOYED",
+ "lockState": "NONE",
"description": "Automation composition element for the operational policy for Performance Management Subscription Handling"
}
}
diff --git a/runtime-acm/src/test/resources/rest/acm/AutomationCompositionElementsNotFound.json b/runtime-acm/src/test/resources/rest/acm/AutomationCompositionElementsNotFound.json
index 80facb29c..34ee3f69d 100644
--- a/runtime-acm/src/test/resources/rest/acm/AutomationCompositionElementsNotFound.json
+++ b/runtime-acm/src/test/resources/rest/acm/AutomationCompositionElementsNotFound.json
@@ -2,8 +2,8 @@
"name": "PMSHInstance0",
"version": "1.0.1",
"compositionId": "709c62b3-8918-41b9-a747-d21eb79c6c40",
- "state": "UNINITIALISED",
- "orderedState": "UNINITIALISED",
+ "deployState": "UNDEPLOYED",
+ "lockState": "NONE",
"description": "PMSH automation composition instance 0",
"elements": {
"709c62b3-8918-41b9-a747-d21eb79c6c20": {
@@ -12,12 +12,8 @@
"name": "org.onap.domain.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-d21eb79c6c21": {
@@ -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 Automation Composition Element for the PMSH instance 0 automation composition"
},
"709c62b3-8918-41b9-a747-d21eb79c6c22": {
@@ -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 Automation Composition Element for the PMSH instance 0 automation composition"
},
"709c62b3-8918-41b9-a747-d21eb79c6c23": {
@@ -54,13 +42,8 @@
"name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement",
"version": "1.2.3"
},
- "participantId": "101c62b3-8918-41b9-a747-d21eb79c6c03",
- "participantType": {
- "name": "org.onap.policy.clamp.acm.PolicyParticipant",
- "version": "2.3.1"
- },
- "state": "UNINITIALISED",
- "orderedState": "UNINITIALISED",
+ "deployState": "UNDEPLOYED",
+ "lockState": "NONE",
"description": "CDS Automation Composition Element for the PMSH instance 0 automation composition"
}
}
diff --git a/runtime-acm/src/test/resources/rest/acm/AutomationCompositionNotFound.json b/runtime-acm/src/test/resources/rest/acm/AutomationCompositionNotFound.json
index a17ba399a..9b3664294 100644
--- a/runtime-acm/src/test/resources/rest/acm/AutomationCompositionNotFound.json
+++ b/runtime-acm/src/test/resources/rest/acm/AutomationCompositionNotFound.json
@@ -2,8 +2,8 @@
"name": "PMSHInstance0",
"version": "1.0.1",
"compositionId": "709c62b3-8918-41b9-a747-d21eb79c6c40",
- "state": "UNINITIALISED",
- "orderedState": "UNINITIALISED",
+ "deployState": "UNDEPLOYED",
+ "lockState": "NONE",
"description": "PMSH automation composition instance 0",
"elements": {
"709c62b3-8918-41b9-a747-d21eb79c6c20": {
@@ -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-d21eb79c6c21": {
@@ -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 Automation Composition Element for the PMSH instance 0 automation composition"
},
"709c62b3-8918-41b9-a747-d21eb79c6c22": {
@@ -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 Automation Composition Element for the PMSH instance 0 automation composition"
},
"709c62b3-8918-41b9-a747-d21eb79c6c23": {
@@ -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"
}
}
diff --git a/runtime-acm/src/test/resources/rest/acm/AutomationCompositionSmoke.json b/runtime-acm/src/test/resources/rest/acm/AutomationCompositionSmoke.json
index e66f3f68d..7a226ac92 100644
--- a/runtime-acm/src/test/resources/rest/acm/AutomationCompositionSmoke.json
+++ b/runtime-acm/src/test/resources/rest/acm/AutomationCompositionSmoke.json
@@ -2,8 +2,8 @@
"name": "PMSHInstance0",
"version": "1.0.1",
"compositionId": "709c62b3-8918-41b9-a747-d21eb79c6c40",
- "state": "UNINITIALISED",
- "orderedState": "UNINITIALISED",
+ "deployState": "UNDEPLOYED",
+ "lockState": "NONE",
"description": "PMSH automation composition instance 0",
"elements": {
"709c62b3-8918-41b9-a747-d21eb79c6c20": {
@@ -12,13 +12,8 @@
"name": "org.onap.domain.database.Http_PMSHMicroserviceAutomationCompositionElement",
"version": "1.2.3"
},
- "participantId": "101c62b3-8918-41b9-a747-d21eb79c6c01",
- "participantType": {
- "name": "org.onap.policy.clamp.acm.HttpParticipant",
- "version": "2.3.4"
- },
- "state": "UNINITIALISED",
- "orderedState": "UNINITIALISED",
+ "deployState": "UNDEPLOYED",
+ "lockState": "NONE",
"description": "Http Automation Composition Element for the PMSH instance 0 automation composition"
},
"709c62b3-8918-41b9-a747-d21eb79c6c22": {
@@ -27,13 +22,8 @@
"name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement",
"version": "1.2.3"
},
- "participantId": "101c62b3-8918-41b9-a747-d21eb79c6c03",
- "participantType": {
- "name": "org.onap.policy.clamp.acm.PolicyParticipant",
- "version": "2.3.1"
- },
- "state": "UNINITIALISED",
- "orderedState": "UNINITIALISED",
+ "deployState": "UNDEPLOYED",
+ "lockState": "NONE",
"description": "Operational Policy Automation Composition Element for the PMSH instance 0 automation composition"
},
"709c62b3-8918-41b9-a747-d21eb79c6c23": {
@@ -42,13 +32,8 @@
"name": "org.onap.domain.database.PMSH_K8SMicroserviceAutomationCompositionElement",
"version": "1.2.3"
},
- "participantId": "101c62b3-8918-41b9-a747-d21eb79c6c02",
- "participantType": {
- "name": "org.onap.policy.clamp.acm.KubernetesParticipant",
- "version": "2.3.4"
- },
- "state": "UNINITIALISED",
- "orderedState": "UNINITIALISED",
+ "deployState": "UNDEPLOYED",
+ "lockState": "NONE",
"description": "K8s Automation Composition Element for the PMSH instance 0 automation composition"
}
}
diff --git a/runtime-acm/src/test/resources/rest/acm/AutomationCompositionUpdate.json b/runtime-acm/src/test/resources/rest/acm/AutomationCompositionUpdate.json
index d0372a342..37568fb19 100644
--- a/runtime-acm/src/test/resources/rest/acm/AutomationCompositionUpdate.json
+++ b/runtime-acm/src/test/resources/rest/acm/AutomationCompositionUpdate.json
@@ -2,8 +2,8 @@
"name": "PMSHInstance0",
"version": "1.0.1",
"compositionId": "709c62b3-8918-41b9-a747-d21eb79c6c40",
- "state": "UNINITIALISED",
- "orderedState": "UNINITIALISED",
+ "deployState": "UNDEPLOYED",
+ "lockState": "NONE",
"description": "PMSH automation composition instance 0",
"elements": {
"709c62b3-8918-41b9-a747-d21eb79c6c21": {
@@ -12,13 +12,8 @@
"name": "org.onap.domain.database.PMSH_K8SMicroserviceAutomationCompositionElement",
"version": "1.2.3"
},
- "participantId": "101c62b3-8918-41b9-a747-d21eb79c6c02",
- "participantType": {
- "name": "org.onap.policy.clamp.acm.KubernetesParticipant",
- "version": "2.3.4"
- },
- "state": "UNINITIALISED",
- "orderedState": "UNINITIALISED",
+ "deployState": "UNDEPLOYED",
+ "lockState": "NONE",
"description": "Automation composition element for the K8S microservice for PMSH"
},
"709c62b3-8918-41b9-a747-d21eb79c6c22": {
@@ -27,13 +22,8 @@
"name": "org.onap.domain.database.Http_PMSHMicroserviceAutomationCompositionElement",
"version": "1.2.3"
},
- "participantId": "101c62b3-8918-41b9-a747-d21eb79c6c01",
- "participantType": {
- "name": "org.onap.policy.clamp.acm.HttpParticipant",
- "version": "2.3.4"
- },
- "state": "UNINITIALISED",
- "orderedState": "UNINITIALISED",
+ "deployState": "UNDEPLOYED",
+ "lockState": "NONE",
"description": "Automation composition element for the operational policy for Performance Management Subscription Handling"
},
"709c62b3-8918-41b9-a747-d21eb79c6c23": {
@@ -42,13 +32,8 @@
"name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement",
"version": "1.2.3"
},
- "participantId": "101c62b3-8918-41b9-a747-d21eb79c6c03",
- "participantType": {
- "name": "org.onap.policy.clamp.acm.PolicyParticipant",
- "version": "2.3.1"
- },
- "state": "UNINITIALISED",
- "orderedState": "UNINITIALISED",
+ "deployState": "UNDEPLOYED",
+ "lockState": "NONE",
"description": "Operational Policy Automation Composition Element for the PMSH instance 0 automation composition"
}
}