summaryrefslogtreecommitdiffstats
path: root/runtime-acm/src
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2023-04-05 16:32:38 +0100
committerFrancescoFioraEst <francesco.fiora@est.tech>2023-04-11 10:06:21 +0100
commit9f1fdf9f419c1724a9cf75a20fdd24df191766bd (patch)
tree16db3d01d45ae45a4fc776d9d23596ec2c6bcc58 /runtime-acm/src
parent2ca7552978f5389ef5ed2e5d4be3cb43e446f7c6 (diff)
Add UseState and OperationalState support in ACM
Issue-ID: POLICY-4639 Change-Id: Iac5249c054bf41d830463826a8f61f477c48235b Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'runtime-acm/src')
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandler.java7
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java5
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandlerTest.java4
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java10
4 files changed, 21 insertions, 5 deletions
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandler.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandler.java
index 5fcb3837f..85beb76c4 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandler.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandler.java
@@ -163,6 +163,13 @@ public class SupervisionAcHandler {
if (element != null) {
element.setDeployState(acElementAck.getValue().getDeployState());
element.setLockState(acElementAck.getValue().getLockState());
+ if (DeployState.DEPLOYED.equals(element.getDeployState())) {
+ element.setOperationalState(acElementAck.getValue().getOperationalState());
+ element.setUseState(acElementAck.getValue().getUseState());
+ } else {
+ element.setOperationalState(null);
+ element.setUseState(null);
+ }
updated = true;
}
}
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java
index c1bfcf07a..564fa8d0e 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java
@@ -36,6 +36,7 @@ import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDe
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessage;
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.persistence.provider.AutomationCompositionProvider;
import org.onap.policy.clamp.models.acm.persistence.provider.ParticipantProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -52,6 +53,7 @@ public class SupervisionParticipantHandler {
private final ParticipantProvider participantProvider;
private final ParticipantRegisterAckPublisher participantRegisterAckPublisher;
private final ParticipantDeregisterAckPublisher participantDeregisterAckPublisher;
+ private final AutomationCompositionProvider automationCompositionProvider;
/**
* Handle a ParticipantRegister message from a participant.
@@ -101,6 +103,9 @@ public class SupervisionParticipantHandler {
LOGGER.debug("Participant Status received {}", participantStatusMsg);
saveParticipantStatus(participantStatusMsg,
listToMap(participantStatusMsg.getParticipantSupportedElementType()));
+ if (!participantStatusMsg.getAutomationCompositionInfoList().isEmpty()) {
+ automationCompositionProvider.upgradeStates(participantStatusMsg.getAutomationCompositionInfoList());
+ }
}
private void saveParticipantStatus(ParticipantMessage participantMessage,
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandlerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandlerTest.java
index 153f7a0e0..c44fa1d21 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandlerTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandlerTest.java
@@ -64,7 +64,7 @@ class SupervisionAcHandlerTest {
var automationCompositionAckMessage =
new AutomationCompositionDeployAck(ParticipantMessageType.AUTOMATION_COMPOSITION_STATECHANGE_ACK);
for (var elementEntry : automationComposition.getElements().entrySet()) {
- var acElementDeployAck = new AcElementDeployAck(DeployState.DEPLOYED, LockState.UNLOCKED, true, "");
+ var acElementDeployAck = new AcElementDeployAck(DeployState.DEPLOYED, LockState.UNLOCKED, "", "", true, "");
automationCompositionAckMessage.getAutomationCompositionResultMap().put(elementEntry.getKey(),
acElementDeployAck);
}
@@ -86,7 +86,7 @@ class SupervisionAcHandlerTest {
var automationCompositionAckMessage =
new AutomationCompositionDeployAck(ParticipantMessageType.AUTOMATION_COMPOSITION_DEPLOY_ACK);
for (var elementEntry : automationComposition.getElements().entrySet()) {
- var acElementDeployAck = new AcElementDeployAck(DeployState.DEPLOYED, LockState.LOCKED, true, "");
+ var acElementDeployAck = new AcElementDeployAck(DeployState.DEPLOYED, LockState.LOCKED, "", "", true, "");
automationCompositionAckMessage
.setAutomationCompositionResultMap(Map.of(elementEntry.getKey(), acElementDeployAck));
}
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java
index fb12e040a..f00747c6b 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java
@@ -38,6 +38,7 @@ import org.onap.policy.clamp.models.acm.concepts.ParticipantSupportedElementType
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDeregister;
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.persistence.provider.AutomationCompositionProvider;
import org.onap.policy.clamp.models.acm.persistence.provider.ParticipantProvider;
class SupervisionParticipantHandlerTest {
@@ -54,7 +55,8 @@ class SupervisionParticipantHandlerTest {
participantDeregisterMessage.setParticipantId(CommonTestData.getParticipantId());
var participantDeregisterAckPublisher = mock(ParticipantDeregisterAckPublisher.class);
var handler = new SupervisionParticipantHandler(participantProvider,
- mock(ParticipantRegisterAckPublisher.class), participantDeregisterAckPublisher);
+ mock(ParticipantRegisterAckPublisher.class), participantDeregisterAckPublisher,
+ mock(AutomationCompositionProvider.class));
handler.handleParticipantMessage(participantDeregisterMessage);
@@ -76,7 +78,8 @@ class SupervisionParticipantHandlerTest {
var participantProvider = mock(ParticipantProvider.class);
var participantRegisterAckPublisher = mock(ParticipantRegisterAckPublisher.class);
var handler = new SupervisionParticipantHandler(participantProvider, participantRegisterAckPublisher,
- mock(ParticipantDeregisterAckPublisher.class));
+ mock(ParticipantDeregisterAckPublisher.class),
+ mock(AutomationCompositionProvider.class));
handler.handleParticipantMessage(participantRegisterMessage);
verify(participantProvider).saveParticipant(any());
@@ -97,7 +100,8 @@ class SupervisionParticipantHandlerTest {
var participantProvider = mock(ParticipantProvider.class);
var handler = new SupervisionParticipantHandler(participantProvider,
- mock(ParticipantRegisterAckPublisher.class), mock(ParticipantDeregisterAckPublisher.class));
+ mock(ParticipantRegisterAckPublisher.class), mock(ParticipantDeregisterAckPublisher.class),
+ mock(AutomationCompositionProvider.class));
var participant = CommonTestData.createParticipant(CommonTestData.getParticipantId());
when(participantProvider.findParticipant(CommonTestData.getParticipantId()))
.thenReturn(Optional.of(participant));