aboutsummaryrefslogtreecommitdiffstats
path: root/runtime-acm
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2023-12-07 08:58:32 +0000
committerFrancesco Fiora <francesco.fiora@est.tech>2023-12-07 11:11:41 +0000
commitb2393969603cb943bc76f2b65da748b871ee9d17 (patch)
tree80610ffcca8752119e8cc105d07002c541fad5ec /runtime-acm
parent3b28926870225fce8df70030d931d5027943e775 (diff)
Add validation for AC instance element id
Issue-ID: POLICY-4900 Change-Id: I78be5924950eec508856be5850a3a749860e0e49 Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'runtime-acm')
-rwxr-xr-xruntime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java2
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/InstantiationUtils.java21
2 files changed, 11 insertions, 12 deletions
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 af4e844d5..9f126406b 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
@@ -237,6 +237,8 @@ public class AutomationCompositionInstantiationProvider {
acDefinitionOpt.get().getServiceTemplate(),
acRuntimeParameterGroup.getAcmParameters().getToscaCompositionName()));
+ result.addResult(automationCompositionProvider.validateElementIds(automationComposition));
+
if (result.isValid()) {
for (var element : automationComposition.getElements().values()) {
var name = element.getDefinition().getName();
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/InstantiationUtils.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/InstantiationUtils.java
index 38c63fa9b..8639dffcd 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/InstantiationUtils.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/InstantiationUtils.java
@@ -25,6 +25,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
import java.io.File;
+import java.util.ArrayList;
+import java.util.UUID;
import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
import org.onap.policy.clamp.models.acm.messages.rest.instantiation.InstantiationResponse;
import org.onap.policy.common.utils.coder.Coder;
@@ -56,6 +58,13 @@ public class InstantiationUtils {
// add suffix to name
automationComposition.setName(automationComposition.getName() + suffix);
+ var elements = new ArrayList<>(automationComposition.getElements().values());
+ automationComposition.getElements().clear();
+ for (var element : elements) {
+ // set unique UUID to the element
+ element.setId(UUID.randomUUID());
+ automationComposition.getElements().put(element.getId(), element);
+ }
return automationComposition;
} catch (CoderException e) {
fail("Cannot read or decode " + path);
@@ -84,18 +93,6 @@ public class InstantiationUtils {
}
/**
- * Assert that Instantiation Response contains proper AutomationCompositions.
- *
- * @param response InstantiationResponse
- * @param affectedAutomationComposition ToscaConceptIdentifier
- */
- public static void assertInstantiationResponse(InstantiationResponse response,
- ToscaConceptIdentifier affectedAutomationComposition) {
- assertThat(response).isNotNull();
- assertEquals(response.getAffectedAutomationComposition(), affectedAutomationComposition);
- }
-
- /**
* Assert that Instantiation Response contains AutomationComposition equals to automationComposition.
*
* @param response InstantiationResponse