summaryrefslogtreecommitdiffstats
path: root/runtime-acm/src/test/java
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2023-08-03 13:21:22 +0100
committerAdheli Tavares <adheli.tavares@est.tech>2023-08-08 09:53:04 +0000
commit092e94405aaeffb9c24b1d4037948d13ff19e7e3 (patch)
tree288f280f469310ffb14f8d55b4ecff0df19d0189 /runtime-acm/src/test/java
parent99416bab41ce90c7931fcf92b042296ba8b9e2e0 (diff)
Add support to save outProperties in AC Definition in ACM runtime
Add support to save outProperties in AC Definition from Participant Status message. Add outProperties support in restart message. Issue-ID: POLICY-4781 Change-Id: I9f9bed5c9c3e6692a1e4666162b752db95994f95 Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'runtime-acm/src/test/java')
-rwxr-xr-xruntime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java63
1 files changed, 47 insertions, 16 deletions
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;
+ }
}