summaryrefslogtreecommitdiffstats
path: root/models/src
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2022-12-19 14:43:11 +0000
committerFrancescoFioraEst <francesco.fiora@est.tech>2022-12-20 10:35:32 +0000
commitc71863696d729286502f951a64c3d2193c6641e7 (patch)
tree024363ddde071c3f59d7468bdc9ddfd011d3701e /models/src
parent66208f7d9ec65d859803ed347c3fdecd2d99022f (diff)
Add compositionId into Messages between ACM and Participants
Issue-ID: POLICY-4489 Change-Id: I1fb8c04eacee040d5c944c522ca59a2a9a50376b Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'models/src')
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElementDefinition.java10
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionUpdate.java4
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessage.java3
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java115
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusTest.java7
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdateTest.java8
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java46
7 files changed, 6 insertions, 187 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElementDefinition.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElementDefinition.java
index aebee0e2c..cba6a93bd 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElementDefinition.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElementDefinition.java
@@ -20,17 +20,12 @@
package org.onap.policy.clamp.models.acm.concepts;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.function.UnaryOperator;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;
-import org.onap.policy.models.base.PfUtils;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty;
/**
* Class to represent an automation composition element definition instance.
@@ -46,10 +41,6 @@ public class AutomationCompositionElementDefinition {
// The definition of the Automation Composition Element in TOSCA
private ToscaNodeTemplate automationCompositionElementToscaNodeTemplate;
- // A map indexed by the property name. Each map entry is the serialized value of the property,
- // which can be deserialized into an instance of the type of the property.
- private Map<String, ToscaProperty> commonPropertiesMap = new LinkedHashMap<>();
-
/**
* Copy constructor, does a deep copy but as all fields here are immutable, it's just a regular copy.
*
@@ -59,6 +50,5 @@ public class AutomationCompositionElementDefinition {
this.acElementDefinitionId = acElementDefinition.acElementDefinitionId;
this.automationCompositionElementToscaNodeTemplate =
new ToscaNodeTemplate(acElementDefinition.automationCompositionElementToscaNodeTemplate);
- this.commonPropertiesMap = PfUtils.mapMap(acElementDefinition.commonPropertiesMap, UnaryOperator.identity());
}
}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionUpdate.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionUpdate.java
index 55fcc7462..6bc79f67e 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionUpdate.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionUpdate.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -58,7 +58,7 @@ public class AutomationCompositionUpdate extends ParticipantMessage {
*/
public AutomationCompositionUpdate(AutomationCompositionUpdate source) {
super(source);
-
+ this.startPhase = source.startPhase;
this.participantUpdatesList = PfUtils.mapList(source.participantUpdatesList, ParticipantUpdates::new);
}
}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessage.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessage.java
index ae6dce515..c1ef4b416 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessage.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessage.java
@@ -62,6 +62,8 @@ public class ParticipantMessage {
*/
private UUID automationCompositionId;
+ private UUID compositionId;
+
/**
* Constructor for instantiating a participant message class.
*
@@ -81,6 +83,7 @@ public class ParticipantMessage {
this.participantType = source.participantType;
this.participantId = source.participantId;
this.automationCompositionId = source.automationCompositionId;
+ this.compositionId = source.compositionId;
}
/**
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 cdd3e1e54..220a3c132 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java
@@ -22,7 +22,6 @@ package org.onap.policy.clamp.models.acm.utils;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
@@ -41,11 +40,8 @@ import org.onap.policy.common.parameters.BeanValidationResult;
import org.onap.policy.common.parameters.ObjectValidationResult;
import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.common.parameters.ValidationStatus;
-import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeType;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.onap.policy.models.tosca.authorative.concepts.ToscaTopologyTemplate;
@@ -120,21 +116,13 @@ public final class AcmUtils {
* @param entryKey key for the entry
* @param entryValue value relates to toscaNodeTemplate
* @param participantDefinitionUpdates list of participantDefinitionUpdates
- * @param commonPropertiesMap common properties map
*/
public static void prepareParticipantDefinitionUpdate(ToscaConceptIdentifier acParticipantType, String entryKey,
- ToscaNodeTemplate entryValue, List<ParticipantDefinition> participantDefinitionUpdates,
- Map<String, ToscaNodeType> commonPropertiesMap) {
+ ToscaNodeTemplate entryValue, List<ParticipantDefinition> participantDefinitionUpdates) {
var acDefinition = new AutomationCompositionElementDefinition();
acDefinition.setAcElementDefinitionId(new ToscaConceptIdentifier(entryKey, entryValue.getVersion()));
acDefinition.setAutomationCompositionElementToscaNodeTemplate(entryValue);
- if (commonPropertiesMap != null) {
- ToscaNodeType nodeType = commonPropertiesMap.get(entryValue.getType());
- if (nodeType != null) {
- acDefinition.setCommonPropertiesMap(nodeType.getProperties());
- }
- }
List<AutomationCompositionElementDefinition> automationCompositionElementDefinitionList = new ArrayList<>();
@@ -252,105 +240,4 @@ public final class AcmUtils {
.collect(Collectors.toList());
// @formatter:on
}
-
- /**
- * Get the initial node types with common or instance properties.
- *
- * @param fullNodeTypes map of all the node types in the specified template
- * @param common boolean to indicate whether common or instance properties are required
- * @return node types map that only has common properties
- */
- private static Map<String, ToscaNodeType> getInitialNodeTypesMap(Map<String, ToscaNodeType> fullNodeTypes,
- boolean common) {
-
- var tempNodeTypesMap = new HashMap<String, ToscaNodeType>();
-
- fullNodeTypes.forEach((key, nodeType) -> {
- var tempToscaNodeType = new ToscaNodeType();
- tempToscaNodeType.setName(key);
-
- var resultantPropertyMap = findCommonOrInstancePropsInNodeTypes(nodeType, common);
-
- if (!resultantPropertyMap.isEmpty()) {
- tempToscaNodeType.setProperties(resultantPropertyMap);
- tempNodeTypesMap.put(key, tempToscaNodeType);
- }
- });
- return tempNodeTypesMap;
- }
-
- private static Map<String, ToscaProperty> findCommonOrInstancePropsInNodeTypes(ToscaNodeType nodeType,
- boolean common) {
-
- var tempCommonPropertyMap = new HashMap<String, ToscaProperty>();
- var tempInstancePropertyMap = new HashMap<String, ToscaProperty>();
-
- nodeType.getProperties().forEach((propKey, prop) -> {
-
- if (prop.getMetadata() != null) {
- prop.getMetadata().forEach((k, v) -> {
- if (k.equals("common") && v.equals("true") && common) {
- tempCommonPropertyMap.put(propKey, prop);
- } else if (k.equals("common") && v.equals("false") && !common) {
- tempInstancePropertyMap.put(propKey, prop);
- }
-
- });
- } else {
- tempInstancePropertyMap.put(propKey, prop);
- }
- });
-
- if (tempCommonPropertyMap.isEmpty() && !common) {
- return tempInstancePropertyMap;
- } else {
- return tempCommonPropertyMap;
- }
- }
-
- /**
- * Get the node types derived from those that have common properties.
- *
- * @param initialNodeTypes map of all the node types in the specified template
- * @param filteredNodeTypes map of all the node types that have common or instance properties
- * @return all node types that have common properties including their children
- * @throws PfModelException on errors getting node type with common properties
- */
- private static Map<String, ToscaNodeType> getFinalNodeTypesMap(Map<String, ToscaNodeType> initialNodeTypes,
- Map<String, ToscaNodeType> filteredNodeTypes) {
- for (var i = 0; i < initialNodeTypes.size(); i++) {
- initialNodeTypes.forEach((key, nodeType) -> {
- var tempToscaNodeType = new ToscaNodeType();
- tempToscaNodeType.setName(key);
-
- if (filteredNodeTypes.get(nodeType.getDerivedFrom()) != null) {
- tempToscaNodeType.setName(key);
-
- var finalProps = new HashMap<String, ToscaProperty>(
- filteredNodeTypes.get(nodeType.getDerivedFrom()).getProperties());
-
- tempToscaNodeType.setProperties(finalProps);
- } else {
- return;
- }
- filteredNodeTypes.putIfAbsent(key, tempToscaNodeType);
-
- });
- }
- return filteredNodeTypes;
- }
-
- /**
- * Get the requested node types with common or instance properties.
- *
- * @param common boolean indicating common or instance properties
- * @param serviceTemplate the ToscaServiceTemplate
- * @return the node types with common or instance properties
- */
- public static Map<String, ToscaNodeType> getCommonOrInstancePropertiesFromNodeTypes(boolean common,
- ToscaServiceTemplate serviceTemplate) {
- var tempNodeTypesMap = getInitialNodeTypesMap(serviceTemplate.getNodeTypes(), common);
-
- return getFinalNodeTypesMap(serviceTemplate.getNodeTypes(), tempNodeTypesMap);
- }
}
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusTest.java
index a8a2267ad..7bf439e3f 100644
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusTest.java
@@ -27,7 +27,6 @@ import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.Partic
import java.time.Instant;
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.AutomationCompositionElementDefinition;
@@ -39,7 +38,6 @@ import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty;
class ParticipantStatusTest {
@@ -100,11 +98,6 @@ class ParticipantStatusTest {
acDefinition.setAcElementDefinitionId(id);
acDefinition.setAutomationCompositionElementToscaNodeTemplate(toscaNodeTemplate);
- var property = new ToscaProperty();
- property.setName("test");
- property.setType("testType");
- var commonPropertiesMap = Map.of("Prop1", property);
- acDefinition.setCommonPropertiesMap(commonPropertiesMap);
return acDefinition;
}
}
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdateTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdateTest.java
index 074f6f2e2..177e22356 100644
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdateTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdateTest.java
@@ -27,7 +27,6 @@ import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.Partic
import java.time.Instant;
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.AutomationCompositionElementDefinition;
@@ -35,7 +34,6 @@ import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
/**
@@ -90,12 +88,6 @@ class ParticipantUpdateTest {
AutomationCompositionElementDefinition acDefinition = new AutomationCompositionElementDefinition();
acDefinition.setAcElementDefinitionId(id);
acDefinition.setAutomationCompositionElementToscaNodeTemplate(toscaNodeTemplate);
-
- ToscaProperty property = new ToscaProperty();
- property.setName("test");
- property.setType("testType");
- Map<String, ToscaProperty> commonPropertiesMap = Map.of("Prop1", property);
- acDefinition.setCommonPropertiesMap(commonPropertiesMap);
return acDefinition;
}
}
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 617b2459c..bb33e4d5a 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
@@ -37,13 +37,9 @@ 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;
import org.onap.policy.models.tosca.authorative.concepts.ToscaDataType;
import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
@@ -55,10 +51,6 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaTopologyTemplate;
class AcmUtilsTest {
private final ToscaConceptIdentifier id = new ToscaConceptIdentifier("id", "1.0.0");
- private final ToscaConceptIdentifier idNode =
- new ToscaConceptIdentifier("org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant", "0.0.0");
- private static final StandardYamlCoder YAML_TRANSLATOR = new StandardYamlCoder();
- private static final String TOSCA_SERVICE_TEMPLATE_YAML = "clamp/acm/pmsh/funtional-pmsh-usecase.yaml";
@Test
void testCommonUtilsParticipantUpdate() {
@@ -88,21 +80,6 @@ class AcmUtilsTest {
}
@Test
- void testCommonUtilsDefinitionUpdate() {
- var toscaServiceTemplate = getDummyToscaServiceTemplate();
- List<ParticipantDefinition> participantDefinitionUpdates = new ArrayList<>();
- assertThat(participantDefinitionUpdates).isEmpty();
-
- checkParticipantDefinitionUpdate(toscaServiceTemplate, participantDefinitionUpdates);
- assertThat(participantDefinitionUpdates).isNotEmpty();
- assertEquals(id, participantDefinitionUpdates.get(0).getParticipantType());
-
- checkParticipantDefinitionUpdate(toscaServiceTemplate, participantDefinitionUpdates);
- assertEquals(idNode, participantDefinitionUpdates.get(0).getAutomationCompositionElementDefinitionList().get(0)
- .getAcElementDefinitionId());
- }
-
- @Test
void testSetServiceTemplatePolicyInfoWithNullInfo() {
var toscaServiceTemplate = getDummyToscaServiceTemplate();
toscaServiceTemplate.setPolicyTypes(null);
@@ -113,16 +90,6 @@ class AcmUtilsTest {
}
@Test
- void testGetCommonOrInstancePropertiesFromNodeTypes() throws Exception {
- var inputServiceTemplate = YAML_TRANSLATOR
- .decode(ResourceUtils.getResourceAsStream(TOSCA_SERVICE_TEMPLATE_YAML), ToscaServiceTemplate.class);
-
- var result = AcmUtils.getCommonOrInstancePropertiesFromNodeTypes(true, inputServiceTemplate);
- assertNotNull(result);
- assertThat(result).hasSize(6);
- }
-
- @Test
void testValidateAutomationComposition() throws Exception {
var automationComposition = getDummyAutomationComposition();
var toscaServiceTemplate = getDummyToscaServiceTemplate();
@@ -196,17 +163,4 @@ class AcmUtilsTest {
nodeTemplates.put("org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant", nodeTemplate);
return nodeTemplates;
}
-
- private void checkParticipantDefinitionUpdate(ToscaServiceTemplate toscaServiceTemplate,
- List<ParticipantDefinition> participantDefinitionUpdates) {
-
- for (Map.Entry<String, ToscaNodeTemplate> toscaInputEntry : toscaServiceTemplate.getToscaTopologyTemplate()
- .getNodeTemplates().entrySet()) {
- if (ParticipantUtils.checkIfNodeTemplateIsAutomationCompositionElement(toscaInputEntry.getValue(),
- toscaServiceTemplate)) {
- AcmUtils.prepareParticipantDefinitionUpdate(id, toscaInputEntry.getKey(), toscaInputEntry.getValue(),
- participantDefinitionUpdates, null);
- }
- }
- }
}