aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlapentafd <francesco.lapenta@est.tech>2022-12-06 12:13:22 +0000
committerFrancesco Davide Lapenta <francesco.lapenta@est.tech>2022-12-06 16:02:43 +0000
commit32909d8d6e1be723cd33834d191ccb92b4dccfc7 (patch)
tree88ba9ab9f1f32bae234aa770cf8507cca9936738
parent6f3447836b04f2fbea1fa4fca526d549bec42661 (diff)
Clamp models utils code coverage
Issue-ID: POLICY-4476 Change-Id: Ia18a80565abbf8e9aaeba270f60b6984aa8078ef Signed-off-by: lapentafd <francesco.lapenta@est.tech>
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java37
1 files changed, 37 insertions, 0 deletions
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 ccb4b8360..617b2459c 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
@@ -22,19 +22,26 @@ package org.onap.policy.clamp.models.acm.utils;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
+import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+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.ParticipantDefinition;
import org.onap.policy.clamp.models.acm.concepts.ParticipantUpdates;
import org.onap.policy.clamp.models.acm.concepts.ParticipantUtils;
+import org.onap.policy.common.utils.coder.CoderException;
+import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.common.utils.coder.StandardYamlCoder;
import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
@@ -115,6 +122,36 @@ class AcmUtilsTest {
assertThat(result).hasSize(6);
}
+ @Test
+ void testValidateAutomationComposition() throws Exception {
+ var automationComposition = getDummyAutomationComposition();
+ var toscaServiceTemplate = getDummyToscaServiceTemplate();
+ var result = AcmUtils.validateAutomationComposition(automationComposition, toscaServiceTemplate);
+ assertNotNull(result);
+ assertFalse(result.isValid());
+
+ Map<String, ToscaNodeTemplate> nodeTemplates = new HashMap<>();
+ var nodeTemplate = new ToscaNodeTemplate();
+ nodeTemplate.setType("org.onap.policy.clamp.acm.AutomationComposition");
+ nodeTemplates.put("org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant", nodeTemplate);
+ toscaServiceTemplate.getToscaTopologyTemplate().setNodeTemplates(nodeTemplates);
+ var result2 = AcmUtils.validateAutomationComposition(automationComposition, toscaServiceTemplate);
+ toscaServiceTemplate.setToscaTopologyTemplate(null);
+ assertFalse(result2.isValid());
+ }
+
+ private AutomationComposition getDummyAutomationComposition() throws CoderException {
+ var automationComposition = new AutomationComposition();
+ var element = new StandardCoder().decode(
+ new File("src/test/resources/json/AutomationCompositionElementNoOrderedState.json"),
+ AutomationCompositionElement.class);
+ automationComposition.setCompositionId(UUID.randomUUID());
+ Map<UUID, AutomationCompositionElement> map = new LinkedHashMap<>();
+ map.put(UUID.randomUUID(), element);
+ automationComposition.setElements(map);
+ return automationComposition;
+ }
+
private ToscaServiceTemplate getDummyToscaServiceTemplate() {
var toscaServiceTemplate = new ToscaServiceTemplate();
var policyTypes = getDummyPolicyTypesMap();