aboutsummaryrefslogtreecommitdiffstats
path: root/participant/participant-intermediary/src
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2024-07-23 12:45:09 +0100
committerFrancesco Fiora <francesco.fiora@est.tech>2024-07-23 15:16:00 +0000
commitb2bc0f63a484abe5b77b1e921d820ae80481602b (patch)
tree57450bb88f425afcb10332c65d36ffe9703a9159 /participant/participant-intermediary/src
parent1c144c87fbe077eb471650064c64888c4501f581 (diff)
Add support for Prepare, Review and Migrate pre-check in participant
Add support for Prepare, Review and Migrate pre-check in ACM participant simulator. Issue-ID: POLICY-5088 Change-Id: Ibad54aacc6102654f93a86169212d91ba3a59b8b Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'participant/participant-intermediary/src')
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/AutomationCompositionElementListener.java9
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV1.java25
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV2.java25
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV1Test.java48
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV2Test.java47
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AutomationCompositionElementListenerTest.java45
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/DummyAcElementListener.java78
7 files changed, 145 insertions, 132 deletions
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/AutomationCompositionElementListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/AutomationCompositionElementListener.java
index 6f4039254..cbcd8dd7f 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/AutomationCompositionElementListener.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/AutomationCompositionElementListener.java
@@ -97,4 +97,13 @@ public interface AutomationCompositionElementListener {
*/
void migrate(CompositionElementDto compositionElement, CompositionElementDto compositionElementTarget,
InstanceElementDto instanceElement, InstanceElementDto instanceElementMigrate) throws PfModelException;
+
+ void migratePrecheck(CompositionElementDto compositionElement, CompositionElementDto compositionElementTarget,
+ InstanceElementDto instanceElement, InstanceElementDto instanceElementMigrate) throws PfModelException;
+
+ void review(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
+ throws PfModelException;
+
+ void prepare(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
+ throws PfModelException;
}
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV1.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV1.java
index cf5ac419d..6bc3f9265 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV1.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV1.java
@@ -224,4 +224,29 @@ public abstract class AcElementListenerV1
intermediaryApi.updateAutomationCompositionElementState(instanceId, element.getId(),
DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Migrated");
}
+
+ @Override
+ public void migratePrecheck(CompositionElementDto compositionElement,
+ CompositionElementDto compositionElementTarget, InstanceElementDto instanceElement,
+ InstanceElementDto instanceElementMigrate) throws PfModelException {
+ intermediaryApi.updateAutomationCompositionElementState(instanceElementMigrate.instanceId(),
+ instanceElementMigrate.elementId(), DeployState.DEPLOYED, null,
+ StateChangeResult.NO_ERROR, "Migration Precheck completed");
+ }
+
+ @Override
+ public void review(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
+ throws PfModelException {
+ intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(),
+ instanceElement.elementId(), DeployState.DEPLOYED, null,
+ StateChangeResult.NO_ERROR, "Review completed");
+ }
+
+ @Override
+ public void prepare(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
+ throws PfModelException {
+ intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(),
+ instanceElement.elementId(), DeployState.UNDEPLOYED, null,
+ StateChangeResult.NO_ERROR, "Prepare completed");
+ }
}
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV2.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV2.java
index 3fe33191f..6e6f96eca 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV2.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV2.java
@@ -103,4 +103,29 @@ public abstract class AcElementListenerV2 implements AutomationCompositionElemen
intermediaryApi.updateAutomationCompositionElementState(instanceElementMigrate.instanceId(),
instanceElementMigrate.elementId(), DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Migrated");
}
+
+ @Override
+ public void migratePrecheck(CompositionElementDto compositionElement,
+ CompositionElementDto compositionElementTarget, InstanceElementDto instanceElement,
+ InstanceElementDto instanceElementMigrate) throws PfModelException {
+ intermediaryApi.updateAutomationCompositionElementState(instanceElementMigrate.instanceId(),
+ instanceElementMigrate.elementId(), DeployState.DEPLOYED, null,
+ StateChangeResult.NO_ERROR, "Migration Precheck completed");
+ }
+
+ @Override
+ public void review(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
+ throws PfModelException {
+ intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(),
+ instanceElement.elementId(), DeployState.DEPLOYED, null,
+ StateChangeResult.NO_ERROR, "Review completed");
+ }
+
+ @Override
+ public void prepare(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
+ throws PfModelException {
+ intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(),
+ instanceElement.elementId(), DeployState.UNDEPLOYED, null,
+ StateChangeResult.NO_ERROR, "Prepare completed");
+ }
}
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV1Test.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV1Test.java
index 7355b03e9..e6a3091f2 100644
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV1Test.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV1Test.java
@@ -163,17 +163,55 @@ class AcElementListenerV1Test {
StateChangeResult.NO_ERROR, "Migrated");
}
+ @Test
+ void migratePrecheckTest() throws PfModelException {
+ var intermediaryApi = mock(ParticipantIntermediaryApi.class);
+ var acElementListenerV1 = createAcElementListenerV1(intermediaryApi);
+ var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
+ Map.of(), Map.of());
+ var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of());
+ acElementListenerV1.migratePrecheck(compositionElement, compositionElement, instanceElement, instanceElement);
+ verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
+ instanceElement.elementId(), DeployState.DEPLOYED, null,
+ StateChangeResult.NO_ERROR, "Migration Precheck completed");
+ }
+
+ @Test
+ void reviewTest() throws PfModelException {
+ var intermediaryApi = mock(ParticipantIntermediaryApi.class);
+ var acElementListenerV1 = createAcElementListenerV1(intermediaryApi);
+ var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
+ Map.of(), Map.of());
+ var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of());
+ acElementListenerV1.review(compositionElement, instanceElement);
+ verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
+ instanceElement.elementId(), DeployState.DEPLOYED, null,
+ StateChangeResult.NO_ERROR, "Review completed");
+ }
+
+ @Test
+ void prepareTest() throws PfModelException {
+ var intermediaryApi = mock(ParticipantIntermediaryApi.class);
+ var acElementListenerV1 = createAcElementListenerV1(intermediaryApi);
+ var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
+ Map.of(), Map.of());
+ var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of());
+ acElementListenerV1.prepare(compositionElement, instanceElement);
+ verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
+ instanceElement.elementId(), DeployState.UNDEPLOYED, null,
+ StateChangeResult.NO_ERROR, "Prepare completed");
+ }
+
private AcElementListenerV1 createAcElementListenerV1(ParticipantIntermediaryApi intermediaryApi) {
return new AcElementListenerV1(intermediaryApi) {
@Override
- public void deploy(UUID instanceId, AcElementDeploy element, Map<String, Object> properties)
- throws PfModelException {
-
+ public void deploy(UUID instanceId, AcElementDeploy element, Map<String, Object> properties) {
+ // dummy implementation
}
@Override
- public void undeploy(UUID instanceId, UUID elementId) throws PfModelException {
-
+ public void undeploy(UUID instanceId, UUID elementId) {
+ // dummy implementation
}
};
}
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV2Test.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV2Test.java
index c8ab9e222..be8275ca6 100644
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV2Test.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV2Test.java
@@ -140,16 +140,55 @@ class AcElementListenerV2Test {
StateChangeResult.NO_ERROR, "Migrated");
}
+ @Test
+ void migratePrecheckTest() throws PfModelException {
+ var intermediaryApi = mock(ParticipantIntermediaryApi.class);
+ var acElementListenerV1 = createAcElementListenerV2(intermediaryApi);
+ var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
+ Map.of(), Map.of());
+ var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of());
+ acElementListenerV1.migratePrecheck(compositionElement, compositionElement, instanceElement, instanceElement);
+ verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
+ instanceElement.elementId(), DeployState.DEPLOYED, null,
+ StateChangeResult.NO_ERROR, "Migration Precheck completed");
+ }
+
+ @Test
+ void reviewTest() throws PfModelException {
+ var intermediaryApi = mock(ParticipantIntermediaryApi.class);
+ var acElementListenerV1 = createAcElementListenerV2(intermediaryApi);
+ var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
+ Map.of(), Map.of());
+ var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of());
+ acElementListenerV1.review(compositionElement, instanceElement);
+ verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
+ instanceElement.elementId(), DeployState.DEPLOYED, null,
+ StateChangeResult.NO_ERROR, "Review completed");
+ }
+
+ @Test
+ void prepareTest() throws PfModelException {
+ var intermediaryApi = mock(ParticipantIntermediaryApi.class);
+ var acElementListenerV1 = createAcElementListenerV2(intermediaryApi);
+ var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
+ Map.of(), Map.of());
+ var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of());
+ acElementListenerV1.prepare(compositionElement, instanceElement);
+ verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
+ instanceElement.elementId(), DeployState.UNDEPLOYED, null,
+ StateChangeResult.NO_ERROR, "Prepare completed");
+ }
+
private AcElementListenerV2 createAcElementListenerV2(ParticipantIntermediaryApi intermediaryApi) {
return new AcElementListenerV2(intermediaryApi) {
@Override
- public void deploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
- throws PfModelException {
+ public void deploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement) {
+ // dummy implementation
}
@Override
- public void undeploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
- throws PfModelException {
+ public void undeploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement) {
+ // dummy implementation
}
};
}
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AutomationCompositionElementListenerTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AutomationCompositionElementListenerTest.java
deleted file mode 100644
index b01065d09..000000000
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AutomationCompositionElementListenerTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2023-2024 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.api.impl;
-
-import static org.assertj.core.api.Assertions.assertThatCode;
-
-import java.util.Map;
-import java.util.UUID;
-import org.junit.jupiter.api.Test;
-import org.onap.policy.clamp.acm.participant.intermediary.api.CompositionElementDto;
-import org.onap.policy.clamp.acm.participant.intermediary.api.InstanceElementDto;
-import org.onap.policy.clamp.acm.participant.intermediary.handler.DummyAcElementListener;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-
-class AutomationCompositionElementListenerTest {
-
- @Test
- void defaultTest() {
- var listener = new DummyAcElementListener();
- var compositionElementDto = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
- Map.of(), Map.of());
- var instanceElementDto = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null,
- Map.of(), Map.of());
- assertThatCode(() -> listener.lock(compositionElementDto, instanceElementDto)).doesNotThrowAnyException();
- assertThatCode(() -> listener.unlock(compositionElementDto, instanceElementDto)).doesNotThrowAnyException();
- }
-}
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/DummyAcElementListener.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/DummyAcElementListener.java
deleted file mode 100644
index 173ed031b..000000000
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/DummyAcElementListener.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2023-2024 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 org.onap.policy.clamp.acm.participant.intermediary.api.AutomationCompositionElementListener;
-import org.onap.policy.clamp.acm.participant.intermediary.api.CompositionDto;
-import org.onap.policy.clamp.acm.participant.intermediary.api.CompositionElementDto;
-import org.onap.policy.clamp.acm.participant.intermediary.api.InstanceElementDto;
-import org.onap.policy.models.base.PfModelException;
-
-public class DummyAcElementListener implements AutomationCompositionElementListener {
- @Override
- public void deploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
- throws PfModelException {
-
- }
-
- @Override
- public void undeploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
- throws PfModelException {
-
- }
-
- @Override
- public void lock(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
- throws PfModelException {
-
- }
-
- @Override
- public void unlock(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
- throws PfModelException {
-
- }
-
- @Override
- public void delete(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
- throws PfModelException {
- }
-
- @Override
- public void update(CompositionElementDto compositionElement, InstanceElementDto instanceElement,
- InstanceElementDto instanceElementUpdated)
- throws PfModelException {
- }
-
- @Override
- public void prime(CompositionDto composition) throws PfModelException {
- }
-
- @Override
- public void deprime(CompositionDto composition) throws PfModelException {
- }
-
- @Override
- public void migrate(CompositionElementDto compositionElement, CompositionElementDto compositionElementTarget,
- InstanceElementDto instanceElement, InstanceElementDto instanceElementMigrate)
- throws PfModelException {
- }
-}