Upgrade AutomationCompositionElementHandler in participants 56/141356/1 master
authorFrancescoFioraEst <francesco.fiora@est.tech>
Mon, 23 Jun 2025 08:18:16 +0000 (09:18 +0100)
committerFrancesco Fiora <francesco.fiora@est.tech>
Mon, 23 Jun 2025 10:29:57 +0000 (10:29 +0000)
Update participant to avoid using old abstract classes
AcElementListenerV1 and AcElementListenerV2 in Intermediary.

Issue-ID: POLICY-5269
Change-Id: I6360a8a05a2eb911356d0e96f929c7aa192dff41
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
14 files changed:
participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AutomationCompositionElementHandler.java
participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/rest/AcElementControllerTest.java
participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/handler/AutomationCompositionElementHandler.java
participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/handler/AcElementHandlerTest.java
participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/webclient/AcHttpClientTest.java
participant/participant-impl/participant-impl-kserve/src/main/java/org/onap/policy/clamp/acm/participant/kserve/handler/AutomationCompositionElementHandler.java
participant/participant-impl/participant-impl-kserve/src/test/java/org/onap/policy/clamp/acm/participant/kserve/k8s/KserveClientTest.java
participant/participant-impl/participant-impl-kserve/src/test/java/org/onap/policy/clamp/acm/participant/kserve/rest/ActuatorControllerTest.java
participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandler.java
participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandlerTest.java
participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/HelmClientTest.java
participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/rest/ChartControllerTest.java
participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandler.java
participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/rest/AcSimRestTest.java

index 970a0ea..89673ea 100644 (file)
@@ -32,7 +32,7 @@ import org.onap.policy.clamp.acm.participant.a1pms.webclient.AcA1PmsClient;
 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.api.ParticipantIntermediaryApi;
-import org.onap.policy.clamp.acm.participant.intermediary.api.impl.AcElementListenerV2;
+import org.onap.policy.clamp.acm.participant.intermediary.api.impl.AcElementListenerV3;
 import org.onap.policy.clamp.models.acm.concepts.DeployState;
 import org.onap.policy.clamp.models.acm.concepts.StateChangeResult;
 import org.onap.policy.common.utils.coder.Coder;
@@ -46,7 +46,7 @@ import org.springframework.stereotype.Component;
  * This class handles implementation of automationCompositionElement updates.
  */
 @Component
-public class AutomationCompositionElementHandler extends AcElementListenerV2 {
+public class AutomationCompositionElementHandler extends AcElementListenerV3 {
 
     private static final Coder CODER = new StandardCoder();
 
index a5e8e2c..b91c454 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2022-2024 Nordix Foundation.
+ *  Copyright (C) 2022-2025 OpenInfra Foundation Europe. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -51,8 +51,8 @@ import org.onap.policy.common.utils.coder.StandardCoder;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
-import org.springframework.boot.test.mock.mockito.MockBean;
 import org.springframework.http.MediaType;
+import org.springframework.test.context.bean.override.mockito.MockitoBean;
 import org.springframework.test.context.junit.jupiter.SpringExtension;
 import org.springframework.test.web.servlet.MockMvc;
 import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
@@ -76,7 +76,7 @@ class AcElementControllerTest {
     @Autowired
     private MockMvc mockMvc;
 
-    @MockBean
+    @MockitoBean
     private ConfigService configService;
 
     @Autowired
index 161cf92..c43fb9b 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2021-2024 Nordix Foundation.
+ *  Copyright (C) 2021-2025 OpenInfra Foundation Europe. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -23,14 +23,15 @@ package org.onap.policy.clamp.acm.participant.http.main.handler;
 import jakarta.validation.Validation;
 import jakarta.ws.rs.core.Response.Status;
 import java.lang.invoke.MethodHandles;
+import java.util.HashMap;
 import java.util.Map;
-import java.util.UUID;
 import org.onap.policy.clamp.acm.participant.http.main.models.ConfigRequest;
 import org.onap.policy.clamp.acm.participant.http.main.webclient.AcHttpClient;
+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.api.ParticipantIntermediaryApi;
-import org.onap.policy.clamp.acm.participant.intermediary.api.impl.AcElementListenerV1;
+import org.onap.policy.clamp.acm.participant.intermediary.api.impl.AcElementListenerV3;
 import org.onap.policy.clamp.common.acm.exception.AutomationCompositionException;
-import org.onap.policy.clamp.models.acm.concepts.AcElementDeploy;
 import org.onap.policy.clamp.models.acm.concepts.DeployState;
 import org.onap.policy.clamp.models.acm.concepts.StateChangeResult;
 import org.onap.policy.common.utils.coder.Coder;
@@ -45,7 +46,7 @@ import org.springframework.stereotype.Component;
  * This class handles implementation of automationCompositionElement updates.
  */
 @Component
-public class AutomationCompositionElementHandler extends AcElementListenerV1 {
+public class AutomationCompositionElementHandler extends AcElementListenerV3 {
 
     private static final Coder CODER = new StandardCoder();
 
@@ -58,43 +59,29 @@ public class AutomationCompositionElementHandler extends AcElementListenerV1 {
         this.acHttpClient = acHttpClient;
     }
 
-    /**
-     * Handle a automation composition element state change.
-     *
-     * @param automationCompositionElementId the ID of the automation composition element
-     */
     @Override
-    public void undeploy(UUID automationCompositionId, UUID automationCompositionElementId) {
-        intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, automationCompositionElementId,
-                DeployState.UNDEPLOYED, null, StateChangeResult.NO_ERROR, "");
-    }
-
-    /**
-     * Callback method to handle an update on a automation composition element.
-     *
-     * @param automationCompositionId the automationComposition Id
-     * @param element the information on the automation composition element
-     * @param properties properties Map
-     */
-    @Override
-    public void deploy(UUID automationCompositionId, AcElementDeploy element, Map<String, Object> properties) {
+    public void deploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement) {
         try {
-            var configRequest = getConfigRequest(properties);
+            var map = new HashMap<>(compositionElement.inProperties());
+            map.putAll(instanceElement.inProperties());
+            var configRequest = getConfigRequest(map);
             var restResponseMap = acHttpClient.run(configRequest);
             var failedResponseStatus = restResponseMap.values().stream()
                     .filter(response -> !HttpStatus.valueOf(response.getKey()).is2xxSuccessful())
                     .toList();
             if (failedResponseStatus.isEmpty()) {
-                intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(),
-                        DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Deployed");
+                intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(),
+                        instanceElement.elementId(), DeployState.DEPLOYED, null,
+                        StateChangeResult.NO_ERROR, "Deployed");
             } else {
-                intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(),
-                        DeployState.UNDEPLOYED, null, StateChangeResult.FAILED,
-                        "Error on Invoking the http request: " + failedResponseStatus);
+                intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(),
+                        instanceElement.elementId(), DeployState.UNDEPLOYED, null,
+                        StateChangeResult.FAILED, "Error on Invoking the http request: " + failedResponseStatus);
             }
         } catch (AutomationCompositionException e) {
-            intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(),
-                    DeployState.UNDEPLOYED, null, StateChangeResult.FAILED, e.getMessage());
+            intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(),
+                    instanceElement.elementId(), DeployState.UNDEPLOYED, null,
+                    StateChangeResult.FAILED, e.getMessage());
         }
     }
 
@@ -114,4 +101,10 @@ public class AutomationCompositionElementHandler extends AcElementListenerV1 {
             throw new AutomationCompositionException(Status.BAD_REQUEST, "Error extracting ConfigRequest ", e);
         }
     }
+
+    @Override
+    public void undeploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement) {
+        intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(),
+                instanceElement.elementId(), DeployState.UNDEPLOYED, null, StateChangeResult.NO_ERROR, "");
+    }
 }
index 9c0b9ae..dccb05f 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2021-2024 Nordix Foundation.
+ *  Copyright (C) 2021-2025 OpenInfra Foundation Europe. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,7 +26,6 @@ import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 import org.apache.commons.lang3.tuple.Pair;
@@ -36,7 +35,11 @@ import org.onap.policy.clamp.acm.participant.http.main.models.ConfigRequest;
 import org.onap.policy.clamp.acm.participant.http.main.webclient.AcHttpClient;
 import org.onap.policy.clamp.acm.participant.http.utils.CommonTestData;
 import org.onap.policy.clamp.acm.participant.http.utils.ToscaUtils;
+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.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi;
+import org.onap.policy.clamp.models.acm.concepts.AcElementDeploy;
 import org.onap.policy.clamp.models.acm.concepts.AcTypeState;
 import org.onap.policy.clamp.models.acm.concepts.DeployState;
 import org.onap.policy.clamp.models.acm.concepts.LockState;
@@ -51,39 +54,47 @@ class AcElementHandlerTest {
     private static final String HTTP_AUTOMATION_COMPOSITION_ELEMENT =
             "org.onap.domain.database.Http_PMSHMicroserviceAutomationCompositionElement";
 
+    private InstanceElementDto creteInstanceElementDto(AcElementDeploy element) {
+        return new InstanceElementDto(commonTestData.getAutomationCompositionId(), element.getId(),
+                element.getProperties(), new HashMap<>());
+    }
+
+    private CompositionElementDto createCompositionElementDto(AcElementDeploy element) {
+        return new CompositionElementDto(UUID.randomUUID(), element.getDefinition(), new HashMap<>(), new HashMap<>());
+    }
+
     @Test
     void testUndeploy() {
-        var instanceId = commonTestData.getAutomationCompositionId();
         var element = commonTestData.getAutomationCompositionElement();
-        var acElementId = element.getId();
         var participantIntermediaryApi = mock(ParticipantIntermediaryApi.class);
-
+        var compositionElement = createCompositionElementDto(element);
+        var instanceElement = creteInstanceElementDto(element);
         var automationCompositionElementHandler =
                 new AutomationCompositionElementHandler(participantIntermediaryApi, mock(AcHttpClient.class));
-        automationCompositionElementHandler.undeploy(instanceId, acElementId);
-        verify(participantIntermediaryApi).updateAutomationCompositionElementState(instanceId, acElementId,
-                DeployState.UNDEPLOYED, null, StateChangeResult.NO_ERROR, "");
+        automationCompositionElementHandler.undeploy(compositionElement, instanceElement);
 
+        verify(participantIntermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
+                element.getId(), DeployState.UNDEPLOYED, null, StateChangeResult.NO_ERROR, "");
     }
 
     @Test
     void testDeployConstraintViolations() {
-        var instanceId = commonTestData.getAutomationCompositionId();
-        var element = commonTestData.getAutomationCompositionElement();
         var participantIntermediaryApi = mock(ParticipantIntermediaryApi.class);
-
         var automationCompositionElementHandler =
                 new AutomationCompositionElementHandler(participantIntermediaryApi, mock(AcHttpClient.class));
 
-        Map<String, Object> map = new HashMap<>();
-        automationCompositionElementHandler.deploy(instanceId, element, map);
-        verify(participantIntermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(),
-                DeployState.UNDEPLOYED, null, StateChangeResult.FAILED, "Constraint violations in the config request");
+        var element = commonTestData.getAutomationCompositionElement();
+        var compositionElement = createCompositionElementDto(element);
+        var instanceElement = creteInstanceElementDto(element);
+        automationCompositionElementHandler.deploy(compositionElement, instanceElement);
+
+        verify(participantIntermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
+                element.getId(), DeployState.UNDEPLOYED, null, StateChangeResult.FAILED,
+                "Constraint violations in the config request");
     }
 
     @Test
     void testDeployError() {
-        var instanceId = commonTestData.getAutomationCompositionId();
         var element = commonTestData.getAutomationCompositionElement();
         var participantIntermediaryApi = mock(ParticipantIntermediaryApi.class);
 
@@ -92,20 +103,26 @@ class AcElementHandlerTest {
 
         Map<String, Object> map = new HashMap<>();
         map.put("httpHeaders", 1);
-        automationCompositionElementHandler.deploy(instanceId, element, map);
-        verify(participantIntermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(),
-                DeployState.UNDEPLOYED, null, StateChangeResult.FAILED, "Error extracting ConfigRequest ");
+        var compositionElement = new CompositionElementDto(UUID.randomUUID(), element.getDefinition(),
+                map, new HashMap<>());
+        var instanceElement = creteInstanceElementDto(element);
+        automationCompositionElementHandler.deploy(compositionElement, instanceElement);
+        verify(participantIntermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
+                element.getId(), DeployState.UNDEPLOYED, null, StateChangeResult.FAILED,
+                "Error extracting ConfigRequest ");
 
     }
 
-    @Test
-    void testDeployFailed() {
+    private CompositionElementDto createCompositionElementDtoFromSt(AcElementDeploy element) {
         var serviceTemplate = ToscaUtils.readAutomationCompositionFromTosca();
         var nodeTemplatesMap = serviceTemplate.getToscaTopologyTemplate().getNodeTemplates();
         var map = new HashMap<>(nodeTemplatesMap.get(HTTP_AUTOMATION_COMPOSITION_ELEMENT).getProperties());
+        return new CompositionElementDto(UUID.randomUUID(), element.getDefinition(), map, new HashMap<>());
+    }
+
+    @Test
+    void testDeployFailed() {
         var element = commonTestData.getAutomationCompositionElement();
-        map.putAll(element.getProperties());
-        var instanceId = commonTestData.getAutomationCompositionId();
         var acHttpClient = mock(AcHttpClient.class);
         when(acHttpClient.run(any())).thenReturn(Map.of(new ToscaConceptIdentifier(),
                 Pair.of(HttpStatus.BAD_REQUEST.value(), "")));
@@ -114,128 +131,136 @@ class AcElementHandlerTest {
         var automationCompositionElementHandler =
                 new AutomationCompositionElementHandler(participantIntermediaryApi, acHttpClient);
 
-        automationCompositionElementHandler.deploy(instanceId, element, map);
+        var compositionElement = createCompositionElementDtoFromSt(element);
+        var instanceElement = creteInstanceElementDto(element);
+        automationCompositionElementHandler.deploy(compositionElement, instanceElement);
         verify(acHttpClient).run(any(ConfigRequest.class));
-        verify(participantIntermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(),
-                DeployState.UNDEPLOYED, null, StateChangeResult.FAILED,
+        verify(participantIntermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
+                element.getId(), DeployState.UNDEPLOYED, null, StateChangeResult.FAILED,
                 "Error on Invoking the http request: [(400,)]");
     }
 
     @Test
     void testDeploy() {
-        var serviceTemplate = ToscaUtils.readAutomationCompositionFromTosca();
-        var nodeTemplatesMap = serviceTemplate.getToscaTopologyTemplate().getNodeTemplates();
-        var map = new HashMap<>(nodeTemplatesMap.get(HTTP_AUTOMATION_COMPOSITION_ELEMENT).getProperties());
         var element = commonTestData.getAutomationCompositionElement();
-        map.putAll(element.getProperties());
-        var instanceId = commonTestData.getAutomationCompositionId();
         var acHttpClient = mock(AcHttpClient.class);
         var participantIntermediaryApi = mock(ParticipantIntermediaryApi.class);
-
         var automationCompositionElementHandler =
                 new AutomationCompositionElementHandler(participantIntermediaryApi, acHttpClient);
 
-        automationCompositionElementHandler.deploy(instanceId, element, map);
+        var compositionElement = createCompositionElementDtoFromSt(element);
+        var instanceElement = creteInstanceElementDto(element);
+        automationCompositionElementHandler.deploy(compositionElement, instanceElement);
         verify(acHttpClient).run(any(ConfigRequest.class));
-        verify(participantIntermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(),
-                DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Deployed");
+        verify(participantIntermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
+                element.getId(), DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Deployed");
     }
 
     @Test
     void testUpdate() throws PfModelException {
-        var instanceId = commonTestData.getAutomationCompositionId();
         var element = commonTestData.getAutomationCompositionElement();
-        var acElementId = element.getId();
         var participantIntermediaryApi = mock(ParticipantIntermediaryApi.class);
 
         var automationCompositionElementHandler =
                 new AutomationCompositionElementHandler(participantIntermediaryApi, mock(AcHttpClient.class));
 
-        automationCompositionElementHandler.update(instanceId, element, Map.of());
-        verify(participantIntermediaryApi).updateAutomationCompositionElementState(instanceId, acElementId,
-                DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Update not supported");
+        var compositionElement = createCompositionElementDto(element);
+        var instanceElement = creteInstanceElementDto(element);
+
+        automationCompositionElementHandler.update(compositionElement, instanceElement, instanceElement);
+        verify(participantIntermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
+                element.getId(), DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR,
+                "Update not supported");
     }
 
     @Test
     void testLock() throws PfModelException {
-        var instanceId = commonTestData.getAutomationCompositionId();
-        var acElementId = UUID.randomUUID();
         var participantIntermediaryApi = mock(ParticipantIntermediaryApi.class);
 
         var automationCompositionElementHandler =
                 new AutomationCompositionElementHandler(participantIntermediaryApi, mock(AcHttpClient.class));
 
-        automationCompositionElementHandler.lock(instanceId, acElementId);
-        verify(participantIntermediaryApi).updateAutomationCompositionElementState(instanceId, acElementId, null,
-                LockState.LOCKED, StateChangeResult.NO_ERROR, "Locked");
+        var element = commonTestData.getAutomationCompositionElement();
+        var compositionElement = createCompositionElementDto(element);
+        var instanceElement = creteInstanceElementDto(element);
+        automationCompositionElementHandler.lock(compositionElement, instanceElement);
+
+        verify(participantIntermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
+                element.getId(), null, LockState.LOCKED, StateChangeResult.NO_ERROR, "Locked");
     }
 
     @Test
     void testUnlock() throws PfModelException {
-        var instanceId = commonTestData.getAutomationCompositionId();
-        var acElementId = UUID.randomUUID();
         var participantIntermediaryApi = mock(ParticipantIntermediaryApi.class);
 
         var automationCompositionElementHandler =
                 new AutomationCompositionElementHandler(participantIntermediaryApi, mock(AcHttpClient.class));
 
-        automationCompositionElementHandler.unlock(instanceId, acElementId);
-        verify(participantIntermediaryApi).updateAutomationCompositionElementState(instanceId, acElementId, null,
-                LockState.UNLOCKED, StateChangeResult.NO_ERROR, "Unlocked");
+        var element = commonTestData.getAutomationCompositionElement();
+        var compositionElement = createCompositionElementDto(element);
+        var instanceElement = creteInstanceElementDto(element);
+        automationCompositionElementHandler.unlock(compositionElement, instanceElement);
+
+        verify(participantIntermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
+                element.getId(), null, LockState.UNLOCKED, StateChangeResult.NO_ERROR, "Unlocked");
     }
 
     @Test
     void testDelete() throws PfModelException {
-        var instanceId = commonTestData.getAutomationCompositionId();
-        var acElementId = UUID.randomUUID();
         var participantIntermediaryApi = mock(ParticipantIntermediaryApi.class);
 
         var automationCompositionElementHandler =
                 new AutomationCompositionElementHandler(participantIntermediaryApi, mock(AcHttpClient.class));
 
-        automationCompositionElementHandler.delete(instanceId, acElementId);
-        verify(participantIntermediaryApi).updateAutomationCompositionElementState(instanceId, acElementId,
-                DeployState.DELETED, null, StateChangeResult.NO_ERROR, "Deleted");
+        var element = commonTestData.getAutomationCompositionElement();
+        var compositionElement = createCompositionElementDto(element);
+        var instanceElement = creteInstanceElementDto(element);
+        automationCompositionElementHandler.delete(compositionElement, instanceElement);
+
+        verify(participantIntermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
+                element.getId(), DeployState.DELETED, null, StateChangeResult.NO_ERROR, "Deleted");
     }
 
     @Test
     void testPrime() throws PfModelException {
-        var compositionId = UUID.randomUUID();
         var participantIntermediaryApi = mock(ParticipantIntermediaryApi.class);
-
         var automationCompositionElementHandler =
                 new AutomationCompositionElementHandler(participantIntermediaryApi, mock(AcHttpClient.class));
 
-        automationCompositionElementHandler.prime(compositionId, List.of());
+        var compositionId = UUID.randomUUID();
+        var composition = new CompositionDto(compositionId, Map.of(), Map.of());
+        automationCompositionElementHandler.prime(composition);
         verify(participantIntermediaryApi).updateCompositionState(compositionId, AcTypeState.PRIMED,
                 StateChangeResult.NO_ERROR, "Primed");
     }
 
     @Test
     void testDeprime() throws PfModelException {
-        var compositionId = UUID.randomUUID();
         var participantIntermediaryApi = mock(ParticipantIntermediaryApi.class);
-
         var automationCompositionElementHandler =
                 new AutomationCompositionElementHandler(participantIntermediaryApi, mock(AcHttpClient.class));
 
-        automationCompositionElementHandler.deprime(compositionId);
+        var compositionId = UUID.randomUUID();
+        var composition = new CompositionDto(compositionId, Map.of(), Map.of());
+        automationCompositionElementHandler.deprime(composition);
         verify(participantIntermediaryApi).updateCompositionState(compositionId, AcTypeState.COMMISSIONED,
                 StateChangeResult.NO_ERROR, "Deprimed");
     }
 
     @Test
     void testMigrate() throws PfModelException {
-        var instanceId = commonTestData.getAutomationCompositionId();
-        var element = commonTestData.getAutomationCompositionElement();
-        var acElementId = element.getId();
         var participantIntermediaryApi = mock(ParticipantIntermediaryApi.class);
 
         var automationCompositionElementHandler =
                 new AutomationCompositionElementHandler(participantIntermediaryApi, mock(AcHttpClient.class));
 
-        automationCompositionElementHandler.migrate(instanceId, element, UUID.randomUUID(), Map.of());
-        verify(participantIntermediaryApi).updateAutomationCompositionElementState(instanceId, acElementId,
-                DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Migrated");
+        var element = commonTestData.getAutomationCompositionElement();
+        var compositionElement = createCompositionElementDto(element);
+        var instanceElement = creteInstanceElementDto(element);
+        automationCompositionElementHandler.migrate(compositionElement, compositionElement,
+                instanceElement, instanceElement, 0);
+
+        verify(participantIntermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
+                element.getId(), DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Migrated");
     }
 }
index ebeba52..e43e7f3 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2021-2023 Nordix Foundation.
+ *  Copyright (C) 2021-2023,2025 OpenInfra Foundation Europe. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -59,7 +59,7 @@ class AcHttpClientTest {
     }
 
     @AfterAll
-    public static void stopServer() throws Exception {
+    static void stopServer() throws Exception {
         mockServer.close();
         mockServer = null;
     }
index 3a05baa..95bde5f 100644 (file)
@@ -35,7 +35,7 @@ import org.apache.hc.core5.http.HttpStatus;
 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.api.ParticipantIntermediaryApi;
-import org.onap.policy.clamp.acm.participant.intermediary.api.impl.AcElementListenerV2;
+import org.onap.policy.clamp.acm.participant.intermediary.api.impl.AcElementListenerV3;
 import org.onap.policy.clamp.acm.participant.kserve.exception.KserveException;
 import org.onap.policy.clamp.acm.participant.kserve.k8s.InferenceServiceValidator;
 import org.onap.policy.clamp.acm.participant.kserve.k8s.KserveClient;
@@ -55,7 +55,7 @@ import org.springframework.stereotype.Component;
  * This class handles implementation of automationCompositionElement updates.
  */
 @Component
-public class AutomationCompositionElementHandler extends AcElementListenerV2 {
+public class AutomationCompositionElementHandler extends AcElementListenerV3 {
 
     private static final Coder CODER = new StandardCoder();
 
index d293cc0..333d572 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2023 Nordix Foundation.
+ *  Copyright (C) 2023-2025 OpenInfra Foundation Europe. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -45,9 +45,9 @@ import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.TestInstance;
 import org.junit.jupiter.api.extension.ExtendWith;
 import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.test.mock.mockito.MockBean;
-import org.springframework.boot.test.mock.mockito.SpyBean;
 import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.bean.override.mockito.MockitoBean;
+import org.springframework.test.context.bean.override.mockito.MockitoSpyBean;
 import org.springframework.test.context.junit.jupiter.SpringExtension;
 
 @ExtendWith(SpringExtension.class)
@@ -56,7 +56,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
 @TestInstance(TestInstance.Lifecycle.PER_CLASS)
 class KserveClientTest {
 
-    @SpyBean
+    @MockitoSpyBean
     private KserveClient kserveClient;
 
     String namespace = "kserve-test";
@@ -67,7 +67,7 @@ class KserveClientTest {
 
     final CustomObjectsApi customObjectsApi = mock(CustomObjectsApi.class);
 
-    @MockBean
+    @MockitoBean
     ApiClient apiClient;
 
     @BeforeAll
index 732dd7b..3551b04 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2021-2025 Nordix Foundation.
+ *  Copyright (C) 2021-2025 OpenInfra Foundation Europe. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -32,8 +32,8 @@ import org.springframework.boot.test.autoconfigure.actuate.observability.AutoCon
 import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
-import org.springframework.boot.test.mock.mockito.MockBean;
 import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.bean.override.mockito.MockitoBean;
 import org.springframework.test.web.reactive.server.WebTestClient;
 import org.springframework.web.reactive.function.client.ExchangeFilterFunctions;
 
@@ -46,7 +46,7 @@ class ActuatorControllerTest {
     @Autowired
     private WebTestClient webClient;
 
-    @MockBean
+    @MockitoBean
     private ApiClient apiClient;
 
     @Value("${spring.security.user.name}")
index b93085e..451ed22 100644 (file)
@@ -29,7 +29,7 @@ import java.util.UUID;
 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.api.ParticipantIntermediaryApi;
-import org.onap.policy.clamp.acm.participant.intermediary.api.impl.AcElementListenerV2;
+import org.onap.policy.clamp.acm.participant.intermediary.api.impl.AcElementListenerV3;
 import org.onap.policy.clamp.acm.participant.kubernetes.exception.ServiceException;
 import org.onap.policy.clamp.acm.participant.kubernetes.helm.PodStatusValidator;
 import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartInfo;
@@ -49,7 +49,7 @@ import org.springframework.stereotype.Component;
  * This class handles implementation of automationCompositionElement updates.
  */
 @Component
-public class AutomationCompositionElementHandler extends AcElementListenerV2 {
+public class AutomationCompositionElementHandler extends AcElementListenerV3 {
     private static final Logger LOGGER = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
     private static final Coder CODER = new StandardCoder();
index 260ef99..d6f5142 100644 (file)
@@ -207,6 +207,6 @@ class AutomationCompositionElementHandlerTest {
         assertDoesNotThrow(() -> automationCompositionElementHandler
                 .migrate(commonTestData.createCompositionElementDto(),
                 commonTestData.createCompositionElementDto(), commonTestData.createInstanceElementDto(Map.of()),
-                commonTestData.createInstanceElementDto(Map.of())));
+                commonTestData.createInstanceElementDto(Map.of()), 0));
     }
 }
index 19106a6..d37f470 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2021 Nordix Foundation.
+ *  Copyright (C) 2021,2025 OpenInfra Foundation Europe. All rights reserved.
  *  Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -79,7 +79,7 @@ class HelmClientTest {
     }
 
     @AfterAll
-    public static void close() throws IOException {
+    static void close() throws IOException {
         FileSystemUtils.deleteRecursively(Path.of("target/tmp"));
     }
 
index 82d833f..cb517bc 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2021-2022,2024 Nordix Foundation.
+ *  Copyright (C) 2021-2022,2025 OpenInfra Foundation Europe. All rights reserved.
  *  Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -53,11 +53,11 @@ import org.springframework.boot.actuate.autoconfigure.metrics.CompositeMeterRegi
 import org.springframework.boot.actuate.autoconfigure.metrics.MetricsAutoConfiguration;
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
-import org.springframework.boot.test.mock.mockito.MockBean;
 import org.springframework.context.annotation.Import;
 import org.springframework.http.MediaType;
 import org.springframework.mock.web.MockMultipartFile;
 import org.springframework.mock.web.MockPart;
+import org.springframework.test.context.bean.override.mockito.MockitoBean;
 import org.springframework.test.context.junit.jupiter.SpringExtension;
 import org.springframework.test.web.servlet.MockMvc;
 import org.springframework.test.web.servlet.RequestBuilder;
@@ -84,7 +84,7 @@ class ChartControllerTest {
     @Autowired
     private MockMvc mockMvc;
 
-    @MockBean
+    @MockitoBean
     private ChartService chartService;
 
     @Autowired
index 9afa039..4230fbe 100644 (file)
@@ -31,7 +31,7 @@ import org.apache.hc.core5.http.HttpStatus;
 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.api.ParticipantIntermediaryApi;
-import org.onap.policy.clamp.acm.participant.intermediary.api.impl.AcElementListenerV2;
+import org.onap.policy.clamp.acm.participant.intermediary.api.impl.AcElementListenerV3;
 import org.onap.policy.clamp.acm.participant.policy.client.PolicyApiHttpClient;
 import org.onap.policy.clamp.acm.participant.policy.client.PolicyPapHttpClient;
 import org.onap.policy.clamp.models.acm.concepts.DeployState;
@@ -51,7 +51,7 @@ import org.springframework.stereotype.Component;
  * This class handles implementation of automationCompositionElement updates.
  */
 @Component
-public class AutomationCompositionElementHandler extends AcElementListenerV2 {
+public class AutomationCompositionElementHandler extends AcElementListenerV3 {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(AutomationCompositionElementHandler.class);
     private static final Coder CODER = new StandardCoder();
index f62d6cd..6d02edd 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2023-2024 Nordix Foundation.
+ *  Copyright (C) 2023-2025 OpenInfra Foundation Europe. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -46,9 +46,9 @@ import org.springframework.boot.actuate.autoconfigure.metrics.CompositeMeterRegi
 import org.springframework.boot.actuate.autoconfigure.metrics.MetricsAutoConfiguration;
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
-import org.springframework.boot.test.mock.mockito.MockBean;
 import org.springframework.context.annotation.Import;
 import org.springframework.http.MediaType;
+import org.springframework.test.context.bean.override.mockito.MockitoBean;
 import org.springframework.test.context.junit.jupiter.SpringExtension;
 import org.springframework.test.web.servlet.MockMvc;
 import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
@@ -70,7 +70,7 @@ class AcSimRestTest {
     @Autowired
     private MockMvc mockMvc;
 
-    @MockBean
+    @MockitoBean
     private SimulatorService simulatorService;
 
     @Autowired