aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiam Fallon <liam.fallon@est.tech>2022-12-21 12:24:18 +0000
committerGerrit Code Review <gerrit@onap.org>2022-12-21 12:24:18 +0000
commitc6fb86de3dae6f26aec9813cd5ef4cc8d9268359 (patch)
tree0acde2a0b8268b78e5e4dba65f3ecdfbcab36ffb
parentcf1861cab006d682952e80a491b6863cf8ae7592 (diff)
parentc71863696d729286502f951a64c3d2193c6641e7 (diff)
Merge "Add compositionId into Messages between ACM and Participants"
-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
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandlerTest.java3
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/TestListenerUtils.java20
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/ParticipantIntermediaryApi.java59
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java71
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java113
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java123
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java29
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandlerTest.java2
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandlerTest.java44
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java2
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProvider.java4
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspect.java29
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java113
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java101
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionStateChangePublisher.java1
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionUpdatePublisher.java4
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantUpdatePublisher.java51
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProviderTest.java4
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspectTest.java31
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java11
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java21
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/comm/SupervisionMessagesTest.java16
29 files changed, 235 insertions, 810 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);
- }
- }
- }
}
diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandlerTest.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandlerTest.java
index 0836dbb3c..c28355d7f 100644
--- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandlerTest.java
+++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandlerTest.java
@@ -23,7 +23,6 @@ package org.onap.policy.clamp.acm.participant.policy.main.handler;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.when;
import java.util.List;
import java.util.Map;
@@ -72,8 +71,6 @@ class AutomationCompositionElementHandlerTest {
private AutomationCompositionElementHandler getTestingHandler() {
var handler = new AutomationCompositionElementHandler(api, pap);
var intermediaryApi = Mockito.mock(ParticipantIntermediaryApi.class);
- var element = getTestingAcElement();
- when(intermediaryApi.getAutomationCompositionElement(automationCompositionElementId)).thenReturn(element);
handler.setIntermediaryApi(intermediaryApi);
return handler;
}
diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/TestListenerUtils.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/TestListenerUtils.java
index d0ad72f83..59d64e754 100644
--- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/TestListenerUtils.java
+++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/TestListenerUtils.java
@@ -25,20 +25,14 @@ import static org.junit.Assert.assertTrue;
import java.io.FileNotFoundException;
import java.time.Instant;
import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
import java.util.Set;
import java.util.UUID;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition;
-import org.onap.policy.clamp.models.acm.concepts.ParticipantUtils;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdate;
-import org.onap.policy.clamp.models.acm.utils.AcmUtils;
import org.onap.policy.common.utils.coder.YamlJsonTranslator;
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.ToscaNodeTemplate;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -70,19 +64,7 @@ public final class TestListenerUtils {
// Add policies to the toscaServiceTemplate
TestListenerUtils.addPoliciesToToscaServiceTemplate(toscaServiceTemplate);
- List<ParticipantDefinition> participantDefinitionUpdates = new ArrayList<>();
- for (Map.Entry<String, ToscaNodeTemplate> toscaInputEntry : toscaServiceTemplate.getToscaTopologyTemplate()
- .getNodeTemplates().entrySet()) {
- if (ParticipantUtils.checkIfNodeTemplateIsAutomationCompositionElement(toscaInputEntry.getValue(),
- toscaServiceTemplate)) {
- AcmUtils.prepareParticipantDefinitionUpdate(
- ParticipantUtils.findParticipantType(toscaInputEntry.getValue().getProperties()),
- toscaInputEntry.getKey(), toscaInputEntry.getValue(),
- participantDefinitionUpdates, null);
- }
- }
-
- participantUpdateMsg.setParticipantDefinitionUpdates(participantDefinitionUpdates);
+ participantUpdateMsg.setParticipantDefinitionUpdates(new ArrayList<>());
return participantUpdateMsg;
}
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/ParticipantIntermediaryApi.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/ParticipantIntermediaryApi.java
index 367215a29..d74c41f35 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/ParticipantIntermediaryApi.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/ParticipantIntermediaryApi.java
@@ -21,18 +21,11 @@
package org.onap.policy.clamp.acm.participant.intermediary.api;
-import java.util.List;
-import java.util.Map;
import java.util.UUID;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositions;
-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.messages.dmaap.participant.ParticipantMessageType;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty;
/**
* This interface is used by participant implementations to use the participant intermediary.
@@ -48,58 +41,6 @@ public interface ParticipantIntermediaryApi {
AutomationCompositionElementListener automationCompositionElementListener);
/**
- * Get participants loops from the intermediary API.
- *
- * @param name the participant name, null for all
- * @param version the participant version, null for all
- * @return the participants
- */
- List<Participant> getParticipants(String name, String version);
-
- /**
- * Get common properties of a automation composition element.
- *
- * @param acElementDef the automation composition element definition
- * @return the common properties
- */
- Map<String, ToscaProperty> getAcElementDefinitionCommonProperties(ToscaConceptIdentifier acElementDef);
-
- /**
- * Update the state of a participant.
- *
- * @param definition the definition of the participant to update the state on
- * @param state the state of the participant
- * @return the participant
- */
- Participant updateParticipantState(ToscaConceptIdentifier definition, ParticipantState state);
-
- /**
- * Get automation compositions from the intermediary API.
- *
- * @param name the automation composition element name, null for all
- * @param version the automation composition element version, null for all
- * @return the automation composition elements
- */
- AutomationCompositions getAutomationCompositions(String name, String version);
-
- /**
- * Get automation composition elements from the intermediary API.
- *
- * @param name the automation composition element name, null for all
- * @param version the automation composition element version, null for all
- * @return the automation composition elements
- */
- Map<UUID, AutomationCompositionElement> getAutomationCompositionElements(String name, String version);
-
- /**
- * Get automation composition element from the intermediary API.
- *
- * @param id automation composition element ID
- * @return the automation composition element
- */
- AutomationCompositionElement getAutomationCompositionElement(UUID id);
-
- /**
* Update the state of a automation composition element.
*
* @param id the ID of the automation composition element to update the state on
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java
index 6dfc82791..acbcc37a6 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java
@@ -21,24 +21,14 @@
package org.onap.policy.clamp.acm.participant.intermediary.api.impl;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
import java.util.UUID;
import org.onap.policy.clamp.acm.participant.intermediary.api.AutomationCompositionElementListener;
import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi;
import org.onap.policy.clamp.acm.participant.intermediary.handler.AutomationCompositionHandler;
-import org.onap.policy.clamp.acm.participant.intermediary.handler.ParticipantHandler;
-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.AutomationCompositionOrderedState;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositions;
-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.messages.dmaap.participant.ParticipantMessageType;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty;
import org.springframework.stereotype.Component;
/**
@@ -47,21 +37,15 @@ import org.springframework.stereotype.Component;
@Component
public class ParticipantIntermediaryApiImpl implements ParticipantIntermediaryApi {
- // The handler for the participant intermediary
- private final ParticipantHandler participantHandler;
-
// The handler for the automationComposition intermediary
private final AutomationCompositionHandler automationCompositionHandler;
/**
* Constructor.
*
- * @param participantHandler ParticipantHandler
* @param automationCompositionHandler AutomationCompositionHandler
*/
- public ParticipantIntermediaryApiImpl(ParticipantHandler participantHandler,
- AutomationCompositionHandler automationCompositionHandler) {
- this.participantHandler = participantHandler;
+ public ParticipantIntermediaryApiImpl(AutomationCompositionHandler automationCompositionHandler) {
this.automationCompositionHandler = automationCompositionHandler;
}
@@ -72,56 +56,9 @@ public class ParticipantIntermediaryApiImpl implements ParticipantIntermediaryAp
}
@Override
- public List<Participant> getParticipants(String name, String version) {
- return List.of(participantHandler.getParticipant(name, version));
- }
-
- @Override
- public Map<String, ToscaProperty> getAcElementDefinitionCommonProperties(ToscaConceptIdentifier acElementDef) {
- return participantHandler.getAcElementDefinitionCommonProperties(acElementDef);
- }
-
- @Override
- public Participant updateParticipantState(ToscaConceptIdentifier definition, ParticipantState state) {
- return participantHandler.updateParticipantState(definition, state);
- }
-
- @Override
- public AutomationCompositions getAutomationCompositions(String name, String version) {
- return automationCompositionHandler.getAutomationCompositions();
- }
-
- @Override
- public Map<UUID, AutomationCompositionElement> getAutomationCompositionElements(String name, String version) {
- var automationCompositions =
- automationCompositionHandler.getAutomationCompositions().getAutomationCompositionList();
-
- for (var automationComposition : automationCompositions) {
- if (name.equals(automationComposition.getName())) {
- return automationComposition.getElements();
- }
- }
- return new LinkedHashMap<>();
- }
-
- @Override
- public AutomationCompositionElement getAutomationCompositionElement(UUID id) {
- List<AutomationComposition> automationCompositions =
- automationCompositionHandler.getAutomationCompositions().getAutomationCompositionList();
-
- for (AutomationComposition automationComposition : automationCompositions) {
- AutomationCompositionElement acElement = automationComposition.getElements().get(id);
- if (acElement != null) {
- return acElement;
- }
- }
- return null;
- }
-
- @Override
- public AutomationCompositionElement updateAutomationCompositionElementState(
- UUID automationCompositionId, UUID id, AutomationCompositionOrderedState currentState,
- AutomationCompositionState newState, ParticipantMessageType messageType) {
+ public AutomationCompositionElement updateAutomationCompositionElementState(UUID automationCompositionId, UUID id,
+ AutomationCompositionOrderedState currentState, AutomationCompositionState newState,
+ ParticipantMessageType messageType) {
return automationCompositionHandler.updateAutomationCompositionElementState(automationCompositionId, id,
currentState, newState);
}
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java
index 66ac0c1dc..568ab8a36 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java
@@ -38,7 +38,6 @@ import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementAck
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDefinition;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositions;
import org.onap.policy.clamp.models.acm.concepts.ParticipantUpdates;
import org.onap.policy.clamp.models.acm.concepts.ParticipantUtils;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionAck;
@@ -97,9 +96,8 @@ public class AutomationCompositionHandler {
* @param newState the ordered state
* @return automationCompositionElement the updated automation composition element
*/
- public AutomationCompositionElement updateAutomationCompositionElementState(
- UUID automationCompositionId, UUID id, AutomationCompositionOrderedState orderedState,
- AutomationCompositionState newState) {
+ public AutomationCompositionElement updateAutomationCompositionElementState(UUID automationCompositionId, UUID id,
+ AutomationCompositionOrderedState orderedState, AutomationCompositionState newState) {
if (id == null) {
LOGGER.warn("Cannot update Automation composition element state, id is null");
@@ -114,7 +112,7 @@ public class AutomationCompositionHandler {
element.setState(newState);
}
var checkOpt = automationComposition.getElements().values().stream()
- .filter(acElement -> !newState.equals(acElement.getState())).findAny();
+ .filter(acElement -> !newState.equals(acElement.getState())).findAny();
if (checkOpt.isEmpty()) {
automationComposition.setState(newState);
automationComposition.setOrderedState(orderedState);
@@ -125,18 +123,18 @@ public class AutomationCompositionHandler {
var acElement = elementsOnThisParticipant.get(id);
if (acElement != null) {
var automationCompositionStateChangeAck =
- new AutomationCompositionAck(ParticipantMessageType.AUTOMATION_COMPOSITION_STATECHANGE_ACK);
+ new AutomationCompositionAck(ParticipantMessageType.AUTOMATION_COMPOSITION_STATECHANGE_ACK);
automationCompositionStateChangeAck.setParticipantId(participantId);
automationCompositionStateChangeAck.setParticipantType(participantType);
automationCompositionStateChangeAck.setAutomationCompositionId(automationCompositionId);
acElement.setOrderedState(orderedState);
acElement.setState(newState);
automationCompositionStateChangeAck.getAutomationCompositionResultMap().put(acElement.getId(),
- new AutomationCompositionElementAck(newState, true,
- "Automation composition element {} state changed to {}\", id, newState)"));
+ new AutomationCompositionElementAck(newState, true,
+ "Automation composition element {} state changed to {}\", id, newState)"));
LOGGER.debug("Automation composition element {} state changed to {}", id, newState);
automationCompositionStateChangeAck
- .setMessage("AutomationCompositionElement state changed to {} " + newState);
+ .setMessage("AutomationCompositionElement state changed to {} " + newState);
automationCompositionStateChangeAck.setResult(true);
publisher.sendAutomationCompositionAck(automationCompositionStateChangeAck);
return acElement;
@@ -151,7 +149,7 @@ public class AutomationCompositionHandler {
* @param acElementDefinitions the list of AutomationCompositionElementDefinition
*/
public void handleAutomationCompositionStateChange(AutomationCompositionStateChange stateChangeMsg,
- List<AutomationCompositionElementDefinition> acElementDefinitions) {
+ List<AutomationCompositionElementDefinition> acElementDefinitions) {
if (stateChangeMsg.getAutomationCompositionId() == null) {
return;
}
@@ -160,22 +158,22 @@ public class AutomationCompositionHandler {
if (automationComposition == null) {
var automationCompositionAck =
- new AutomationCompositionAck(ParticipantMessageType.AUTOMATION_COMPOSITION_STATECHANGE_ACK);
+ new AutomationCompositionAck(ParticipantMessageType.AUTOMATION_COMPOSITION_STATECHANGE_ACK);
automationCompositionAck.setParticipantId(participantId);
automationCompositionAck.setParticipantType(participantType);
automationCompositionAck.setMessage("Automation composition " + stateChangeMsg.getAutomationCompositionId()
- + " does not use this participant " + participantId);
+ + " does not use this participant " + participantId);
automationCompositionAck.setResult(false);
automationCompositionAck.setResponseTo(stateChangeMsg.getMessageId());
automationCompositionAck.setAutomationCompositionId(stateChangeMsg.getAutomationCompositionId());
publisher.sendAutomationCompositionAck(automationCompositionAck);
LOGGER.debug("Automation composition {} does not use this participant",
- stateChangeMsg.getAutomationCompositionId());
+ stateChangeMsg.getAutomationCompositionId());
return;
}
handleState(automationComposition, stateChangeMsg.getOrderedState(), stateChangeMsg.getStartPhase(),
- acElementDefinitions);
+ acElementDefinitions);
}
/**
@@ -187,8 +185,8 @@ public class AutomationCompositionHandler {
* @param acElementDefinitions the list of AutomationCompositionElementDefinition
*/
private void handleState(final AutomationComposition automationComposition,
- AutomationCompositionOrderedState orderedState, Integer startPhaseMsg,
- List<AutomationCompositionElementDefinition> acElementDefinitions) {
+ AutomationCompositionOrderedState orderedState, Integer startPhaseMsg,
+ List<AutomationCompositionElementDefinition> acElementDefinitions) {
switch (orderedState) {
case UNINITIALISED:
handleUninitialisedState(automationComposition, orderedState, startPhaseMsg, acElementDefinitions);
@@ -200,8 +198,7 @@ public class AutomationCompositionHandler {
handleRunningState(automationComposition, orderedState, startPhaseMsg, acElementDefinitions);
break;
default:
- LOGGER.debug("StateChange message has no state, state is null {}",
- automationComposition.getKey());
+ LOGGER.debug("StateChange message has no state, state is null {}", automationComposition.getKey());
break;
}
}
@@ -213,7 +210,7 @@ public class AutomationCompositionHandler {
* @param acElementDefinitions the list of AutomationCompositionElementDefinition
*/
public void handleAutomationCompositionUpdate(AutomationCompositionUpdate updateMsg,
- List<AutomationCompositionElementDefinition> acElementDefinitions) {
+ List<AutomationCompositionElementDefinition> acElementDefinitions) {
if (!updateMsg.appliesTo(participantType, participantId)) {
return;
@@ -227,7 +224,7 @@ public class AutomationCompositionHandler {
}
private void handleAcUpdatePhase0(AutomationCompositionUpdate updateMsg,
- List<AutomationCompositionElementDefinition> acElementDefinitions) {
+ List<AutomationCompositionElementDefinition> acElementDefinitions) {
var automationComposition = automationCompositionMap.get(updateMsg.getAutomationCompositionId());
// TODO: Updates to existing AutomationCompositions are not supported yet (Addition/Removal of
@@ -235,12 +232,12 @@ public class AutomationCompositionHandler {
// elements to existing AutomationComposition has to be supported).
if (automationComposition != null) {
var automationCompositionUpdateAck =
- new AutomationCompositionAck(ParticipantMessageType.AUTOMATION_COMPOSITION_UPDATE_ACK);
+ new AutomationCompositionAck(ParticipantMessageType.AUTOMATION_COMPOSITION_UPDATE_ACK);
automationCompositionUpdateAck.setParticipantId(participantId);
automationCompositionUpdateAck.setParticipantType(participantType);
automationCompositionUpdateAck.setMessage("Automation composition " + updateMsg.getAutomationCompositionId()
- + " already defined on participant " + participantId);
+ + " already defined on participant " + participantId);
automationCompositionUpdateAck.setResult(false);
automationCompositionUpdateAck.setResponseTo(updateMsg.getMessageId());
automationCompositionUpdateAck.setAutomationCompositionId(updateMsg.getAutomationCompositionId());
@@ -250,7 +247,7 @@ public class AutomationCompositionHandler {
if (updateMsg.getParticipantUpdatesList().isEmpty()) {
LOGGER.warn("No AutomationCompositionElement updates in message {}",
- updateMsg.getAutomationCompositionId());
+ updateMsg.getAutomationCompositionId());
return;
}
@@ -262,23 +259,23 @@ public class AutomationCompositionHandler {
automationCompositionMap.put(updateMsg.getAutomationCompositionId(), automationComposition);
handleAutomationCompositionElementUpdate(acElements, acElementDefinitions, updateMsg.getStartPhase(),
- updateMsg.getAutomationCompositionId());
+ updateMsg.getAutomationCompositionId());
}
private void handleAcUpdatePhaseN(AutomationCompositionUpdate updateMsg,
- List<AutomationCompositionElementDefinition> acElementDefinitions) {
+ List<AutomationCompositionElementDefinition> acElementDefinitions) {
var acElementList = updateMsg.getParticipantUpdatesList().stream()
- .flatMap(participantUpdate -> participantUpdate.getAutomationCompositionElementList().stream())
- .filter(element -> participantType.equals(element.getParticipantType())).collect(Collectors.toList());
+ .flatMap(participantUpdate -> participantUpdate.getAutomationCompositionElementList().stream())
+ .filter(element -> participantType.equals(element.getParticipantType())).collect(Collectors.toList());
handleAutomationCompositionElementUpdate(acElementList, acElementDefinitions, updateMsg.getStartPhase(),
- updateMsg.getAutomationCompositionId());
+ updateMsg.getAutomationCompositionId());
}
private void handleAutomationCompositionElementUpdate(List<AutomationCompositionElement> acElements,
- List<AutomationCompositionElementDefinition> acElementDefinitions, Integer startPhaseMsg,
- UUID automationCompositionId) {
+ List<AutomationCompositionElementDefinition> acElementDefinitions, Integer startPhaseMsg,
+ UUID automationCompositionId) {
try {
for (var element : acElements) {
var acElementNodeTemplate = getAcElementNodeTemplate(acElementDefinitions, element.getDefinition());
@@ -300,7 +297,7 @@ public class AutomationCompositionHandler {
}
private ToscaNodeTemplate getAcElementNodeTemplate(
- List<AutomationCompositionElementDefinition> acElementDefinitions, ToscaConceptIdentifier acElementDefId) {
+ List<AutomationCompositionElementDefinition> acElementDefinitions, ToscaConceptIdentifier acElementDefId) {
for (var acElementDefinition : acElementDefinitions) {
if (acElementDefId.getName().contains(acElementDefinition.getAcElementDefinitionId().getName())) {
@@ -311,10 +308,10 @@ public class AutomationCompositionHandler {
}
private List<AutomationCompositionElement> storeElementsOnThisParticipant(
- List<ParticipantUpdates> participantUpdates) {
+ List<ParticipantUpdates> participantUpdates) {
var acElementList = participantUpdates.stream()
- .flatMap(participantUpdate -> participantUpdate.getAutomationCompositionElementList().stream())
- .filter(element -> participantType.equals(element.getParticipantType())).collect(Collectors.toList());
+ .flatMap(participantUpdate -> participantUpdate.getAutomationCompositionElementList().stream())
+ .filter(element -> participantType.equals(element.getParticipantType())).collect(Collectors.toList());
for (var element : acElementList) {
elementsOnThisParticipant.put(element.getId(), element);
@@ -339,16 +336,16 @@ public class AutomationCompositionHandler {
* @param acElementDefinitions the list of AutomationCompositionElementDefinition
*/
private void handleUninitialisedState(final AutomationComposition automationComposition,
- final AutomationCompositionOrderedState orderedState, Integer startPhaseMsg,
- List<AutomationCompositionElementDefinition> acElementDefinitions) {
+ final AutomationCompositionOrderedState orderedState, Integer startPhaseMsg,
+ List<AutomationCompositionElementDefinition> acElementDefinitions) {
handleStateChange(automationComposition, orderedState, startPhaseMsg, acElementDefinitions);
boolean isAllUninitialised = automationComposition.getElements().values().stream()
- .filter(element -> !AutomationCompositionState.UNINITIALISED.equals(element.getState())).findAny()
- .isEmpty();
+ .filter(element -> !AutomationCompositionState.UNINITIALISED.equals(element.getState())).findAny()
+ .isEmpty();
if (isAllUninitialised) {
automationCompositionMap.remove(automationComposition.getInstanceId());
automationComposition.getElements().values()
- .forEach(element -> elementsOnThisParticipant.remove(element.getId()));
+ .forEach(element -> elementsOnThisParticipant.remove(element.getId()));
}
}
@@ -361,8 +358,8 @@ public class AutomationCompositionHandler {
* @param acElementDefinitions the list of AutomationCompositionElementDefinition
*/
private void handlePassiveState(final AutomationComposition automationComposition,
- final AutomationCompositionOrderedState orderedState, Integer startPhaseMsg,
- List<AutomationCompositionElementDefinition> acElementDefinitions) {
+ final AutomationCompositionOrderedState orderedState, Integer startPhaseMsg,
+ List<AutomationCompositionElementDefinition> acElementDefinitions) {
handleStateChange(automationComposition, orderedState, startPhaseMsg, acElementDefinitions);
}
@@ -375,8 +372,8 @@ public class AutomationCompositionHandler {
* @param acElementDefinitions the list of AutomationCompositionElementDefinition
*/
private void handleRunningState(final AutomationComposition automationComposition,
- final AutomationCompositionOrderedState orderedState, Integer startPhaseMsg,
- List<AutomationCompositionElementDefinition> acElementDefinitions) {
+ final AutomationCompositionOrderedState orderedState, Integer startPhaseMsg,
+ List<AutomationCompositionElementDefinition> acElementDefinitions) {
handleStateChange(automationComposition, orderedState, startPhaseMsg, acElementDefinitions);
}
@@ -389,12 +386,12 @@ public class AutomationCompositionHandler {
* @param acElementDefinitions the list of AutomationCompositionElementDefinition
*/
private void handleStateChange(AutomationComposition automationComposition,
- final AutomationCompositionOrderedState orderedState, Integer startPhaseMsg,
- List<AutomationCompositionElementDefinition> acElementDefinitions) {
+ final AutomationCompositionOrderedState orderedState, Integer startPhaseMsg,
+ List<AutomationCompositionElementDefinition> acElementDefinitions) {
if (orderedState.equals(automationComposition.getOrderedState())) {
var automationCompositionAck =
- new AutomationCompositionAck(ParticipantMessageType.AUTOMATION_COMPOSITION_STATECHANGE_ACK);
+ new AutomationCompositionAck(ParticipantMessageType.AUTOMATION_COMPOSITION_STATECHANGE_ACK);
automationCompositionAck.setParticipantId(participantId);
automationCompositionAck.setParticipantType(participantType);
automationCompositionAck.setMessage("Automation composition is already in state " + orderedState);
@@ -405,22 +402,21 @@ public class AutomationCompositionHandler {
}
automationComposition.getElements().values().stream()
- .forEach(acElement -> automationCompositionElementStateChange(automationComposition, orderedState,
- acElement, startPhaseMsg, acElementDefinitions));
+ .forEach(acElement -> automationCompositionElementStateChange(automationComposition, orderedState,
+ acElement, startPhaseMsg, acElementDefinitions));
}
private void automationCompositionElementStateChange(AutomationComposition automationComposition,
- AutomationCompositionOrderedState orderedState, AutomationCompositionElement acElement, Integer startPhaseMsg,
- List<AutomationCompositionElementDefinition> acElementDefinitions) {
+ AutomationCompositionOrderedState orderedState, AutomationCompositionElement acElement,
+ Integer startPhaseMsg, List<AutomationCompositionElementDefinition> acElementDefinitions) {
var acElementNodeTemplate = getAcElementNodeTemplate(acElementDefinitions, acElement.getDefinition());
if (acElementNodeTemplate != null) {
int startPhase = ParticipantUtils.findStartPhase(acElementNodeTemplate.getProperties());
if (startPhaseMsg.equals(startPhase)) {
for (var acElementListener : listeners) {
try {
- acElementListener.automationCompositionElementStateChange(
- automationComposition.getInstanceId(), acElement.getId(), acElement.getState(),
- orderedState);
+ acElementListener.automationCompositionElementStateChange(automationComposition.getInstanceId(),
+ acElement.getId(), acElement.getState(), orderedState);
} catch (PfModelException e) {
LOGGER.debug("Automation composition element update failed {}",
automationComposition.getInstanceId());
@@ -429,15 +425,4 @@ public class AutomationCompositionHandler {
}
}
}
-
- /**
- * Get automation compositions as a {@link ConrolLoops} class.
- *
- * @return the automation compositions
- */
- public AutomationCompositions getAutomationCompositions() {
- var automationCompositions = new AutomationCompositions();
- automationCompositions.setAutomationCompositionList(new ArrayList<>(automationCompositionMap.values()));
- return automationCompositions;
- }
}
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java
index d29186844..b442b9967 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java
@@ -27,7 +27,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Objects;
import java.util.UUID;
import lombok.Getter;
import lombok.Setter;
@@ -35,7 +34,6 @@ import org.onap.policy.clamp.acm.participant.intermediary.comm.ParticipantMessag
import org.onap.policy.clamp.acm.participant.intermediary.parameters.ParticipantParameters;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDefinition;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionInfo;
-import org.onap.policy.clamp.models.acm.concepts.Participant;
import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition;
import org.onap.policy.clamp.models.acm.concepts.ParticipantHealthStatus;
import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
@@ -52,7 +50,6 @@ import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantSt
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdate;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdateAck;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@@ -79,7 +76,7 @@ public class ParticipantHandler {
@Setter
private ParticipantHealthStatus healthStatus = ParticipantHealthStatus.UNKNOWN;
- private final List<AutomationCompositionElementDefinition> acElementDefsOnThisParticipant = new ArrayList<>();
+ private final Map<UUID, List<AutomationCompositionElementDefinition>> acElementDefsMap = new HashMap<>();
/**
* Constructor, set the participant ID and sender.
@@ -88,7 +85,7 @@ public class ParticipantHandler {
* @param publisher the publisher for sending responses to messages
*/
public ParticipantHandler(ParticipantParameters parameters, ParticipantMessagePublisher publisher,
- AutomationCompositionHandler automationCompositionHandler) {
+ AutomationCompositionHandler automationCompositionHandler) {
this.participantType = parameters.getIntermediaryParameters().getParticipantType();
this.participantId = parameters.getIntermediaryParameters().getParticipantId();
this.publisher = publisher;
@@ -100,8 +97,7 @@ public class ParticipantHandler {
*
* @param participantStatusReqMsg participant participantStatusReq message
*/
- @Timed(value = "listener.participant_status_req",
- description = "PARTICIPANT_STATUS_REQ messages received")
+ @Timed(value = "listener.participant_status_req", description = "PARTICIPANT_STATUS_REQ messages received")
public void handleParticipantStatusReq(final ParticipantStatusReq participantStatusReqMsg) {
var participantStatus = makeHeartbeat(true);
publisher.sendParticipantStatus(participantStatus);
@@ -112,10 +108,12 @@ public class ParticipantHandler {
*
* @param updateMsg the update message
*/
- @Timed(value = "listener.automation_composition_update",
+ @Timed(
+ value = "listener.automation_composition_update",
description = "AUTOMATION_COMPOSITION_UPDATE messages received")
public void handleAutomationCompositionUpdate(AutomationCompositionUpdate updateMsg) {
- automationCompositionHandler.handleAutomationCompositionUpdate(updateMsg, acElementDefsOnThisParticipant);
+ automationCompositionHandler.handleAutomationCompositionUpdate(updateMsg,
+ acElementDefsMap.get(updateMsg.getCompositionId()));
}
/**
@@ -123,75 +121,12 @@ public class ParticipantHandler {
*
* @param stateChangeMsg the state change message
*/
- @Timed(value = "listener.automation_composition_state_change",
+ @Timed(
+ value = "listener.automation_composition_state_change",
description = "AUTOMATION_COMPOSITION_STATE_CHANGE messages received")
public void handleAutomationCompositionStateChange(AutomationCompositionStateChange stateChangeMsg) {
automationCompositionHandler.handleAutomationCompositionStateChange(stateChangeMsg,
- acElementDefsOnThisParticipant);
- }
-
- private void handleStateChange(ParticipantState newParticipantState, ParticipantUpdateAck response) {
- if (state.equals(newParticipantState)) {
- response.setResult(false);
- response.setMessage("Participant already in state " + newParticipantState);
- } else {
- response.setResult(true);
- response.setMessage("Participant state changed from " + state + " to " + newParticipantState);
- state = newParticipantState;
- }
- }
-
- /**
- * Method to update participant state.
- *
- * @param definition participant definition
- * @param participantState participant state
- * @return the participant
- */
- public Participant updateParticipantState(ToscaConceptIdentifier definition, ParticipantState participantState) {
- if (!Objects.equals(definition, participantId)) {
- LOGGER.debug("No participant with this ID {}", definition.getName());
- return null;
- }
-
- var participantUpdateAck = new ParticipantUpdateAck();
- handleStateChange(participantState, participantUpdateAck);
- publisher.sendParticipantUpdateAck(participantUpdateAck);
- return getParticipant(definition.getName(), definition.getVersion());
- }
-
- /**
- * Get participants as a {@link Participant} class.
- *
- * @param name the participant name to get
- * @param version the version of the participant to get
- * @return the participant
- */
- public Participant getParticipant(String name, String version) {
- if (participantId.getName().equals(name)) {
- var participant = new Participant();
- participant.setDefinition(participantId);
- participant.setParticipantState(state);
- participant.setHealthStatus(healthStatus);
- return participant;
- }
- return null;
- }
-
- /**
- * Get common properties of a automation composition element.
- *
- * @param acElementDef the automation composition element definition
- * @return the common properties
- */
- public Map<String, ToscaProperty> getAcElementDefinitionCommonProperties(ToscaConceptIdentifier acElementDef) {
- Map<String, ToscaProperty> commonPropertiesMap = new HashMap<>();
- acElementDefsOnThisParticipant.stream().forEach(definition -> {
- if (definition.getAcElementDefinitionId().equals(acElementDef)) {
- commonPropertiesMap.putAll(definition.getCommonPropertiesMap());
- }
- });
- return commonPropertiesMap;
+ acElementDefsMap.get(stateChangeMsg.getCompositionId()));
}
/**
@@ -230,11 +165,10 @@ public class ParticipantHandler {
*
* @param participantRegisterAckMsg the participantRegisterAck message
*/
- @Timed(value = "listener.participant_register_ack",
- description = "PARTICIPANT_REGISTER_ACK messages received")
+ @Timed(value = "listener.participant_register_ack", description = "PARTICIPANT_REGISTER_ACK messages received")
public void handleParticipantRegisterAck(ParticipantRegisterAck participantRegisterAckMsg) {
LOGGER.debug("ParticipantRegisterAck message received as responseTo {}",
- participantRegisterAckMsg.getResponseTo());
+ participantRegisterAckMsg.getResponseTo());
statusToPassive();
publisher.sendParticipantStatus(makeHeartbeat(false));
}
@@ -266,11 +200,10 @@ public class ParticipantHandler {
*
* @param participantDeregisterAckMsg the participantDeregisterAck message
*/
- @Timed(value = "listener.participant_deregister_ack",
- description = "PARTICIPANT_DEREGISTER_ACK messages received")
+ @Timed(value = "listener.participant_deregister_ack", description = "PARTICIPANT_DEREGISTER_ACK messages received")
public void handleParticipantDeregisterAck(ParticipantDeregisterAck participantDeregisterAckMsg) {
LOGGER.debug("ParticipantDeregisterAck message received as responseTo {}",
- participantDeregisterAckMsg.getResponseTo());
+ participantDeregisterAckMsg.getResponseTo());
}
/**
@@ -278,25 +211,25 @@ public class ParticipantHandler {
*
* @param participantUpdateMsg the ParticipantUpdate message
*/
- @Timed(value = "listener.participant_update",
- description = "PARTICIPANT_UPDATE messages received")
+ @Timed(value = "listener.participant_update", description = "PARTICIPANT_UPDATE messages received")
public void handleParticipantUpdate(ParticipantUpdate participantUpdateMsg) {
LOGGER.debug("ParticipantUpdate message received for participantId {}",
- participantUpdateMsg.getParticipantId());
+ participantUpdateMsg.getParticipantId());
+ acElementDefsMap.putIfAbsent(participantUpdateMsg.getCompositionId(), new ArrayList<>());
if (!participantUpdateMsg.getParticipantDefinitionUpdates().isEmpty()) {
statusToPassive();
// This message is to commission the automation composition
- for (ParticipantDefinition participantDefinition : participantUpdateMsg.getParticipantDefinitionUpdates()) {
+ for (var participantDefinition : participantUpdateMsg.getParticipantDefinitionUpdates()) {
if (participantDefinition.getParticipantType().equals(participantType)) {
- acElementDefsOnThisParticipant
- .addAll(participantDefinition.getAutomationCompositionElementDefinitionList());
+ acElementDefsMap.get(participantUpdateMsg.getCompositionId())
+ .addAll(participantDefinition.getAutomationCompositionElementDefinitionList());
break;
}
}
} else {
// This message is to decommission the automation composition
- acElementDefsOnThisParticipant.clear();
+ acElementDefsMap.get(participantUpdateMsg.getCompositionId()).clear();
this.state = ParticipantState.TERMINATED;
}
sendParticipantUpdateAck(participantUpdateMsg.getMessageId());
@@ -335,11 +268,15 @@ public class ParticipantHandler {
heartbeat.setAutomationCompositionInfoList(getAutomationCompositionInfoList());
if (responseToParticipantStatusReq) {
- ParticipantDefinition participantDefinition = new ParticipantDefinition();
- participantDefinition.setParticipantId(participantId);
- participantDefinition.setParticipantType(participantType);
- participantDefinition.setAutomationCompositionElementDefinitionList(acElementDefsOnThisParticipant);
- heartbeat.setParticipantDefinitionUpdates(List.of(participantDefinition));
+ List<ParticipantDefinition> participantDefinitionList = new ArrayList<>(acElementDefsMap.size());
+ for (var acElementDefsOnThisParticipant : acElementDefsMap.values()) {
+ var participantDefinition = new ParticipantDefinition();
+ participantDefinition.setParticipantId(participantId);
+ participantDefinition.setParticipantType(participantType);
+ participantDefinition.setAutomationCompositionElementDefinitionList(acElementDefsOnThisParticipant);
+ participantDefinitionList.add(participantDefinition);
+ }
+ heartbeat.setParticipantDefinitionUpdates(participantDefinitionList);
}
return heartbeat;
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java
index 4458f0bfa..bc5db8571 100644
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java
@@ -20,10 +20,7 @@
package org.onap.policy.clamp.acm.participant.intermediary.api.impl;
-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.assertNotNull;
import java.util.UUID;
import org.junit.jupiter.api.Test;
@@ -32,7 +29,6 @@ import org.onap.policy.clamp.acm.participant.intermediary.api.AutomationComposit
import org.onap.policy.clamp.acm.participant.intermediary.main.parameters.CommonTestData;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
-import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
@@ -43,38 +39,15 @@ class ParticipantIntermediaryApiImplTest {
private static final String ID_NAME = "org.onap.PM_CDS_Blueprint";
private static final String ID_VERSION = "1.0.1";
- private static final String ID_NAME_E = "PMSHInstance1";
- private static final String ID_VERSION_E = "1.0.1";
-
- private static final String ID_NAME_TYPE = "org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant";
- private static final String ID_VERSION_TYPE = "2.3.4";
-
@Test
void mockParticipantIntermediaryApiImplTest() throws CoderException {
var uuid = UUID.randomUUID();
var id = new ToscaConceptIdentifier(ID_NAME, ID_VERSION);
- var participantHandler = commonTestData.getParticipantHandlerAutomationCompositions();
var automationComposiitonHandler = commonTestData.setTestAutomationCompositionHandler(id, uuid);
- var apiImpl = new ParticipantIntermediaryApiImpl(participantHandler, automationComposiitonHandler);
+ var apiImpl = new ParticipantIntermediaryApiImpl(automationComposiitonHandler);
var acElementListener = Mockito.mock(AutomationCompositionElementListener.class);
apiImpl.registerAutomationCompositionElementListener(acElementListener);
- assertNotNull(apiImpl.getAutomationCompositions(id.getName(), id.getVersion()));
- assertThat(apiImpl.getAcElementDefinitionCommonProperties(id)).isEmpty();
-
- var participants = apiImpl.getParticipants(id.getName(), id.getVersion());
- assertEquals(ParticipantState.UNKNOWN, participants.get(0).getParticipantState());
-
- var participant = apiImpl.updateParticipantState(id, ParticipantState.TERMINATED);
- assertEquals(ParticipantState.TERMINATED, participant.getParticipantState());
-
- var elements = apiImpl.getAutomationCompositionElements(ID_NAME_E, ID_VERSION_E);
- assertFalse(elements.containsKey(uuid));
-
- var element = apiImpl.getAutomationCompositionElement(elements.keySet().iterator().next());
- var idType = new ToscaConceptIdentifier(ID_NAME_TYPE, ID_VERSION_TYPE);
- assertEquals(idType, element.getParticipantType());
-
var acElement = apiImpl.updateAutomationCompositionElementState(UUID.randomUUID(), uuid,
AutomationCompositionOrderedState.UNINITIALISED, AutomationCompositionState.PASSIVE,
ParticipantMessageType.AUTOMATION_COMPOSITION_STATECHANGE_ACK);
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandlerTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandlerTest.java
index 06700fcce..8b52c1cfe 100644
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandlerTest.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandlerTest.java
@@ -54,8 +54,6 @@ class AutomationCompositionHandlerTest {
@Test
void automationCompositionHandlerTest() {
var ach = commonTestData.getMockAutomationCompositionHandler();
- assertNotNull(ach.getAutomationCompositions());
-
assertNotNull(ach.getAutomationCompositionMap());
assertNotNull(ach.getElementsOnThisParticipant());
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandlerTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandlerTest.java
index fd0b54f5e..f6988b0e8 100644
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandlerTest.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandlerTest.java
@@ -24,7 +24,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.time.Instant;
@@ -35,12 +34,9 @@ import org.junit.jupiter.api.Test;
import org.onap.policy.clamp.acm.participant.intermediary.comm.ParticipantMessagePublisher;
import org.onap.policy.clamp.acm.participant.intermediary.main.parameters.CommonTestData;
import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition;
-import org.onap.policy.clamp.models.acm.concepts.ParticipantHealthStatus;
-import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantAckMessage;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessage;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType;
-import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantRegisterAck;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdate;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
@@ -52,19 +48,6 @@ class ParticipantHandlerTest {
private static final String ID_VERSION = "1.0.1";
@Test
- void mockParticipantHandlerTest() {
- var participantHandler = commonTestData.getMockParticipantHandler();
- assertNull(participantHandler.getParticipant(null, null));
- assertEquals("org.onap.PM_CDS_Blueprint 1.0.1", participantHandler.getParticipantId().toString());
-
- var id = new ToscaConceptIdentifier(ID_NAME, ID_VERSION);
- assertEquals(id, participantHandler.getParticipantId());
- assertEquals(id, participantHandler.getParticipantType());
- assertThat(participantHandler.getAcElementDefinitionCommonProperties(id)).isEmpty();
-
- }
-
- @Test
void handleUpdateTest() {
var parameters = CommonTestData.getParticipantParameters();
var automationCompositionHander = commonTestData.getMockAutomationCompositionHandler();
@@ -81,6 +64,7 @@ class ParticipantHandlerTest {
var id = new ToscaConceptIdentifier(ID_NAME, ID_VERSION);
participantUpdateMsg.setAutomationCompositionId(CommonTestData.AC_ID_1);
+ participantUpdateMsg.setCompositionId(CommonTestData.AC_ID_1);
participantUpdateMsg.setParticipantId(id);
participantUpdateMsg.setParticipantType(id);
participantUpdateMsg.setMessageId(UUID.randomUUID());
@@ -91,7 +75,6 @@ class ParticipantHandlerTest {
assertThat(heartbeatF.getAutomationCompositionInfoList()).isEmpty();
participantHandler.handleParticipantUpdate(participantUpdateMsg);
- assertThat(participantHandler.getAcElementDefinitionCommonProperties(id)).isEmpty();
var heartbeatT = participantHandler.makeHeartbeat(true);
assertEquals(id, heartbeatT.getParticipantId());
@@ -116,31 +99,6 @@ class ParticipantHandlerTest {
}
@Test
- void handleParticipantTest() {
- var participantHandler = commonTestData.getMockParticipantHandler();
- var id = new ToscaConceptIdentifier(ID_NAME, ID_VERSION);
- var p = participantHandler.getParticipant(id.getName(), id.getVersion());
- assertEquals(ParticipantState.UNKNOWN, p.getParticipantState());
-
- participantHandler.updateParticipantState(id, ParticipantState.PASSIVE);
- var p2 = participantHandler.getParticipant(id.getName(), id.getVersion());
- assertEquals(ParticipantState.PASSIVE, p2.getParticipantState());
-
- var participantRegisterAckMsg = new ParticipantRegisterAck();
- participantRegisterAckMsg.setState(ParticipantState.TERMINATED);
- participantHandler.handleParticipantRegisterAck(participantRegisterAckMsg);
- assertEquals(ParticipantHealthStatus.HEALTHY, participantHandler.makeHeartbeat(false).getHealthStatus());
-
- var emptyid = new ToscaConceptIdentifier("", ID_VERSION);
- assertNull(participantHandler.updateParticipantState(emptyid, ParticipantState.PASSIVE));
-
- var sameid = new ToscaConceptIdentifier(ID_NAME, ID_VERSION);
- var participant = participantHandler.updateParticipantState(sameid, ParticipantState.PASSIVE);
- assertEquals(participant.getDefinition(), sameid);
-
- }
-
- @Test
void checkAppliesTo() {
var participantHandler = commonTestData.getMockParticipantHandler();
var participantAckMsg =
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java
index 01a8f3c28..10c438f93 100644
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java
@@ -196,8 +196,6 @@ public class CommonTestData {
*/
public ParticipantHandler getParticipantHandlerAutomationCompositions() throws CoderException {
var automationCompositionHandler = Mockito.mock(AutomationCompositionHandler.class);
- Mockito.doReturn(getTestAutomationCompositions()).when(automationCompositionHandler)
- .getAutomationCompositions();
Mockito.doReturn(getTestAutomationCompositionMap()).when(automationCompositionHandler)
.getAutomationCompositionMap();
var publisher = new ParticipantMessagePublisher();
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 66a67a304..1d3b2992b 100644
--- 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
@@ -98,7 +98,7 @@ public class CommissioningProvider {
serviceTemplate = acmDefinition.getServiceTemplate();
var participantList = participantProvider.getParticipants();
if (!participantList.isEmpty()) {
- supervisionHandler.handleSendCommissionMessage(serviceTemplate.getName(), serviceTemplate.getVersion());
+ supervisionHandler.handleSendCommissionMessage(acmDefinition);
}
return createCommissioningResponse(acmDefinition.getCompositionId(), serviceTemplate);
}
@@ -145,7 +145,7 @@ public class CommissioningProvider {
}
var participantList = participantProvider.getParticipants();
if (!participantList.isEmpty()) {
- supervisionHandler.handleSendDeCommissionMessage();
+ supervisionHandler.handleSendDeCommissionMessage(compositionId);
}
var serviceTemplate = acDefinitionProvider.deleteAcDefintion(compositionId);
return createCommissioningResponse(compositionId, serviceTemplate);
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspect.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspect.java
index ea851da81..8d1f98388 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspect.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspect.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.
@@ -26,14 +26,10 @@ import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import lombok.RequiredArgsConstructor;
-import org.apache.commons.lang3.tuple.ImmutablePair;
import org.aspectj.lang.annotation.After;
-import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
-import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantRegister;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantStatus;
-import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdateAck;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
@@ -75,29 +71,6 @@ public class SupervisionAspect implements Closeable {
executor.execute(() -> supervisionScanner.handleParticipantStatus(participantStatusMessage.getParticipantId()));
}
- /**
- * Intercepts participant Register Message
- * if there is a Commissioning starts an execution of handleParticipantRegister.
- *
- * @param participantRegisterMessage the ParticipantRegister message
- * @param isCommissioning is Commissioning
- */
- @AfterReturning(
- value = "@annotation(MessageIntercept) && args(participantRegisterMessage,..)",
- returning = "isCommissioning")
- public void handleParticipantRegister(ParticipantRegister participantRegisterMessage, boolean isCommissioning) {
- if (isCommissioning) {
- executor.execute(() -> supervisionScanner.handleParticipantRegister(new ImmutablePair<>(
- participantRegisterMessage.getParticipantId(), participantRegisterMessage.getParticipantType())));
- }
- }
-
- @Before("@annotation(MessageIntercept) && args(participantUpdateAckMessage,..)")
- public void handleParticipantUpdateAck(ParticipantUpdateAck participantUpdateAckMessage) {
- executor.execute(() -> supervisionScanner.handleParticipantUpdateAck(new ImmutablePair<>(
- participantUpdateAckMessage.getParticipantId(), participantUpdateAckMessage.getParticipantType())));
- }
-
@Override
public void close() throws IOException {
executor.shutdown();
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 de67360f8..9a80508e5 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
@@ -34,6 +34,7 @@ import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantRegisterAck
import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantUpdatePublisher;
import org.onap.policy.clamp.common.acm.exception.AutomationCompositionException;
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.AutomationCompositionElementAck;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
import org.onap.policy.clamp.models.acm.concepts.Participant;
@@ -67,9 +68,9 @@ public class SupervisionHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(SupervisionHandler.class);
private static final String AUTOMATION_COMPOSITION_CANNOT_TRANSITION_FROM_STATE =
- "Automation composition can't transition from state ";
+ "Automation composition can't transition from state ";
private static final String AUTOMATION_COMPOSITION_IS_ALREADY_IN_STATE =
- "Automation composition is already in state ";
+ "Automation composition is already in state ";
private static final String TO_STATE = " to state ";
private static final String AND_TRANSITIONING_TO_STATE = " and transitioning to state ";
@@ -107,7 +108,7 @@ public class SupervisionHandler {
*/
@MessageIntercept
@Timed(value = "listener.participant_register", description = "PARTICIPANT_REGISTER messages received")
- public boolean handleParticipantMessage(ParticipantRegister participantRegisterMessage) {
+ public void handleParticipantMessage(ParticipantRegister participantRegisterMessage) {
LOGGER.debug("Participant Register received {}", participantRegisterMessage);
try {
checkParticipant(participantRegisterMessage, ParticipantState.UNKNOWN, ParticipantHealthStatus.UNKNOWN);
@@ -115,12 +116,11 @@ public class SupervisionHandler {
LOGGER.warn("error saving participant {}", participantRegisterMessage.getParticipantId(), svExc);
}
- var isCommissioning = participantUpdatePublisher.sendCommissioning(null, null,
- participantRegisterMessage.getParticipantId(), participantRegisterMessage.getParticipantType());
+ participantUpdatePublisher.sendCommissioning(participantRegisterMessage.getParticipantId(),
+ participantRegisterMessage.getParticipantType());
participantRegisterAckPublisher.send(participantRegisterMessage.getMessageId(),
- participantRegisterMessage.getParticipantId(), participantRegisterMessage.getParticipantType());
- return isCommissioning;
+ participantRegisterMessage.getParticipantId(), participantRegisterMessage.getParticipantType());
}
/**
@@ -134,8 +134,8 @@ public class SupervisionHandler {
LOGGER.debug("Participant Deregister received {}", participantDeregisterMessage);
try {
var participantOpt =
- participantProvider.findParticipant(participantDeregisterMessage.getParticipantId().getName(),
- participantDeregisterMessage.getParticipantId().getVersion());
+ participantProvider.findParticipant(participantDeregisterMessage.getParticipantId().getName(),
+ participantDeregisterMessage.getParticipantId().getVersion());
if (participantOpt.isPresent()) {
var participant = participantOpt.get();
@@ -145,7 +145,7 @@ public class SupervisionHandler {
}
} catch (PfModelException pfme) {
LOGGER.warn("Model exception occured with participant id {}",
- participantDeregisterMessage.getParticipantId());
+ participantDeregisterMessage.getParticipantId());
}
participantDeregisterAckPublisher.send(participantDeregisterMessage.getMessageId());
@@ -162,8 +162,8 @@ public class SupervisionHandler {
LOGGER.debug("Participant Update Ack received {}", participantUpdateAckMessage);
try {
var participantOpt =
- participantProvider.findParticipant(participantUpdateAckMessage.getParticipantId().getName(),
- participantUpdateAckMessage.getParticipantId().getVersion());
+ participantProvider.findParticipant(participantUpdateAckMessage.getParticipantId().getName(),
+ participantUpdateAckMessage.getParticipantId().getVersion());
if (participantOpt.isPresent()) {
var participant = participantOpt.get();
@@ -174,29 +174,28 @@ public class SupervisionHandler {
}
} catch (PfModelException pfme) {
LOGGER.warn("Model exception occured with participant id {}",
- participantUpdateAckMessage.getParticipantId());
+ participantUpdateAckMessage.getParticipantId());
}
}
/**
* Send commissioning update message to dmaap.
*
- * @param name the ToscaServiceTemplate name
- * @param version the ToscaServiceTemplate version
+ * @param acmDefinition the AutomationComposition Definition
*/
- public void handleSendCommissionMessage(String name, String version) {
- LOGGER.debug("Participant update message with serviveTemplate {} {} being sent to all participants", name,
- version);
- participantUpdatePublisher.sendComissioningBroadcast(name, version);
+ public void handleSendCommissionMessage(AutomationCompositionDefinition acmDefinition) {
+ LOGGER.debug("Participant update message with serviveTemplate {} being sent to all participants",
+ acmDefinition.getCompositionId());
+ participantUpdatePublisher.sendComissioningBroadcast(acmDefinition);
}
/**
* Send decommissioning update message to dmaap.
*
*/
- public void handleSendDeCommissionMessage() {
- LOGGER.debug("Participant update message being sent");
- participantUpdatePublisher.sendDecomisioning();
+ public void handleSendDeCommissionMessage(UUID compositionId) {
+ LOGGER.debug("Participant update message being sent {}", compositionId);
+ participantUpdatePublisher.sendDecomisioning(compositionId);
}
/**
@@ -205,8 +204,9 @@ public class SupervisionHandler {
* @param automationCompositionAckMessage the AutomationCompositionAck message received from a participant
*/
@MessageIntercept
- @Timed(value = "listener.automation_composition_update_ack",
- description = "AUTOMATION_COMPOSITION_UPDATE_ACK messages received")
+ @Timed(
+ value = "listener.automation_composition_update_ack",
+ description = "AUTOMATION_COMPOSITION_UPDATE_ACK messages received")
public void handleAutomationCompositionUpdateAckMessage(AutomationCompositionAck automationCompositionAckMessage) {
LOGGER.debug("AutomationComposition Update Ack message received {}", automationCompositionAckMessage);
setAcElementStateInDb(automationCompositionAckMessage);
@@ -218,10 +218,11 @@ public class SupervisionHandler {
* @param automationCompositionAckMessage the AutomationCompositionAck message received from a participant
*/
@MessageIntercept
- @Timed(value = "listener.automation_composition_statechange_ack",
- description = "AUTOMATION_COMPOSITION_STATECHANGE_ACK messages received")
+ @Timed(
+ value = "listener.automation_composition_statechange_ack",
+ description = "AUTOMATION_COMPOSITION_STATECHANGE_ACK messages received")
public void handleAutomationCompositionStateChangeAckMessage(
- AutomationCompositionAck automationCompositionAckMessage) {
+ AutomationCompositionAck automationCompositionAckMessage) {
LOGGER.debug("AutomationComposition StateChange Ack message received {}", automationCompositionAckMessage);
setAcElementStateInDb(automationCompositionAckMessage);
}
@@ -245,7 +246,7 @@ public class SupervisionHandler {
}
private boolean updateState(AutomationComposition automationComposition,
- Set<Map.Entry<UUID, AutomationCompositionElementAck>> automationCompositionResultSet) {
+ Set<Map.Entry<UUID, AutomationCompositionElementAck>> automationCompositionResultSet) {
var updated = false;
for (var acElementAck : automationCompositionResultSet) {
var element = automationComposition.getElements().get(acElementAck.getKey());
@@ -262,9 +263,9 @@ public class SupervisionHandler {
if (acElements != null) {
Boolean primedFlag = true;
var checkOpt = automationComposition.getElements().values().stream()
- .filter(acElement -> (!acElement.getState().equals(AutomationCompositionState.PASSIVE)
- || !acElement.getState().equals(AutomationCompositionState.RUNNING)))
- .findAny();
+ .filter(acElement -> (!acElement.getState().equals(AutomationCompositionState.PASSIVE)
+ || !acElement.getState().equals(AutomationCompositionState.RUNNING)))
+ .findAny();
if (checkOpt.isEmpty()) {
primedFlag = false;
}
@@ -283,7 +284,7 @@ public class SupervisionHandler {
* @throws AutomationCompositionException on supervision errors
*/
public void triggerAutomationCompositionSupervision(AutomationComposition automationComposition)
- throws AutomationCompositionException {
+ throws AutomationCompositionException {
switch (automationComposition.getOrderedState()) {
case UNINITIALISED:
superviseAutomationCompositionUninitialization(automationComposition);
@@ -299,8 +300,8 @@ public class SupervisionHandler {
default:
exceptionOccured(Response.Status.NOT_ACCEPTABLE,
- "A automation composition cannot be commanded to go into state "
- + automationComposition.getOrderedState().name());
+ "A automation composition cannot be commanded to go into state "
+ + automationComposition.getOrderedState().name());
}
}
@@ -313,39 +314,39 @@ public class SupervisionHandler {
* @throws AutomationCompositionException on supervision errors
*/
private void superviseAutomationCompositionUninitialization(AutomationComposition automationComposition)
- throws AutomationCompositionException {
+ throws AutomationCompositionException {
switch (automationComposition.getState()) {
case UNINITIALISED:
exceptionOccured(Response.Status.NOT_ACCEPTABLE,
- AUTOMATION_COMPOSITION_IS_ALREADY_IN_STATE + automationComposition.getState().name());
+ AUTOMATION_COMPOSITION_IS_ALREADY_IN_STATE + automationComposition.getState().name());
break;
case UNINITIALISED2PASSIVE:
case PASSIVE:
automationComposition.setState(AutomationCompositionState.PASSIVE2UNINITIALISED);
automationCompositionStateChangePublisher.send(automationComposition,
- getFirstStartPhase(automationComposition));
+ getFirstStartPhase(automationComposition));
break;
case PASSIVE2UNINITIALISED:
exceptionOccured(Response.Status.NOT_ACCEPTABLE,
- AUTOMATION_COMPOSITION_IS_ALREADY_IN_STATE + automationComposition.getState().name()
- + AND_TRANSITIONING_TO_STATE + automationComposition.getOrderedState());
+ AUTOMATION_COMPOSITION_IS_ALREADY_IN_STATE + automationComposition.getState().name()
+ + AND_TRANSITIONING_TO_STATE + automationComposition.getOrderedState());
break;
default:
exceptionOccured(Response.Status.NOT_ACCEPTABLE, AUTOMATION_COMPOSITION_CANNOT_TRANSITION_FROM_STATE
- + automationComposition.getState().name() + TO_STATE + automationComposition.getOrderedState());
+ + automationComposition.getState().name() + TO_STATE + automationComposition.getOrderedState());
break;
}
}
private void superviseAutomationCompositionPassivation(AutomationComposition automationComposition)
- throws AutomationCompositionException {
+ throws AutomationCompositionException {
switch (automationComposition.getState()) {
case PASSIVE:
exceptionOccured(Response.Status.NOT_ACCEPTABLE,
- AUTOMATION_COMPOSITION_IS_ALREADY_IN_STATE + automationComposition.getState().name());
+ AUTOMATION_COMPOSITION_IS_ALREADY_IN_STATE + automationComposition.getState().name());
break;
case UNINITIALISED:
automationComposition.setState(AutomationCompositionState.UNINITIALISED2PASSIVE);
@@ -355,46 +356,46 @@ public class SupervisionHandler {
case UNINITIALISED2PASSIVE:
case RUNNING2PASSIVE:
exceptionOccured(Response.Status.NOT_ACCEPTABLE,
- AUTOMATION_COMPOSITION_IS_ALREADY_IN_STATE + automationComposition.getState().name()
- + AND_TRANSITIONING_TO_STATE + automationComposition.getOrderedState());
+ AUTOMATION_COMPOSITION_IS_ALREADY_IN_STATE + automationComposition.getState().name()
+ + AND_TRANSITIONING_TO_STATE + automationComposition.getOrderedState());
break;
case RUNNING:
automationComposition.setState(AutomationCompositionState.RUNNING2PASSIVE);
automationCompositionStateChangePublisher.send(automationComposition,
- getFirstStartPhase(automationComposition));
+ getFirstStartPhase(automationComposition));
break;
default:
exceptionOccured(Response.Status.NOT_ACCEPTABLE, AUTOMATION_COMPOSITION_CANNOT_TRANSITION_FROM_STATE
- + automationComposition.getState().name() + TO_STATE + automationComposition.getOrderedState());
+ + automationComposition.getState().name() + TO_STATE + automationComposition.getOrderedState());
break;
}
}
private void superviseAutomationCompositionActivation(AutomationComposition automationComposition)
- throws AutomationCompositionException {
+ throws AutomationCompositionException {
switch (automationComposition.getState()) {
case RUNNING:
exceptionOccured(Response.Status.NOT_ACCEPTABLE,
- AUTOMATION_COMPOSITION_IS_ALREADY_IN_STATE + automationComposition.getState().name());
+ AUTOMATION_COMPOSITION_IS_ALREADY_IN_STATE + automationComposition.getState().name());
break;
case PASSIVE2RUNNING:
exceptionOccured(Response.Status.NOT_ACCEPTABLE,
- AUTOMATION_COMPOSITION_IS_ALREADY_IN_STATE + automationComposition.getState().name()
- + AND_TRANSITIONING_TO_STATE + automationComposition.getOrderedState());
+ AUTOMATION_COMPOSITION_IS_ALREADY_IN_STATE + automationComposition.getState().name()
+ + AND_TRANSITIONING_TO_STATE + automationComposition.getOrderedState());
break;
case PASSIVE:
automationComposition.setState(AutomationCompositionState.PASSIVE2RUNNING);
automationCompositionStateChangePublisher.send(automationComposition,
- getFirstStartPhase(automationComposition));
+ getFirstStartPhase(automationComposition));
break;
default:
exceptionOccured(Response.Status.NOT_ACCEPTABLE, AUTOMATION_COMPOSITION_CANNOT_TRANSITION_FROM_STATE
- + automationComposition.getState().name() + TO_STATE + automationComposition.getOrderedState());
+ + automationComposition.getState().name() + TO_STATE + automationComposition.getOrderedState());
break;
}
}
@@ -405,12 +406,12 @@ public class SupervisionHandler {
}
private void checkParticipant(ParticipantMessage participantMessage, ParticipantState participantState,
- ParticipantHealthStatus healthStatus) throws AutomationCompositionException, PfModelException {
+ ParticipantHealthStatus healthStatus) throws AutomationCompositionException, PfModelException {
if (participantMessage.getParticipantId() == null) {
exceptionOccured(Response.Status.NOT_FOUND, "Participant ID on PARTICIPANT_STATUS message is null");
}
var participantOpt = participantProvider.findParticipant(participantMessage.getParticipantId().getName(),
- participantMessage.getParticipantId().getVersion());
+ participantMessage.getParticipantId().getVersion());
if (participantOpt.isEmpty()) {
var participant = new Participant();
@@ -432,10 +433,10 @@ public class SupervisionHandler {
}
private void superviseParticipant(ParticipantStatus participantStatusMessage)
- throws PfModelException, AutomationCompositionException {
+ throws PfModelException, AutomationCompositionException {
checkParticipant(participantStatusMessage, participantStatusMessage.getState(),
- participantStatusMessage.getHealthStatus());
+ participantStatusMessage.getHealthStatus());
}
private void exceptionOccured(Response.Status status, String reason) throws AutomationCompositionException {
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 129569b6b..a71f49c10 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
@@ -24,14 +24,12 @@ package org.onap.policy.clamp.acm.runtime.supervision;
import java.util.HashMap;
import java.util.Map;
-import org.apache.commons.lang3.tuple.Pair;
+import java.util.UUID;
import org.onap.policy.clamp.acm.runtime.main.parameters.AcRuntimeParameterGroup;
import org.onap.policy.clamp.acm.runtime.supervision.comm.AutomationCompositionStateChangePublisher;
import org.onap.policy.clamp.acm.runtime.supervision.comm.AutomationCompositionUpdatePublisher;
import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantStatusReqPublisher;
-import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantUpdatePublisher;
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.AutomationCompositionState;
import org.onap.policy.clamp.models.acm.concepts.Participant;
import org.onap.policy.clamp.models.acm.concepts.ParticipantHealthStatus;
@@ -41,7 +39,6 @@ import org.onap.policy.clamp.models.acm.persistence.provider.AutomationCompositi
import org.onap.policy.clamp.models.acm.persistence.provider.ParticipantProvider;
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.ToscaServiceTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -54,12 +51,10 @@ import org.springframework.stereotype.Component;
public class SupervisionScanner {
private static final Logger LOGGER = LoggerFactory.getLogger(SupervisionScanner.class);
- private final HandleCounter<ToscaConceptIdentifier> automationCompositionCounter = new HandleCounter<>();
+ private final HandleCounter<UUID> automationCompositionCounter = new HandleCounter<>();
private final HandleCounter<ToscaConceptIdentifier> participantStatusCounter = new HandleCounter<>();
- private final HandleCounter<Pair<ToscaConceptIdentifier, ToscaConceptIdentifier>> participantUpdateCounter =
- new HandleCounter<>();
- private final Map<ToscaConceptIdentifier, Integer> phaseMap = new HashMap<>();
+ private final Map<UUID, Integer> phaseMap = new HashMap<>();
private final AutomationCompositionProvider automationCompositionProvider;
private final AcDefinitionProvider acDefinitionProvider;
@@ -67,7 +62,6 @@ public class SupervisionScanner {
private final AutomationCompositionUpdatePublisher automationCompositionUpdatePublisher;
private final ParticipantProvider participantProvider;
private final ParticipantStatusReqPublisher participantStatusReqPublisher;
- private final ParticipantUpdatePublisher participantUpdatePublisher;
/**
* Constructor for instantiating SupervisionScanner.
@@ -78,7 +72,6 @@ public class SupervisionScanner {
* @param automationCompositionUpdatePublisher the AutomationCompositionUpdate Publisher
* @param participantProvider the Participant Provider
* @param participantStatusReqPublisher the Participant StatusReq Publisher
- * @param participantUpdatePublisher the Participant Update Publisher
* @param acRuntimeParameterGroup the parameters for the automation composition runtime
*/
public SupervisionScanner(final AutomationCompositionProvider automationCompositionProvider,
@@ -86,7 +79,6 @@ public class SupervisionScanner {
final AutomationCompositionStateChangePublisher automationCompositionStateChangePublisher,
AutomationCompositionUpdatePublisher automationCompositionUpdatePublisher,
ParticipantProvider participantProvider, ParticipantStatusReqPublisher participantStatusReqPublisher,
- ParticipantUpdatePublisher participantUpdatePublisher,
final AcRuntimeParameterGroup acRuntimeParameterGroup) {
this.automationCompositionProvider = automationCompositionProvider;
this.acDefinitionProvider = acDefinitionProvider;
@@ -94,18 +86,12 @@ public class SupervisionScanner {
this.automationCompositionUpdatePublisher = automationCompositionUpdatePublisher;
this.participantProvider = participantProvider;
this.participantStatusReqPublisher = participantStatusReqPublisher;
- this.participantUpdatePublisher = participantUpdatePublisher;
automationCompositionCounter.setMaxRetryCount(
acRuntimeParameterGroup.getParticipantParameters().getUpdateParameters().getMaxRetryCount());
automationCompositionCounter
.setMaxWaitMs(acRuntimeParameterGroup.getParticipantParameters().getMaxStatusWaitMs());
- participantUpdateCounter.setMaxRetryCount(
- acRuntimeParameterGroup.getParticipantParameters().getUpdateParameters().getMaxRetryCount());
- participantUpdateCounter
- .setMaxWaitMs(acRuntimeParameterGroup.getParticipantParameters().getUpdateParameters().getMaxWaitMs());
-
participantStatusCounter.setMaxRetryCount(
acRuntimeParameterGroup.getParticipantParameters().getUpdateParameters().getMaxRetryCount());
participantStatusCounter.setMaxWaitMs(acRuntimeParameterGroup.getParticipantParameters().getMaxStatusWaitMs());
@@ -130,48 +116,17 @@ public class SupervisionScanner {
}
}
- try {
- var list = acDefinitionProvider.getAllAcDefinitions();
- for (var acDefinition : list) {
- var acList =
- automationCompositionProvider.getAcInstancesByCompositionId(acDefinition.getCompositionId());
- for (var automationComposition : acList) {
- scanAutomationComposition(automationComposition, acDefinition.getServiceTemplate(), counterCheck);
- }
+ var list = acDefinitionProvider.getAllAcDefinitions();
+ for (var acDefinition : list) {
+ var acList = automationCompositionProvider.getAcInstancesByCompositionId(acDefinition.getCompositionId());
+ for (var automationComposition : acList) {
+ scanAutomationComposition(automationComposition, acDefinition.getServiceTemplate(), counterCheck);
}
- } catch (PfModelException pfme) {
- LOGGER.warn("error reading automation compositions from database", pfme);
- }
-
- if (counterCheck) {
- scanParticipantUpdate();
}
LOGGER.debug("Automation composition scan complete . . .");
}
- private void scanParticipantUpdate() {
- LOGGER.debug("Scanning participants to update . . .");
-
- for (var id : participantUpdateCounter.keySet()) {
- if (participantUpdateCounter.isFault(id)) {
- LOGGER.debug("report Participant Update fault");
-
- } else if (participantUpdateCounter.getDuration(id) > participantUpdateCounter.getMaxWaitMs()) {
-
- if (participantUpdateCounter.count(id)) {
- LOGGER.debug("retry message ParticipantUpdate");
- participantUpdatePublisher.sendCommissioning(null, null, id.getLeft(), id.getRight());
- } else {
- LOGGER.debug("report Participant Update fault");
- participantUpdateCounter.setFault(id);
- }
- }
- }
-
- LOGGER.debug("Participants to update scan complete . . .");
- }
-
private void scanParticipantStatus(Participant participant) throws PfModelException {
ToscaConceptIdentifier id = participant.getKey().asIdentifier();
if (participantStatusCounter.isFault(id)) {
@@ -199,20 +154,12 @@ public class SupervisionScanner {
participantStatusCounter.clear(id);
}
- public void handleParticipantRegister(Pair<ToscaConceptIdentifier, ToscaConceptIdentifier> id) {
- participantUpdateCounter.clear(id);
- }
-
- public void handleParticipantUpdateAck(Pair<ToscaConceptIdentifier, ToscaConceptIdentifier> id) {
- participantUpdateCounter.remove(id);
- }
-
private void scanAutomationComposition(final AutomationComposition automationComposition,
- ToscaServiceTemplate toscaServiceTemplate, boolean counterCheck) throws PfModelException {
- LOGGER.debug("scanning automation composition {} . . .", automationComposition.getKey().asIdentifier());
+ ToscaServiceTemplate toscaServiceTemplate, boolean counterCheck) {
+ LOGGER.debug("scanning automation composition {} . . .", automationComposition.getInstanceId());
if (automationComposition.getState().equals(automationComposition.getOrderedState().asState())) {
- LOGGER.debug("automation composition {} scanned, OK", automationComposition.getKey().asIdentifier());
+ LOGGER.debug("automation composition {} scanned, OK", automationComposition.getInstanceId());
// Clear missed report counter on automation composition
clearFaultAndCounter(automationComposition);
@@ -224,8 +171,8 @@ public class SupervisionScanner {
var maxSpNotCompleted = 0; // max startPhase not completed
var defaultMin = 1000; // min startPhase
var defaultMax = 0; // max startPhase
- for (AutomationCompositionElement element : automationComposition.getElements().values()) {
- ToscaNodeTemplate toscaNodeTemplate = toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates()
+ for (var element : automationComposition.getElements().values()) {
+ var toscaNodeTemplate = toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates()
.get(element.getDefinition().getName());
int startPhase = ParticipantUtils.findStartPhase(toscaNodeTemplate.getProperties());
defaultMin = Math.min(defaultMin, startPhase);
@@ -262,36 +209,36 @@ public class SupervisionScanner {
? defaultMin
: defaultMax;
- if (nextSpNotCompleted != phaseMap.getOrDefault(automationComposition.getKey().asIdentifier(),
+ if (nextSpNotCompleted != phaseMap.getOrDefault(automationComposition.getInstanceId(),
firstStartPhase)) {
- phaseMap.put(automationComposition.getKey().asIdentifier(), nextSpNotCompleted);
+ phaseMap.put(automationComposition.getInstanceId(), nextSpNotCompleted);
sendAutomationCompositionMsg(automationComposition, nextSpNotCompleted);
} else if (counterCheck) {
- phaseMap.put(automationComposition.getKey().asIdentifier(), nextSpNotCompleted);
+ phaseMap.put(automationComposition.getInstanceId(), nextSpNotCompleted);
handleCounter(automationComposition, nextSpNotCompleted);
}
}
}
private void clearFaultAndCounter(AutomationComposition automationComposition) {
- automationCompositionCounter.clear(automationComposition.getKey().asIdentifier());
- phaseMap.clear();
+ automationCompositionCounter.clear(automationComposition.getInstanceId());
+ phaseMap.remove(automationComposition.getInstanceId());
}
private void handleCounter(AutomationComposition automationComposition, int startPhase) {
- ToscaConceptIdentifier id = automationComposition.getKey().asIdentifier();
- if (automationCompositionCounter.isFault(id)) {
+ var instanceId = automationComposition.getInstanceId();
+ if (automationCompositionCounter.isFault(instanceId)) {
LOGGER.debug("report AutomationComposition fault");
return;
}
- if (automationCompositionCounter.getDuration(id) > automationCompositionCounter.getMaxWaitMs()) {
- if (automationCompositionCounter.count(id)) {
- phaseMap.put(id, startPhase);
+ if (automationCompositionCounter.getDuration(instanceId) > automationCompositionCounter.getMaxWaitMs()) {
+ if (automationCompositionCounter.count(instanceId)) {
+ phaseMap.put(instanceId, startPhase);
sendAutomationCompositionMsg(automationComposition, startPhase);
} else {
LOGGER.debug("report AutomationComposition fault");
- automationCompositionCounter.setFault(id);
+ automationCompositionCounter.setFault(instanceId);
}
}
}
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionStateChangePublisher.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionStateChangePublisher.java
index 4c3cc958b..8d6378e3f 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionStateChangePublisher.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionStateChangePublisher.java
@@ -43,6 +43,7 @@ public class AutomationCompositionStateChangePublisher
description = "AUTOMATION_COMPOSITION_STATE_CHANGE messages published")
public void send(AutomationComposition automationComposition, int startPhase) {
var acsc = new AutomationCompositionStateChange();
+ acsc.setCompositionId(automationComposition.getCompositionId());
acsc.setAutomationCompositionId(automationComposition.getInstanceId());
acsc.setMessageId(UUID.randomUUID());
acsc.setOrderedState(automationComposition.getOrderedState());
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionUpdatePublisher.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionUpdatePublisher.java
index c10e47bb4..7b114c920 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionUpdatePublisher.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionUpdatePublisher.java
@@ -29,7 +29,6 @@ import java.util.List;
import java.util.UUID;
import lombok.AllArgsConstructor;
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.ParticipantUpdates;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionUpdate;
import org.onap.policy.clamp.models.acm.persistence.provider.AcDefinitionProvider;
@@ -69,6 +68,7 @@ public class AutomationCompositionUpdatePublisher extends AbstractParticipantPub
description = "AUTOMATION_COMPOSITION_UPDATE messages published")
public void send(AutomationComposition automationComposition, int startPhase) {
var automationCompositionUpdateMsg = new AutomationCompositionUpdate();
+ automationCompositionUpdateMsg.setCompositionId(automationComposition.getCompositionId());
automationCompositionUpdateMsg.setStartPhase(startPhase);
automationCompositionUpdateMsg.setAutomationCompositionId(automationComposition.getInstanceId());
automationCompositionUpdateMsg.setMessageId(UUID.randomUUID());
@@ -76,7 +76,7 @@ public class AutomationCompositionUpdatePublisher extends AbstractParticipantPub
var toscaServiceTemplate = acDefinitionProvider.getAcDefinition(automationComposition.getCompositionId());
List<ParticipantUpdates> participantUpdates = new ArrayList<>();
- for (AutomationCompositionElement element : automationComposition.getElements().values()) {
+ for (var element : automationComposition.getElements().values()) {
AcmUtils.setAcPolicyInfo(element, toscaServiceTemplate);
AcmUtils.prepareParticipantUpdate(element, participantUpdates);
}
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantUpdatePublisher.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantUpdatePublisher.java
index fa5e423d7..af9023815 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantUpdatePublisher.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantUpdatePublisher.java
@@ -26,7 +26,9 @@ import io.micrometer.core.annotation.Timed;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
+import java.util.UUID;
import lombok.AllArgsConstructor;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionDefinition;
import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition;
import org.onap.policy.clamp.models.acm.concepts.ParticipantUtils;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdate;
@@ -51,47 +53,56 @@ public class ParticipantUpdatePublisher extends AbstractParticipantPublisher<Par
/**
* Send ParticipantUpdate to all Participants.
*
- * @param name the ToscaServiceTemplate name
- * @param version the ToscaServiceTemplate version
+ * @param acmDefinition the AutomationComposition Definition
*/
@Timed(value = "publisher.participant_update", description = "PARTICIPANT_UPDATE messages published")
- public void sendComissioningBroadcast(String name, String version) {
- sendCommissioning(name, version, null, null);
+ public void sendComissioningBroadcast(AutomationCompositionDefinition acmDefinition) {
+ sendCommissioning(acmDefinition, null, null);
}
/**
* Send ParticipantUpdate to Participant
* if participantType and participantId are null then message is broadcast.
*
- * @param name the ToscaServiceTemplate name
- * @param version the ToscaServiceTemplate version
* @param participantType the ParticipantType
* @param participantId the ParticipantId
*/
@Timed(value = "publisher.participant_update", description = "PARTICIPANT_UPDATE messages published")
- public boolean sendCommissioning(String name, String version, ToscaConceptIdentifier participantType,
- ToscaConceptIdentifier participantId) {
+ public void sendCommissioning(ToscaConceptIdentifier participantType, ToscaConceptIdentifier participantId) {
+ var list = acDefinitionProvider.getAllAcDefinitions();
+ if (list.isEmpty()) {
+ LOGGER.warn("No tosca service template found, cannot send participantupdate");
+ }
+ for (var acmDefinition : list) {
+ sendCommissioning(acmDefinition, participantType, participantId);
+ }
+ }
+
+ /**
+ * Send ParticipantUpdate to Participant
+ * if participantType and participantId are null then message is broadcast.
+ *
+ * @param acmDefinition the AutomationComposition Definition
+ * @param participantType the ParticipantType
+ * @param participantId the ParticipantId
+ */
+ @Timed(value = "publisher.participant_update", description = "PARTICIPANT_UPDATE messages published")
+ public void sendCommissioning(AutomationCompositionDefinition acmDefinition,
+ ToscaConceptIdentifier participantType, ToscaConceptIdentifier participantId) {
var message = new ParticipantUpdate();
+ message.setCompositionId(acmDefinition.getCompositionId());
message.setParticipantType(participantType);
message.setParticipantId(participantId);
message.setTimestamp(Instant.now());
- var list = acDefinitionProvider.getServiceTemplateList(name, version);
- if (list.isEmpty()) {
- LOGGER.warn("No tosca service template found, cannot send participantupdate {} {}", name, version);
- return false;
- }
- var toscaServiceTemplate = list.get(0);
- var commonPropertiesMap = AcmUtils.getCommonOrInstancePropertiesFromNodeTypes(true, toscaServiceTemplate);
-
+ var toscaServiceTemplate = acmDefinition.getServiceTemplate();
List<ParticipantDefinition> participantDefinitionUpdates = new ArrayList<>();
for (var toscaInputEntry : toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates().entrySet()) {
if (ParticipantUtils.checkIfNodeTemplateIsAutomationCompositionElement(toscaInputEntry.getValue(),
toscaServiceTemplate)) {
AcmUtils.prepareParticipantDefinitionUpdate(
ParticipantUtils.findParticipantType(toscaInputEntry.getValue().getProperties()),
- toscaInputEntry.getKey(), toscaInputEntry.getValue(), participantDefinitionUpdates,
- commonPropertiesMap);
+ toscaInputEntry.getKey(), toscaInputEntry.getValue(), participantDefinitionUpdates);
}
}
@@ -99,15 +110,15 @@ public class ParticipantUpdatePublisher extends AbstractParticipantPublisher<Par
message.setParticipantDefinitionUpdates(participantDefinitionUpdates);
LOGGER.debug("Participant Update sent {}", message);
super.send(message);
- return true;
}
/**
* Send ParticipantUpdate to Participant after that commissioning has been removed.
*/
@Timed(value = "publisher.participant_update", description = "PARTICIPANT_UPDATE messages published")
- public void sendDecomisioning() {
+ public void sendDecomisioning(UUID compositionId) {
var message = new ParticipantUpdate();
+ message.setCompositionId(compositionId);
message.setTimestamp(Instant.now());
// DeCommission the automation composition but deleting participantdefinitions on participants
message.setParticipantDefinitionUpdates(null);
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 792cb4a75..fe0180a74 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
@@ -90,7 +90,7 @@ class CommissioningProviderTest {
var affectedDefinitions = provider
.createAutomationCompositionDefinitions(serviceTemplate).getAffectedAutomationCompositionDefinitions();
verify(acDefinitionProvider).createAutomationCompositionDefinition(serviceTemplate);
- verify(supervisionHandler).handleSendCommissionMessage(serviceTemplate.getName(), serviceTemplate.getVersion());
+ verify(supervisionHandler).handleSendCommissionMessage(acmDefinition);
// Response should return the number of node templates present in the service template
assertThat(affectedDefinitions).hasSize(7);
}
@@ -148,7 +148,7 @@ class CommissioningProviderTest {
provider.deleteAutomationCompositionDefinition(compositionId);
- verify(supervisionHandler).handleSendDeCommissionMessage();
+ verify(supervisionHandler).handleSendDeCommissionMessage(compositionId);
verify(acDefinitionProvider).deleteAcDefintion(compositionId);
}
}
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspectTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspectTest.java
index 84b756816..abc3ccb1a 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspectTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspectTest.java
@@ -25,11 +25,8 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.timeout;
import static org.mockito.Mockito.verify;
-import org.apache.commons.lang3.tuple.ImmutablePair;
import org.junit.jupiter.api.Test;
-import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantRegister;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantStatus;
-import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdateAck;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
class SupervisionAspectTest {
@@ -70,32 +67,4 @@ class SupervisionAspectTest {
verify(supervisionScanner, timeout(500)).handleParticipantStatus(PARTICIPANT_ID);
}
}
-
- @Test
- void testHandleParticipantUpdateAck() throws Exception {
- var updateAckMessage = new ParticipantUpdateAck();
- updateAckMessage.setParticipantId(PARTICIPANT_ID);
- updateAckMessage.setParticipantType(PARTICIPANT_TYPE);
-
- var supervisionScanner = mock(SupervisionScanner.class);
- try (var supervisionAspect = new SupervisionAspect(supervisionScanner)) {
- supervisionAspect.handleParticipantUpdateAck(updateAckMessage);
- verify(supervisionScanner, timeout(500))
- .handleParticipantUpdateAck(new ImmutablePair<>(PARTICIPANT_ID, PARTICIPANT_TYPE));
- }
- }
-
- @Test
- void testHandleParticipantRegister() throws Exception {
- var participantRegister = new ParticipantRegister();
- participantRegister.setParticipantId(PARTICIPANT_ID);
- participantRegister.setParticipantType(PARTICIPANT_TYPE);
-
- var supervisionScanner = mock(SupervisionScanner.class);
- try (var supervisionAspect = new SupervisionAspect(supervisionScanner)) {
- supervisionAspect.handleParticipantRegister(participantRegister, true);
- verify(supervisionScanner, timeout(500))
- .handleParticipantRegister(new ImmutablePair<>(PARTICIPANT_ID, PARTICIPANT_TYPE));
- }
- }
}
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 832d25da0..2da869072 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
@@ -43,6 +43,7 @@ import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantRegisterAck
import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantUpdatePublisher;
import org.onap.policy.clamp.common.acm.exception.AutomationCompositionException;
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.AutomationCompositionOrderedState;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
import org.onap.policy.clamp.models.acm.concepts.Participant;
@@ -365,10 +366,10 @@ class SupervisionHandlerTest {
mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionUpdatePublisher.class),
mock(AutomationCompositionStateChangePublisher.class), participantUpdatePublisher,
AutomationCompositionOrderedState.PASSIVE, AutomationCompositionState.UNINITIALISED);
- handler.handleSendCommissionMessage(participantId.getName(), participantId.getVersion());
+ var acmDefinition = new AutomationCompositionDefinition();
+ handler.handleSendCommissionMessage(acmDefinition);
- verify(participantUpdatePublisher).sendComissioningBroadcast(participantId.getName(),
- participantId.getVersion());
+ verify(participantUpdatePublisher).sendComissioningBroadcast(acmDefinition);
}
@Test
@@ -379,9 +380,9 @@ class SupervisionHandlerTest {
mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionUpdatePublisher.class),
mock(AutomationCompositionStateChangePublisher.class), participantUpdatePublisher,
AutomationCompositionOrderedState.PASSIVE, AutomationCompositionState.UNINITIALISED);
- handler.handleSendDeCommissionMessage();
+ handler.handleSendDeCommissionMessage(identifier);
- verify(participantUpdatePublisher).sendDecomisioning();
+ verify(participantUpdatePublisher).sendDecomisioning(identifier);
}
private SupervisionHandler createSupervisionHandler(AutomationCompositionProvider automationCompositionProvider,
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 1455e9246..a6d4d3b0d 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
@@ -31,14 +31,12 @@ import static org.onap.policy.clamp.acm.runtime.util.CommonTestData.TOSCA_SERVIC
import java.util.List;
import java.util.Objects;
import java.util.UUID;
-import org.apache.commons.lang3.tuple.ImmutablePair;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.onap.policy.clamp.acm.runtime.instantiation.InstantiationUtils;
import org.onap.policy.clamp.acm.runtime.supervision.comm.AutomationCompositionStateChangePublisher;
import org.onap.policy.clamp.acm.runtime.supervision.comm.AutomationCompositionUpdatePublisher;
import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantStatusReqPublisher;
-import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantUpdatePublisher;
import org.onap.policy.clamp.acm.runtime.util.CommonTestData;
import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionDefinition;
@@ -84,7 +82,6 @@ class SupervisionScannerTest {
var automationCompositionUpdatePublisher = mock(AutomationCompositionUpdatePublisher.class);
var participantProvider = mock(ParticipantProvider.class);
var participantStatusReqPublisher = mock(ParticipantStatusReqPublisher.class);
- var participantUpdatePublisher = mock(ParticipantUpdatePublisher.class);
var acRuntimeParameterGroup = CommonTestData.geParameterGroup("dbScanner");
var automationComposition = InstantiationUtils.getAutomationCompositionFromResource(AC_JSON, "Crud");
@@ -93,7 +90,7 @@ class SupervisionScannerTest {
var supervisionScanner = new SupervisionScanner(automationCompositionProvider, acDefinitionProvider,
automationCompositionStateChangePublisher, automationCompositionUpdatePublisher, participantProvider,
- participantStatusReqPublisher, participantUpdatePublisher, acRuntimeParameterGroup);
+ participantStatusReqPublisher, acRuntimeParameterGroup);
supervisionScanner.run(false);
verify(automationCompositionProvider, times(0)).updateAutomationComposition(any(AutomationComposition.class));
@@ -112,12 +109,11 @@ class SupervisionScannerTest {
var automationCompositionStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class);
var participantProvider = mock(ParticipantProvider.class);
var participantStatusReqPublisher = mock(ParticipantStatusReqPublisher.class);
- var participantUpdatePublisher = mock(ParticipantUpdatePublisher.class);
var acRuntimeParameterGroup = CommonTestData.geParameterGroup("dbScanner");
var supervisionScanner = new SupervisionScanner(automationCompositionProvider, acDefinitionProvider,
automationCompositionStateChangePublisher, automationCompositionUpdatePublisher, participantProvider,
- participantStatusReqPublisher, participantUpdatePublisher, acRuntimeParameterGroup);
+ participantStatusReqPublisher, acRuntimeParameterGroup);
supervisionScanner.run(false);
verify(automationCompositionProvider, times(1)).updateAutomationComposition(any(AutomationComposition.class));
@@ -139,12 +135,11 @@ class SupervisionScannerTest {
var automationCompositionUpdatePublisher = mock(AutomationCompositionUpdatePublisher.class);
var participantStatusReqPublisher = mock(ParticipantStatusReqPublisher.class);
var automationCompositionStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class);
- var participantUpdatePublisher = mock(ParticipantUpdatePublisher.class);
var acRuntimeParameterGroup = CommonTestData.geParameterGroup("dbScanner");
var supervisionScanner = new SupervisionScanner(automationCompositionProvider, acDefinitionProvider,
automationCompositionStateChangePublisher, automationCompositionUpdatePublisher, participantProvider,
- participantStatusReqPublisher, participantUpdatePublisher, acRuntimeParameterGroup);
+ participantStatusReqPublisher, acRuntimeParameterGroup);
supervisionScanner.handleParticipantStatus(participant.getKey().asIdentifier());
supervisionScanner.run(true);
@@ -176,12 +171,11 @@ class SupervisionScannerTest {
var automationCompositionUpdatePublisher = mock(AutomationCompositionUpdatePublisher.class);
var participantStatusReqPublisher = mock(ParticipantStatusReqPublisher.class);
var automationCompositionStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class);
- var participantUpdatePublisher = mock(ParticipantUpdatePublisher.class);
var acRuntimeParameterGroup = CommonTestData.geParameterGroup("dbScanner");
var supervisionScanner = new SupervisionScanner(automationCompositionProvider, acDefinitionProvider,
automationCompositionStateChangePublisher, automationCompositionUpdatePublisher, participantProvider,
- participantStatusReqPublisher, participantUpdatePublisher, acRuntimeParameterGroup);
+ participantStatusReqPublisher, acRuntimeParameterGroup);
supervisionScanner.run(false);
@@ -212,21 +206,16 @@ class SupervisionScannerTest {
var automationCompositionUpdatePublisher = mock(AutomationCompositionUpdatePublisher.class);
var participantStatusReqPublisher = mock(ParticipantStatusReqPublisher.class);
var automationCompositionStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class);
- var participantUpdatePublisher = mock(ParticipantUpdatePublisher.class);
var supervisionScanner = new SupervisionScanner(automationCompositionProvider, acDefinitionProvider,
automationCompositionStateChangePublisher, automationCompositionUpdatePublisher, participantProvider,
- participantStatusReqPublisher, participantUpdatePublisher, acRuntimeParameterGroup);
+ participantStatusReqPublisher, acRuntimeParameterGroup);
- supervisionScanner
- .handleParticipantRegister(new ImmutablePair<>(participant.getKey().asIdentifier(), PARTICIPANT_TYPE));
supervisionScanner.handleParticipantStatus(participant.getKey().asIdentifier());
supervisionScanner.run(true);
verify(participantStatusReqPublisher).send(any(ToscaConceptIdentifier.class));
verify(participantProvider).saveParticipant(any());
- supervisionScanner
- .handleParticipantUpdateAck(new ImmutablePair<>(participant.getKey().asIdentifier(), PARTICIPANT_TYPE));
supervisionScanner.run(true);
verify(participantProvider, times(2)).saveParticipant(any());
}
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 2cfe7eb3c..b545fd957 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
@@ -24,15 +24,17 @@ package org.onap.policy.clamp.acm.runtime.supervision.comm;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
+import static org.onap.policy.clamp.acm.runtime.util.CommonTestData.TOSCA_SERVICE_TEMPLATE_YAML;
import java.util.Collections;
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.supervision.SupervisionHandler;
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.AutomationCompositionState;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionAck;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDeregister;
@@ -133,7 +135,7 @@ class SupervisionMessagesTest {
var publisher = new ParticipantUpdatePublisher(mock(AcDefinitionProvider.class));
var topicSink = mock(TopicSink.class);
publisher.active(List.of(topicSink));
- publisher.sendDecomisioning();
+ publisher.sendDecomisioning(UUID.randomUUID());
verify(topicSink).send(anyString());
}
@@ -142,8 +144,14 @@ class SupervisionMessagesTest {
var publisher = new ParticipantUpdatePublisher(mock(AcDefinitionProvider.class));
var topicSink = mock(TopicSink.class);
publisher.active(List.of(topicSink));
- publisher.sendComissioningBroadcast("NAME", "1.0.0");
- verify(topicSink, times(0)).send(anyString());
+ var serviceTemplate = InstantiationUtils.getToscaServiceTemplate(TOSCA_SERVICE_TEMPLATE_YAML);
+ serviceTemplate.setName("Name");
+ serviceTemplate.setVersion("1.0.0");
+ var acmDefinition = new AutomationCompositionDefinition();
+ acmDefinition.setCompositionId(UUID.randomUUID());
+ acmDefinition.setServiceTemplate(serviceTemplate);
+ publisher.sendComissioningBroadcast(acmDefinition);
+ verify(topicSink).send(anyString());
}
@Test