summaryrefslogtreecommitdiffstats
path: root/participant/participant-intermediary/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'participant/participant-intermediary/src/test/java')
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java (renamed from participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java)65
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantCommTest.java (renamed from participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantCommTest.java)57
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandlerTest.java227
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/DummyParticipantParameters.java (renamed from participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/DummyParticipantParameters.java)6
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/IntermediaryActivatorTest.java (renamed from participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/IntermediaryActivatorTest.java)10
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandlerTest.java (renamed from participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandlerTest.java)44
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java (renamed from participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/main/parameters/CommonTestData.java)139
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/TestParticipantIntermediaryParameters.java (renamed from participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/main/parameters/TestParticipantIntermediaryParameters.java)10
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandlerTest.java226
9 files changed, 392 insertions, 392 deletions
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java
index b08e796b7..5d9675606 100644
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.participant.intermediary.api.impl;
+package org.onap.policy.clamp.acm.participant.intermediary.api.impl;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
@@ -29,15 +29,15 @@ import java.time.Instant;
import java.util.UUID;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantHealthStatus;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType;
-import org.onap.policy.clamp.controlloop.participant.intermediary.api.ControlLoopElementListener;
-import org.onap.policy.clamp.controlloop.participant.intermediary.main.parameters.CommonTestData;
+import org.onap.policy.clamp.acm.participant.intermediary.api.AutomationCompositionElementListener;
+import org.onap.policy.clamp.acm.participant.intermediary.main.parameters.CommonTestData;
+import org.onap.policy.clamp.models.acm.concepts.AcElementStatistics;
+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.ParticipantHealthStatus;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantStatistics;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
@@ -47,24 +47,24 @@ class ParticipantIntermediaryApiImplTest {
private static final String ID_NAME = "org.onap.PM_CDS_Blueprint";
private static final String ID_VERSION = "1.0.1";
- private static final String ID_NAME_E = "org.onap.domain.pmsh.PMSHControlLoopDefinition";
+ private static final String ID_NAME_E = "org.onap.domain.pmsh.PMSHAutomationCompositionDefinition";
private static final String ID_VERSION_E = "1.0.0";
- private static final String ID_NAME_TYPE = "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant";
+ private static final String ID_NAME_TYPE = "org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant";
private static final String ID_VERSION_TYPE = "2.3.4";
@Test
void mockParticipantIntermediaryApiImplTest() throws CoderException {
var uuid = UUID.randomUUID();
var id = new ToscaConceptIdentifier(ID_NAME, ID_VERSION);
- var participantHandler = commonTestData.getParticipantHandlerControlLoops();
- var controlLoopHandler = commonTestData.setTestControlLoopHandler(id, uuid);
- var apiImpl = new ParticipantIntermediaryApiImpl(participantHandler, controlLoopHandler);
- var clElementListener = Mockito.mock(ControlLoopElementListener.class);
- apiImpl.registerControlLoopElementListener(clElementListener);
+ var participantHandler = commonTestData.getParticipantHandlerAutomationCompositions();
+ var automationComposiitonHandler = commonTestData.setTestAutomationCompositionHandler(id, uuid);
+ var apiImpl = new ParticipantIntermediaryApiImpl(participantHandler, automationComposiitonHandler);
+ var acElementListener = Mockito.mock(AutomationCompositionElementListener.class);
+ apiImpl.registerAutomationCompositionElementListener(acElementListener);
- assertNotNull(apiImpl.getControlLoops(id.getName(), id.getVersion()));
- assertThat(apiImpl.getClElementDefinitionCommonProperties(id)).isEmpty();
+ assertNotNull(apiImpl.getAutomationCompositions(id.getName(), id.getVersion()));
+ assertThat(apiImpl.getAcElementDefinitionCommonProperties(id)).isEmpty();
var participantStatistics = new ParticipantStatistics();
participantStatistics.setParticipantId(id);
@@ -79,24 +79,25 @@ class ParticipantIntermediaryApiImplTest {
var participant = apiImpl.updateParticipantState(id, ParticipantState.TERMINATED);
assertEquals(ParticipantState.TERMINATED, participant.getParticipantState());
- var elements = apiImpl.getControlLoopElements(ID_NAME_E, ID_VERSION_E);
+ var elements = apiImpl.getAutomationCompositionElements(ID_NAME_E, ID_VERSION_E);
assertFalse(elements.containsKey(uuid));
- var element = apiImpl.getControlLoopElement(elements.keySet().iterator().next());
+ var element = apiImpl.getAutomationCompositionElement(elements.keySet().iterator().next());
var idType = new ToscaConceptIdentifier(ID_NAME_TYPE, ID_VERSION_TYPE);
assertEquals(idType, element.getParticipantType());
- var clElementStatistics = new ClElementStatistics();
- var controlLoopId = new ToscaConceptIdentifier("defName", "0.0.1");
- clElementStatistics.setParticipantId(controlLoopId);
- clElementStatistics.setControlLoopState(ControlLoopState.RUNNING);
- clElementStatistics.setTimeStamp(Instant.now());
-
- apiImpl.updateControlLoopElementStatistics(uuid, clElementStatistics);
- var clElement = apiImpl.updateControlLoopElementState(id, uuid, ControlLoopOrderedState.UNINITIALISED,
- ControlLoopState.PASSIVE, ParticipantMessageType.CONTROLLOOP_STATECHANGE_ACK);
- assertEquals(ControlLoopOrderedState.UNINITIALISED, clElement.getOrderedState());
- assertEquals(uuid, clElement.getId());
+ var acElementStatistics = new AcElementStatistics();
+ var automationCompositionId = new ToscaConceptIdentifier("defName", "0.0.1");
+ acElementStatistics.setParticipantId(automationCompositionId);
+ acElementStatistics.setState(AutomationCompositionState.RUNNING);
+ acElementStatistics.setTimeStamp(Instant.now());
+
+ apiImpl.updateAutomationCompositionElementStatistics(uuid, acElementStatistics);
+ var acElement =
+ apiImpl.updateAutomationCompositionElementState(id, uuid, AutomationCompositionOrderedState.UNINITIALISED,
+ AutomationCompositionState.PASSIVE, ParticipantMessageType.AUTOMATION_COMPOSITION_STATECHANGE_ACK);
+ assertEquals(AutomationCompositionOrderedState.UNINITIALISED, acElement.getOrderedState());
+ assertEquals(uuid, acElement.getId());
}
}
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantCommTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantCommTest.java
index a40a41853..26dddc9ba 100644
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantCommTest.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantCommTest.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.participant.intermediary.comm;
+package org.onap.policy.clamp.acm.participant.intermediary.comm;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -28,13 +28,13 @@ import java.util.Collections;
import java.util.List;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
-import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopAck;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantDeregister;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantRegister;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStatus;
-import org.onap.policy.clamp.controlloop.participant.intermediary.main.parameters.CommonTestData;
+import org.onap.policy.clamp.acm.participant.intermediary.main.parameters.CommonTestData;
+import org.onap.policy.clamp.common.acm.exception.AutomationCompositionRuntimeException;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionAck;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDeregister;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType;
+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.common.endpoints.event.comm.TopicSink;
import org.onap.policy.common.utils.coder.CoderException;
@@ -44,31 +44,28 @@ class ParticipantCommTest {
@Test
void participantReqTest() throws CoderException {
- var participantHandler = commonTestData.getParticipantHandlerControlLoops();
+ var participantHandler = commonTestData.getParticipantHandlerAutomationCompositions();
var participantRegisterAckListener = new ParticipantRegisterAckListener(participantHandler);
- assertEquals(ParticipantMessageType.PARTICIPANT_REGISTER_ACK.name(),
- participantRegisterAckListener.getType());
+ assertEquals(ParticipantMessageType.PARTICIPANT_REGISTER_ACK.name(), participantRegisterAckListener.getType());
var participantStatusReqListener = new ParticipantStatusReqListener(participantHandler);
- assertEquals(ParticipantMessageType.PARTICIPANT_STATUS_REQ.name(),
- participantStatusReqListener.getType());
+ assertEquals(ParticipantMessageType.PARTICIPANT_STATUS_REQ.name(), participantStatusReqListener.getType());
var participantDeregisterAckListener = new ParticipantDeregisterAckListener(participantHandler);
assertEquals(ParticipantMessageType.PARTICIPANT_DEREGISTER_ACK.name(),
- participantDeregisterAckListener.getType());
+ participantDeregisterAckListener.getType());
var participantUpdateListener = new ParticipantUpdateListener(participantHandler);
- assertEquals(ParticipantMessageType.PARTICIPANT_UPDATE.name(),
- participantUpdateListener.getType());
+ assertEquals(ParticipantMessageType.PARTICIPANT_UPDATE.name(), participantUpdateListener.getType());
- var controlLoopUpdateListener = new ControlLoopUpdateListener(participantHandler);
- assertEquals(ParticipantMessageType.CONTROL_LOOP_UPDATE.name(),
- controlLoopUpdateListener.getType());
+ var automationCompositionUpdateListener = new AutomationCompositionUpdateListener(participantHandler);
+ assertEquals(ParticipantMessageType.AUTOMATION_COMPOSITION_UPDATE.name(),
+ automationCompositionUpdateListener.getType());
- var controlLoopStateChangeListener = new ControlLoopStateChangeListener(participantHandler);
- assertEquals(ParticipantMessageType.CONTROL_LOOP_STATE_CHANGE.name(),
- controlLoopStateChangeListener.getType());
+ var automationCompositionStateChangeListener = new AutomationCompositionStateChangeListener(participantHandler);
+ assertEquals(ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE.name(),
+ automationCompositionStateChangeListener.getType());
}
@Test
@@ -76,26 +73,26 @@ class ParticipantCommTest {
var participantMessagePublisher = new ParticipantMessagePublisher();
var participantStatus = Mockito.mock(ParticipantStatus.class);
- assertThrows(ControlLoopRuntimeException.class, () -> {
+ assertThrows(AutomationCompositionRuntimeException.class, () -> {
participantMessagePublisher.sendParticipantStatus(participantStatus);
});
- assertThrows(ControlLoopRuntimeException.class, () -> {
+ assertThrows(AutomationCompositionRuntimeException.class, () -> {
participantMessagePublisher.sendHeartbeat(participantStatus);
});
var participantRegister = Mockito.mock(ParticipantRegister.class);
- assertThrows(ControlLoopRuntimeException.class, () -> {
+ assertThrows(AutomationCompositionRuntimeException.class, () -> {
participantMessagePublisher.sendParticipantRegister(participantRegister);
});
var participantDeregister = Mockito.mock(ParticipantDeregister.class);
- assertThrows(ControlLoopRuntimeException.class, () -> {
+ assertThrows(AutomationCompositionRuntimeException.class, () -> {
participantMessagePublisher.sendParticipantDeregister(participantDeregister);
});
- var controlLoopAck = Mockito.mock(ControlLoopAck.class);
- assertThrows(ControlLoopRuntimeException.class, () -> {
- participantMessagePublisher.sendControlLoopAck(controlLoopAck);
+ var automationCompositionAck = Mockito.mock(AutomationCompositionAck.class);
+ assertThrows(AutomationCompositionRuntimeException.class, () -> {
+ participantMessagePublisher.sendAutomationCompositionAck(automationCompositionAck);
});
List<TopicSink> emptyList = Collections.emptyList();
@@ -108,7 +105,7 @@ class ParticipantCommTest {
@Test
void messageSenderTest() throws CoderException {
- var participantHandler = commonTestData.getParticipantHandlerControlLoops();
+ var participantHandler = commonTestData.getParticipantHandlerAutomationCompositions();
var participantParameters = CommonTestData.getParticipantParameters();
var messageSender = new MessageSender(participantHandler, participantParameters);
messageSender.run();
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandlerTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandlerTest.java
new file mode 100644
index 000000000..5585e5190
--- /dev/null
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandlerTest.java
@@ -0,0 +1,227 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.acm.participant.intermediary.handler;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.mockito.Mockito.mock;
+
+import java.time.Instant;
+import java.util.List;
+import java.util.UUID;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.onap.policy.clamp.acm.participant.intermediary.api.AutomationCompositionElementListener;
+import org.onap.policy.clamp.acm.participant.intermediary.main.parameters.CommonTestData;
+import org.onap.policy.clamp.models.acm.concepts.AcElementStatistics;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDefinition;
+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.ParticipantUpdates;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionStateChange;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionUpdate;
+import org.onap.policy.common.utils.coder.CoderException;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+
+@ExtendWith(SpringExtension.class)
+class AutomationCompositionHandlerTest {
+
+ private CommonTestData commonTestData = new CommonTestData();
+
+ @Test
+ void automationCompositionHandlerTest() {
+ var ach = commonTestData.getMockAutomationCompositionHandler();
+ assertNotNull(ach.getAutomationCompositions());
+
+ assertNotNull(ach.getAutomationCompositionMap());
+ assertNotNull(ach.getElementsOnThisParticipant());
+
+ var elementId1 = UUID.randomUUID();
+ var element = new AutomationCompositionElement();
+ element.setId(elementId1);
+ element.setDefinition(
+ new ToscaConceptIdentifier("org.onap.policy.acm.PolicyAutomationCompositionParticipant", "1.0.1"));
+
+ element.setOrderedState(AutomationCompositionOrderedState.PASSIVE);
+
+ AutomationCompositionElementListener listener = mock(AutomationCompositionElementListener.class);
+ ach.registerAutomationCompositionElementListener(listener);
+ assertThat(ach.getListeners()).contains(listener);
+ }
+
+ @Test
+ void updateNullAutomationCompositionHandlerTest() {
+ var id = UUID.randomUUID();
+
+ var ach = commonTestData.getMockAutomationCompositionHandler();
+ assertNull(ach.updateAutomationCompositionElementState(null, null,
+ AutomationCompositionOrderedState.UNINITIALISED, AutomationCompositionState.PASSIVE));
+
+ assertNull(ach.updateAutomationCompositionElementState(null, id,
+ AutomationCompositionOrderedState.UNINITIALISED, AutomationCompositionState.PASSIVE));
+
+ var acElementStatistics = new AcElementStatistics();
+ var automationCompositionId = new ToscaConceptIdentifier("defName", "0.0.1");
+ acElementStatistics.setParticipantId(automationCompositionId);
+ acElementStatistics.setState(AutomationCompositionState.RUNNING);
+ acElementStatistics.setTimeStamp(Instant.now());
+
+ ach.updateAutomationCompositionElementStatistics(id, acElementStatistics);
+ assertNull(ach.updateAutomationCompositionElementState(automationCompositionId, id,
+ AutomationCompositionOrderedState.UNINITIALISED, AutomationCompositionState.PASSIVE));
+ }
+
+ @Test
+ void updateAutomationCompositionHandlerTest() throws CoderException {
+ var uuid = UUID.randomUUID();
+ var id = CommonTestData.getParticipantId();
+
+ var ach = commonTestData.setTestAutomationCompositionHandler(id, uuid);
+ var key = ach.getElementsOnThisParticipant().keySet().iterator().next();
+ var value = ach.getElementsOnThisParticipant().get(key);
+ assertEquals(AutomationCompositionState.UNINITIALISED, value.getState());
+ ach.updateAutomationCompositionElementState(id, uuid, AutomationCompositionOrderedState.UNINITIALISED,
+ AutomationCompositionState.PASSIVE);
+ assertEquals(AutomationCompositionState.PASSIVE, value.getState());
+
+ ach.getAutomationCompositionMap().values().iterator().next().getElements().putIfAbsent(key, value);
+ ach.updateAutomationCompositionElementState(id, key, AutomationCompositionOrderedState.PASSIVE,
+ AutomationCompositionState.RUNNING);
+ assertEquals(AutomationCompositionState.RUNNING, value.getState());
+
+ var acElementStatistics = new AcElementStatistics();
+ acElementStatistics.setParticipantId(id);
+ acElementStatistics.setState(AutomationCompositionState.RUNNING);
+ acElementStatistics.setTimeStamp(Instant.now());
+
+ assertNotEquals(uuid, value.getAcElementStatistics().getId());
+ ach.updateAutomationCompositionElementStatistics(uuid, acElementStatistics);
+ assertEquals(uuid, value.getAcElementStatistics().getId());
+
+ ach.getElementsOnThisParticipant().remove(key, value);
+ ach.getAutomationCompositionMap().values().iterator().next().getElements().clear();
+ assertNull(ach.updateAutomationCompositionElementState(id, key, AutomationCompositionOrderedState.PASSIVE,
+ AutomationCompositionState.RUNNING));
+
+ }
+
+ @Test
+ void handleAutomationCompositionUpdateExceptionTest() throws CoderException {
+ var uuid = UUID.randomUUID();
+ var id = CommonTestData.getParticipantId();
+ var stateChange = getStateChange(id, uuid, AutomationCompositionOrderedState.RUNNING);
+ var ach = commonTestData.setTestAutomationCompositionHandler(id, uuid);
+ assertDoesNotThrow(
+ () -> ach.handleAutomationCompositionStateChange(mock(AutomationCompositionStateChange.class), List.of()));
+
+ ach.handleAutomationCompositionStateChange(stateChange, List.of());
+ var newid = new ToscaConceptIdentifier("id", "1.2.3");
+ stateChange.setAutomationCompositionId(newid);
+ stateChange.setParticipantId(newid);
+ assertDoesNotThrow(() -> ach.handleAutomationCompositionStateChange(stateChange, List.of()));
+
+ var acd = new AutomationCompositionElementDefinition();
+ acd.setAcElementDefinitionId(id);
+ var updateMsg = new AutomationCompositionUpdate();
+ updateMsg.setAutomationCompositionId(id);
+ updateMsg.setMessageId(uuid);
+ updateMsg.setParticipantId(id);
+ updateMsg.setStartPhase(0);
+ var acElementDefinitions = List.of(acd);
+ assertDoesNotThrow(() -> ach.handleAutomationCompositionUpdate(updateMsg, acElementDefinitions));
+ updateMsg.setStartPhase(1);
+ assertDoesNotThrow(() -> ach.handleAutomationCompositionUpdate(updateMsg, acElementDefinitions));
+ assertThat(ach.getAcElementInstanceProperties(uuid)).isEmpty();
+
+ ach.getAutomationCompositionMap().clear();
+ updateMsg.setStartPhase(0);
+ assertDoesNotThrow(() -> ach.handleAutomationCompositionUpdate(updateMsg, acElementDefinitions));
+
+ updateMsg.setAutomationCompositionId(new ToscaConceptIdentifier("new", "0.0.1"));
+ updateMsg.setParticipantUpdatesList(List.of(mock(ParticipantUpdates.class)));
+ assertDoesNotThrow(() -> ach.handleAutomationCompositionUpdate(updateMsg, acElementDefinitions));
+
+ updateMsg.setStartPhase(1);
+ var participantUpdate = new ParticipantUpdates();
+ participantUpdate.setParticipantId(id);
+ var element = new AutomationCompositionElement();
+ element.setParticipantType(id);
+ element.setDefinition(id);
+ participantUpdate.setAutomationCompositionElementList(List.of(element));
+ updateMsg.setParticipantUpdatesList(List.of(participantUpdate));
+
+ var acd2 = new AutomationCompositionElementDefinition();
+ acd2.setAcElementDefinitionId(id);
+ acd2.setAutomationCompositionElementToscaNodeTemplate(mock(ToscaNodeTemplate.class));
+ assertDoesNotThrow(() -> ach.handleAutomationCompositionUpdate(updateMsg, List.of(acd2)));
+
+ }
+
+ @Test
+ void automationCompositionStateChangeUninitialisedTest() throws CoderException {
+ var uuid = UUID.randomUUID();
+ var id = CommonTestData.getParticipantId();
+
+ var stateChangeUninitialised = getStateChange(id, uuid, AutomationCompositionOrderedState.UNINITIALISED);
+
+ var ach = commonTestData.setTestAutomationCompositionHandler(id, uuid);
+ ach.handleAutomationCompositionStateChange(stateChangeUninitialised, List.of());
+ var newid = new ToscaConceptIdentifier("id", "1.2.3");
+ stateChangeUninitialised.setAutomationCompositionId(newid);
+ stateChangeUninitialised.setParticipantId(newid);
+ assertDoesNotThrow(() -> ach.handleAutomationCompositionStateChange(stateChangeUninitialised, List.of()));
+ }
+
+ @Test
+ void automationCompositionStateChangePassiveTest() throws CoderException {
+ var uuid = UUID.randomUUID();
+ var id = CommonTestData.getParticipantId();
+
+ var stateChangePassive = getStateChange(id, uuid, AutomationCompositionOrderedState.PASSIVE);
+
+ var ach = commonTestData.setTestAutomationCompositionHandler(id, uuid);
+ ach.handleAutomationCompositionStateChange(stateChangePassive, List.of());
+ var newid = new ToscaConceptIdentifier("id", "1.2.3");
+ stateChangePassive.setAutomationCompositionId(newid);
+ stateChangePassive.setParticipantId(newid);
+ assertDoesNotThrow(() -> ach.handleAutomationCompositionStateChange(stateChangePassive, List.of()));
+ }
+
+ private AutomationCompositionStateChange getStateChange(ToscaConceptIdentifier id, UUID uuid,
+ AutomationCompositionOrderedState state) {
+ var stateChange = new AutomationCompositionStateChange();
+ stateChange.setAutomationCompositionId(id);
+ stateChange.setParticipantId(id);
+ stateChange.setMessageId(uuid);
+ stateChange.setOrderedState(state);
+ stateChange.setCurrentState(AutomationCompositionState.UNINITIALISED);
+ stateChange.setTimestamp(Instant.ofEpochMilli(3000));
+ return stateChange;
+ }
+
+}
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/DummyParticipantParameters.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/DummyParticipantParameters.java
index d60bb71bc..b82fbed6a 100644
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/DummyParticipantParameters.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/DummyParticipantParameters.java
@@ -18,13 +18,13 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.participant.intermediary.handler;
+package org.onap.policy.clamp.acm.participant.intermediary.handler;
import javax.validation.constraints.NotNull;
import lombok.Getter;
import lombok.Setter;
-import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantIntermediaryParameters;
-import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantParameters;
+import org.onap.policy.clamp.acm.participant.intermediary.parameters.ParticipantIntermediaryParameters;
+import org.onap.policy.clamp.acm.participant.intermediary.parameters.ParticipantParameters;
@Getter
@Setter
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/IntermediaryActivatorTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/IntermediaryActivatorTest.java
index 8c400c12f..9ecf59ba4 100644
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/IntermediaryActivatorTest.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/IntermediaryActivatorTest.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.participant.intermediary.handler;
+package org.onap.policy.clamp.acm.participant.intermediary.handler;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
@@ -34,10 +34,10 @@ import static org.mockito.Mockito.when;
import java.util.List;
import org.junit.jupiter.api.Test;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStatusReq;
-import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ParticipantStatusReqListener;
-import org.onap.policy.clamp.controlloop.participant.intermediary.main.parameters.CommonTestData;
-import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantParameters;
+import org.onap.policy.clamp.acm.participant.intermediary.comm.ParticipantStatusReqListener;
+import org.onap.policy.clamp.acm.participant.intermediary.main.parameters.CommonTestData;
+import org.onap.policy.clamp.acm.participant.intermediary.parameters.ParticipantParameters;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantStatusReq;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.common.utils.coder.StandardCoderObject;
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandlerTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandlerTest.java
index d00697521..8e22784db 100644
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandlerTest.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandlerTest.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.participant.intermediary.handler;
+package org.onap.policy.clamp.acm.participant.intermediary.handler;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
@@ -32,16 +32,16 @@ import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import org.junit.jupiter.api.Test;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantDefinition;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantHealthStatus;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantAckMessage;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessage;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantRegisterAck;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdate;
-import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ParticipantMessagePublisher;
-import org.onap.policy.clamp.controlloop.participant.intermediary.main.parameters.CommonTestData;
+import org.onap.policy.clamp.acm.participant.intermediary.comm.ParticipantMessagePublisher;
+import org.onap.policy.clamp.acm.participant.intermediary.main.parameters.CommonTestData;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantHealthStatus;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantAckMessage;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessage;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantRegisterAck;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdate;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
@@ -60,17 +60,17 @@ class ParticipantHandlerTest {
var id = new ToscaConceptIdentifier(ID_NAME, ID_VERSION);
assertEquals(id, participantHandler.getParticipantId());
assertEquals(id, participantHandler.getParticipantType());
- assertThat(participantHandler.getClElementDefinitionCommonProperties(id)).isEmpty();
+ assertThat(participantHandler.getAcElementDefinitionCommonProperties(id)).isEmpty();
}
@Test
void handleUpdateTest() {
var parameters = CommonTestData.getParticipantParameters();
- var controlLoopHander = commonTestData.getMockControlLoopHandler();
+ var automationCompositionHander = commonTestData.getMockAutomationCompositionHandler();
var publisher = new ParticipantMessagePublisher();
var emptyParticipantHandler =
- new ParticipantHandler(parameters, publisher, controlLoopHander);
+ new ParticipantHandler(parameters, publisher, automationCompositionHander);
var participantUpdateMsg = new ParticipantUpdate();
assertThatThrownBy(() ->
@@ -80,7 +80,7 @@ class ParticipantHandlerTest {
var participantHandler = commonTestData.getMockParticipantHandler();
var id = new ToscaConceptIdentifier(ID_NAME, ID_VERSION);
- participantUpdateMsg.setControlLoopId(id);
+ participantUpdateMsg.setAutomationCompositionId(id);
participantUpdateMsg.setParticipantId(id);
participantUpdateMsg.setParticipantType(id);
participantUpdateMsg.setMessageId(UUID.randomUUID());
@@ -89,10 +89,10 @@ class ParticipantHandlerTest {
var heartbeatF = participantHandler.makeHeartbeat(false);
assertEquals(id, heartbeatF.getParticipantId());
assertEquals(ParticipantState.UNKNOWN, heartbeatF.getParticipantStatistics().getState());
- assertThat(heartbeatF.getControlLoopInfoList()).isEmpty();
+ assertThat(heartbeatF.getAutomationCompositionInfoList()).isEmpty();
participantHandler.handleParticipantUpdate(participantUpdateMsg);
- assertThat(participantHandler.getClElementDefinitionCommonProperties(id)).isEmpty();
+ assertThat(participantHandler.getAcElementDefinitionCommonProperties(id)).isEmpty();
var heartbeatT = participantHandler.makeHeartbeat(true);
assertEquals(id, heartbeatT.getParticipantId());
@@ -148,7 +148,7 @@ class ParticipantHandlerTest {
void checkAppliesTo() {
var participantHandler = commonTestData.getMockParticipantHandler();
var participantAckMsg =
- new ParticipantAckMessage(ParticipantMessageType.CONTROL_LOOP_UPDATE);
+ new ParticipantAckMessage(ParticipantMessageType.AUTOMATION_COMPOSITION_UPDATE);
assertTrue(participantHandler.appliesTo(participantAckMsg));
var participantMsg =
@@ -162,14 +162,14 @@ class ParticipantHandlerTest {
}
@Test
- void getControlLoopInfoListTest() throws CoderException {
- var participantHandler = commonTestData.getParticipantHandlerControlLoops();
+ void getAutomationCompositionInfoListTest() throws CoderException {
+ var participantHandler = commonTestData.getParticipantHandlerAutomationCompositions();
var id = new ToscaConceptIdentifier(ID_NAME, ID_VERSION);
participantHandler.sendHeartbeat();
assertEquals(id, participantHandler.makeHeartbeat(false)
- .getControlLoopInfoList()
+ .getAutomationCompositionInfoList()
.get(0)
- .getControlLoopId());
+ .getAutomationCompositionId());
}
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/main/parameters/CommonTestData.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java
index 9bbf8964c..ad54d402c 100644
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/main/parameters/CommonTestData.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.participant.intermediary.main.parameters;
+package org.onap.policy.clamp.acm.participant.intermediary.main.parameters;
import java.io.File;
import java.time.Instant;
@@ -30,18 +30,18 @@ import java.util.Map;
import java.util.TreeMap;
import java.util.UUID;
import org.mockito.Mockito;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantDeregisterAck;
-import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ParticipantMessagePublisher;
-import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ControlLoopHandler;
-import org.onap.policy.clamp.controlloop.participant.intermediary.handler.DummyParticipantParameters;
-import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler;
-import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantIntermediaryParameters;
+import org.onap.policy.clamp.acm.participant.intermediary.comm.ParticipantMessagePublisher;
+import org.onap.policy.clamp.acm.participant.intermediary.handler.AutomationCompositionHandler;
+import org.onap.policy.clamp.acm.participant.intermediary.handler.DummyParticipantParameters;
+import org.onap.policy.clamp.acm.participant.intermediary.handler.ParticipantHandler;
+import org.onap.policy.clamp.acm.participant.intermediary.parameters.ParticipantIntermediaryParameters;
+import org.onap.policy.clamp.models.acm.concepts.AcElementStatistics;
+import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement;
+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.AutomationCompositions;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDeregisterAck;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
import org.onap.policy.common.endpoints.parameters.TopicParameters;
import org.onap.policy.common.utils.coder.Coder;
@@ -53,7 +53,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
* Class to hold/create all parameters for test cases.
*/
public class CommonTestData {
- public static final String PARTICIPANT_GROUP_NAME = "ControlLoopParticipantGroup";
+ public static final String PARTICIPANT_GROUP_NAME = "AutomationCompositionParticipantGroup";
public static final String DESCRIPTION = "Participant description";
public static final long TIME_INTERVAL = 2000;
public static final List<TopicParameters> TOPIC_PARAMS = Arrays.asList(getTopicParams());
@@ -68,7 +68,7 @@ public class CommonTestData {
public ParticipantIntermediaryParameters getParticipantIntermediaryParameters() {
try {
return CODER.convert(getIntermediaryParametersMap(PARTICIPANT_GROUP_NAME),
- ParticipantIntermediaryParameters.class);
+ ParticipantIntermediaryParameters.class);
} catch (final CoderException e) {
throw new RuntimeException("cannot create ParticipantSimulatorParameters from map", e);
}
@@ -81,8 +81,7 @@ public class CommonTestData {
*/
public static DummyParticipantParameters getParticipantParameters() {
try {
- return CODER.convert(getParametersMap(PARTICIPANT_GROUP_NAME),
- DummyParticipantParameters.class);
+ return CODER.convert(getParametersMap(PARTICIPANT_GROUP_NAME), DummyParticipantParameters.class);
} catch (final CoderException e) {
throw new RuntimeException("cannot create ParticipantSimulatorParameters from map", e);
}
@@ -113,7 +112,7 @@ public class CommonTestData {
map.put("description", DESCRIPTION);
map.put("participantType", getParticipantId());
map.put("reportingTimeIntervalMs", TIME_INTERVAL);
- map.put("clampControlLoopTopics", getTopicParametersMap(false));
+ map.put("clampAutomationCompositionTopics", getTopicParametersMap(false));
return map;
}
@@ -140,7 +139,7 @@ public class CommonTestData {
*/
public static TopicParameters getTopicParams() {
final var topicParams = new TopicParameters();
- topicParams.setTopic("POLICY-CLRUNTIME-PARTICIPANT");
+ topicParams.setTopic("POLICY-ACRUNTIME-PARTICIPANT");
topicParams.setTopicCommInfrastructure("dmaap");
topicParams.setServers(Arrays.asList("localhost"));
return topicParams;
@@ -169,14 +168,12 @@ public class CommonTestData {
}
/**
- * Returns a mocked ControlLoopHandler for test cases.
+ * Returns a mocked AutomationCompositionHandler for test cases.
*
- * @return ControlLoopHandler
+ * @return AutomationCompositionHandler
*/
- public ControlLoopHandler getMockControlLoopHandler() {
- return new ControlLoopHandler(
- getParticipantParameters(),
- getParticipantMessagePublisher());
+ public AutomationCompositionHandler getMockAutomationCompositionHandler() {
+ return new AutomationCompositionHandler(getParticipantParameters(), getParticipantMessagePublisher());
}
/**
@@ -186,10 +183,10 @@ public class CommonTestData {
*/
public ParticipantHandler getMockParticipantHandler() {
var parameters = getParticipantParameters();
- var controlLoopHandler = getMockControlLoopHandler();
+ var automationCompositionHandler = getMockAutomationCompositionHandler();
var publisher = new ParticipantMessagePublisher();
publisher.active(Collections.singletonList(Mockito.mock(TopicSink.class)));
- var participantHandler = new ParticipantHandler(parameters, publisher, controlLoopHandler);
+ var participantHandler = new ParticipantHandler(parameters, publisher, automationCompositionHandler);
return participantHandler;
}
@@ -200,14 +197,16 @@ public class CommonTestData {
*
* @throws CoderException if there is an error with .json file.
*/
- public ParticipantHandler getParticipantHandlerControlLoops() throws CoderException {
- var controlLoopHandler = Mockito.mock(ControlLoopHandler.class);
- Mockito.doReturn(getTestControlLoops()).when(controlLoopHandler).getControlLoops();
- Mockito.doReturn(getTestControlLoopMap()).when(controlLoopHandler).getControlLoopMap();
+ public ParticipantHandler getParticipantHandlerAutomationCompositions() throws CoderException {
+ var automationCompositionHandler = Mockito.mock(AutomationCompositionHandler.class);
+ Mockito.doReturn(getTestAutomationCompositions()).when(automationCompositionHandler)
+ .getAutomationCompositions();
+ Mockito.doReturn(getTestAutomationCompositionMap()).when(automationCompositionHandler)
+ .getAutomationCompositionMap();
var publisher = new ParticipantMessagePublisher();
publisher.active(Collections.singletonList(Mockito.mock(TopicSink.class)));
var parameters = getParticipantParameters();
- var participantHandler = new ParticipantHandler(parameters, publisher, controlLoopHandler);
+ var participantHandler = new ParticipantHandler(parameters, publisher, automationCompositionHandler);
participantHandler.sendParticipantRegister();
participantHandler.handleParticipantStatusReq(null);
participantHandler.sendParticipantDeregister();
@@ -218,31 +217,31 @@ public class CommonTestData {
}
/**
- * Returns a Map of ToscaConceptIdentifier and ControlLoop for test cases.
+ * Returns a Map of ToscaConceptIdentifier and AutomationComposition for test cases.
*
- * @return controlLoopMap
+ * @return automationCompositionMap
*
* @throws CoderException if there is an error with .json file.
*/
- public Map<ToscaConceptIdentifier, ControlLoop> getTestControlLoopMap() throws CoderException {
- var controlLoops = getTestControlLoops();
- var controlLoop = controlLoops.getControlLoopList().get(1);
+ public Map<ToscaConceptIdentifier, AutomationComposition> getTestAutomationCompositionMap() throws CoderException {
+ var automationCompositions = getTestAutomationCompositions();
+ var automationComposition = automationCompositions.getAutomationCompositionList().get(1);
var id = getParticipantId();
- Map<ToscaConceptIdentifier, ControlLoop> controlLoopMap = new LinkedHashMap<>();
- controlLoopMap.put(id, controlLoop);
- return controlLoopMap;
+ Map<ToscaConceptIdentifier, AutomationComposition> automationCompositionMap = new LinkedHashMap<>();
+ automationCompositionMap.put(id, automationComposition);
+ return automationCompositionMap;
}
/**
- * Returns List of ControlLoop for test cases.
+ * Returns List of AutomationComposition for test cases.
*
- * @return ControlLoops
+ * @return AutomationCompositions
*
* @throws CoderException if there is an error with .json file.
*/
- public ControlLoops getTestControlLoops() throws CoderException {
- return new StandardCoder()
- .decode(new File("src/test/resources/providers/TestControlLoops.json"), ControlLoops.class);
+ public AutomationCompositions getTestAutomationCompositions() throws CoderException {
+ return new StandardCoder().decode(new File("src/test/resources/providers/TestAutomationCompositions.json"),
+ AutomationCompositions.class);
}
/**
@@ -251,43 +250,45 @@ public class CommonTestData {
* @param uuid UUID and id ToscaConceptIdentifier
* @return a map suitable for elementsOnThisParticipant
*/
- public Map<UUID, ControlLoopElement> setControlLoopElementTest(UUID uuid, ToscaConceptIdentifier id) {
- var clElement = new ControlLoopElement();
- clElement.setId(uuid);
- clElement.setParticipantId(id);
- clElement.setDefinition(id);
- clElement.setOrderedState(ControlLoopOrderedState.UNINITIALISED);
+ public Map<UUID, AutomationCompositionElement> setAutomationCompositionElementTest(UUID uuid,
+ ToscaConceptIdentifier id) {
+ var acElement = new AutomationCompositionElement();
+ acElement.setId(uuid);
+ acElement.setParticipantId(id);
+ acElement.setDefinition(id);
+ acElement.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED);
- var clElementStatistics = new ClElementStatistics();
- clElementStatistics.setParticipantId(id);
- clElementStatistics.setControlLoopState(ControlLoopState.UNINITIALISED);
- clElementStatistics.setTimeStamp(Instant.now());
+ var acElementStatistics = new AcElementStatistics();
+ acElementStatistics.setParticipantId(id);
+ acElementStatistics.setState(AutomationCompositionState.UNINITIALISED);
+ acElementStatistics.setTimeStamp(Instant.now());
- clElement.setClElementStatistics(clElementStatistics);
+ acElement.setAcElementStatistics(acElementStatistics);
- Map<UUID, ControlLoopElement> elementsOnThisParticipant = new LinkedHashMap<>();
- elementsOnThisParticipant.put(uuid, clElement);
+ Map<UUID, AutomationCompositionElement> elementsOnThisParticipant = new LinkedHashMap<>();
+ elementsOnThisParticipant.put(uuid, acElement);
return elementsOnThisParticipant;
}
/**
- * Returns a ControlLoopHandler with elements on the id,uuid.
+ * Returns a AutomationCompositionHandler with elements on the id,uuid.
*
* @param id ToscaConceptIdentifier and uuid UUID
- * @return a ControlLoopHander with elements
+ * @return a AutomationCompositionHander with elements
*/
- public ControlLoopHandler setTestControlLoopHandler(ToscaConceptIdentifier id, UUID uuid) throws CoderException {
- var clh = getMockControlLoopHandler();
+ public AutomationCompositionHandler setTestAutomationCompositionHandler(ToscaConceptIdentifier id, UUID uuid)
+ throws CoderException {
+ var ach = getMockAutomationCompositionHandler();
- var key = getTestControlLoopMap().keySet().iterator().next();
- var value = getTestControlLoopMap().get(key);
- clh.getControlLoopMap().put(key, value);
+ var key = getTestAutomationCompositionMap().keySet().iterator().next();
+ var value = getTestAutomationCompositionMap().get(key);
+ ach.getAutomationCompositionMap().put(key, value);
- var keyElem = setControlLoopElementTest(uuid, id).keySet().iterator().next();
- var valueElem = setControlLoopElementTest(uuid, id).get(keyElem);
- clh.getElementsOnThisParticipant().put(keyElem, valueElem);
+ var keyElem = setAutomationCompositionElementTest(uuid, id).keySet().iterator().next();
+ var valueElem = setAutomationCompositionElementTest(uuid, id).get(keyElem);
+ ach.getElementsOnThisParticipant().put(keyElem, valueElem);
- return clh;
+ return ach;
}
}
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/main/parameters/TestParticipantIntermediaryParameters.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/TestParticipantIntermediaryParameters.java
index d554a55b6..cc2b110f3 100644
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/main/parameters/TestParticipantIntermediaryParameters.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/TestParticipantIntermediaryParameters.java
@@ -18,14 +18,14 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.participant.intermediary.main.parameters;
+package org.onap.policy.clamp.acm.participant.intermediary.main.parameters;
import static org.assertj.core.api.Assertions.assertThat;
import javax.validation.Validation;
import javax.validation.ValidatorFactory;
import org.junit.jupiter.api.Test;
-import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantIntermediaryParameters;
+import org.onap.policy.clamp.acm.participant.intermediary.parameters.ParticipantIntermediaryParameters;
/**
* Class to perform unit test of {@link ParticipantParameterGroup}.
@@ -45,7 +45,7 @@ class TestParticipantIntermediaryParameters {
void testParticipantIntermediaryParameterGroup_EmptyParameter() {
final ParticipantIntermediaryParameters participantParameters =
commonTestData.getParticipantIntermediaryParameters();
- participantParameters.setClampControlLoopTopics(null);
+ participantParameters.setClampAutomationCompositionTopics(null);
assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty();
}
@@ -53,7 +53,7 @@ class TestParticipantIntermediaryParameters {
void testParticipantIntermediaryParameters_NullTopicSinks() {
final ParticipantIntermediaryParameters participantParameters =
commonTestData.getParticipantIntermediaryParameters();
- participantParameters.getClampControlLoopTopics().setTopicSinks(null);
+ participantParameters.getClampAutomationCompositionTopics().setTopicSinks(null);
assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty();
}
@@ -61,7 +61,7 @@ class TestParticipantIntermediaryParameters {
void testParticipantIntermediaryParameters_NullTopicSources() {
final ParticipantIntermediaryParameters participantParameters =
commonTestData.getParticipantIntermediaryParameters();
- participantParameters.getClampControlLoopTopics().setTopicSources(null);
+ participantParameters.getClampAutomationCompositionTopics().setTopicSources(null);
assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty();
}
}
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandlerTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandlerTest.java
deleted file mode 100644
index 43b43e3bf..000000000
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandlerTest.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.controlloop.participant.intermediary.handler;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
-import static org.mockito.Mockito.mock;
-
-import java.time.Instant;
-import java.util.List;
-import java.util.UUID;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElementDefinition;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantUpdates;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopStateChange;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopUpdate;
-import org.onap.policy.clamp.controlloop.participant.intermediary.api.ControlLoopElementListener;
-import org.onap.policy.clamp.controlloop.participant.intermediary.main.parameters.CommonTestData;
-import org.onap.policy.common.utils.coder.CoderException;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
-import org.springframework.test.context.junit.jupiter.SpringExtension;
-
-@ExtendWith(SpringExtension.class)
-class ControlLoopHandlerTest {
-
- private CommonTestData commonTestData = new CommonTestData();
-
- @Test
- void controlLoopHandlerTest() {
- var clh = commonTestData.getMockControlLoopHandler();
- assertNotNull(clh.getControlLoops());
-
- assertNotNull(clh.getControlLoopMap());
- assertNotNull(clh.getElementsOnThisParticipant());
-
- var elementId1 = UUID.randomUUID();
- var element = new ControlLoopElement();
- element.setId(elementId1);
- element.setDefinition(new ToscaConceptIdentifier(
- "org.onap.policy.controlloop.PolicyControlLoopParticipant", "1.0.1"));
-
- element.setOrderedState(ControlLoopOrderedState.PASSIVE);
-
- ControlLoopElementListener listener = mock(ControlLoopElementListener.class);
- clh.registerControlLoopElementListener(listener);
- assertThat(clh.getListeners()).contains(listener);
- }
-
- @Test
- void updateNullControlLoopHandlerTest() {
- var id = UUID.randomUUID();
-
- var clh = commonTestData.getMockControlLoopHandler();
- assertNull(clh.updateControlLoopElementState(null, null, ControlLoopOrderedState.UNINITIALISED,
- ControlLoopState.PASSIVE));
-
- assertNull(clh.updateControlLoopElementState(null, id, ControlLoopOrderedState.UNINITIALISED,
- ControlLoopState.PASSIVE));
-
- var clElementStatistics = new ClElementStatistics();
- var controlLoopId = new ToscaConceptIdentifier("defName", "0.0.1");
- clElementStatistics.setParticipantId(controlLoopId);
- clElementStatistics.setControlLoopState(ControlLoopState.RUNNING);
- clElementStatistics.setTimeStamp(Instant.now());
-
- clh.updateControlLoopElementStatistics(id, clElementStatistics);
- assertNull(clh.updateControlLoopElementState(controlLoopId, id, ControlLoopOrderedState.UNINITIALISED,
- ControlLoopState.PASSIVE));
- }
-
- @Test
- void updateControlLoopHandlerTest() throws CoderException {
- var uuid = UUID.randomUUID();
- var id = CommonTestData.getParticipantId();
-
- var clh = commonTestData.setTestControlLoopHandler(id, uuid);
- var key = clh.getElementsOnThisParticipant().keySet().iterator().next();
- var value = clh.getElementsOnThisParticipant().get(key);
- assertEquals(ControlLoopState.UNINITIALISED, value.getState());
- clh.updateControlLoopElementState(id, uuid, ControlLoopOrderedState.UNINITIALISED,
- ControlLoopState.PASSIVE);
- assertEquals(ControlLoopState.PASSIVE, value.getState());
-
- clh.getControlLoopMap().values().iterator().next().getElements().putIfAbsent(key, value);
- clh.updateControlLoopElementState(id, key, ControlLoopOrderedState.PASSIVE,
- ControlLoopState.RUNNING);
- assertEquals(ControlLoopState.RUNNING, value.getState());
-
- var clElementStatistics = new ClElementStatistics();
- clElementStatistics.setParticipantId(id);
- clElementStatistics.setControlLoopState(ControlLoopState.RUNNING);
- clElementStatistics.setTimeStamp(Instant.now());
-
- assertNotEquals(uuid, value.getClElementStatistics().getId());
- clh.updateControlLoopElementStatistics(uuid, clElementStatistics);
- assertEquals(uuid, value.getClElementStatistics().getId());
-
- clh.getElementsOnThisParticipant().remove(key, value);
- clh.getControlLoopMap().values().iterator().next().getElements().clear();
- assertNull(clh.updateControlLoopElementState(id, key, ControlLoopOrderedState.PASSIVE,
- ControlLoopState.RUNNING));
-
- }
-
- @Test
- void handleControlLoopUpdateExceptionTest() throws CoderException {
- var uuid = UUID.randomUUID();
- var id = CommonTestData.getParticipantId();
- var stateChange = getStateChange(id, uuid, ControlLoopOrderedState.RUNNING);
- var clh = commonTestData.setTestControlLoopHandler(id, uuid);
- assertDoesNotThrow(() -> clh.handleControlLoopStateChange(mock(ControlLoopStateChange.class), List.of()));
-
- clh.handleControlLoopStateChange(stateChange, List.of());
- var newid = new ToscaConceptIdentifier("id", "1.2.3");
- stateChange.setControlLoopId(newid);
- stateChange.setParticipantId(newid);
- assertDoesNotThrow(() -> clh.handleControlLoopStateChange(stateChange, List.of()));
-
- var cld = new ControlLoopElementDefinition();
- cld.setClElementDefinitionId(id);
- var updateMsg = new ControlLoopUpdate();
- updateMsg.setControlLoopId(id);
- updateMsg.setMessageId(uuid);
- updateMsg.setParticipantId(id);
- updateMsg.setStartPhase(0);
- var clElementDefinitions = List.of(cld);
- assertDoesNotThrow(() -> clh.handleControlLoopUpdate(updateMsg, clElementDefinitions));
- updateMsg.setStartPhase(1);
- assertDoesNotThrow(() -> clh.handleControlLoopUpdate(updateMsg, clElementDefinitions));
- assertThat(clh.getClElementInstanceProperties(uuid)).isEmpty();
-
- clh.getControlLoopMap().clear();
- updateMsg.setStartPhase(0);
- assertDoesNotThrow(() -> clh.handleControlLoopUpdate(updateMsg, clElementDefinitions));
-
- updateMsg.setControlLoopId(new ToscaConceptIdentifier("new", "0.0.1"));
- updateMsg.setParticipantUpdatesList(List.of(mock(ParticipantUpdates.class)));
- assertDoesNotThrow(() -> clh.handleControlLoopUpdate(updateMsg, clElementDefinitions));
-
- updateMsg.setStartPhase(1);
- var participantUpdate = new ParticipantUpdates();
- participantUpdate.setParticipantId(id);
- var element = new ControlLoopElement();
- element.setParticipantType(id);
- element.setDefinition(id);
- participantUpdate.setControlLoopElementList(List.of(element));
- updateMsg.setParticipantUpdatesList(List.of(participantUpdate));
-
- var cld2 = new ControlLoopElementDefinition();
- cld2.setClElementDefinitionId(id);
- cld2.setControlLoopElementToscaNodeTemplate(mock(ToscaNodeTemplate.class));
- assertDoesNotThrow(() -> clh.handleControlLoopUpdate(updateMsg, List.of(cld2)));
-
- }
-
- @Test
- void controlLoopStateChangeUninitialisedTest() throws CoderException {
- var uuid = UUID.randomUUID();
- var id = CommonTestData.getParticipantId();
-
- var stateChangeUninitialised = getStateChange(id, uuid, ControlLoopOrderedState.UNINITIALISED);
-
- var clh = commonTestData.setTestControlLoopHandler(id, uuid);
- clh.handleControlLoopStateChange(stateChangeUninitialised, List.of());
- var newid = new ToscaConceptIdentifier("id", "1.2.3");
- stateChangeUninitialised.setControlLoopId(newid);
- stateChangeUninitialised.setParticipantId(newid);
- assertDoesNotThrow(() -> clh.handleControlLoopStateChange(stateChangeUninitialised, List.of()));
- }
-
- @Test
- void controlLoopStateChangePassiveTest() throws CoderException {
- var uuid = UUID.randomUUID();
- var id = CommonTestData.getParticipantId();
-
- var stateChangePassive = getStateChange(id, uuid, ControlLoopOrderedState.PASSIVE);
-
- var clh = commonTestData.setTestControlLoopHandler(id, uuid);
- clh.handleControlLoopStateChange(stateChangePassive, List.of());
- var newid = new ToscaConceptIdentifier("id", "1.2.3");
- stateChangePassive.setControlLoopId(newid);
- stateChangePassive.setParticipantId(newid);
- assertDoesNotThrow(() -> clh.handleControlLoopStateChange(stateChangePassive, List.of()));
- }
-
-
- private ControlLoopStateChange getStateChange(ToscaConceptIdentifier id, UUID uuid, ControlLoopOrderedState state) {
- var stateChange = new ControlLoopStateChange();
- stateChange.setControlLoopId(id);
- stateChange.setParticipantId(id);
- stateChange.setMessageId(uuid);
- stateChange.setOrderedState(state);
- stateChange.setCurrentState(ControlLoopState.UNINITIALISED);
- stateChange.setTimestamp(Instant.ofEpochMilli(3000));
- return stateChange;
- }
-
-}