aboutsummaryrefslogtreecommitdiffstats
path: root/runtime-acm/src
diff options
context:
space:
mode:
Diffstat (limited to 'runtime-acm/src')
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java15
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java33
2 files changed, 26 insertions, 22 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 d0b7b62b6..5627bead2 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
@@ -25,6 +25,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
+import java.util.function.UnaryOperator;
+import java.util.stream.Collectors;
import lombok.AllArgsConstructor;
import org.apache.commons.collections4.MapUtils;
import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantDeregisterAckPublisher;
@@ -33,6 +35,7 @@ import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantSyncPublish
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.NodeTemplateState;
import org.onap.policy.clamp.models.acm.concepts.Participant;
import org.onap.policy.clamp.models.acm.concepts.ParticipantReplica;
import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
@@ -109,11 +112,19 @@ public class SupervisionParticipantHandler {
participantStatusMsg.getParticipantSupportedElementType(), false);
if (!participantStatusMsg.getAutomationCompositionInfoList().isEmpty()) {
- messageProvider.save(participantStatusMsg);
+ messageProvider.saveInstanceOutProperties(participantStatusMsg);
}
if (!participantStatusMsg.getParticipantDefinitionUpdates().isEmpty()
&& participantStatusMsg.getCompositionId() != null) {
- messageProvider.save(participantStatusMsg);
+ var acDefinition = acDefinitionProvider.findAcDefinition(participantStatusMsg.getCompositionId());
+ if (acDefinition.isPresent()) {
+ var map = acDefinition.get().getElementStateMap()
+ .values().stream().collect(Collectors.toMap(NodeTemplateState::getNodeTemplateId,
+ UnaryOperator.identity()));
+ messageProvider.saveCompositionOutProperties(participantStatusMsg, map);
+ } else {
+ LOGGER.error("Not valid ParticipantStatus message");
+ }
}
}
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 315fb8c48..2cdcf210a 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
@@ -169,16 +169,11 @@ class SupervisionParticipantHandlerTest {
}
@Test
- void testHandleParticipantStatus() {
+ void testHandleParticipantStatusWithInstanceOutProperties() {
var participantStatusMessage = createParticipantStatus();
participantStatusMessage.setAutomationCompositionInfoList(List.of(new AutomationCompositionInfo()));
participantStatusMessage.setCompositionId(UUID.randomUUID());
- var acDefinitionProvider = mock(AcDefinitionProvider.class);
- var acDefinition = new AutomationCompositionDefinition();
- acDefinition.setCompositionId(participantStatusMessage.getCompositionId());
- when(acDefinitionProvider.getAcDefinition(acDefinition.getCompositionId())).thenReturn(acDefinition);
-
var participantProvider = mock(ParticipantProvider.class);
var participant = CommonTestData.createParticipant(CommonTestData.getParticipantId());
when(participantProvider.findParticipant(CommonTestData.getParticipantId()))
@@ -190,17 +185,18 @@ class SupervisionParticipantHandlerTest {
var automationCompositionProvider = mock(AutomationCompositionProvider.class);
var messageProvider = mock(MessageProvider.class);
+ var acDefinitionProvider = mock(AcDefinitionProvider.class);
var handler =
new SupervisionParticipantHandler(participantProvider, mock(ParticipantRegisterAckPublisher.class),
mock(ParticipantDeregisterAckPublisher.class), automationCompositionProvider,
acDefinitionProvider, mock(ParticipantSyncPublisher.class), messageProvider);
handler.handleParticipantMessage(participantStatusMessage);
- verify(messageProvider).save(any(ParticipantStatus.class));
+ verify(messageProvider).saveInstanceOutProperties(any(ParticipantStatus.class));
}
@Test
- void testAcDefinitionOutProperties() {
+ void testHandleParticipantStatusWithCompositionOutProperties() {
var participantStatusMessage = createParticipantStatus();
var participantDefinition = new ParticipantDefinition();
participantStatusMessage.setParticipantDefinitionUpdates(List.of(participantDefinition));
@@ -228,31 +224,30 @@ class SupervisionParticipantHandlerTest {
mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionProvider.class),
acDefinitionProvider, mock(ParticipantSyncPublisher.class), messageProvider);
handler.handleParticipantMessage(participantStatusMessage);
- verify(messageProvider).save(participantStatusMessage);
+ verify(messageProvider).saveCompositionOutProperties(any(), any());
}
@Test
- void testAcOutProperties() {
+ void testAcOutPropertiesNotValid() {
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 acDefinitionProvider = mock(AcDefinitionProvider.class);
var messageProvider = mock(MessageProvider.class);
- when(acDefinitionProvider.findAcDefinition(compositionId)).thenReturn(Optional.of(acDefinition));
- when(acDefinitionProvider.getAcDefinition(compositionId)).thenReturn(acDefinition);
-
var participantProvider = mock(ParticipantProvider.class);
var handler =
new SupervisionParticipantHandler(participantProvider, mock(ParticipantRegisterAckPublisher.class),
mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionProvider.class),
acDefinitionProvider, mock(ParticipantSyncPublisher.class), messageProvider);
handler.handleParticipantMessage(participantStatusMessage);
- verify(messageProvider).save(participantStatusMessage);
+ verify(messageProvider, times(0)).saveCompositionOutProperties(any(), any());
}
@Test
@@ -275,7 +270,6 @@ class SupervisionParticipantHandlerTest {
@Test
void testHandleParticipantStatusCheckOnline() {
var participantStatusMessage = createParticipantStatus();
- participantStatusMessage.setAutomationCompositionInfoList(List.of(new AutomationCompositionInfo()));
participantStatusMessage.setCompositionId(UUID.randomUUID());
var acDefinitionProvider = mock(AcDefinitionProvider.class);
@@ -296,7 +290,6 @@ class SupervisionParticipantHandlerTest {
handler.handleParticipantMessage(participantStatusMessage);
verify(participantProvider).saveParticipant(any());
- verify(messageProvider).save(any(ParticipantStatus.class));
}
private ParticipantStatus createParticipantStatus() {