summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrameshiyer27 <ramesh.murugan.iyer@est.tech>2023-09-22 15:46:30 +0100
committerRamesh Murugan Iyer <ramesh.murugan.iyer@est.tech>2023-09-27 13:49:20 +0000
commit5a92f5dc2d2066635d59a0b986ec77487198a821 (patch)
tree4ea39827c5cbc183b4e52c2d28f051b2ceedae90
parent3398b96f53bd1c5f9926a88db996abbbfe1da500 (diff)
Allow customisation in element and composition names in TOSCA
User defined values can be provided in the spring properties file for runtime-acm. The same values will be expected from the TOSCA template. If not configured in application properties, default values will be used. Issue-ID: POLICY-4827 Signed-off-by: zrrmmua <ramesh.murugan.iyer@est.tech> Change-Id: I17bfe811c2531c65e90679e95de9732129b54898
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/document/base/ToscaServiceTemplateValidation.java23
-rwxr-xr-xmodels/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionDefinition.java2
-rwxr-xr-xmodels/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcDefinitionProvider.java28
-rwxr-xr-xmodels/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java18
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AcDefinitionProviderTest.java14
-rwxr-xr-xmodels/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java27
-rwxr-xr-xruntime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProvider.java18
-rwxr-xr-xruntime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java5
-rwxr-xr-xruntime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/AcRuntimeParameterGroup.java6
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/AcmParameters.java38
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java5
-rwxr-xr-xruntime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java8
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java5
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantPrimePublisher.java5
-rwxr-xr-xruntime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantRestartPublisher.java5
-rwxr-xr-xruntime-acm/src/main/resources/application.yaml3
-rw-r--r--runtime-acm/src/main/resources/openapi/openapi.yaml4
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProviderTest.java37
-rwxr-xr-xruntime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/rest/CommissioningControllerTest.java10
-rwxr-xr-xruntime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProviderTest.java41
-rwxr-xr-xruntime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/rest/InstantiationControllerTest.java4
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java15
-rwxr-xr-xruntime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java27
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java10
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/comm/SupervisionMessagesTest.java16
-rwxr-xr-xruntime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/CommonTestData.java21
-rw-r--r--runtime-acm/src/test/resources/application-test.yaml3
-rw-r--r--runtime-acm/src/test/resources/parameters/TestParameters.json5
28 files changed, 288 insertions, 115 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/document/base/ToscaServiceTemplateValidation.java b/models/src/main/java/org/onap/policy/clamp/models/acm/document/base/ToscaServiceTemplateValidation.java
index c265e6458..ff580c7c2 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/document/base/ToscaServiceTemplateValidation.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/document/base/ToscaServiceTemplateValidation.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2022 Nordix Foundation.
+ * Copyright (C) 2022-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,7 +30,6 @@ import lombok.NonNull;
import org.onap.policy.clamp.models.acm.document.concepts.DocToscaEntity;
import org.onap.policy.clamp.models.acm.document.concepts.DocToscaServiceTemplate;
import org.onap.policy.clamp.models.acm.document.concepts.DocToscaTopologyTemplate;
-import org.onap.policy.clamp.models.acm.utils.AcmUtils;
import org.onap.policy.common.parameters.BeanValidationResult;
import org.onap.policy.common.parameters.ValidationStatus;
import org.onap.policy.models.base.Validated;
@@ -39,8 +38,6 @@ import org.onap.policy.models.base.Validated;
public final class ToscaServiceTemplateValidation {
private static final String ROOT_KEY_NAME_SUFFIX = ".Root";
- private static final String AC_NODE_TYPE_NOT_PRESENT =
- "NodeTemplate with type " + AcmUtils.AUTOMATION_COMPOSITION_NODE_TYPE + " must exist!";
/**
* validate a serviceTemplate.
@@ -48,7 +45,8 @@ public final class ToscaServiceTemplateValidation {
* @param result the result
* @param serviceTemplate the serviceTemplate to validate
*/
- public static void validate(final BeanValidationResult result, DocToscaServiceTemplate serviceTemplate) {
+ public static void validate(final BeanValidationResult result, DocToscaServiceTemplate serviceTemplate,
+ String toscaCompositionName) {
var references = DocUtil.getToscaReferences(serviceTemplate);
@@ -66,7 +64,7 @@ public final class ToscaServiceTemplateValidation {
}
}
- validateToscaTopologyTemplate(result, serviceTemplate.getToscaTopologyTemplate());
+ validateToscaTopologyTemplate(result, serviceTemplate.getToscaTopologyTemplate(), toscaCompositionName);
if (serviceTemplate.getToscaTopologyTemplate() != null) {
validEntityTypeAncestors(serviceTemplate.getToscaTopologyTemplate().getNodeTemplates(),
@@ -98,21 +96,24 @@ public final class ToscaServiceTemplateValidation {
* @param topologyTemplate the ToscaServiceTemplate
*/
public static void validateToscaTopologyTemplate(BeanValidationResult result,
- DocToscaTopologyTemplate topologyTemplate) {
+ DocToscaTopologyTemplate topologyTemplate, String toscaCompositionName) {
+ String acNodeTypeNotPresent =
+ "NodeTemplate with type " + toscaCompositionName + " must exist!";
+
if (topologyTemplate != null && topologyTemplate.getNodeTemplates() != null) {
var nodeTemplates = topologyTemplate.getNodeTemplates();
var acNumber = nodeTemplates.values().stream().filter(
- nodeTemplate -> AcmUtils.AUTOMATION_COMPOSITION_NODE_TYPE.equals(nodeTemplate.getType()))
+ nodeTemplate -> toscaCompositionName.equals(nodeTemplate.getType()))
.count();
if (acNumber == 0) {
- result.addResult("TopologyTemplate", nodeTemplates, ValidationStatus.INVALID, AC_NODE_TYPE_NOT_PRESENT);
+ result.addResult("TopologyTemplate", nodeTemplates, ValidationStatus.INVALID, acNodeTypeNotPresent);
}
if (acNumber > 1) {
result.addResult("TopologyTemplate", nodeTemplates, ValidationStatus.INVALID, "NodeTemplate with type "
- + AcmUtils.AUTOMATION_COMPOSITION_NODE_TYPE + " not allowed to be more than one!");
+ + toscaCompositionName + " not allowed to be more than one!");
}
} else {
- result.addResult("TopologyTemplate", topologyTemplate, ValidationStatus.INVALID, AC_NODE_TYPE_NOT_PRESENT);
+ result.addResult("TopologyTemplate", topologyTemplate, ValidationStatus.INVALID, acNodeTypeNotPresent);
}
}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionDefinition.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionDefinition.java
index 641c9ad15..4069d7bb1 100755
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionDefinition.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionDefinition.java
@@ -138,8 +138,6 @@ public class JpaAutomationCompositionDefinition extends Validated
@Override
public BeanValidationResult validate(@NonNull String fieldName) {
var result = super.validate(fieldName);
- ToscaServiceTemplateValidation.validate(result, serviceTemplate);
-
if (!result.isValid()) {
return result;
}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcDefinitionProvider.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcDefinitionProvider.java
index 588039b07..9f267d32d 100755
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcDefinitionProvider.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcDefinitionProvider.java
@@ -28,10 +28,12 @@ import java.util.UUID;
import lombok.RequiredArgsConstructor;
import org.onap.policy.clamp.models.acm.concepts.AcTypeState;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionDefinition;
+import org.onap.policy.clamp.models.acm.document.base.ToscaServiceTemplateValidation;
import org.onap.policy.clamp.models.acm.document.concepts.DocToscaServiceTemplate;
import org.onap.policy.clamp.models.acm.persistence.concepts.JpaAutomationCompositionDefinition;
import org.onap.policy.clamp.models.acm.persistence.repository.AutomationCompositionDefinitionRepository;
import org.onap.policy.clamp.models.acm.utils.AcmUtils;
+import org.onap.policy.common.parameters.BeanValidationResult;
import org.onap.policy.models.base.PfModelRuntimeException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.springframework.data.domain.Example;
@@ -53,7 +55,7 @@ public class AcDefinitionProvider {
* @return the created ACM Definition
*/
public AutomationCompositionDefinition createAutomationCompositionDefinition(
- final ToscaServiceTemplate serviceTemplate) {
+ final ToscaServiceTemplate serviceTemplate, final String toscaElementName, String toscaCompositionName) {
var acmDefinition = new AutomationCompositionDefinition();
var compositionId = UUID.randomUUID();
acmDefinition.setCompositionId(compositionId);
@@ -63,10 +65,16 @@ public class AcDefinitionProvider {
}
serviceTemplate.getMetadata().put("compositionId", compositionId);
acmDefinition.setServiceTemplate(serviceTemplate);
- var acElements = AcmUtils.extractAcElementsFromServiceTemplate(serviceTemplate);
+ var acElements = AcmUtils.extractAcElementsFromServiceTemplate(serviceTemplate, toscaElementName);
acmDefinition.setElementStateMap(AcmUtils.createElementStateMap(acElements, AcTypeState.COMMISSIONED));
var jpaAcmDefinition = ProviderUtils.getJpaAndValidate(acmDefinition, JpaAutomationCompositionDefinition::new,
"AutomationCompositionDefinition");
+ var validationResult = new BeanValidationResult("AutomationCompositionDefinition", acmDefinition);
+ ToscaServiceTemplateValidation.validate(validationResult, jpaAcmDefinition.getServiceTemplate(),
+ toscaCompositionName);
+ if (! validationResult.isValid()) {
+ throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, validationResult.getResult());
+ }
var result = acmDefinitionRepository.save(jpaAcmDefinition);
return result.toAuthorative();
@@ -78,14 +86,16 @@ public class AcDefinitionProvider {
* @param compositionId The UUID of the automation composition definition to delete
* @param serviceTemplate the service template to be created
*/
- public void updateServiceTemplate(UUID compositionId, ToscaServiceTemplate serviceTemplate) {
+ public void updateServiceTemplate(UUID compositionId, ToscaServiceTemplate serviceTemplate, String toscaElementName,
+ String toscaCompositionName) {
var acmDefinition = new AutomationCompositionDefinition();
acmDefinition.setCompositionId(compositionId);
acmDefinition.setState(AcTypeState.COMMISSIONED);
acmDefinition.setServiceTemplate(serviceTemplate);
- var acElements = AcmUtils.extractAcElementsFromServiceTemplate(serviceTemplate);
+ var acElements =
+ AcmUtils.extractAcElementsFromServiceTemplate(serviceTemplate, toscaElementName);
acmDefinition.setElementStateMap(AcmUtils.createElementStateMap(acElements, AcTypeState.COMMISSIONED));
- updateAcDefinition(acmDefinition);
+ updateAcDefinition(acmDefinition, toscaCompositionName);
}
/**
@@ -93,9 +103,15 @@ public class AcDefinitionProvider {
*
* @param acDefinition the AutomationCompositionDefinition to be updated
*/
- public void updateAcDefinition(AutomationCompositionDefinition acDefinition) {
+ public void updateAcDefinition(AutomationCompositionDefinition acDefinition, String toscaCompositionName) {
var jpaAcmDefinition = ProviderUtils.getJpaAndValidate(acDefinition, JpaAutomationCompositionDefinition::new,
"AutomationCompositionDefinition");
+ var validationResult = new BeanValidationResult("AutomationCompositionDefinition", acDefinition);
+ ToscaServiceTemplateValidation.validate(validationResult, jpaAcmDefinition.getServiceTemplate(),
+ toscaCompositionName);
+ if (! validationResult.isValid()) {
+ throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, validationResult.getResult());
+ }
acmDefinitionRepository.save(jpaAcmDefinition);
acmDefinitionRepository.flush();
}
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 fe44050d5..c3d8fc4a4 100755
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java
@@ -65,10 +65,6 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaTopologyTemplate;
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class AcmUtils {
-
- public static final String AUTOMATION_COMPOSITION_ELEMENT =
- "org.onap.policy.clamp.acm.AutomationCompositionElement";
- public static final String AUTOMATION_COMPOSITION_NODE_TYPE = "org.onap.policy.clamp.acm.AutomationComposition";
public static final String ENTRY = "entry ";
/**
@@ -99,15 +95,15 @@ public final class AcmUtils {
* @return true if the NodeTemplate is an AutomationCompositionElement
*/
public static boolean checkIfNodeTemplateIsAutomationCompositionElement(ToscaNodeTemplate nodeTemplate,
- ToscaServiceTemplate toscaServiceTemplate) {
- if (nodeTemplate.getType().contains(AUTOMATION_COMPOSITION_ELEMENT)) {
+ ToscaServiceTemplate toscaServiceTemplate, String toscaElementName) {
+ if (nodeTemplate.getType().contains(toscaElementName)) {
return true;
} else {
var nodeType = toscaServiceTemplate.getNodeTypes().get(nodeTemplate.getType());
if (nodeType != null) {
var derivedFrom = nodeType.getDerivedFrom();
if (derivedFrom != null) {
- return derivedFrom.contains(AUTOMATION_COMPOSITION_ELEMENT);
+ return derivedFrom.contains(toscaElementName);
}
}
}
@@ -167,10 +163,10 @@ public final class AcmUtils {
* @return the list of Entry of AutomationCompositionElement
*/
public static List<Entry<String, ToscaNodeTemplate>> extractAcElementsFromServiceTemplate(
- ToscaServiceTemplate serviceTemplate) {
+ ToscaServiceTemplate serviceTemplate, String toscaElementName) {
return serviceTemplate.getToscaTopologyTemplate().getNodeTemplates().entrySet().stream().filter(
nodeTemplateEntry -> checkIfNodeTemplateIsAutomationCompositionElement(nodeTemplateEntry.getValue(),
- serviceTemplate))
+ serviceTemplate, toscaElementName))
.toList();
}
@@ -203,13 +199,13 @@ public final class AcmUtils {
* @return the result of validation
*/
public static BeanValidationResult validateAutomationComposition(AutomationComposition automationComposition,
- ToscaServiceTemplate serviceTemplate) {
+ ToscaServiceTemplate serviceTemplate, String toscaCompositionName) {
var result = new BeanValidationResult(ENTRY + automationComposition.getName(), automationComposition);
var map = getMapToscaNodeTemplates(serviceTemplate);
var nodeTemplateGet = map.values().stream()
- .filter(nodeTemplate -> AUTOMATION_COMPOSITION_NODE_TYPE.equals(nodeTemplate.getType())).findFirst();
+ .filter(nodeTemplate -> toscaCompositionName.equals(nodeTemplate.getType())).findFirst();
if (nodeTemplateGet.isEmpty()) {
result.addResult(new ObjectValidationResult("ToscaServiceTemplate", serviceTemplate.getName(),
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AcDefinitionProviderTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AcDefinitionProviderTest.java
index f907892f9..2d0803a8a 100644
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AcDefinitionProviderTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AcDefinitionProviderTest.java
@@ -52,6 +52,9 @@ class AcDefinitionProviderTest {
private static final String TOSCA_SERVICE_TEMPLATE_YAML_PROP =
"clamp/acm/test/tosca-template-additional-properties.yaml";
+ private static final String ELEMENT_NAME = "org.onap.policy.clamp.acm.AutomationCompositionElement";
+ private static final String NODE_TYPE = "org.onap.policy.clamp.acm.AutomationComposition";
+
private static ToscaServiceTemplate inputServiceTemplate;
@BeforeAll
@@ -87,7 +90,8 @@ class AcDefinitionProviderTest {
.thenReturn(new JpaAutomationCompositionDefinition(acmDefinition));
var acDefinitionProvider = new AcDefinitionProvider(acmDefinitionRepository);
- var result = acDefinitionProvider.createAutomationCompositionDefinition(inputServiceTemplate);
+ var result = acDefinitionProvider
+ .createAutomationCompositionDefinition(inputServiceTemplate, ELEMENT_NAME, NODE_TYPE);
assertThat(result.getServiceTemplate()).isEqualTo(docServiceTemplate.toAuthorative());
assertThat(result.getServiceTemplate().getMetadata()).isNotNull();
@@ -104,7 +108,9 @@ class AcDefinitionProviderTest {
.thenReturn(new JpaAutomationCompositionDefinition(acmDefinition));
var acDefinitionProvider = new AcDefinitionProvider(acmDefinitionRepository);
- var result = acDefinitionProvider.createAutomationCompositionDefinition(inputServiceTemplate);
+ inputServiceTemplate.setMetadata(new HashMap<>());
+ var result = acDefinitionProvider
+ .createAutomationCompositionDefinition(inputServiceTemplate, ELEMENT_NAME, NODE_TYPE);
assertThat(result.getServiceTemplate()).isEqualTo(docServiceTemplate.toAuthorative());
assertThat(result.getServiceTemplate().getMetadata()).isNotNull();
@@ -114,7 +120,7 @@ class AcDefinitionProviderTest {
void testUpdateServiceTemplate() {
var acmDefinitionRepository = mock(AutomationCompositionDefinitionRepository.class);
var acDefinitionProvider = new AcDefinitionProvider(acmDefinitionRepository);
- acDefinitionProvider.updateServiceTemplate(UUID.randomUUID(), inputServiceTemplate);
+ acDefinitionProvider.updateServiceTemplate(UUID.randomUUID(), inputServiceTemplate, ELEMENT_NAME, NODE_TYPE);
verify(acmDefinitionRepository).save(any(JpaAutomationCompositionDefinition.class));
}
@@ -123,7 +129,7 @@ class AcDefinitionProviderTest {
var acmDefinitionRepository = mock(AutomationCompositionDefinitionRepository.class);
var acDefinitionProvider = new AcDefinitionProvider(acmDefinitionRepository);
var acmDefinition = getAcDefinition(new DocToscaServiceTemplate(inputServiceTemplate));
- acDefinitionProvider.updateAcDefinition(acmDefinition);
+ acDefinitionProvider.updateAcDefinition(acmDefinition, NODE_TYPE);
verify(acmDefinitionRepository).save(any(JpaAutomationCompositionDefinition.class));
}
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 e0e5a2edc..8e10e81ad 100755
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java
@@ -59,6 +59,10 @@ class AcmUtilsTest {
private static final String PARTICIPANT_AUTOMATION_COMPOSITION_ELEMENT = "org.onap.policy.clamp.acm.Participant";
private static final String TOSCA_TEMPLATE_YAML = "clamp/acm/pmsh/funtional-pmsh-usecase.yaml";
+ public static final String AUTOMATION_COMPOSITION_ELEMENT =
+ "org.onap.policy.clamp.acm.AutomationCompositionElement";
+ public static final String AUTOMATION_COMPOSITION_NODE_TYPE = "org.onap.policy.clamp.acm.AutomationComposition";
+
@Test
void testIsInTransitionalState() {
assertThat(AcmUtils.isInTransitionalState(DeployState.DEPLOYED, LockState.LOCKED)).isFalse();
@@ -75,21 +79,25 @@ class AcmUtilsTest {
void testCheckIfNodeTemplateIsAutomationCompositionElement() {
var serviceTemplate = CommonTestData.getToscaServiceTemplate(TOSCA_TEMPLATE_YAML);
var nodeTemplate = new ToscaNodeTemplate();
- nodeTemplate.setType(AcmUtils.AUTOMATION_COMPOSITION_ELEMENT);
- assertThat(AcmUtils.checkIfNodeTemplateIsAutomationCompositionElement(nodeTemplate, serviceTemplate)).isTrue();
+ nodeTemplate.setType(AUTOMATION_COMPOSITION_ELEMENT);
+ assertThat(AcmUtils.checkIfNodeTemplateIsAutomationCompositionElement(nodeTemplate, serviceTemplate,
+ AUTOMATION_COMPOSITION_ELEMENT)).isTrue();
nodeTemplate.setType(POLICY_AUTOMATION_COMPOSITION_ELEMENT);
- assertThat(AcmUtils.checkIfNodeTemplateIsAutomationCompositionElement(nodeTemplate, serviceTemplate)).isTrue();
+ assertThat(AcmUtils.checkIfNodeTemplateIsAutomationCompositionElement(nodeTemplate, serviceTemplate,
+ AUTOMATION_COMPOSITION_ELEMENT)).isTrue();
nodeTemplate.setType(PARTICIPANT_AUTOMATION_COMPOSITION_ELEMENT);
- assertThat(AcmUtils.checkIfNodeTemplateIsAutomationCompositionElement(nodeTemplate, serviceTemplate)).isFalse();
+ assertThat(AcmUtils.checkIfNodeTemplateIsAutomationCompositionElement(nodeTemplate, serviceTemplate,
+ AUTOMATION_COMPOSITION_ELEMENT)).isFalse();
}
@Test
void testPrepareParticipantPriming() {
var serviceTemplate = CommonTestData.getToscaServiceTemplate(TOSCA_TEMPLATE_YAML);
- var acElements = AcmUtils.extractAcElementsFromServiceTemplate(serviceTemplate);
+ var acElements =
+ AcmUtils.extractAcElementsFromServiceTemplate(serviceTemplate, AUTOMATION_COMPOSITION_ELEMENT);
Map<ToscaConceptIdentifier, UUID> map = new HashMap<>();
var participantId = UUID.randomUUID();
assertThatThrownBy(() -> AcmUtils.prepareParticipantPriming(acElements, map)).hasMessageMatching(
@@ -126,7 +134,8 @@ class AcmUtilsTest {
void testValidateAutomationComposition() {
var automationComposition = getDummyAutomationComposition();
var toscaServiceTemplate = getDummyToscaServiceTemplate();
- var result = AcmUtils.validateAutomationComposition(automationComposition, toscaServiceTemplate);
+ var result = AcmUtils.validateAutomationComposition(automationComposition,
+ toscaServiceTemplate, AUTOMATION_COMPOSITION_NODE_TYPE);
assertNotNull(result);
assertFalse(result.isValid());
@@ -135,11 +144,13 @@ class AcmUtilsTest {
nodeTemplate.setType("org.onap.policy.clamp.acm.AutomationComposition");
nodeTemplates.put("org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant", nodeTemplate);
toscaServiceTemplate.getToscaTopologyTemplate().setNodeTemplates(nodeTemplates);
- result = AcmUtils.validateAutomationComposition(automationComposition, toscaServiceTemplate);
+ result = AcmUtils.validateAutomationComposition(automationComposition, toscaServiceTemplate,
+ AUTOMATION_COMPOSITION_NODE_TYPE);
assertFalse(result.isValid());
var doc = new DocToscaServiceTemplate(CommonTestData.getToscaServiceTemplate(TOSCA_TEMPLATE_YAML));
- result = AcmUtils.validateAutomationComposition(automationComposition, doc.toAuthorative());
+ result = AcmUtils.validateAutomationComposition(automationComposition, doc.toAuthorative(),
+ AUTOMATION_COMPOSITION_NODE_TYPE);
assertFalse(result.isValid());
}
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProvider.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProvider.java
index 3400b2e60..dd0ddaae9 100755
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProvider.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProvider.java
@@ -26,8 +26,8 @@ import java.util.HashSet;
import java.util.UUID;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
-import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
+import org.onap.policy.clamp.acm.runtime.main.parameters.AcRuntimeParameterGroup;
import org.onap.policy.clamp.acm.runtime.participants.AcmParticipantProvider;
import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantPrimePublisher;
import org.onap.policy.clamp.models.acm.concepts.AcTypeState;
@@ -52,13 +52,13 @@ import org.springframework.transaction.annotation.Transactional;
@Service
@RequiredArgsConstructor
public class CommissioningProvider {
- public static final String AUTOMATION_COMPOSITION_NODE_TYPE = "org.onap.policy.clamp.acm.AutomationComposition";
private final AcDefinitionProvider acDefinitionProvider;
private final AutomationCompositionProvider acProvider;
private final AcmParticipantProvider acmParticipantProvider;
private final AcTypeStateResolver acTypeStateResolver;
private final ParticipantPrimePublisher participantPrimePublisher;
+ private final AcRuntimeParameterGroup acRuntimeParameterGroup;
private final ExecutorService executor = Executors.newFixedThreadPool(1);
@@ -87,7 +87,9 @@ public class CommissioningProvider {
@Transactional
public CommissioningResponse createAutomationCompositionDefinition(ToscaServiceTemplate serviceTemplate) {
- var acmDefinition = acDefinitionProvider.createAutomationCompositionDefinition(serviceTemplate);
+ var acmDefinition = acDefinitionProvider.createAutomationCompositionDefinition(serviceTemplate,
+ acRuntimeParameterGroup.getAcmParameters().getToscaElementName(),
+ acRuntimeParameterGroup.getAcmParameters().getToscaCompositionName());
serviceTemplate = acmDefinition.getServiceTemplate();
return createCommissioningResponse(acmDefinition.getCompositionId(), serviceTemplate);
}
@@ -110,7 +112,9 @@ public class CommissioningProvider {
throw new PfModelRuntimeException(Status.BAD_REQUEST,
"ACM not in COMMISSIONED state, Update of ACM Definition not allowed");
}
- acDefinitionProvider.updateServiceTemplate(compositionId, serviceTemplate);
+ acDefinitionProvider.updateServiceTemplate(compositionId, serviceTemplate,
+ acRuntimeParameterGroup.getAcmParameters().getToscaElementName(),
+ acRuntimeParameterGroup.getAcmParameters().getToscaCompositionName());
return createCommissioningResponse(compositionId, serviceTemplate);
}
@@ -208,7 +212,8 @@ public class CommissioningProvider {
private void prime(AutomationCompositionDefinition acmDefinition) {
acmDefinition.setStateChangeResult(StateChangeResult.NO_ERROR);
var preparation = participantPrimePublisher.prepareParticipantPriming(acmDefinition);
- acDefinitionProvider.updateAcDefinition(acmDefinition);
+ acDefinitionProvider.updateAcDefinition(acmDefinition,
+ acRuntimeParameterGroup.getAcmParameters().getToscaCompositionName());
executor.execute(
() -> participantPrimePublisher.sendPriming(preparation, acmDefinition.getCompositionId(), null));
@@ -228,7 +233,8 @@ public class CommissioningProvider {
acmParticipantProvider.verifyParticipantState(participantIds);
}
acmDefinition.setState(AcTypeState.DEPRIMING);
- acDefinitionProvider.updateAcDefinition(acmDefinition);
+ acDefinitionProvider.updateAcDefinition(acmDefinition,
+ acRuntimeParameterGroup.getAcmParameters().getToscaCompositionName());
executor.execute(() -> participantPrimePublisher.sendDepriming(acmDefinition.getCompositionId()));
}
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 f8d5894b3..977708ee1 100755
--- 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
@@ -27,6 +27,7 @@ import jakarta.ws.rs.core.Response.Status;
import java.util.UUID;
import java.util.stream.Collectors;
import lombok.AllArgsConstructor;
+import org.onap.policy.clamp.acm.runtime.main.parameters.AcRuntimeParameterGroup;
import org.onap.policy.clamp.acm.runtime.participants.AcmParticipantProvider;
import org.onap.policy.clamp.acm.runtime.supervision.SupervisionAcHandler;
import org.onap.policy.clamp.models.acm.concepts.AcTypeState;
@@ -63,6 +64,7 @@ public class AutomationCompositionInstantiationProvider {
private final AcInstanceStateResolver acInstanceStateResolver;
private final SupervisionAcHandler supervisionAcHandler;
private final AcmParticipantProvider acmParticipantProvider;
+ private final AcRuntimeParameterGroup acRuntimeParameterGroup;
/**
* Create automation composition.
@@ -207,7 +209,8 @@ public class AutomationCompositionInstantiationProvider {
acmParticipantProvider.verifyParticipantState(participantIds);
result.addResult(AcmUtils.validateAutomationComposition(automationComposition,
- acDefinitionOpt.get().getServiceTemplate()));
+ acDefinitionOpt.get().getServiceTemplate(),
+ acRuntimeParameterGroup.getAcmParameters().getToscaCompositionName()));
if (result.isValid()) {
for (var element : automationComposition.getElements().values()) {
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/AcRuntimeParameterGroup.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/AcRuntimeParameterGroup.java
index 87aa92386..a30b531a4 100755
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/AcRuntimeParameterGroup.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/AcRuntimeParameterGroup.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.
@@ -46,4 +46,8 @@ public class AcRuntimeParameterGroup {
@NotNull
@ParameterGroupConstraint
private TopicParameterGroup topicParameterGroup;
+
+ @Valid
+ @NotNull
+ private AcmParameters acmParameters = new AcmParameters();
}
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/AcmParameters.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/AcmParameters.java
new file mode 100644
index 000000000..3ae21e5fb
--- /dev/null
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/AcmParameters.java
@@ -0,0 +1,38 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.acm.runtime.main.parameters;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.springframework.validation.annotation.Validated;
+
+/**
+ * Parameters for ac element name and ac node type.
+ */
+@Getter
+@Setter
+@Validated
+public class AcmParameters {
+
+ // Default values for the element name and composition name
+ private String toscaElementName = "org.onap.policy.clamp.acm.AutomationCompositionElement";
+
+ private String toscaCompositionName = "org.onap.policy.clamp.acm.AutomationComposition";
+
+}
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 4f58801c3..6090c644c 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
@@ -23,6 +23,7 @@ package org.onap.policy.clamp.acm.runtime.supervision;
import io.micrometer.core.annotation.Timed;
import lombok.AllArgsConstructor;
+import org.onap.policy.clamp.acm.runtime.main.parameters.AcRuntimeParameterGroup;
import org.onap.policy.clamp.models.acm.concepts.AcTypeState;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionDefinition;
import org.onap.policy.clamp.models.acm.concepts.StateChangeResult;
@@ -42,6 +43,7 @@ public class SupervisionHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(SupervisionHandler.class);
private final AcDefinitionProvider acDefinitionProvider;
+ private final AcRuntimeParameterGroup acRuntimeParameterGroup;
/**
* Handle a ParticipantPrimeAck message from a participant.
@@ -101,7 +103,8 @@ public class SupervisionHandler {
if (!restarting) {
acDefinition.setRestarting(null);
}
- acDefinitionProvider.updateAcDefinition(acDefinition);
+ acDefinitionProvider.updateAcDefinition(acDefinition,
+ acRuntimeParameterGroup.getAcmParameters().getToscaCompositionName());
}
}
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java
index ebccc2f66..4c136c478 100755
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java
@@ -28,6 +28,7 @@ import java.util.Map;
import java.util.UUID;
import lombok.AllArgsConstructor;
import org.apache.commons.collections4.MapUtils;
+import org.onap.policy.clamp.acm.runtime.main.parameters.AcRuntimeParameterGroup;
import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantDeregisterAckPublisher;
import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantRegisterAckPublisher;
import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantRestartPublisher;
@@ -63,6 +64,7 @@ public class SupervisionParticipantHandler {
private final AutomationCompositionProvider automationCompositionProvider;
private final AcDefinitionProvider acDefinitionProvider;
private final ParticipantRestartPublisher participantRestartPublisher;
+ private final AcRuntimeParameterGroup acRuntimeParameterGroup;
/**
* Handle a ParticipantRegister message from a participant.
@@ -153,7 +155,8 @@ public class SupervisionParticipantHandler {
}
}
}
- acDefinitionProvider.updateAcDefinition(acDefinition);
+ acDefinitionProvider.updateAcDefinition(acDefinition,
+ acRuntimeParameterGroup.getAcmParameters().getToscaCompositionName());
}
private void checkOnline(Participant participant) {
@@ -196,7 +199,8 @@ public class SupervisionParticipantHandler {
acDefinition.setStateChangeResult(StateChangeResult.NO_ERROR);
}
acDefinition.setRestarting(true);
- acDefinitionProvider.updateAcDefinition(acDefinition);
+ acDefinitionProvider.updateAcDefinition(acDefinition,
+ acRuntimeParameterGroup.getAcmParameters().getToscaCompositionName());
participantRestartPublisher.send(participantId, acDefinition, automationCompositions);
}
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java
index 0ccdaed3e..15283609a 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java
@@ -56,6 +56,7 @@ public class SupervisionScanner {
private final AcDefinitionProvider acDefinitionProvider;
private final AutomationCompositionStateChangePublisher automationCompositionStateChangePublisher;
private final AutomationCompositionDeployPublisher automationCompositionDeployPublisher;
+ private final AcRuntimeParameterGroup acRuntimeParameterGroup;
/**
* Constructor for instantiating SupervisionScanner.
@@ -75,6 +76,7 @@ public class SupervisionScanner {
this.acDefinitionProvider = acDefinitionProvider;
this.automationCompositionStateChangePublisher = automationCompositionStateChangePublisher;
this.automationCompositionDeployPublisher = automationCompositionDeployPublisher;
+ this.acRuntimeParameterGroup = acRuntimeParameterGroup;
acTimeout.setMaxWaitMs(acRuntimeParameterGroup.getParticipantParameters().getMaxStatusWaitMs());
}
@@ -227,7 +229,8 @@ public class SupervisionScanner {
LOGGER.debug("Report timeout for the ac definition {}", acDefinition.getCompositionId());
acTimeout.setTimeout(compositionId);
acDefinition.setStateChangeResult(StateChangeResult.TIMEOUT);
- acDefinitionProvider.updateAcDefinition(acDefinition);
+ acDefinitionProvider.updateAcDefinition(acDefinition,
+ acRuntimeParameterGroup.getAcmParameters().getToscaCompositionName());
}
}
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantPrimePublisher.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantPrimePublisher.java
index 539a992ff..f3fcfe67a 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantPrimePublisher.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantPrimePublisher.java
@@ -30,6 +30,7 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
import lombok.AllArgsConstructor;
+import org.onap.policy.clamp.acm.runtime.main.parameters.AcRuntimeParameterGroup;
import org.onap.policy.clamp.acm.runtime.participants.AcmParticipantProvider;
import org.onap.policy.clamp.models.acm.concepts.AcTypeState;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionDefinition;
@@ -53,6 +54,7 @@ public class ParticipantPrimePublisher extends AbstractParticipantPublisher<Part
private final ParticipantProvider participantProvider;
private final AcmParticipantProvider acmParticipantProvider;
+ private final AcRuntimeParameterGroup acRuntimeParameterGroup;
/**
* Send ParticipantPrime to Participant
@@ -83,7 +85,8 @@ public class ParticipantPrimePublisher extends AbstractParticipantPublisher<Part
*/
public List<ParticipantDefinition> prepareParticipantPriming(AutomationCompositionDefinition acmDefinition) {
acmDefinition.setState(AcTypeState.PRIMING);
- var acElements = AcmUtils.extractAcElementsFromServiceTemplate(acmDefinition.getServiceTemplate());
+ var acElements = AcmUtils.extractAcElementsFromServiceTemplate(acmDefinition.getServiceTemplate(),
+ acRuntimeParameterGroup.getAcmParameters().getToscaElementName());
Map<ToscaConceptIdentifier, UUID> supportedElementMap = new HashMap<>();
var participantIds = new HashSet<UUID>();
if (AcTypeState.PRIMED.equals(acmDefinition.getState())) {
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantRestartPublisher.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantRestartPublisher.java
index c00116e3b..163d3299d 100755
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantRestartPublisher.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantRestartPublisher.java
@@ -29,6 +29,7 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.UUID;
import lombok.AllArgsConstructor;
+import org.onap.policy.clamp.acm.runtime.main.parameters.AcRuntimeParameterGroup;
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.ParticipantDefinition;
@@ -46,6 +47,7 @@ import org.springframework.stereotype.Component;
public class ParticipantRestartPublisher extends AbstractParticipantPublisher<ParticipantRestart> {
private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantRestartPublisher.class);
+ private final AcRuntimeParameterGroup acRuntimeParameterGroup;
/**
* Send Restart to Participant.
@@ -86,7 +88,8 @@ public class ParticipantRestartPublisher extends AbstractParticipantPublisher<Pa
private List<ParticipantDefinition> prepareParticipantRestarting(UUID participantId,
AutomationCompositionDefinition acmDefinition) {
- var acElements = AcmUtils.extractAcElementsFromServiceTemplate(acmDefinition.getServiceTemplate());
+ var acElements = AcmUtils.extractAcElementsFromServiceTemplate(acmDefinition.getServiceTemplate(),
+ acRuntimeParameterGroup.getAcmParameters().getToscaElementName());
// list of entry entry filtered by participantId
List<Entry<String, ToscaNodeTemplate>> elementList = new ArrayList<>();
diff --git a/runtime-acm/src/main/resources/application.yaml b/runtime-acm/src/main/resources/application.yaml
index 6a0213720..84ddcfc76 100755
--- a/runtime-acm/src/main/resources/application.yaml
+++ b/runtime-acm/src/main/resources/application.yaml
@@ -61,6 +61,9 @@ runtime:
servers:
- ${topicServer:localhost}
topicCommInfrastructure: dmaap
+ acmParameters:
+ toscaElementName: org.onap.policy.clamp.acm.AutomationCompositionElement
+ toscaCompositionName: org.onap.policy.clamp.acm.AutomationComposition
management:
endpoints:
diff --git a/runtime-acm/src/main/resources/openapi/openapi.yaml b/runtime-acm/src/main/resources/openapi/openapi.yaml
index 74f1d4874..988b9d164 100644
--- a/runtime-acm/src/main/resources/openapi/openapi.yaml
+++ b/runtime-acm/src/main/resources/openapi/openapi.yaml
@@ -1011,12 +1011,12 @@ paths:
schema:
$ref: '#/components/schemas/AutomationCompositions'
example:
- externalValue: 'https://raw.githubusercontent.com/onap/policy-clamp/master/runtime-acm/src/main/resources/openapi/examples/getCompositionInstancesResponse.json'
+ externalValue: 'https://raw.githubusercontent.com/onap/policy-clamp/master/runtime-acm/src/main/resources/openapi/examples/getAllCompositionInstancesResponse.json'
application/yaml:
schema:
$ref: '#/components/schemas/AutomationCompositions'
example:
- externalValue: 'https://raw.githubusercontent.com/onap/policy-clamp/master/runtime-acm/src/main/resources/openapi/examples/getCompositionInstancesResponse.yaml'
+ externalValue: 'https://raw.githubusercontent.com/onap/policy-clamp/master/runtime-acm/src/main/resources/openapi/examples/getAllCompositionInstancesResponse.yaml'
401:
description: Authentication Error, returns an instance of
[SimpleResponse](https://github.com/onap/policy-clamp/blob/master/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/SimpleResponse.java)
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProviderTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProviderTest.java
index d7c79bc3b..5c26ea3bd 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProviderTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProviderTest.java
@@ -35,6 +35,7 @@ import java.util.List;
import java.util.UUID;
import org.junit.jupiter.api.Test;
import org.onap.policy.clamp.acm.runtime.instantiation.InstantiationUtils;
+import org.onap.policy.clamp.acm.runtime.main.parameters.AcRuntimeParameterGroup;
import org.onap.policy.clamp.acm.runtime.participants.AcmParticipantProvider;
import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantPrimePublisher;
import org.onap.policy.clamp.acm.runtime.util.CommonTestData;
@@ -59,8 +60,10 @@ class CommissioningProviderTest {
void testGetAutomationCompositionDefinitions() {
var acProvider = mock(AutomationCompositionProvider.class);
var acDefinitionProvider = mock(AcDefinitionProvider.class);
+ var acRuntimeParameterGroup = mock(AcRuntimeParameterGroup.class);
- var provider = new CommissioningProvider(acDefinitionProvider, acProvider, null, null, null);
+ var provider = new CommissioningProvider(acDefinitionProvider, acProvider, null, null, null,
+ acRuntimeParameterGroup);
var serviceTemplates = provider.getAutomationCompositionDefinitions(null, null);
assertThat(serviceTemplates.getServiceTemplates()).isEmpty();
@@ -84,13 +87,16 @@ class CommissioningProviderTest {
acmDefinition.setCompositionId(UUID.randomUUID());
acmDefinition.setServiceTemplate(serviceTemplate);
var acDefinitionProvider = mock(AcDefinitionProvider.class);
- when(acDefinitionProvider.createAutomationCompositionDefinition(serviceTemplate)).thenReturn(acmDefinition);
+ when(acDefinitionProvider.createAutomationCompositionDefinition(serviceTemplate,
+ CommonTestData.TOSCA_ELEMENT_NAME, CommonTestData.TOSCA_COMP_NAME)).thenReturn(acmDefinition);
var acProvider = mock(AutomationCompositionProvider.class);
- var provider = new CommissioningProvider(acDefinitionProvider, acProvider, null, null, null);
+ var provider = new CommissioningProvider(acDefinitionProvider, acProvider, null, null, null,
+ CommonTestData.getTestParamaterGroup());
var affectedDefinitions = provider.createAutomationCompositionDefinition(serviceTemplate)
.getAffectedAutomationCompositionDefinitions();
- verify(acDefinitionProvider).createAutomationCompositionDefinition(serviceTemplate);
+ verify(acDefinitionProvider).createAutomationCompositionDefinition(serviceTemplate,
+ CommonTestData.TOSCA_ELEMENT_NAME, CommonTestData.TOSCA_COMP_NAME);
// Response should return the number of node templates present in the service template
assertThat(affectedDefinitions).hasSize(7);
}
@@ -105,7 +111,7 @@ class CommissioningProviderTest {
var acDefinitionProvider = mock(AcDefinitionProvider.class);
var acProvider = mock(AutomationCompositionProvider.class);
- var provider = new CommissioningProvider(acDefinitionProvider, acProvider, null, null, null);
+ var provider = new CommissioningProvider(acDefinitionProvider, acProvider, null, null, null, null);
var serviceTemplate = InstantiationUtils.getToscaServiceTemplate(TOSCA_SERVICE_TEMPLATE_YAML);
when(acDefinitionProvider.getServiceTemplateList(null, null)).thenReturn(List.of(serviceTemplate));
@@ -122,7 +128,7 @@ class CommissioningProviderTest {
var compositionId = UUID.randomUUID();
when(acProvider.getAcInstancesByCompositionId(compositionId)).thenReturn(List.of(new AutomationComposition()));
- var provider = new CommissioningProvider(acDefinitionProvider, acProvider, null, null, null);
+ var provider = new CommissioningProvider(acDefinitionProvider, acProvider, null, null, null, null);
assertThatThrownBy(() -> provider.deleteAutomationCompositionDefinition(compositionId))
.hasMessageMatching("Delete instances, to commission automation composition definitions");
@@ -142,7 +148,7 @@ class CommissioningProviderTest {
when(acDefinitionProvider.getAcDefinition(compositionId)).thenReturn(acmDefinition);
var acProvider = mock(AutomationCompositionProvider.class);
- var provider = new CommissioningProvider(acDefinitionProvider, acProvider, null, null, null);
+ var provider = new CommissioningProvider(acDefinitionProvider, acProvider, null, null, null, null);
provider.deleteAutomationCompositionDefinition(compositionId);
@@ -159,12 +165,13 @@ class CommissioningProviderTest {
var participantPrimePublisher = mock(ParticipantPrimePublisher.class);
var provider = new CommissioningProvider(acDefinitionProvider, mock(AutomationCompositionProvider.class),
- mock(AcmParticipantProvider.class), new AcTypeStateResolver(), participantPrimePublisher);
+ mock(AcmParticipantProvider.class), new AcTypeStateResolver(), participantPrimePublisher,
+ CommonTestData.getTestParamaterGroup());
var acTypeStateUpdate = new AcTypeStateUpdate();
acTypeStateUpdate.setPrimeOrder(PrimeOrder.PRIME);
provider.compositionDefinitionPriming(compositionId, acTypeStateUpdate);
- verify(acDefinitionProvider).updateAcDefinition(acmDefinition);
+ verify(acDefinitionProvider).updateAcDefinition(acmDefinition, CommonTestData.TOSCA_COMP_NAME);
verify(participantPrimePublisher, timeout(1000).times(1)).sendPriming(any(), any(), any());
}
@@ -179,7 +186,8 @@ class CommissioningProviderTest {
var participantPrimePublisher = mock(ParticipantPrimePublisher.class);
var acmParticipantProvider = mock(AcmParticipantProvider.class);
var provider = new CommissioningProvider(acDefinitionProvider, mock(AutomationCompositionProvider.class),
- acmParticipantProvider, new AcTypeStateResolver(), participantPrimePublisher);
+ acmParticipantProvider, new AcTypeStateResolver(), participantPrimePublisher,
+ CommonTestData.getTestParamaterGroup());
var acTypeStateUpdate = new AcTypeStateUpdate();
acTypeStateUpdate.setPrimeOrder(PrimeOrder.DEPRIME);
@@ -193,7 +201,8 @@ class CommissioningProviderTest {
void testBadRequest() {
var acProvider = mock(AutomationCompositionProvider.class);
var provider = new CommissioningProvider(mock(AcDefinitionProvider.class), acProvider,
- mock(AcmParticipantProvider.class), new AcTypeStateResolver(), mock(ParticipantPrimePublisher.class));
+ mock(AcmParticipantProvider.class), new AcTypeStateResolver(), mock(ParticipantPrimePublisher.class),
+ mock(AcRuntimeParameterGroup.class));
var compositionId = UUID.randomUUID();
when(acProvider.getAcInstancesByCompositionId(compositionId)).thenReturn(List.of(new AutomationComposition()));
@@ -216,7 +225,8 @@ class CommissioningProviderTest {
when(acDefinitionProvider.getAcDefinition(compositionId)).thenReturn(acmDefinition);
var provider = new CommissioningProvider(acDefinitionProvider, mock(AutomationCompositionProvider.class),
- mock(AcmParticipantProvider.class), new AcTypeStateResolver(), mock(ParticipantPrimePublisher.class));
+ mock(AcmParticipantProvider.class), new AcTypeStateResolver(), mock(ParticipantPrimePublisher.class),
+ mock(AcRuntimeParameterGroup.class));
assertThatThrownBy(() -> provider.updateCompositionDefinition(compositionId, toscaServiceTemplate))
.hasMessageMatching("ACM not in COMMISSIONED state, Update of ACM Definition not allowed");
@@ -235,7 +245,8 @@ class CommissioningProviderTest {
when(acDefinitionProvider.getAcDefinition(compositionId)).thenReturn(acmDefinition);
var provider = new CommissioningProvider(acDefinitionProvider, mock(AutomationCompositionProvider.class),
- mock(AcmParticipantProvider.class), new AcTypeStateResolver(), mock(ParticipantPrimePublisher.class));
+ mock(AcmParticipantProvider.class), new AcTypeStateResolver(), mock(ParticipantPrimePublisher.class),
+ mock(AcRuntimeParameterGroup.class));
var acTypeStateUpdate = new AcTypeStateUpdate();
assertThatThrownBy(() -> provider.compositionDefinitionPriming(compositionId, acTypeStateUpdate))
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/rest/CommissioningControllerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/rest/CommissioningControllerTest.java
index 2aab744ad..b2e151126 100755
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/rest/CommissioningControllerTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/rest/CommissioningControllerTest.java
@@ -38,18 +38,14 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.onap.policy.clamp.acm.runtime.instantiation.InstantiationUtils;
+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.AutomationCompositionDefinition;
-import org.onap.policy.clamp.models.acm.concepts.Participant;
-import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
-import org.onap.policy.clamp.models.acm.concepts.ParticipantSupportedElementType;
import org.onap.policy.clamp.models.acm.messages.rest.commissioning.AcTypeStateUpdate;
import org.onap.policy.clamp.models.acm.messages.rest.commissioning.CommissioningResponse;
import org.onap.policy.clamp.models.acm.messages.rest.commissioning.PrimeOrder;
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.utils.AcmUtils;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaDataType;
import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
@@ -230,7 +226,9 @@ class CommissioningControllerTest extends CommonRestController {
private UUID createEntryInDB(String name) {
var serviceTemplateCreate = new ToscaServiceTemplate(serviceTemplate);
serviceTemplateCreate.setName(name);
- var acmDefinition = acDefinitionProvider.createAutomationCompositionDefinition(serviceTemplateCreate);
+ var acmDefinition = acDefinitionProvider
+ .createAutomationCompositionDefinition(serviceTemplateCreate, CommonTestData.TOSCA_ELEMENT_NAME,
+ CommonTestData.TOSCA_COMP_NAME);
return acmDefinition.getCompositionId();
}
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 a59872f0a..308eed5da 100755
--- 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
@@ -35,6 +35,8 @@ import java.util.Optional;
import java.util.UUID;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
+import org.onap.policy.clamp.acm.runtime.main.parameters.AcRuntimeParameterGroup;
+import org.onap.policy.clamp.acm.runtime.main.parameters.AcmParameters;
import org.onap.policy.clamp.acm.runtime.participants.AcmParticipantProvider;
import org.onap.policy.clamp.acm.runtime.supervision.SupervisionAcHandler;
import org.onap.policy.clamp.acm.runtime.util.CommonTestData;
@@ -101,7 +103,8 @@ class AutomationCompositionInstantiationProviderTest {
var supervisionAcHandler = mock(SupervisionAcHandler.class);
var acmParticipantProvider = mock(AcmParticipantProvider.class);
var instantiationProvider = new AutomationCompositionInstantiationProvider(acProvider, acDefinitionProvider,
- null, supervisionAcHandler, acmParticipantProvider);
+ null, supervisionAcHandler, acmParticipantProvider,
+ CommonTestData.getTestParamaterGroup());
var automationCompositionCreate =
InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Crud");
automationCompositionCreate.setCompositionId(compositionId);
@@ -166,7 +169,8 @@ class AutomationCompositionInstantiationProviderTest {
var supervisionAcHandler = mock(SupervisionAcHandler.class);
var acmParticipantProvider = mock(AcmParticipantProvider.class);
var instantiationProvider = new AutomationCompositionInstantiationProvider(acProvider, acDefinitionProvider,
- null, supervisionAcHandler, acmParticipantProvider);
+ null, supervisionAcHandler, acmParticipantProvider,
+ CommonTestData.getTestParamaterGroup());
var instantiationResponse = instantiationProvider.updateAutomationComposition(
automationCompositionUpdate.getCompositionId(), automationCompositionUpdate);
@@ -187,7 +191,8 @@ class AutomationCompositionInstantiationProviderTest {
var instantiationProvider =
new AutomationCompositionInstantiationProvider(acProvider, mock(AcDefinitionProvider.class), null,
- mock(SupervisionAcHandler.class), mock(AcmParticipantProvider.class));
+ mock(SupervisionAcHandler.class), mock(AcmParticipantProvider.class),
+ mock(AcRuntimeParameterGroup.class));
var compositionId = automationCompositionUpdate.getCompositionId();
assertThatThrownBy(
@@ -209,7 +214,8 @@ class AutomationCompositionInstantiationProviderTest {
var instantiationProvider =
new AutomationCompositionInstantiationProvider(acProvider, mock(AcDefinitionProvider.class), null,
- mock(SupervisionAcHandler.class), mock(AcmParticipantProvider.class));
+ mock(SupervisionAcHandler.class), mock(AcmParticipantProvider.class),
+ mock(AcRuntimeParameterGroup.class));
var compositionId = automationCompositionUpdate.getCompositionId();
assertThatThrownBy(
@@ -246,7 +252,8 @@ class AutomationCompositionInstantiationProviderTest {
var supervisionAcHandler = mock(SupervisionAcHandler.class);
var acmParticipantProvider = mock(AcmParticipantProvider.class);
var instantiationProvider = new AutomationCompositionInstantiationProvider(acProvider, acDefinitionProvider,
- null, supervisionAcHandler, acmParticipantProvider);
+ null, supervisionAcHandler, acmParticipantProvider,
+ mock(AcRuntimeParameterGroup.class));
assertThatThrownBy(
() -> instantiationProvider.updateAutomationComposition(compositionId, automationCompositionUpdate))
.hasMessageMatching("\"AutomationComposition\" INVALID, item has status INVALID\n"
@@ -263,9 +270,10 @@ class AutomationCompositionInstantiationProviderTest {
var acDefinitionProvider = mock(AcDefinitionProvider.class);
var supervisionAcHandler = mock(SupervisionAcHandler.class);
var acmParticipantProvider = mock(AcmParticipantProvider.class);
+ var acRuntimeParameterGroup = mock(AcRuntimeParameterGroup.class);
var instantiationProvider = new AutomationCompositionInstantiationProvider(acProvider, acDefinitionProvider,
- null, supervisionAcHandler, acmParticipantProvider);
+ null, supervisionAcHandler, acmParticipantProvider, acRuntimeParameterGroup);
when(acProvider.getAutomationComposition(automationComposition.getInstanceId()))
.thenReturn(automationComposition);
@@ -295,9 +303,11 @@ class AutomationCompositionInstantiationProviderTest {
automationComposition.setLockState(lockState);
var acProvider = mock(AutomationCompositionProvider.class);
var acDefinitionProvider = mock(AcDefinitionProvider.class);
+ var acRuntimeParamaterGroup = mock(AcRuntimeParameterGroup.class);
var instantiationProvider =
- new AutomationCompositionInstantiationProvider(acProvider, acDefinitionProvider, null, null, null);
+ new AutomationCompositionInstantiationProvider(acProvider, acDefinitionProvider, null, null, null,
+ acRuntimeParamaterGroup);
when(acProvider.getAutomationComposition(automationComposition.getInstanceId()))
.thenReturn(automationComposition);
@@ -326,7 +336,8 @@ class AutomationCompositionInstantiationProviderTest {
var acmParticipantProvider = mock(AcmParticipantProvider.class);
var instantiationProvider = new AutomationCompositionInstantiationProvider(acProvider, acDefinitionProvider,
- null, null, acmParticipantProvider);
+ null, null, acmParticipantProvider,
+ CommonTestData.getTestParamaterGroup());
var instantiationResponse = instantiationProvider.createAutomationComposition(
automationCompositionCreate.getCompositionId(), automationCompositionCreate);
@@ -353,7 +364,7 @@ class AutomationCompositionInstantiationProviderTest {
var acProvider = mock(AutomationCompositionProvider.class);
var provider = new AutomationCompositionInstantiationProvider(acProvider, acDefinitionProvider, null, null,
- acmParticipantProvider);
+ acmParticipantProvider, CommonTestData.getTestParamaterGroup());
assertThatThrownBy(() -> provider.createAutomationComposition(compositionId, automationComposition))
.hasMessageMatching(AC_ELEMENT_NAME_NOT_FOUND);
@@ -374,7 +385,8 @@ class AutomationCompositionInstantiationProviderTest {
when(acProvider.getAutomationComposition(automationComposition.getInstanceId()))
.thenReturn(automationComposition);
var provider = new AutomationCompositionInstantiationProvider(acProvider, mock(AcDefinitionProvider.class),
- null, null, null);
+ null, null, null,
+ mock(AcRuntimeParameterGroup.class));
var compositionId = automationComposition.getCompositionId();
assertThatThrownBy(() -> provider.createAutomationComposition(compositionId, automationComposition))
@@ -393,7 +405,8 @@ class AutomationCompositionInstantiationProviderTest {
when(acProvider.getAutomationComposition(automationComposition.getInstanceId()))
.thenReturn(automationComposition);
var provider = new AutomationCompositionInstantiationProvider(acProvider, mock(AcDefinitionProvider.class),
- null, null, null);
+ null, null, null,
+ mock(AcRuntimeParameterGroup.class));
var compositionId = automationComposition.getCompositionId();
var wrongCompositionId = UUID.randomUUID();
@@ -419,7 +432,8 @@ class AutomationCompositionInstantiationProviderTest {
when(acDefinitionProvider.findAcDefinition(compositionId)).thenReturn(Optional.of(acDefinition));
var acProvider = mock(AutomationCompositionProvider.class);
var provider =
- new AutomationCompositionInstantiationProvider(acProvider, acDefinitionProvider, null, null, null);
+ new AutomationCompositionInstantiationProvider(acProvider, acDefinitionProvider, null, null, null,
+ null);
var automationComposition =
InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Crud");
@@ -448,7 +462,8 @@ class AutomationCompositionInstantiationProviderTest {
var supervisionAcHandler = mock(SupervisionAcHandler.class);
var acmParticipantProvider = mock(AcmParticipantProvider.class);
var provider = new AutomationCompositionInstantiationProvider(acProvider, acDefinitionProvider,
- new AcInstanceStateResolver(), supervisionAcHandler, acmParticipantProvider);
+ new AcInstanceStateResolver(), supervisionAcHandler, acmParticipantProvider,
+ mock(AcRuntimeParameterGroup.class));
var acInstanceStateUpdate = new AcInstanceStateUpdate();
acInstanceStateUpdate.setDeployOrder(DeployOrder.DEPLOY);
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 985d9a0c3..1e5aa6c89 100755
--- 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
@@ -74,6 +74,8 @@ class InstantiationControllerTest extends CommonRestController {
private static ToscaServiceTemplate serviceTemplate = new ToscaServiceTemplate();
+ private static final String NODE_TYPE = "org.onap.policy.clamp.acm.AutomationComposition";
+
@Autowired
private AcDefinitionProvider acDefinitionProvider;
@@ -338,7 +340,7 @@ class InstantiationControllerTest extends CommonRestController {
var serviceTemplateCreate = new ToscaServiceTemplate(serviceTemplate);
serviceTemplateCreate.setName(name);
var acmDefinition = CommonTestData.createAcDefinition(serviceTemplate, AcTypeState.PRIMED);
- acDefinitionProvider.updateAcDefinition(acmDefinition);
+ acDefinitionProvider.updateAcDefinition(acmDefinition, NODE_TYPE);
saveDummyParticipantInDb();
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 9ce63b005..e1c6127d4 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
@@ -29,6 +29,7 @@ import static org.onap.policy.clamp.acm.runtime.util.CommonTestData.TOSCA_SERVIC
import java.util.Optional;
import org.junit.jupiter.api.Test;
import org.onap.policy.clamp.acm.runtime.instantiation.InstantiationUtils;
+import org.onap.policy.clamp.acm.runtime.main.parameters.AcRuntimeParameterGroup;
import org.onap.policy.clamp.acm.runtime.util.CommonTestData;
import org.onap.policy.clamp.models.acm.concepts.AcTypeState;
import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
@@ -44,7 +45,8 @@ class SupervisionHandlerTest {
participantPrimeAckMessage.setParticipantId(CommonTestData.getParticipantId());
participantPrimeAckMessage.setState(ParticipantState.ON_LINE);
var acDefinitionProvider = mock(AcDefinitionProvider.class);
- var handler = new SupervisionHandler(acDefinitionProvider);
+ var acRuntimeParameterGroup = mock(AcRuntimeParameterGroup.class);
+ var handler = new SupervisionHandler(acDefinitionProvider, acRuntimeParameterGroup);
handler.handleParticipantMessage(participantPrimeAckMessage);
verify(acDefinitionProvider).findAcDefinition(any());
@@ -63,8 +65,9 @@ class SupervisionHandlerTest {
var acDefinitionProvider = mock(AcDefinitionProvider.class);
when(acDefinitionProvider.findAcDefinition(acDefinition.getCompositionId()))
.thenReturn(Optional.of(acDefinition));
+ var acRuntimeParameterGroup = mock(AcRuntimeParameterGroup.class);
- var handler = new SupervisionHandler(acDefinitionProvider);
+ var handler = new SupervisionHandler(acDefinitionProvider, acRuntimeParameterGroup);
handler.handleParticipantMessage(participantPrimeAckMessage);
verify(acDefinitionProvider).findAcDefinition(any());
@@ -86,11 +89,11 @@ class SupervisionHandlerTest {
when(acDefinitionProvider.findAcDefinition(acDefinition.getCompositionId()))
.thenReturn(Optional.of(acDefinition));
- var handler = new SupervisionHandler(acDefinitionProvider);
+ var handler = new SupervisionHandler(acDefinitionProvider, CommonTestData.getTestParamaterGroup());
handler.handleParticipantMessage(participantPrimeAckMessage);
verify(acDefinitionProvider).findAcDefinition(any());
- verify(acDefinitionProvider).updateAcDefinition(any());
+ verify(acDefinitionProvider).updateAcDefinition(any(), any());
}
@Test
@@ -110,10 +113,10 @@ class SupervisionHandlerTest {
when(acDefinitionProvider.findAcDefinition(acDefinition.getCompositionId()))
.thenReturn(Optional.of(acDefinition));
- var handler = new SupervisionHandler(acDefinitionProvider);
+ var handler = new SupervisionHandler(acDefinitionProvider, CommonTestData.getTestParamaterGroup());
handler.handleParticipantMessage(participantPrimeAckMessage);
verify(acDefinitionProvider).findAcDefinition(any());
- verify(acDefinitionProvider).updateAcDefinition(any());
+ verify(acDefinitionProvider).updateAcDefinition(any(), any());
}
}
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java
index 670806f65..cfef1a5ee 100755
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java
@@ -21,6 +21,7 @@
package org.onap.policy.clamp.acm.runtime.supervision;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -32,6 +33,7 @@ import java.util.Set;
import java.util.UUID;
import org.junit.jupiter.api.Test;
import org.onap.policy.clamp.acm.runtime.instantiation.InstantiationUtils;
+import org.onap.policy.clamp.acm.runtime.main.parameters.AcRuntimeParameterGroup;
import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantDeregisterAckPublisher;
import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantRegisterAckPublisher;
import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantRestartPublisher;
@@ -71,7 +73,8 @@ class SupervisionParticipantHandlerTest {
var handler =
new SupervisionParticipantHandler(participantProvider, mock(ParticipantRegisterAckPublisher.class),
participantDeregisterAckPublisher, mock(AutomationCompositionProvider.class),
- mock(AcDefinitionProvider.class), mock(ParticipantRestartPublisher.class));
+ mock(AcDefinitionProvider.class), mock(ParticipantRestartPublisher.class),
+ mock(AcRuntimeParameterGroup.class));
handler.handleParticipantMessage(participantDeregisterMessage);
@@ -91,7 +94,8 @@ class SupervisionParticipantHandlerTest {
var participantRegisterAckPublisher = mock(ParticipantRegisterAckPublisher.class);
var handler = new SupervisionParticipantHandler(participantProvider, participantRegisterAckPublisher,
mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionProvider.class),
- mock(AcDefinitionProvider.class), mock(ParticipantRestartPublisher.class));
+ mock(AcDefinitionProvider.class), mock(ParticipantRestartPublisher.class),
+ mock(AcRuntimeParameterGroup.class));
handler.handleParticipantMessage(participantRegisterMessage);
verify(participantProvider).saveParticipant(any());
@@ -141,11 +145,12 @@ class SupervisionParticipantHandlerTest {
var participantRestartPublisher = mock(ParticipantRestartPublisher.class);
var handler = new SupervisionParticipantHandler(participantProvider, participantRegisterAckPublisher,
mock(ParticipantDeregisterAckPublisher.class), automationCompositionProvider, acDefinitionProvider,
- participantRestartPublisher);
+ participantRestartPublisher, CommonTestData.getTestParamaterGroup());
handler.handleParticipantMessage(participantRegisterMessage);
verify(participantRegisterAckPublisher).send(participantRegisterMessage.getMessageId(), participantId);
- verify(acDefinitionProvider).updateAcDefinition(any(AutomationCompositionDefinition.class));
+ verify(acDefinitionProvider).updateAcDefinition(any(AutomationCompositionDefinition.class),
+ eq(CommonTestData.TOSCA_COMP_NAME));
verify(participantRestartPublisher).send(any(), any(AutomationCompositionDefinition.class), any());
}
@@ -159,7 +164,8 @@ class SupervisionParticipantHandlerTest {
var handler =
new SupervisionParticipantHandler(participantProvider, mock(ParticipantRegisterAckPublisher.class),
mock(ParticipantDeregisterAckPublisher.class), automationCompositionProvider,
- mock(AcDefinitionProvider.class), mock(ParticipantRestartPublisher.class));
+ mock(AcDefinitionProvider.class), mock(ParticipantRestartPublisher.class),
+ mock(AcRuntimeParameterGroup.class));
var participant = CommonTestData.createParticipant(CommonTestData.getParticipantId());
when(participantProvider.findParticipant(CommonTestData.getParticipantId()))
.thenReturn(Optional.of(participant));
@@ -194,10 +200,11 @@ class SupervisionParticipantHandlerTest {
var handler =
new SupervisionParticipantHandler(participantProvider, mock(ParticipantRegisterAckPublisher.class),
mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionProvider.class),
- acDefinitionProvider, mock(ParticipantRestartPublisher.class));
+ acDefinitionProvider, mock(ParticipantRestartPublisher.class),
+ CommonTestData.getTestParamaterGroup());
handler.handleParticipantMessage(participantStatusMessage);
- verify(acDefinitionProvider).updateAcDefinition(acDefinition);
+ verify(acDefinitionProvider).updateAcDefinition(acDefinition, CommonTestData.TOSCA_COMP_NAME);
}
@Test
@@ -210,7 +217,8 @@ class SupervisionParticipantHandlerTest {
var handler =
new SupervisionParticipantHandler(participantProvider, mock(ParticipantRegisterAckPublisher.class),
mock(ParticipantDeregisterAckPublisher.class), automationCompositionProvider,
- mock(AcDefinitionProvider.class), mock(ParticipantRestartPublisher.class));
+ mock(AcDefinitionProvider.class), mock(ParticipantRestartPublisher.class),
+ mock(AcRuntimeParameterGroup.class));
handler.handleParticipantMessage(participantStatusMessage);
verify(participantProvider).saveParticipant(any());
@@ -227,7 +235,8 @@ class SupervisionParticipantHandlerTest {
var handler =
new SupervisionParticipantHandler(participantProvider, mock(ParticipantRegisterAckPublisher.class),
mock(ParticipantDeregisterAckPublisher.class), automationCompositionProvider,
- mock(AcDefinitionProvider.class), mock(ParticipantRestartPublisher.class));
+ mock(AcDefinitionProvider.class), mock(ParticipantRestartPublisher.class),
+ mock(AcRuntimeParameterGroup.class));
var participant = CommonTestData.createParticipant(CommonTestData.getParticipantId());
participant.setParticipantState(ParticipantState.OFF_LINE);
when(participantProvider.findParticipant(CommonTestData.getParticipantId()))
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java
index 9b596c89a..5fe4f4c25 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java
@@ -23,6 +23,7 @@ package org.onap.policy.clamp.acm.runtime.supervision;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -80,7 +81,8 @@ class SupervisionScannerTest {
mock(AutomationCompositionStateChangePublisher.class), mock(AutomationCompositionDeployPublisher.class),
acRuntimeParameterGroup);
supervisionScanner.run();
- verify(acDefinitionProvider, times(0)).updateAcDefinition(any(AutomationCompositionDefinition.class));
+ verify(acDefinitionProvider, times(0)).updateAcDefinition(any(AutomationCompositionDefinition.class),
+ eq(CommonTestData.TOSCA_COMP_NAME));
}
@Test
@@ -91,14 +93,16 @@ class SupervisionScannerTest {
mock(AutomationCompositionStateChangePublisher.class), mock(AutomationCompositionDeployPublisher.class),
acRuntimeParameterGroup);
supervisionScanner.run();
- verify(acDefinitionProvider, times(0)).updateAcDefinition(any(AutomationCompositionDefinition.class));
+ verify(acDefinitionProvider, times(0)).updateAcDefinition(any(AutomationCompositionDefinition.class),
+ eq(CommonTestData.TOSCA_COMP_NAME));
acRuntimeParameterGroup.getParticipantParameters().setMaxStatusWaitMs(-1);
supervisionScanner = new SupervisionScanner(mock(AutomationCompositionProvider.class), acDefinitionProvider,
mock(AutomationCompositionStateChangePublisher.class), mock(AutomationCompositionDeployPublisher.class),
acRuntimeParameterGroup);
supervisionScanner.run();
- verify(acDefinitionProvider).updateAcDefinition(any(AutomationCompositionDefinition.class));
+ verify(acDefinitionProvider).updateAcDefinition(any(AutomationCompositionDefinition.class),
+ eq(CommonTestData.TOSCA_COMP_NAME));
}
@Test
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/comm/SupervisionMessagesTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/comm/SupervisionMessagesTest.java
index 06684d863..85444ed2f 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/comm/SupervisionMessagesTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/comm/SupervisionMessagesTest.java
@@ -35,6 +35,7 @@ import java.util.Map;
import java.util.UUID;
import org.junit.jupiter.api.Test;
import org.onap.policy.clamp.acm.runtime.instantiation.InstantiationUtils;
+import org.onap.policy.clamp.acm.runtime.main.parameters.AcRuntimeParameterGroup;
import org.onap.policy.clamp.acm.runtime.participants.AcmParticipantProvider;
import org.onap.policy.clamp.acm.runtime.supervision.SupervisionAcHandler;
import org.onap.policy.clamp.acm.runtime.supervision.SupervisionHandler;
@@ -67,6 +68,8 @@ class SupervisionMessagesTest {
private static final CommInfrastructure INFRA = CommInfrastructure.NOOP;
private static final String TOPIC = "my-topic";
+ private static final String TOSCA_ELEMENT_NAME = "org.onap.policy.clamp.acm.AutomationCompositionElement";
+
@Test
void testSendParticipantRegisterAck() {
var acRegisterAckPublisher = new ParticipantRegisterAckPublisher();
@@ -146,7 +149,7 @@ class SupervisionMessagesTest {
@Test
void testParticipantPrimePublisherDecommissioning() {
var publisher = new ParticipantPrimePublisher(mock(ParticipantProvider.class),
- mock(AcmParticipantProvider.class));
+ mock(AcmParticipantProvider.class), mock(AcRuntimeParameterGroup.class));
var topicSink = mock(TopicSink.class);
publisher.active(List.of(topicSink));
publisher.sendDepriming(UUID.randomUUID());
@@ -167,7 +170,8 @@ class SupervisionMessagesTest {
participantId);
var participantProvider = mock(ParticipantProvider.class);
when(participantProvider.getSupportedElementMap()).thenReturn(supportedElementMap);
- var publisher = new ParticipantPrimePublisher(participantProvider, mock(AcmParticipantProvider.class));
+ var publisher = new ParticipantPrimePublisher(participantProvider, mock(AcmParticipantProvider.class),
+ CommonTestData.getTestParamaterGroup());
var topicSink = mock(TopicSink.class);
publisher.active(List.of(topicSink));
var serviceTemplate = InstantiationUtils.getToscaServiceTemplate(TOSCA_SERVICE_TEMPLATE_YAML);
@@ -176,7 +180,8 @@ class SupervisionMessagesTest {
var acmDefinition = new AutomationCompositionDefinition();
acmDefinition.setCompositionId(UUID.randomUUID());
acmDefinition.setServiceTemplate(serviceTemplate);
- var acElements = AcmUtils.extractAcElementsFromServiceTemplate(serviceTemplate);
+ var acElements = AcmUtils
+ .extractAcElementsFromServiceTemplate(serviceTemplate, TOSCA_ELEMENT_NAME);
acmDefinition.setElementStateMap(AcmUtils.createElementStateMap(acElements, AcTypeState.COMMISSIONED));
var preparation = publisher.prepareParticipantPriming(acmDefinition);
publisher.sendPriming(preparation, acmDefinition.getCompositionId(), null);
@@ -223,7 +228,7 @@ class SupervisionMessagesTest {
@Test
void testParticipantRestartPublisher() {
- var publisher = new ParticipantRestartPublisher();
+ var publisher = new ParticipantRestartPublisher(CommonTestData.getTestParamaterGroup());
var topicSink = mock(TopicSink.class);
publisher.active(List.of(topicSink));
@@ -233,7 +238,8 @@ class SupervisionMessagesTest {
var acmDefinition = new AutomationCompositionDefinition();
acmDefinition.setCompositionId(UUID.randomUUID());
acmDefinition.setServiceTemplate(serviceTemplate);
- var acElements = AcmUtils.extractAcElementsFromServiceTemplate(serviceTemplate);
+ var acElements = AcmUtils
+ .extractAcElementsFromServiceTemplate(serviceTemplate, "");
acmDefinition.setElementStateMap(AcmUtils.createElementStateMap(acElements, AcTypeState.PRIMED));
var automationComposition =
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 0620b05a3..54d312477 100755
--- 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
@@ -24,6 +24,7 @@ import jakarta.ws.rs.core.Response.Status;
import java.util.List;
import java.util.UUID;
import org.onap.policy.clamp.acm.runtime.main.parameters.AcRuntimeParameterGroup;
+import org.onap.policy.clamp.acm.runtime.main.parameters.AcmParameters;
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.AutomationCompositionDefinition;
@@ -45,6 +46,9 @@ public class CommonTestData {
private static final Coder CODER = new StandardCoder();
public static final String TOSCA_SERVICE_TEMPLATE_YAML = "clamp/acm/pmsh/funtional-pmsh-usecase.yaml";
+ public static final String TOSCA_COMP_NAME = "org.onap.policy.clamp.acm.AutomationComposition";
+ public static final String TOSCA_ELEMENT_NAME = "org.onap.policy.clamp.acm.AutomationCompositionElement";
+
/**
* Gets the standard automation composition parameters.
*
@@ -127,7 +131,8 @@ public class CommonTestData {
acDefinition.setCompositionId(UUID.randomUUID());
acDefinition.setState(state);
acDefinition.setServiceTemplate(serviceTemplate);
- var acElements = AcmUtils.extractAcElementsFromServiceTemplate(serviceTemplate);
+ var acElements = AcmUtils
+ .extractAcElementsFromServiceTemplate(serviceTemplate, TOSCA_ELEMENT_NAME);
acDefinition.setElementStateMap(AcmUtils.createElementStateMap(acElements, state));
if (AcTypeState.PRIMED.equals(state)) {
for (var element : acDefinition.getElementStateMap().values()) {
@@ -137,4 +142,18 @@ public class CommonTestData {
return acDefinition;
}
+ /**
+ * Create a new Test parameter group.
+ *
+ * @return a new AutomationCompositionDefinition
+ */
+ public static AcRuntimeParameterGroup getTestParamaterGroup() {
+ var acRuntimeParameterGroup = new AcRuntimeParameterGroup();
+ AcmParameters acmParameters = new AcmParameters();
+ acmParameters.setToscaCompositionName(TOSCA_COMP_NAME);
+ acmParameters.setToscaElementName(TOSCA_ELEMENT_NAME);
+ acRuntimeParameterGroup.setAcmParameters(acmParameters);
+ return acRuntimeParameterGroup;
+ }
+
}
diff --git a/runtime-acm/src/test/resources/application-test.yaml b/runtime-acm/src/test/resources/application-test.yaml
index e6fed2475..aa4044534 100644
--- a/runtime-acm/src/test/resources/application-test.yaml
+++ b/runtime-acm/src/test/resources/application-test.yaml
@@ -38,3 +38,6 @@ runtime:
servers:
- localhost
topic: POLICY-ACRUNTIME-PARTICIPANT
+ acmParameters:
+ acElementName: org.onap.policy.clamp.acm.AutomationCompositionElement
+ acNodeType: org.onap.policy.clamp.acm.AutomationComposition
diff --git a/runtime-acm/src/test/resources/parameters/TestParameters.json b/runtime-acm/src/test/resources/parameters/TestParameters.json
index c44e92e4d..92e81d29e 100644
--- a/runtime-acm/src/test/resources/parameters/TestParameters.json
+++ b/runtime-acm/src/test/resources/parameters/TestParameters.json
@@ -40,5 +40,10 @@
"topicCommInfrastructure": "dmaap"
}
]
+ },
+ "acmParameters": {
+ "toscaElementName": "org.onap.policy.clamp.acm.AutomationCompositionElement",
+ "toscaCompositionName": "org.onap.policy.clamp.acm.AutomationComposition"
}
+
}