summaryrefslogtreecommitdiffstats
path: root/participant/participant-intermediary
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2023-04-27 15:22:50 +0100
committerFrancescoFioraEst <francesco.fiora@est.tech>2023-05-03 16:48:44 +0100
commit5c921c62ef5fd97ae86efe28e932619546966907 (patch)
treea8fa5a2ad5c52f41e12e43750aee7ff026e245bf /participant/participant-intermediary
parentb619e00e3dbb4c7e2d5a484be8cae4db29afe149 (diff)
Add participant properties capability to acm/participants
Add statusProperties support in acm acm/participants. Issue-ID: POLICY-4652 Change-Id: I6dd37c9be58fce36def022364abe46c791e98a77 Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'participant/participant-intermediary')
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/AutomationCompositionElementListener.java6
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java43
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AutomationCompositionElementListenerTest.java42
3 files changed, 85 insertions, 6 deletions
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/AutomationCompositionElementListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/AutomationCompositionElementListener.java
index c99241f27..a61a6678a 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/AutomationCompositionElementListener.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/AutomationCompositionElementListener.java
@@ -69,4 +69,10 @@ public interface AutomationCompositionElementListener {
// default Operational State
return "";
}
+
+ public default Map<String, Object> getStatusProperties(UUID automationCompositionId,
+ UUID automationCompositionElementId) throws PfModelException {
+ // default StatusProperties
+ return Map.of();
+ }
}
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 1eaf63dcc..f918ed12c 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
@@ -21,6 +21,7 @@
package org.onap.policy.clamp.acm.participant.intermediary.handler;
+import com.att.aft.dme2.internal.apache.commons.lang.StringUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
@@ -96,6 +97,7 @@ public class AutomationCompositionHandler {
* @param automationCompositionId the automationComposition Id
* @param id the automationComposition UUID
* @param deployState the DeployState state
+ * @param lockState the LockState state
*/
public void updateAutomationCompositionElementState(UUID automationCompositionId, UUID id, DeployState deployState,
LockState lockState) {
@@ -113,6 +115,7 @@ public class AutomationCompositionHandler {
element.setLockState(lockState);
element.setUseState(getUseState(automationCompositionId, id));
element.setOperationalState(getOperationalState(automationCompositionId, id));
+ element.setStatusProperties(getStatusProperties(automationCompositionId, id));
}
var checkOpt = automationComposition.getElements().values().stream()
.filter(acElement -> !deployState.equals(acElement.getDeployState())).findAny();
@@ -137,9 +140,10 @@ public class AutomationCompositionHandler {
acElement.setLockState(lockState);
acElement.setUseState(getUseState(automationCompositionId, id));
acElement.setOperationalState(getOperationalState(automationCompositionId, id));
+ acElement.setStatusProperties(getStatusProperties(automationCompositionId, id));
automationCompositionStateChangeAck.getAutomationCompositionResultMap().put(acElement.getId(),
- new AcElementDeployAck(deployState, lockState,
- acElement.getOperationalState(), acElement.getUseState(), true,
+ new AcElementDeployAck(deployState, lockState, acElement.getOperationalState(),
+ acElement.getUseState(), acElement.getStatusProperties(), true,
"Automation composition element {} state changed to {}\", id, newState)"));
LOGGER.debug("Automation composition element {} state changed to {}", id, deployState);
automationCompositionStateChangeAck
@@ -470,14 +474,18 @@ public class AutomationCompositionHandler {
* @return the UseState of the Automation Composition Element
*/
public String getUseState(UUID instanceId, UUID acElementId) {
+ var result = new StringBuilder();
for (var acElementListener : listeners) {
try {
- return acElementListener.getUseState(instanceId, acElementId);
+ var state = acElementListener.getUseState(instanceId, acElementId);
+ if (!StringUtils.isBlank(state)) {
+ result.append(state);
+ }
} catch (PfModelException e) {
LOGGER.error("Automation composition element get Use State failed {}", acElementId);
}
}
- return null;
+ return result.toString();
}
/**
@@ -488,13 +496,36 @@ public class AutomationCompositionHandler {
* @return the OperationalState of the Automation Composition Element
*/
public String getOperationalState(UUID instanceId, UUID acElementId) {
+ var result = new StringBuilder();
for (var acElementListener : listeners) {
try {
- return acElementListener.getOperationalState(instanceId, acElementId);
+ var state = acElementListener.getOperationalState(instanceId, acElementId);
+ if (!StringUtils.isBlank(state)) {
+ result.append(state);
+ }
} catch (PfModelException e) {
LOGGER.error("Automation composition element get Use State failed {}", acElementId);
}
}
- return null;
+ return result.toString();
+ }
+
+ /**
+ * Get StatusProperties.
+ *
+ * @param instanceId the instance Id
+ * @param acElementId the Automation Composition Element Id
+ * @return the Status Properties Map
+ */
+ public Map<String, Object> getStatusProperties(UUID instanceId, UUID acElementId) {
+ Map<String, Object> result = new HashMap<>();
+ for (var acElementListener : listeners) {
+ try {
+ result.putAll(acElementListener.getStatusProperties(instanceId, acElementId));
+ } catch (PfModelException e) {
+ LOGGER.error("Automation composition element get Status Properties failed {}", acElementId);
+ }
+ }
+ return result;
}
}
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AutomationCompositionElementListenerTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AutomationCompositionElementListenerTest.java
new file mode 100644
index 000000000..6255b886c
--- /dev/null
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AutomationCompositionElementListenerTest.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.acm.participant.intermediary.api.impl;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatCode;
+
+import java.util.UUID;
+import org.junit.jupiter.api.Test;
+import org.onap.policy.clamp.acm.participant.intermediary.handler.DummyAcElementListener;
+import org.onap.policy.models.base.PfModelException;
+
+class AutomationCompositionElementListenerTest {
+
+ @Test
+ void defaultTest() throws PfModelException {
+ var listener = new DummyAcElementListener();
+ assertThat(listener.getStatusProperties(UUID.randomUUID(), UUID.randomUUID())).isNotNull().isEmpty();
+ assertThat(listener.getOperationalState(UUID.randomUUID(), UUID.randomUUID())).isNotNull().isEmpty();
+ assertThat(listener.getUseState(UUID.randomUUID(), UUID.randomUUID())).isNotNull().isEmpty();
+ assertThatCode(() -> listener.lock(UUID.randomUUID(), UUID.randomUUID())).doesNotThrowAnyException();
+ assertThatCode(() -> listener.unlock(UUID.randomUUID(), UUID.randomUUID())).doesNotThrowAnyException();
+ }
+}