Merge "Add tests for Prepare, Review and Migrate pre-check in CSIT"
diff --git a/csit/resources/tests/data/PrepareAC.json b/csit/resources/tests/data/PrepareAC.json
new file mode 100644
index 0000000..bc3a3c0
--- /dev/null
+++ b/csit/resources/tests/data/PrepareAC.json
@@ -0,0 +1,3 @@
+{
+  "subOrder": "PREPARE"
+}
diff --git a/csit/resources/tests/data/ReviewAC.json b/csit/resources/tests/data/ReviewAC.json
new file mode 100644
index 0000000..e4d7434
--- /dev/null
+++ b/csit/resources/tests/data/ReviewAC.json
@@ -0,0 +1,3 @@
+{
+  "subOrder": "REVIEW"
+}
diff --git a/csit/resources/tests/data/ac-instance-precheck-migration.yaml b/csit/resources/tests/data/ac-instance-precheck-migration.yaml
new file mode 100644
index 0000000..3380c15
--- /dev/null
+++ b/csit/resources/tests/data/ac-instance-precheck-migration.yaml
@@ -0,0 +1,60 @@
+# ============LICENSE_START=======================================================
+# Copyright (C) 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=========================================================
+name: Instance-Migration-To
+version: 1.0.1
+compositionId: COMPOSITIONIDPLACEHOLDER
+instanceId: INSTACEIDPLACEHOLDER
+compositionTargetId: COMPOSITIONTARGETIDPLACEHOLDER
+precheck: true
+description: Demo automation composition instance 0
+elements:
+
+  709c62b3-8918-41b9-a747-d21eb79c6c34:
+    id: 709c62b3-8918-41b9-a747-d21eb79c6c34
+    definition:
+      name: onap.policy.clamp.ac.element.Sim_StarterAutomationCompositionElement
+      version: 1.2.4
+    description: Starter Automation Composition Element for the Demo
+    properties:
+      baseUrl: http://10.101.0.249:30800
+      configurationEntities:
+        - configurationEntityId:
+          myParameterToUpdate: text updated for migration
+
+  709c62b3-8918-41b9-a747-d21eb79c6c35:
+    id: 709c62b3-8918-41b9-a747-d21eb79c6c35
+    definition:
+      name: onap.policy.clamp.ac.element.Sim_BridgeAutomationCompositionElement
+      version: 1.2.4
+    description: Bridge Automation Composition Element for the Demo
+    properties:
+      baseUrl: http://10.101.0.249:30801
+      configurationEntities:
+        - configurationEntityId:
+          myParameterToUpdate: TEXTPLACEHOLDER
+
+  709c62b3-8918-41b9-a747-d21eb79c6c37:
+    id: 709c62b3-8918-41b9-a747-d21eb79c6c37
+    definition:
+      name: onap.policy.clamp.ac.element.Sim_NewAutomationCompositionElement
+      version: 1.2.4
+    description: Sink Automation Composition Element for the Demo
+    properties:
+      configurationEntities:
+        - configurationEntityId:
+          myParameterToUpdate: text updated for migration
diff --git a/csit/resources/tests/policy-clamp-test.robot b/csit/resources/tests/policy-clamp-test.robot
index 72c5672..3afcf12 100644
--- a/csit/resources/tests/policy-clamp-test.robot
+++ b/csit/resources/tests/policy-clamp-test.robot
@@ -161,6 +161,18 @@
      set Suite variable  ${instanceMigrationId}    ${respyaml["instanceId"]}
      Should Be Equal As Strings    ${resp.status_code}     201
 
+PrepareAutomationComposition
+     [Documentation]  Prepare automation composition.
+     ${auth}=    Create List    runtimeUser    zb!XztG34
+     Log    Creating session http://${POLICY_RUNTIME_ACM_IP}
+     ${postjson}=  Get file  ${CURDIR}/data/PrepareAC.json
+     ${session}=    Create Session      policy  http://${POLICY_RUNTIME_ACM_IP}   auth=${auth}
+     ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
+     ${resp}=   PUT On Session     policy  /onap/policy/clamp/acm/v2/compositions/${compositionId}/instances/${instanceId}   data=${postjson}  headers=${headers}
+     Log    Received response from runtime acm ${resp.text}
+     Should Be Equal As Strings    ${resp.status_code}     202
+     Wait Until Keyword Succeeds    10 min    5 sec    VerifyDeployStatus  ${compositionId}  ${instanceId}  UNDEPLOYED
+
 DeployAutomationComposition
      [Documentation]  Deploy automation composition.
      ${auth}=    Create List    runtimeUser    zb!XztG34
@@ -230,6 +242,18 @@
      Should Be Equal As Strings    ${resp.status_code}     200
      List Should Contain Value  ${resp.json()['policy_types']}  onap.policies.native.Apex
 
+ReviewAutomationComposition
+     [Documentation]  Review automation composition.
+     ${auth}=    Create List    runtimeUser    zb!XztG34
+     Log    Creating session http://${POLICY_RUNTIME_ACM_IP}
+     ${postjson}=  Get file  ${CURDIR}/data/ReviewAC.json
+     ${session}=    Create Session      policy  http://${POLICY_RUNTIME_ACM_IP}   auth=${auth}
+     ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
+     ${resp}=   PUT On Session     policy  /onap/policy/clamp/acm/v2/compositions/${compositionId}/instances/${instanceId}   data=${postjson}  headers=${headers}
+     Log    Received response from runtime acm ${resp.text}
+     Should Be Equal As Strings    ${resp.status_code}     202
+     Wait Until Keyword Succeeds    10 min    5 sec    VerifyDeployStatus  ${compositionId}  ${instanceId}  DEPLOYED
+
 FailDeployAutomationCompositionMigration
      [Documentation]  Fail Deploy automation composition.
      SetParticipantSimFail
@@ -287,6 +311,22 @@
      VerifyPropertiesUpdated  ${compositionFromId}  ${instanceMigrationId}  MyTextUpdated
      VerifyParticipantSim  ${instanceMigrationId}  MyTextUpdated
 
+PrecheckAutomationCompositionMigration
+     [Documentation]  Precheck Migration of an automation composition.
+     ${auth}=    Create List    runtimeUser    zb!XztG34
+     Log    Creating session http://${POLICY_RUNTIME_ACM_IP}
+     ${postyaml}=  Get file  ${CURDIR}/data/ac-instance-precheck-migration.yaml
+     ${updatedpostyaml}=   Replace String     ${postyaml}     COMPOSITIONIDPLACEHOLDER       ${compositionFromId}
+     ${updatedpostyaml}=   Replace String     ${updatedpostyaml}     COMPOSITIONTARGETIDPLACEHOLDER       ${compositionToId}
+     ${updatedpostyaml}=   Replace String     ${updatedpostyaml}     INSTACEIDPLACEHOLDER       ${instanceMigrationId}
+     ${updatedpostyaml}=   Replace String     ${updatedpostyaml}     TEXTPLACEHOLDER       TextForMigration
+     ${session}=    Create Session      policy  http://${POLICY_RUNTIME_ACM_IP}   auth=${auth}
+     ${headers}=  Create Dictionary     Accept=application/yaml    Content-Type=application/yaml
+     ${resp}=   POST On Session     policy  /onap/policy/clamp/acm/v2/compositions/${compositionFromId}/instances   data=${updatedpostyaml}  headers=${headers}
+     Log    Received response from runtime acm ${resp.text}
+     Should Be Equal As Strings    ${resp.status_code}     200
+     Wait Until Keyword Succeeds    2 min    5 sec    VerifyDeployStatus  ${compositionFromId}  ${instanceMigrationId}  DEPLOYED
+
 AutomationCompositionMigrationTo
      [Documentation]  Migration of an automation composition.
      ${auth}=    Create List    runtimeUser    zb!XztG34