Remove useless code from intermediary 98/142298/2
authorFrancescoFioraEst <francesco.fiora@est.tech>
Tue, 21 Oct 2025 12:10:15 +0000 (13:10 +0100)
committerFrancesco Fiora <francesco.fiora@est.tech>
Tue, 21 Oct 2025 15:45:40 +0000 (15:45 +0000)
Remove useless update due the sync message.
Remove useless validation.

Issue-ID: POLICY-5469
Change-Id: Ie4b01ff540037e0b232c2218407bc8c301d9bfd8
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java
participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionOutHandler.java
participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionOutHandlerTest.java

index 3572945..0b076e5 100644 (file)
@@ -70,10 +70,6 @@ public class AutomationCompositionHandler {
      * @param stateChangeMsg the state change message
      */
     public void handleAutomationCompositionStateChange(AutomationCompositionStateChange stateChangeMsg) {
-        if (stateChangeMsg.getAutomationCompositionId() == null) {
-            return;
-        }
-
         var automationComposition = cacheProvider.getAutomationComposition(stateChangeMsg.getAutomationCompositionId());
 
         if (automationComposition == null) {
@@ -291,10 +287,6 @@ public class AutomationCompositionHandler {
      * @param migrationMsg the AutomationCompositionMigration
      */
     public void handleAutomationCompositionMigration(AutomationCompositionMigration migrationMsg) {
-        if (migrationMsg.getAutomationCompositionId() == null || migrationMsg.getCompositionTargetId() == null) {
-            return;
-        }
-
         var automationComposition = cacheProvider.getAutomationComposition(migrationMsg.getAutomationCompositionId());
         if (automationComposition == null) {
             LOGGER.debug("Automation composition {} does not use this participant",
index 32b8c8a..30b52bd 100644 (file)
@@ -160,12 +160,16 @@ public class AutomationCompositionOutHandler {
         }
 
         if (!SubState.NONE.equals(element.getSubState())) {
-            handleSubState(automationComposition, element, stateChangeResult);
+            if (!StateChangeResult.FAILED.equals(stateChangeResult)) {
+                element.setSubState(SubState.NONE);
+            }
         } else if (deployState != null) {
-            handleDeployState(automationComposition, element, deployState, stateChangeResult);
+            element.setDeployState(deployState);
+            element.setLockState(
+                    DeployState.DEPLOYED.equals(element.getDeployState()) ? LockState.LOCKED : LockState.NONE);
         }
         if (lockState != null) {
-            handleLockState(automationComposition, element, lockState, stateChangeResult);
+            element.setLockState(lockState);
         }
 
         var acStateChangeAck = createAutomationCompositionDeployAck();
@@ -210,59 +214,6 @@ public class AutomationCompositionOutHandler {
         return acStateChangeAck;
     }
 
-    private void handleDeployState(AutomationComposition automationComposition, AutomationCompositionElement element,
-            DeployState deployState, StateChangeResult stateChangeResult) {
-        element.setDeployState(deployState);
-        element.setLockState(DeployState.DEPLOYED.equals(element.getDeployState()) ? LockState.LOCKED : LockState.NONE);
-        if (StateChangeResult.FAILED.equals(stateChangeResult)) {
-            return;
-        }
-        var checkOpt = automationComposition.getElements().values().stream()
-                .filter(acElement -> !deployState.equals(acElement.getDeployState())).findAny();
-        if (checkOpt.isEmpty()) {
-            if (DeployState.DEPLOYED.equals(automationComposition.getDeployState())
-                    && automationComposition.getCompositionTargetId() != null) {
-                // migration scenario
-                automationComposition.setCompositionId(automationComposition.getCompositionTargetId());
-                automationComposition.setCompositionTargetId(null);
-            }
-            automationComposition.setDeployState(deployState);
-            automationComposition.setLockState(element.getLockState());
-            automationComposition.setSubState(SubState.NONE);
-
-            if (DeployState.DELETED.equals(deployState)) {
-                cacheProvider.removeAutomationComposition(automationComposition.getInstanceId());
-            }
-        }
-    }
-
-    private void handleLockState(AutomationComposition automationComposition, AutomationCompositionElement element,
-            LockState lockState, StateChangeResult stateChangeResult) {
-        element.setLockState(lockState);
-        if (StateChangeResult.FAILED.equals(stateChangeResult)) {
-            return;
-        }
-        var checkOpt = automationComposition.getElements().values().stream()
-                .filter(acElement -> !lockState.equals(acElement.getLockState())).findAny();
-        if (checkOpt.isEmpty()) {
-            automationComposition.setLockState(lockState);
-            automationComposition.setSubState(SubState.NONE);
-        }
-    }
-
-    private void handleSubState(AutomationComposition automationComposition, AutomationCompositionElement element,
-            StateChangeResult stateChangeResult) {
-        if (StateChangeResult.FAILED.equals(stateChangeResult)) {
-            return;
-        }
-        element.setSubState(SubState.NONE);
-        var checkOpt = automationComposition.getElements().values().stream()
-                .filter(acElement -> !SubState.NONE.equals(acElement.getSubState())).findAny();
-        if (checkOpt.isEmpty()) {
-            automationComposition.setSubState(SubState.NONE);
-        }
-    }
-
     /**
      * Send Ac Element Info.
      *
index e65f7bb..7726391 100644 (file)
@@ -201,7 +201,6 @@ class AutomationCompositionOutHandlerTest {
         }
         verify(publisher, times(automationComposition.getElements().size()))
                 .sendAutomationCompositionAck(any(AutomationCompositionDeployAck.class));
-        verify(cacheProvider).removeAutomationComposition(automationComposition.getInstanceId());
     }
 
     @Test
@@ -347,7 +346,6 @@ class AutomationCompositionOutHandlerTest {
         }
         verify(publisher, times(automationComposition.getElements().size()))
                 .sendAutomationCompositionAck(any(AutomationCompositionDeployAck.class));
-        assertEquals(compositionTarget, automationComposition.getCompositionId());
     }
 
     @Test