summaryrefslogtreecommitdiffstats
path: root/runtime-acm
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2022-09-28 13:24:50 +0100
committerFrancesco Fiora <francesco.fiora@est.tech>2022-09-28 12:27:50 +0000
commit9e7b5161c1fad7c8d3bd7b150a70e1e4b1e0213b (patch)
tree0481225c68e16f32a2849529d4f6fc5c8f6f7b6a /runtime-acm
parenta7a709e3088c2ce2715e0ae9ed927f8bd4b47153 (diff)
Increase code coverage in runtime-acm
Issue-ID: POLICY-4370 Change-Id: If017da7bfe555dcbc9c7be62628751dbf9707623 Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'runtime-acm')
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspectTest.java51
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java132
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java21
3 files changed, 156 insertions, 48 deletions
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspectTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspectTest.java
index 487d41139..84b756816 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspectTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspectTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,19 +22,27 @@
package org.onap.policy.clamp.acm.runtime.supervision;
import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.timeout;
import static org.mockito.Mockito.verify;
+import org.apache.commons.lang3.tuple.ImmutablePair;
import org.junit.jupiter.api.Test;
+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.messages.dmaap.participant.ParticipantUpdateAck;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
class SupervisionAspectTest {
+ private static final ToscaConceptIdentifier PARTICIPANT_ID =
+ new ToscaConceptIdentifier("org.onap.PM_Policy", "1.0.0");
+
+ private static final ToscaConceptIdentifier PARTICIPANT_TYPE =
+ new ToscaConceptIdentifier("org.onap.policy.clamp.acm.PolicyParticipant", "1.0.0");
+
@Test
void testSchedule() throws Exception {
- var supervisionScanner = spy(mock(SupervisionScanner.class));
+ var supervisionScanner = mock(SupervisionScanner.class);
try (var supervisionAspect = new SupervisionAspect(supervisionScanner)) {
supervisionAspect.schedule();
verify(supervisionScanner, timeout(500)).run(true);
@@ -43,7 +51,7 @@ class SupervisionAspectTest {
@Test
void testDoCheck() throws Exception {
- var supervisionScanner = spy(mock(SupervisionScanner.class));
+ var supervisionScanner = mock(SupervisionScanner.class);
try (var supervisionAspect = new SupervisionAspect(supervisionScanner)) {
supervisionAspect.doCheck();
supervisionAspect.doCheck();
@@ -53,14 +61,41 @@ class SupervisionAspectTest {
@Test
void testHandleParticipantStatus() throws Exception {
- var supervisionScanner = spy(mock(SupervisionScanner.class));
var participantStatusMessage = new ParticipantStatus();
- var identifier = new ToscaConceptIdentifier("abc", "1.0.0");
- participantStatusMessage.setParticipantId(identifier);
+ participantStatusMessage.setParticipantId(PARTICIPANT_ID);
+ var supervisionScanner = mock(SupervisionScanner.class);
try (var supervisionAspect = new SupervisionAspect(supervisionScanner)) {
supervisionAspect.handleParticipantStatus(participantStatusMessage);
- verify(supervisionScanner, timeout(500)).handleParticipantStatus(identifier);
+ verify(supervisionScanner, timeout(500)).handleParticipantStatus(PARTICIPANT_ID);
+ }
+ }
+
+ @Test
+ void testHandleParticipantUpdateAck() throws Exception {
+ var updateAckMessage = new ParticipantUpdateAck();
+ updateAckMessage.setParticipantId(PARTICIPANT_ID);
+ updateAckMessage.setParticipantType(PARTICIPANT_TYPE);
+
+ var supervisionScanner = mock(SupervisionScanner.class);
+ try (var supervisionAspect = new SupervisionAspect(supervisionScanner)) {
+ supervisionAspect.handleParticipantUpdateAck(updateAckMessage);
+ verify(supervisionScanner, timeout(500))
+ .handleParticipantUpdateAck(new ImmutablePair<>(PARTICIPANT_ID, PARTICIPANT_TYPE));
+ }
+ }
+
+ @Test
+ void testHandleParticipantRegister() throws Exception {
+ var participantRegister = new ParticipantRegister();
+ participantRegister.setParticipantId(PARTICIPANT_ID);
+ participantRegister.setParticipantType(PARTICIPANT_TYPE);
+
+ var supervisionScanner = mock(SupervisionScanner.class);
+ try (var supervisionAspect = new SupervisionAspect(supervisionScanner)) {
+ supervisionAspect.handleParticipantRegister(participantRegister, true);
+ verify(supervisionScanner, timeout(500))
+ .handleParticipantRegister(new ImmutablePair<>(PARTICIPANT_ID, PARTICIPANT_TYPE));
}
}
}
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java
index eb7bafa78..a80d39ebc 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java
@@ -23,10 +23,11 @@ package org.onap.policy.clamp.acm.runtime.supervision;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyList;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import static org.onap.policy.clamp.acm.runtime.util.CommonTestData.TOSCA_ST_TEMPLATE_YAML;
+import static org.onap.policy.clamp.acm.runtime.util.CommonTestData.TOSCA_SERVICE_TEMPLATE_YAML;
import java.util.List;
import java.util.Map;
@@ -45,6 +46,7 @@ import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantUpdatePubli
import org.onap.policy.clamp.common.acm.exception.AutomationCompositionException;
import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
import org.onap.policy.clamp.models.acm.concepts.Participant;
import org.onap.policy.clamp.models.acm.concepts.ParticipantHealthStatus;
import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
@@ -72,11 +74,8 @@ class SupervisionHandlerTest {
@Test
void testTriggerAutomationCompositionSupervisionEmpty() throws PfModelException, CoderException {
- var handler =
- createSupervisionHandler(mock(AutomationCompositionProvider.class), mock(ParticipantProvider.class),
- mock(MonitoringProvider.class), mock(ParticipantRegisterAckPublisher.class),
- mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionUpdatePublisher.class),
- mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE);
+ var handler = createSupervisionHandler(AutomationCompositionOrderedState.PASSIVE,
+ AutomationCompositionState.UNINITIALISED);
assertThatThrownBy(() -> handler.triggerAutomationCompositionSupervision(List.of()))
.hasMessageMatching("The list of automation compositions for supervision is empty");
@@ -90,7 +89,8 @@ class SupervisionHandlerTest {
var handler = createSupervisionHandler(automationCompositionProvider, mock(ParticipantProvider.class),
mock(MonitoringProvider.class), mock(ParticipantRegisterAckPublisher.class),
mock(ParticipantDeregisterAckPublisher.class), automationCompositionUpdatePublisher,
- mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE);
+ mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE,
+ AutomationCompositionState.UNINITIALISED);
handler.triggerAutomationCompositionSupervision(List.of(identifier));
@@ -99,26 +99,68 @@ class SupervisionHandlerTest {
}
@Test
- void testTriggerAutomationCompositionUninitialised() throws PfModelException, CoderException {
- var automationCompositionProvider = mock(AutomationCompositionProvider.class);
- var automationCompositionUpdatePublisher = mock(AutomationCompositionUpdatePublisher.class);
- var handler = createSupervisionHandler(automationCompositionProvider, mock(ParticipantProvider.class),
- mock(MonitoringProvider.class), mock(ParticipantRegisterAckPublisher.class),
- mock(ParticipantDeregisterAckPublisher.class), automationCompositionUpdatePublisher,
- mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.UNINITIALISED);
+ void testAcUninitialisedToUninitialised() throws PfModelException, CoderException {
+ var handler = createSupervisionHandler(AutomationCompositionOrderedState.UNINITIALISED,
+ AutomationCompositionState.UNINITIALISED);
assertThatThrownBy(() -> handler.triggerAutomationCompositionSupervision(List.of(identifier)))
.hasMessageMatching("Automation composition is already in state UNINITIALISED");
}
@Test
- void testTriggerAutomationCompositionRunning() throws PfModelException, CoderException {
+ void testAcUninitialisedToPassive() throws PfModelException, CoderException, AutomationCompositionException {
+
+ var automationCompositionsCreate =
+ InstantiationUtils.getAutomationCompositionsFromResource(AC_INSTANTIATION_CREATE_JSON, "Crud");
+
+ var automationComposition = automationCompositionsCreate.getAutomationCompositionList().get(0);
+ automationComposition.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED);
+ automationComposition.setState(AutomationCompositionState.PASSIVE);
+
var automationCompositionProvider = mock(AutomationCompositionProvider.class);
- var automationCompositionUpdatePublisher = mock(AutomationCompositionUpdatePublisher.class);
- var handler = createSupervisionHandler(automationCompositionProvider, mock(ParticipantProvider.class),
- mock(MonitoringProvider.class), mock(ParticipantRegisterAckPublisher.class),
- mock(ParticipantDeregisterAckPublisher.class), automationCompositionUpdatePublisher,
- mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.RUNNING);
+ when(automationCompositionProvider.findAutomationComposition(identifier))
+ .thenReturn(Optional.of(automationComposition));
+ when(automationCompositionProvider.getAutomationComposition(identifier)).thenReturn(automationComposition);
+
+ var serviceTemplateProvider = Mockito.mock(ServiceTemplateProvider.class);
+ when(serviceTemplateProvider.getAllServiceTemplates())
+ .thenReturn(List.of(Objects.requireNonNull(InstantiationUtils.getToscaServiceTemplate(
+ TOSCA_SERVICE_TEMPLATE_YAML))));
+
+ var automationCompositionStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class);
+
+ var handler = new SupervisionHandler(automationCompositionProvider, mock(ParticipantProvider.class),
+ mock(MonitoringProvider.class), serviceTemplateProvider, mock(AutomationCompositionUpdatePublisher.class),
+ automationCompositionStateChangePublisher, mock(ParticipantRegisterAckPublisher.class),
+ mock(ParticipantDeregisterAckPublisher.class), mock(ParticipantUpdatePublisher.class));
+
+ handler.triggerAutomationCompositionSupervision(List.of(identifier));
+
+ verify(automationCompositionStateChangePublisher).send(any(AutomationComposition.class), eq(0));
+ }
+
+ @Test
+ void testAcPassiveToPassive() throws PfModelException, CoderException {
+ var handler = createSupervisionHandler(AutomationCompositionOrderedState.PASSIVE,
+ AutomationCompositionState.PASSIVE);
+
+ assertThatThrownBy(() -> handler.triggerAutomationCompositionSupervision(List.of(identifier)))
+ .hasMessageMatching("Automation composition is already in state PASSIVE");
+ }
+
+ @Test
+ void testAcRunningToRunning() throws PfModelException, CoderException {
+ var handler = createSupervisionHandler(AutomationCompositionOrderedState.RUNNING,
+ AutomationCompositionState.RUNNING);
+
+ assertThatThrownBy(() -> handler.triggerAutomationCompositionSupervision(List.of(identifier)))
+ .hasMessageMatching("Automation composition is already in state RUNNING");
+ }
+
+ @Test
+ void testAcRunningToUninitialised() throws PfModelException, CoderException {
+ var handler = createSupervisionHandler(AutomationCompositionOrderedState.RUNNING,
+ AutomationCompositionState.UNINITIALISED);
assertThatThrownBy(() -> handler.triggerAutomationCompositionSupervision(List.of(identifier)))
.hasMessageMatching("Automation composition can't transition from state UNINITIALISED to state RUNNING");
@@ -130,7 +172,8 @@ class SupervisionHandlerTest {
var handler = createSupervisionHandler(automationCompositionProvider, mock(ParticipantProvider.class),
mock(MonitoringProvider.class), mock(ParticipantRegisterAckPublisher.class),
mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionUpdatePublisher.class),
- mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE);
+ mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE,
+ AutomationCompositionState.UNINITIALISED);
var automationCompositionAckMessage =
new AutomationCompositionAck(ParticipantMessageType.AUTOMATION_COMPOSITION_STATECHANGE_ACK);
automationCompositionAckMessage.setAutomationCompositionResultMap(Map.of());
@@ -153,7 +196,8 @@ class SupervisionHandlerTest {
var handler = createSupervisionHandler(automationCompositionProvider, mock(ParticipantProvider.class),
mock(MonitoringProvider.class), mock(ParticipantRegisterAckPublisher.class),
mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionUpdatePublisher.class),
- mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE);
+ mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE,
+ AutomationCompositionState.UNINITIALISED);
handler.handleAutomationCompositionUpdateAckMessage(automationCompositionAckMessage);
@@ -179,7 +223,8 @@ class SupervisionHandlerTest {
var handler = createSupervisionHandler(mock(AutomationCompositionProvider.class), participantProvider,
mock(MonitoringProvider.class), mock(ParticipantRegisterAckPublisher.class),
participantDeregisterAckPublisher, mock(AutomationCompositionUpdatePublisher.class),
- mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE);
+ mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE,
+ AutomationCompositionState.UNINITIALISED);
handler.handleParticipantMessage(participantDeregisterMessage);
@@ -203,7 +248,8 @@ class SupervisionHandlerTest {
var handler = createSupervisionHandler(mock(AutomationCompositionProvider.class), participantProvider,
mock(MonitoringProvider.class), participantRegisterAckPublisher,
mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionUpdatePublisher.class),
- mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE);
+ mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE,
+ AutomationCompositionState.UNINITIALISED);
handler.handleParticipantMessage(participantRegisterMessage);
@@ -230,7 +276,8 @@ class SupervisionHandlerTest {
var handler = createSupervisionHandler(mock(AutomationCompositionProvider.class), participantProvider,
mock(MonitoringProvider.class), mock(ParticipantRegisterAckPublisher.class),
mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionUpdatePublisher.class),
- mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE);
+ mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE,
+ AutomationCompositionState.UNINITIALISED);
handler.handleParticipantMessage(participantUpdateAckMessage);
@@ -251,7 +298,8 @@ class SupervisionHandlerTest {
var handler = createSupervisionHandler(mock(AutomationCompositionProvider.class), participantProvider,
monitoringProvider, mock(ParticipantRegisterAckPublisher.class),
mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionUpdatePublisher.class),
- mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE);
+ mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE,
+ AutomationCompositionState.UNINITIALISED);
handler.handleParticipantMessage(participantStatusMessage);
verify(participantProvider).saveParticipant(any());
@@ -265,7 +313,8 @@ class SupervisionHandlerTest {
createSupervisionHandler(mock(AutomationCompositionProvider.class), mock(ParticipantProvider.class),
mock(MonitoringProvider.class), mock(ParticipantRegisterAckPublisher.class),
mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionUpdatePublisher.class),
- participantUpdatePublisher, AutomationCompositionOrderedState.PASSIVE);
+ participantUpdatePublisher, AutomationCompositionOrderedState.PASSIVE,
+ AutomationCompositionState.UNINITIALISED);
handler.handleSendCommissionMessage(participantId.getName(), participantId.getVersion());
verify(participantUpdatePublisher).sendComissioningBroadcast(participantId.getName(),
@@ -279,24 +328,34 @@ class SupervisionHandlerTest {
createSupervisionHandler(mock(AutomationCompositionProvider.class), mock(ParticipantProvider.class),
mock(MonitoringProvider.class), mock(ParticipantRegisterAckPublisher.class),
mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionUpdatePublisher.class),
- participantUpdatePublisher, AutomationCompositionOrderedState.PASSIVE);
+ participantUpdatePublisher, AutomationCompositionOrderedState.PASSIVE,
+ AutomationCompositionState.UNINITIALISED);
handler.handleSendDeCommissionMessage();
verify(participantUpdatePublisher).sendDecomisioning();
}
+ private SupervisionHandler createSupervisionHandler(AutomationCompositionOrderedState orderedState,
+ AutomationCompositionState state) throws PfModelException, CoderException {
+ return createSupervisionHandler(mock(AutomationCompositionProvider.class), mock(ParticipantProvider.class),
+ mock(MonitoringProvider.class), mock(ParticipantRegisterAckPublisher.class),
+ mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionUpdatePublisher.class),
+ mock(ParticipantUpdatePublisher.class), orderedState, state);
+ }
+
private SupervisionHandler createSupervisionHandler(AutomationCompositionProvider automationCompositionProvider,
- ParticipantProvider participantProvider, MonitoringProvider monitoringProvider,
- ParticipantRegisterAckPublisher participantRegisterAckPublisher,
- ParticipantDeregisterAckPublisher participantDeregisterAckPublisher,
- AutomationCompositionUpdatePublisher automationCompositionUpdatePublisher,
- ParticipantUpdatePublisher participantUpdatePublisher, AutomationCompositionOrderedState orderedState)
- throws PfModelException, CoderException {
+ ParticipantProvider participantProvider, MonitoringProvider monitoringProvider,
+ ParticipantRegisterAckPublisher participantRegisterAckPublisher,
+ ParticipantDeregisterAckPublisher participantDeregisterAckPublisher,
+ AutomationCompositionUpdatePublisher automationCompositionUpdatePublisher,
+ ParticipantUpdatePublisher participantUpdatePublisher, AutomationCompositionOrderedState orderedState,
+ AutomationCompositionState state) throws PfModelException, CoderException {
var automationCompositionsCreate =
InstantiationUtils.getAutomationCompositionsFromResource(AC_INSTANTIATION_CREATE_JSON, "Crud");
var automationComposition = automationCompositionsCreate.getAutomationCompositionList().get(0);
automationComposition.setOrderedState(orderedState);
+ automationComposition.setState(state);
when(automationCompositionProvider.findAutomationComposition(identifier))
.thenReturn(Optional.of(automationComposition));
@@ -305,7 +364,10 @@ class SupervisionHandlerTest {
var serviceTemplateProvider = Mockito.mock(ServiceTemplateProvider.class);
when(serviceTemplateProvider.getServiceTemplateList(any(), any()))
.thenReturn(List.of(Objects.requireNonNull(InstantiationUtils.getToscaServiceTemplate(
- TOSCA_ST_TEMPLATE_YAML))));
+ TOSCA_SERVICE_TEMPLATE_YAML))));
+ when(serviceTemplateProvider.getAllServiceTemplates())
+ .thenReturn(List.of(Objects.requireNonNull(InstantiationUtils.getToscaServiceTemplate(
+ TOSCA_SERVICE_TEMPLATE_YAML))));
var automationCompositionStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class);
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java
index 68476f50e..cc3a95e81 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java
@@ -30,6 +30,7 @@ import static org.onap.policy.clamp.acm.runtime.util.CommonTestData.TOSCA_ST_TEM
import java.util.List;
import java.util.Objects;
+import org.apache.commons.lang3.tuple.ImmutablePair;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.onap.policy.clamp.acm.runtime.instantiation.InstantiationUtils;
@@ -58,6 +59,12 @@ class SupervisionScannerTest {
private static final ServiceTemplateProvider serviceTemplateProvider = mock(ServiceTemplateProvider.class);
+ private static final String PARTICIPANT_NAME = "Participant0";
+ private static final String PARTICIPANT_VERSION = "1.0.0";
+
+ private static final ToscaConceptIdentifier PARTICIPANT_TYPE =
+ new ToscaConceptIdentifier("org.onap.policy.clamp.acm.PolicyParticipant", PARTICIPANT_VERSION);
+
@BeforeAll
public static void setUpBeforeAll() throws Exception {
ToscaServiceTemplate serviceTemplate = InstantiationUtils.getToscaServiceTemplate(TOSCA_ST_TEMPLATE_YAML);
@@ -119,8 +126,8 @@ class SupervisionScannerTest {
var participantProvider = mock(ParticipantProvider.class);
var participant = new Participant();
- participant.setName("Participant0");
- participant.setVersion("1.0.0");
+ participant.setName(PARTICIPANT_NAME);
+ participant.setVersion(PARTICIPANT_VERSION);
when(participantProvider.getParticipants(null, null)).thenReturn(List.of(participant));
var automationCompositionUpdatePublisher = mock(AutomationCompositionUpdatePublisher.class);
@@ -186,12 +193,12 @@ class SupervisionScannerTest {
acRuntimeParameterGroup.getParticipantParameters().setMaxStatusWaitMs(-1);
var participant = new Participant();
- participant.setName("Participant0");
- participant.setVersion("1.0.0");
+ participant.setName(PARTICIPANT_NAME);
+ participant.setVersion(PARTICIPANT_VERSION);
participant.setHealthStatus(ParticipantHealthStatus.HEALTHY);
participant.setParticipantState(ParticipantState.ACTIVE);
participant.setDefinition(new ToscaConceptIdentifier("unknown", "0.0.0"));
- participant.setParticipantType(new ToscaConceptIdentifier("ParticipantType1", "1.0.0"));
+ participant.setParticipantType(PARTICIPANT_TYPE);
var participantProvider = mock(ParticipantProvider.class);
when(participantProvider.getParticipants()).thenReturn(List.of(participant));
@@ -204,11 +211,15 @@ class SupervisionScannerTest {
automationCompositionStateChangePublisher, automationCompositionUpdatePublisher, participantProvider,
participantStatusReqPublisher, participantUpdatePublisher, acRuntimeParameterGroup);
+ supervisionScanner
+ .handleParticipantRegister(new ImmutablePair<>(participant.getKey().asIdentifier(), PARTICIPANT_TYPE));
supervisionScanner.handleParticipantStatus(participant.getKey().asIdentifier());
supervisionScanner.run(true);
verify(participantStatusReqPublisher).send(any(ToscaConceptIdentifier.class));
verify(participantProvider).saveParticipant(any());
+ supervisionScanner
+ .handleParticipantUpdateAck(new ImmutablePair<>(participant.getKey().asIdentifier(), PARTICIPANT_TYPE));
supervisionScanner.run(true);
verify(participantProvider, times(2)).saveParticipant(any());
}