aboutsummaryrefslogtreecommitdiffstats
path: root/runtime-acm/src
diff options
context:
space:
mode:
Diffstat (limited to 'runtime-acm/src')
-rwxr-xr-xruntime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java24
-rwxr-xr-x[-rw-r--r--]runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantRestartPublisher.java11
-rwxr-xr-xruntime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java63
3 files changed, 81 insertions, 17 deletions
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 f8bc233e9..ebccc2f66 100755
--- 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
@@ -35,6 +35,7 @@ import org.onap.policy.clamp.models.acm.concepts.AcTypeState;
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.Participant;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition;
import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
import org.onap.policy.clamp.models.acm.concepts.ParticipantSupportedElementType;
import org.onap.policy.clamp.models.acm.concepts.StateChangeResult;
@@ -130,6 +131,29 @@ public class SupervisionParticipantHandler {
if (!participantStatusMsg.getAutomationCompositionInfoList().isEmpty()) {
automationCompositionProvider.upgradeStates(participantStatusMsg.getAutomationCompositionInfoList());
}
+ if (!participantStatusMsg.getParticipantDefinitionUpdates().isEmpty()
+ && participantStatusMsg.getCompositionId() != null) {
+ updateAcDefinitionOutProperties(participantStatusMsg.getCompositionId(),
+ participantStatusMsg.getParticipantDefinitionUpdates());
+ }
+ }
+
+ private void updateAcDefinitionOutProperties(UUID composotionId, List<ParticipantDefinition> list) {
+ var acDefinitionOpt = acDefinitionProvider.findAcDefinition(composotionId);
+ if (acDefinitionOpt.isEmpty()) {
+ LOGGER.error("Ac Definition with id {} not found", composotionId);
+ return;
+ }
+ var acDefinition = acDefinitionOpt.get();
+ for (var acElements : list) {
+ for (var element : acElements.getAutomationCompositionElementDefinitionList()) {
+ var state = acDefinition.getElementStateMap().get(element.getAcElementDefinitionId().getName());
+ if (state != null) {
+ state.setOutProperties(element.getOutProperties());
+ }
+ }
+ }
+ acDefinitionProvider.updateAcDefinition(acDefinition);
}
private void checkOnline(Participant participant) {
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantRestartPublisher.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantRestartPublisher.java
index b086b1914..c00116e3b 100644..100755
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantRestartPublisher.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantRestartPublisher.java
@@ -100,6 +100,15 @@ public class ParticipantRestartPublisher extends AbstractParticipantPublisher<Pa
elementList.add(elementEntry);
}
}
- return AcmUtils.prepareParticipantPriming(elementList, supportedElementMap);
+ var list = AcmUtils.prepareParticipantPriming(elementList, supportedElementMap);
+ for (var participantDefinition : list) {
+ for (var elementDe : participantDefinition.getAutomationCompositionElementDefinitionList()) {
+ var state = acmDefinition.getElementStateMap().get(elementDe.getAcElementDefinitionId().getName());
+ if (state != null) {
+ elementDe.setOutProperties(state.getOutProperties());
+ }
+ }
+ }
+ return list;
}
}
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 49aa03096..670806f65 100755
--- 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,17 +38,19 @@ import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantRestartPubl
import org.onap.policy.clamp.acm.runtime.util.CommonTestData;
import org.onap.policy.clamp.models.acm.concepts.AcTypeState;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionDefinition;
+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.NodeTemplateState;
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.ParticipantState;
-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.AcDefinitionProvider;
import org.onap.policy.clamp.models.acm.persistence.provider.AutomationCompositionProvider;
import org.onap.policy.clamp.models.acm.persistence.provider.ParticipantProvider;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
class SupervisionParticipantHandlerTest {
@@ -149,11 +151,7 @@ class SupervisionParticipantHandlerTest {
@Test
void testHandleParticipantStatus() {
- var participantStatusMessage = new ParticipantStatus();
- participantStatusMessage.setParticipantId(CommonTestData.getParticipantId());
- participantStatusMessage.setState(ParticipantState.ON_LINE);
- var supportedElementType = CommonTestData.createParticipantSupportedElementType();
- participantStatusMessage.setParticipantSupportedElementType(List.of(supportedElementType));
+ var participantStatusMessage = createParticipantStatus();
participantStatusMessage.setAutomationCompositionInfoList(List.of(new AutomationCompositionInfo()));
var participantProvider = mock(ParticipantProvider.class);
@@ -171,12 +169,40 @@ class SupervisionParticipantHandlerTest {
}
@Test
+ void testAcDefinitionOutProperties() {
+ var participantStatusMessage = createParticipantStatus();
+ participantStatusMessage.setAutomationCompositionInfoList(List.of(new AutomationCompositionInfo()));
+ var participantDefinition = new ParticipantDefinition();
+ participantStatusMessage.setParticipantDefinitionUpdates(List.of(participantDefinition));
+ participantDefinition.setParticipantId(participantStatusMessage.getParticipantId());
+ var acElementDefinition = new AutomationCompositionElementDefinition();
+ acElementDefinition.setAcElementDefinitionId(new ToscaConceptIdentifier("code", "1.0.0"));
+ participantDefinition.setAutomationCompositionElementDefinitionList(List.of(acElementDefinition));
+
+ var compositionId = UUID.randomUUID();
+ participantStatusMessage.setCompositionId(compositionId);
+ var acDefinition = new AutomationCompositionDefinition();
+ acDefinition.setState(AcTypeState.COMMISSIONED);
+ acDefinition.setCompositionId(compositionId);
+ var nodeTemplateState = new NodeTemplateState();
+ acDefinition.setElementStateMap(
+ Map.of(acElementDefinition.getAcElementDefinitionId().getName(), nodeTemplateState));
+ var acDefinitionProvider = mock(AcDefinitionProvider.class);
+ when(acDefinitionProvider.findAcDefinition(compositionId)).thenReturn(Optional.of(acDefinition));
+
+ var participantProvider = mock(ParticipantProvider.class);
+ var handler =
+ new SupervisionParticipantHandler(participantProvider, mock(ParticipantRegisterAckPublisher.class),
+ mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionProvider.class),
+ acDefinitionProvider, mock(ParticipantRestartPublisher.class));
+ handler.handleParticipantMessage(participantStatusMessage);
+
+ verify(acDefinitionProvider).updateAcDefinition(acDefinition);
+ }
+
+ @Test
void testHandleParticipantStatusNotRegisterd() {
- var participantStatusMessage = new ParticipantStatus();
- participantStatusMessage.setParticipantId(CommonTestData.getParticipantId());
- participantStatusMessage.setState(ParticipantState.ON_LINE);
- var supportedElementType = CommonTestData.createParticipantSupportedElementType();
- participantStatusMessage.setParticipantSupportedElementType(List.of(supportedElementType));
+ var participantStatusMessage = createParticipantStatus();
participantStatusMessage.setAutomationCompositionInfoList(List.of(new AutomationCompositionInfo()));
var participantProvider = mock(ParticipantProvider.class);
@@ -193,11 +219,7 @@ class SupervisionParticipantHandlerTest {
@Test
void testHandleParticipantStatusCheckOnline() {
- var participantStatusMessage = new ParticipantStatus();
- participantStatusMessage.setParticipantId(CommonTestData.getParticipantId());
- participantStatusMessage.setState(ParticipantState.ON_LINE);
- var supportedElementType = CommonTestData.createParticipantSupportedElementType();
- participantStatusMessage.setParticipantSupportedElementType(List.of(supportedElementType));
+ var participantStatusMessage = createParticipantStatus();
participantStatusMessage.setAutomationCompositionInfoList(List.of(new AutomationCompositionInfo()));
var participantProvider = mock(ParticipantProvider.class);
@@ -215,4 +237,13 @@ class SupervisionParticipantHandlerTest {
verify(participantProvider).saveParticipant(any());
verify(automationCompositionProvider).upgradeStates(any());
}
+
+ private ParticipantStatus createParticipantStatus() {
+ var statusMessage = new ParticipantStatus();
+ statusMessage.setParticipantId(CommonTestData.getParticipantId());
+ statusMessage.setState(ParticipantState.ON_LINE);
+ var supportedElementType = CommonTestData.createParticipantSupportedElementType();
+ statusMessage.setParticipantSupportedElementType(List.of(supportedElementType));
+ return statusMessage;
+ }
}