From b2393969603cb943bc76f2b65da748b871ee9d17 Mon Sep 17 00:00:00 2001 From: FrancescoFioraEst Date: Thu, 7 Dec 2023 08:58:32 +0000 Subject: Add validation for AC instance element id Issue-ID: POLICY-4900 Change-Id: I78be5924950eec508856be5850a3a749860e0e49 Signed-off-by: FrancescoFioraEst --- .../runtime/instantiation/InstantiationUtils.java | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'runtime-acm/src/test/java/org/onap') 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); @@ -83,18 +92,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. * -- cgit 1.2.3-korg