import org.onap.policy.clamp.acm.participant.intermediary.api.impl.AcElementListenerV1;
import org.onap.policy.clamp.models.acm.concepts.AcElementDeploy;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDefinition;
-import org.onap.policy.models.base.PfModelException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
}
@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) {
LOGGER.debug("deploy call instanceId: {}, element: {}, properties: {}", instanceId, element, properties);
simulatorService.deploy(instanceId, element.getId());
}
@Override
- public void undeploy(UUID instanceId, UUID elementId) throws PfModelException {
+ public void undeploy(UUID instanceId, UUID elementId) {
LOGGER.debug("undeploy call instanceId: {}, elementId: {}", instanceId, elementId);
simulatorService.undeploy(instanceId, elementId);
}
@Override
- public void lock(UUID instanceId, UUID elementId) throws PfModelException {
+ public void lock(UUID instanceId, UUID elementId) {
LOGGER.debug("lock call instanceId: {}, elementId: {}", instanceId, elementId);
simulatorService.lock(instanceId, elementId);
}
@Override
- public void unlock(UUID instanceId, UUID elementId) throws PfModelException {
+ public void unlock(UUID instanceId, UUID elementId) {
LOGGER.debug("unlock call instanceId: {}, elementId: {}", instanceId, elementId);
simulatorService.unlock(instanceId, elementId);
}
@Override
- public void delete(UUID instanceId, UUID elementId) throws PfModelException {
+ public void delete(UUID instanceId, UUID elementId) {
LOGGER.debug("delete call instanceId: {}, elementId: {}", instanceId, elementId);
simulatorService.delete(instanceId, elementId);
}
@Override
- public void update(UUID instanceId, AcElementDeploy element, Map<String, Object> properties)
- throws PfModelException {
+ public void update(UUID instanceId, AcElementDeploy element, Map<String, Object> properties) {
LOGGER.debug("update call instanceId: {}, element: {}, properties: {}", instanceId, element, properties);
simulatorService.update(instanceId, element.getId());
}
@Override
- public void prime(UUID compositionId, List<AutomationCompositionElementDefinition> elementDefinitionList)
- throws PfModelException {
+ public void prime(UUID compositionId, List<AutomationCompositionElementDefinition> elementDefinitionList) {
LOGGER.debug("prime call compositionId: {}, elementDefinitionList: {}", compositionId, elementDefinitionList);
simulatorService.prime(compositionId);
}
@Override
- public void deprime(UUID compositionId) throws PfModelException {
+ public void deprime(UUID compositionId) {
LOGGER.debug("deprime call compositionId: {}", compositionId);
simulatorService.deprime(compositionId);
}
@Override
public void migrate(UUID instanceId, AcElementDeploy element, UUID compositionTargetId,
- Map<String, Object> properties) throws PfModelException {
+ Map<String, Object> properties) {
LOGGER.debug("migrate call instanceId: {}, element: {}, compositionTargetId: {}, properties: {}",
instanceId, element, compositionTargetId, properties);
simulatorService.migrate(instanceId, element.getId());
*
* @param compositionElement the information of the Automation Composition Definition Element
* @param instanceElement the information of the Automation Composition Instance Element
- * @throws PfModelException from Policy framework
*/
@Override
- public void deploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
- throws PfModelException {
+ public void deploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement) {
LOGGER.debug("deploy call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
simulatorService.deploy(instanceElement.instanceId(), instanceElement.elementId());
}
*
* @param compositionElement the information of the Automation Composition Definition Element
* @param instanceElement the information of the Automation Composition Instance Element
- * @throws PfModelException from Policy framework
*/
@Override
- public void undeploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
- throws PfModelException {
+ public void undeploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement) {
LOGGER.debug("undeploy call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
simulatorService.undeploy(instanceElement.instanceId(), instanceElement.elementId());
}
@Override
- public void lock(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
- throws PfModelException {
+ public void lock(CompositionElementDto compositionElement, InstanceElementDto instanceElement) {
LOGGER.debug("lock call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
simulatorService.lock(instanceElement.instanceId(), instanceElement.elementId());
}
@Override
- public void unlock(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
- throws PfModelException {
+ public void unlock(CompositionElementDto compositionElement, InstanceElementDto instanceElement) {
LOGGER.debug("unlock call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
simulatorService.unlock(instanceElement.instanceId(), instanceElement.elementId());
}
@Override
- public void delete(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
- throws PfModelException {
+ public void delete(CompositionElementDto compositionElement, InstanceElementDto instanceElement) {
LOGGER.debug("delete call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
simulatorService.delete(instanceElement.instanceId(), instanceElement.elementId());
}
@Override
public void update(CompositionElementDto compositionElement, InstanceElementDto instanceElement,
- InstanceElementDto instanceElementUpdated) throws PfModelException {
+ InstanceElementDto instanceElementUpdated) {
LOGGER.debug("update call compositionElement: {}, instanceElement: {}, instanceElementUpdated: {}",
compositionElement, instanceElement, instanceElementUpdated);
simulatorService.update(instanceElement.instanceId(), instanceElement.elementId());
}
@Override
- public void prime(CompositionDto composition) throws PfModelException {
+ public void prime(CompositionDto composition) {
LOGGER.debug("prime call composition: {}", composition);
simulatorService.prime(composition.compositionId());
}
@Override
- public void deprime(CompositionDto composition) throws PfModelException {
+ public void deprime(CompositionDto composition) {
LOGGER.debug("deprime call composition: {}", composition);
simulatorService.deprime(composition.compositionId());
}
compositionElement, compositionElementTarget, instanceElement, instanceElementMigrate);
simulatorService.migrate(instanceElement.instanceId(), instanceElement.elementId());
}
+
+ @Override
+ public void migratePrecheck(CompositionElementDto compositionElement,
+ CompositionElementDto compositionElementTarget, InstanceElementDto instanceElement,
+ InstanceElementDto instanceElementMigrate) {
+ LOGGER.debug("migrate precheck call compositionElement: {}, compositionElementTarget: {}, instanceElement: {},"
+ + " instanceElementMigrate: {}",
+ compositionElement, compositionElementTarget, instanceElement, instanceElementMigrate);
+ simulatorService.migratePrecheck(instanceElement.instanceId(), instanceElement.elementId());
+ }
+
+ @Override
+ public void prepare(CompositionElementDto compositionElement, InstanceElementDto instanceElement) {
+ LOGGER.debug("prepare call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
+ simulatorService.prepare(instanceElement.instanceId(), instanceElement.elementId());
+ }
+
+ @Override
+ public void review(CompositionElementDto compositionElement, InstanceElementDto instanceElement) {
+ LOGGER.debug("review call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
+ simulatorService.review(instanceElement.instanceId(), instanceElement.elementId());
+ }
}
DeployState.DEPLOYED, null, StateChangeResult.FAILED, "Migrate failed!");
}
}
+
+ /**
+ * Handle a Migrate Precheck on a automation composition element.
+ *
+ * @param instanceId the instanceId
+ * @param elementId the elementId
+ */
+ public void migratePrecheck(UUID instanceId, UUID elementId) {
+ if (!execution(config.getMigratePrecheckTimerMs(),
+ "Current Thread migrate precheck is Interrupted during execution {}", elementId)) {
+ return;
+ }
+
+ if (config.isMigratePrecheck()) {
+ intermediaryApi.updateAutomationCompositionElementState(instanceId, elementId,
+ DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Migration precheck completed");
+ } else {
+ intermediaryApi.updateAutomationCompositionElementState(instanceId, elementId,
+ DeployState.DEPLOYED, null, StateChangeResult.FAILED, "Migration precheck failed");
+ }
+ }
+
+ /**
+ * Handle a Prepare on a automation composition element.
+ *
+ * @param instanceId the instanceId
+ * @param elementId the elementId
+ */
+ public void prepare(UUID instanceId, UUID elementId) {
+ if (!execution(config.getPrepareTimerMs(),
+ "Current Thread prepare is Interrupted during execution {}", elementId)) {
+ return;
+ }
+
+ if (config.isPrepare()) {
+ intermediaryApi.updateAutomationCompositionElementState(instanceId, elementId,
+ DeployState.UNDEPLOYED, null, StateChangeResult.NO_ERROR, "Prepare completed");
+ } else {
+ intermediaryApi.updateAutomationCompositionElementState(instanceId, elementId,
+ DeployState.UNDEPLOYED, null, StateChangeResult.FAILED, "Prepare failed");
+ }
+ }
+
+ /**
+ * Handle a Review on a automation composition element.
+ *
+ * @param instanceId the instanceId
+ * @param elementId the elementId
+ */
+ public void review(UUID instanceId, UUID elementId) {
+ if (!execution(config.getReviewTimerMs(),
+ "Current Thread review is Interrupted during execution {}", elementId)) {
+ return;
+ }
+
+ if (config.isReview()) {
+ intermediaryApi.updateAutomationCompositionElementState(instanceId, elementId,
+ DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Review completed");
+ } else {
+ intermediaryApi.updateAutomationCompositionElementState(instanceId, elementId,
+ DeployState.DEPLOYED, null, StateChangeResult.FAILED, "Review failed");
+ }
+ }
}
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2023 Nordix Foundation.
+ * 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.
private boolean migrateSuccess = true;
+ private boolean migratePrecheck = true;
+
+ private boolean prepare = true;
+
+ private boolean review = true;
+
private boolean primeSuccess = true;
private boolean deprimeSuccess = true;
private int migrateTimerMs = 100;
+ private int migratePrecheckTimerMs = 100;
+
+ private int prepareTimerMs = 100;
+
+ private int reviewTimerMs = 100;
+
private int deleteTimerMs = 100;
private int primeTimerMs = 100;
class AutomationCompositionElementHandlerV2Test {
@Test
- void testDeploy() throws PfModelException {
+ void testDeploy() {
var config = new SimConfig();
config.setDeployTimerMs(1);
var intermediaryApi = mock(ParticipantIntermediaryApi.class);
}
@Test
- void testUndeploy() throws PfModelException {
+ void testUndeploy() {
var config = new SimConfig();
config.setUndeployTimerMs(1);
var intermediaryApi = mock(ParticipantIntermediaryApi.class);
}
@Test
- void testLock() throws PfModelException {
+ void testLock() {
var config = new SimConfig();
config.setLockTimerMs(1);
var intermediaryApi = mock(ParticipantIntermediaryApi.class);
}
@Test
- void testUnlock() throws PfModelException {
+ void testUnlock() {
var config = new SimConfig();
config.setUnlockTimerMs(1);
var intermediaryApi = mock(ParticipantIntermediaryApi.class);
}
@Test
- void testUpdate() throws PfModelException {
+ void testUpdate() {
var config = new SimConfig();
config.setUpdateTimerMs(1);
var intermediaryApi = mock(ParticipantIntermediaryApi.class);
}
@Test
- void testDelete() throws PfModelException {
+ void testDelete() {
var config = new SimConfig();
config.setDeleteTimerMs(1);
var intermediaryApi = mock(ParticipantIntermediaryApi.class);
}
@Test
- void testPrime() throws PfModelException {
+ void testPrime() {
var config = new SimConfig();
config.setPrimeTimerMs(1);
var intermediaryApi = mock(ParticipantIntermediaryApi.class);
}
@Test
- void testDeprime() throws PfModelException {
+ void testDeprime() {
var config = new SimConfig();
config.setDeprimeTimerMs(1);
var intermediaryApi = mock(ParticipantIntermediaryApi.class);
verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(),
DeployState.DEPLOYED, null, StateChangeResult.FAILED, "Migrate failed!");
}
+
+ @Test
+ void testMigratePrecheck() {
+ var config = new SimConfig();
+ config.setUpdateTimerMs(1);
+ var intermediaryApi = mock(ParticipantIntermediaryApi.class);
+ var simulatorService = new SimulatorService(intermediaryApi);
+ var acElementHandler = new AutomationCompositionElementHandlerV2(intermediaryApi, simulatorService);
+ simulatorService.setConfig(config);
+ var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
+ Map.of(), Map.of());
+ var compositionElementTraget = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
+ Map.of(), Map.of());
+ var instanceId = UUID.randomUUID();
+ var element = new AcElementDeploy();
+ element.setId(UUID.randomUUID());
+ var instanceElement = new InstanceElementDto(instanceId, element.getId(), null, Map.of(), Map.of());
+ var instanceElementMigrated = new InstanceElementDto(instanceId, element.getId(),
+ null, Map.of("key", "value"), Map.of());
+ acElementHandler.migratePrecheck(compositionElement, compositionElementTraget,
+ instanceElement, instanceElementMigrated);
+ verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(),
+ DeployState.DEPLOYED, null,
+ StateChangeResult.NO_ERROR, "Migration precheck completed");
+
+ config.setMigratePrecheck(false);
+ acElementHandler.migratePrecheck(compositionElement, compositionElementTraget,
+ instanceElement, instanceElementMigrated);
+ verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(),
+ DeployState.DEPLOYED, null,
+ StateChangeResult.FAILED, "Migration precheck failed");
+ }
+
+ @Test
+ void testPrepare() {
+ var config = new SimConfig();
+ config.setDeployTimerMs(1);
+ var intermediaryApi = mock(ParticipantIntermediaryApi.class);
+ var simulatorService = new SimulatorService(intermediaryApi);
+ var acElementHandler = new AutomationCompositionElementHandlerV2(intermediaryApi, simulatorService);
+ simulatorService.setConfig(config);
+ var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
+ Map.of(), Map.of());
+ var instanceId = UUID.randomUUID();
+ var elementId = UUID.randomUUID();
+ var instanceElement = new InstanceElementDto(instanceId, elementId, null, Map.of(), Map.of());
+ acElementHandler.prepare(compositionElement, instanceElement);
+ verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId, DeployState.UNDEPLOYED,
+ null, StateChangeResult.NO_ERROR, "Prepare completed");
+
+ config.setPrepare(false);
+ acElementHandler.prepare(compositionElement, instanceElement);
+ verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId, DeployState.UNDEPLOYED,
+ null, StateChangeResult.FAILED, "Prepare failed");
+ }
+
+ @Test
+ void testReview() {
+ var config = new SimConfig();
+ config.setDeployTimerMs(1);
+ var intermediaryApi = mock(ParticipantIntermediaryApi.class);
+ var simulatorService = new SimulatorService(intermediaryApi);
+ var acElementHandler = new AutomationCompositionElementHandlerV2(intermediaryApi, simulatorService);
+ simulatorService.setConfig(config);
+ var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
+ Map.of(), Map.of());
+ var instanceId = UUID.randomUUID();
+ var elementId = UUID.randomUUID();
+ var instanceElement = new InstanceElementDto(instanceId, elementId, null, Map.of(), Map.of());
+ acElementHandler.review(compositionElement, instanceElement);
+ verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId, DeployState.DEPLOYED,
+ null, StateChangeResult.NO_ERROR, "Review completed");
+
+ config.setReview(false);
+ acElementHandler.review(compositionElement, instanceElement);
+ verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId, DeployState.DEPLOYED,
+ null, StateChangeResult.FAILED, "Review failed");
+ }
}
*/
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;
}
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");
+ }
}
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");
+ }
}
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
}
};
}
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
}
};
}
+++ /dev/null
-/*-
- * ============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();
- }
-}
+++ /dev/null
-/*-
- * ============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 {
- }
-}