Add OutProperties instance support for restart scenario in acm-model 19/136919/1
authorFrancescoFioraEst <francesco.fiora@est.tech>
Thu, 4 Jan 2024 10:28:13 +0000 (10:28 +0000)
committerFrancesco Fiora <francesco.fiora@est.tech>
Thu, 4 Jan 2024 10:32:05 +0000 (10:32 +0000)
Add support for OutProperties instance, operationalState
and useState in restart scenario.

Issue-ID: POLICY-4909
Change-Id: I2106bc3bd60ba9ca568acfa64c09a2984ad8a337
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementRestart.java
models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java
models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRestartTest.java
models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java
models/src/test/resources/json/AutomationCompositionElementNoOrderedState.json

index 3815989..3f0dff2 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============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.
@@ -50,12 +50,17 @@ public class AcElementRestart {
     // State of the AutomationCompositionElement
     private LockState lockState;
 
+    private String operationalState;
+    private String useState;
+
     private ToscaServiceTemplate toscaServiceTemplateFragment;
 
     // A map indexed by the property name. Each map entry is the serialized value of the property,
     // which can be deserialized into an instance of the type of the property.
     private Map<String, Object> properties = new LinkedHashMap<>();
 
+    private Map<String, Object> outProperties = new LinkedHashMap<>();
+
     /**
      * Copy constructor, does a deep copy but as all fields here are immutable, it's just a regular copy.
      *
@@ -66,8 +71,11 @@ public class AcElementRestart {
         this.definition = new ToscaConceptIdentifier(otherElement.definition);
         this.deployState = otherElement.deployState;
         this.lockState = otherElement.lockState;
+        this.operationalState = otherElement.operationalState;
+        this.useState = otherElement.useState;
         this.toscaServiceTemplateFragment = otherElement.toscaServiceTemplateFragment;
         this.properties = PfUtils.mapMap(otherElement.properties, UnaryOperator.identity());
+        this.outProperties = PfUtils.mapMap(otherElement.outProperties, UnaryOperator.identity());
     }
 
 }
index 0fd7ab9..504d3ef 100755 (executable)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2021-2023 Nordix Foundation.
+ *  Copyright (C) 2021-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.
@@ -437,7 +437,10 @@ public final class AcmUtils {
         acElementRestart.setDefinition(new ToscaConceptIdentifier(element.getDefinition()));
         acElementRestart.setDeployState(element.getDeployState());
         acElementRestart.setLockState(element.getLockState());
+        acElementRestart.setOperationalState(element.getOperationalState());
+        acElementRestart.setUseState(element.getUseState());
         acElementRestart.setProperties(PfUtils.mapMap(element.getProperties(), UnaryOperator.identity()));
+        acElementRestart.setOutProperties(PfUtils.mapMap(element.getOutProperties(), UnaryOperator.identity()));
         return acElementRestart;
     }
 }
index ba84ac7..4a2a958 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============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.
@@ -27,9 +27,12 @@ import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.Partic
 
 import java.time.Instant;
 import java.util.List;
+import java.util.Map;
 import java.util.UUID;
 import org.junit.jupiter.api.Test;
 import org.onap.policy.clamp.models.acm.concepts.AcElementRestart;
+import org.onap.policy.clamp.models.acm.concepts.DeployState;
+import org.onap.policy.clamp.models.acm.concepts.LockState;
 import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition;
 import org.onap.policy.clamp.models.acm.concepts.ParticipantRestartAc;
 import org.onap.policy.clamp.models.acm.utils.CommonTestData;
@@ -62,6 +65,12 @@ class ParticipantRestartTest {
         acElement.setId(UUID.randomUUID());
         var id = new ToscaConceptIdentifier("id", "1.2.3");
         acElement.setDefinition(id);
+        acElement.setDeployState(DeployState.DEPLOYED);
+        acElement.setLockState(LockState.LOCKED);
+        acElement.setOperationalState("OperationalState");
+        acElement.setUseState("UseState");
+        acElement.setProperties(Map.of("key", "value"));
+        acElement.setOutProperties(Map.of("keyOut", "valueOut"));
 
         var acRestart = new ParticipantRestartAc();
         acRestart.setAcElementList(List.of(acElement));
index 8e10e81..bc8741e 100755 (executable)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2021-2023 Nordix Foundation.
+ *  Copyright (C) 2021-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.
@@ -226,6 +226,10 @@ class AcmUtilsTest {
         assertEquals(element.getDefinition(), result.getDefinition());
         assertEquals(element.getDeployState(), result.getDeployState());
         assertEquals(element.getLockState(), result.getLockState());
+        assertEquals(element.getOperationalState(), result.getOperationalState());
+        assertEquals(element.getUseState(), result.getUseState());
+        assertEquals(element.getProperties(), result.getProperties());
+        assertEquals(element.getOutProperties(), result.getOutProperties());
     }
 
     private AutomationComposition getDummyAutomationComposition() {
index 934535a..abb8215 100644 (file)
@@ -4,11 +4,10 @@
         "name": "aceDef",
         "version": "0.0.1"
     },
-    "participantType": {
-        "name": "participantType",
-        "version": "0.0.1"
-    },
-    "state": "UNINITIALISED",
-    "orderedState": null,
-    "properties":{"key":"{}"}
+    "deployState": "DEPLOYED",
+    "lockState": "LOCKED",
+    "operationalState": "operationalState",
+    "useState": "useState",
+    "properties":{"key":"{}"},
+    "outProperties":{"key":"{}"}
 }