change management integration with reduce flag
[vid.git] / vid-automation / src / main / java / vid / automation / test / test / ChangeManagementTest.java
index 0f75df6..7c577ca 100644 (file)
@@ -40,6 +40,7 @@ import org.onap.sdc.ci.tests.datatypes.UserCredentials;
 import org.onap.sdc.ci.tests.execute.setup.ExtentTestActions;
 import org.onap.sdc.ci.tests.utilities.GeneralUIUtils;
 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubscribersGet;
+import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetTenants;
 import org.onap.simulator.presetGenerator.presets.aai.PresetBaseAAICustomQuery;
 import org.onap.simulator.presetGenerator.presets.scheduler.PresetDeleteSchedulerChangeManagement;
 import org.openqa.selenium.JavascriptExecutor;
@@ -93,7 +94,15 @@ public class ChangeManagementTest extends VidBaseTestCase {
         Assert.assertTrue(Exists.byId(Constants.ChangeManagement.newModalSubscriberInputId));
         Assert.assertTrue(Exists.byId(Constants.ChangeManagement.newModalServiceTypeInputId));
         Assert.assertTrue(Exists.byId(Constants.ChangeManagement.newModalVNFNameInputId));
-        Assert.assertTrue(Exists.byId(Constants.ChangeManagement.newModalVNFTypeInputId));
+
+        if (Features.FLAG_FLASH_CLOUD_REGION_AND_NF_ROLE_OPTIONAL_SEARCH.isActive()) {
+            Assert.assertTrue(Exists.byId(Constants.ChangeManagement.newModalVNFTypeInputId1));
+            Assert.assertTrue(Exists.byId(Constants.ChangeManagement.newModalVNFCloudRegion));
+            Assert.assertTrue(Exists.byId(Constants.ChangeManagement.newModalVNFSearchVNF));
+        } else {
+            Assert.assertTrue(Exists.byId(Constants.ChangeManagement.newModalVNFTypeInputId));
+        }
+
         Assert.assertTrue(Exists.byId(Constants.ChangeManagement.newModalFromVNFVersionInputId));
         Assert.assertTrue(Exists.byId(Constants.ChangeManagement.newModalWorkFlowInputId));
         Assert.assertTrue(Exists.byId(Constants.generalSubmitButtonId));
@@ -105,6 +114,7 @@ public class ChangeManagementTest extends VidBaseTestCase {
         String subscriberName = VNF_DATA_WITH_IN_PLACE.subscriberName;
         String serviceType = VNF_DATA_WITH_IN_PLACE.serviceType;
         String vnfType = VNF_DATA_WITH_IN_PLACE.vnfType;
+        String cloudRegion = VNF_DATA_WITH_IN_PLACE.cloudRegion;
         String vnfSourceVersion = VNF_DATA_WITH_IN_PLACE.vnfSourceVersion;
         ChangeManagementPage.openNewChangeManagementModal();
         Wait.angularHttpRequestsLoaded();
@@ -115,8 +125,15 @@ public class ChangeManagementTest extends VidBaseTestCase {
         SelectOption.byIdAndVisibleText(Constants.ChangeManagement.newModalServiceTypeInputId, serviceType);
         Wait.angularHttpRequestsLoaded();
 
-        SelectOption.byIdAndVisibleText(Constants.ChangeManagement.newModalVNFTypeInputId, vnfType);
+        if (Features.FLAG_FLASH_CLOUD_REGION_AND_NF_ROLE_OPTIONAL_SEARCH.isActive()) {
+            Input.text(vnfType, Constants.ChangeManagement.newModalVNFTypeInputId);
+            SelectOption.byIdAndVisibleText(Constants.ChangeManagement.newModalVNFCloudRegion, cloudRegion);
+            Click.byId(Constants.ChangeManagement.newModalVNFSearchVNF);
+        } else {
+            SelectOption.byIdAndVisibleText(Constants.ChangeManagement.newModalVNFTypeInputId, vnfType);
+        }
         Wait.angularHttpRequestsLoaded();
+
         SelectOption.byIdAndVisibleText(Constants.ChangeManagement.newModalFromVNFVersionInputId, vnfSourceVersion);
         Wait.angularHttpRequestsLoaded();
         Click.byId(Constants.ChangeManagement.newModalVNFNameInputId);
@@ -159,6 +176,7 @@ public class ChangeManagementTest extends VidBaseTestCase {
         static String subscriberName = "Emanuel";
         static String serviceType = "vRichardson";
         static String vnfType = "vMobileDNS";
+        static String cloudRegion = "AAIAIC25 (AIC)";
         static String vnfSourceVersion = "1.0";
         static String vnfName = "zolson3amdns02test2";
         static String vnfTargetVersion = "5.0";
@@ -210,18 +228,30 @@ public class ChangeManagementTest extends VidBaseTestCase {
             String globalCustomerId = "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb";
             String serviceType = "vRichardson";
             SimulatorApi.registerExpectationFromPreset(new PresetBaseAAICustomQuery(
-                SIMPLE,
-                "/business/customers/customer/" + globalCustomerId + "/service-subscriptions/service-subscription/"
-                    + serviceType + "/service-instances",
-                "query/vnfs-fromServiceInstance-filter"
+                    SIMPLE,
+                    "/business/customers/customer/" + globalCustomerId + "/service-subscriptions/service-subscription/"
+                            + serviceType + "/service-instances",
+                    "query/vnfs-fromServiceInstance-filterByCloudRegion?nfRole=vMobileDNS&cloudRegionID=092eb9e8e4b7412e8787dd091bc58e86"
             ) {
                 @Override
                 public Object getResponseBody() {
                     return getResourceAsString(
-                        AAI_VNFS_FOR_CHANGE_MANAGEMENT_JSON_BY_PARAMS);
+                            AAI_VNFS_FOR_CHANGE_MANAGEMENT_JSON_BY_PARAMS);
                 }
             }, APPEND);
         }
+
+
+        SimulatorApi.registerExpectationFromPreset(new PresetAAIGetSubscribersGet(), SimulatorApi.RegistrationStrategy.APPEND);
+
+        if (Features.FLAG_FLASH_CLOUD_REGION_AND_NF_ROLE_OPTIONAL_SEARCH.isActive()) {
+            SimulatorApi.registerExpectationFromPreset(new PresetAAIGetTenants(
+                    VNF_DATA_WITH_IN_PLACE.subscriberId,
+                    VNF_DATA_WITH_IN_PLACE.serviceType,
+                    "presets_templates/PresetAAIGetTenants_service_type_vWINIFRED.json"), SimulatorApi.RegistrationStrategy.APPEND);
+
+        }
+
         registerDefaultTablesData();
         resetGetServicesCache();
     }
@@ -516,9 +546,9 @@ public class ChangeManagementTest extends VidBaseTestCase {
         fillVNFInPlace3Fields(operationsTimeout, existingSwVersion, newSwVersion);
 
         assertThatVidToPortalCallbackDataIsOk(VNF_DATA_WITH_IN_PLACE.workflowName, ImmutableMap.of(
-            "existingSoftwareVersion", existingSwVersion,
-            "newSoftwareVersion", newSwVersion,
-            "operationTimeout", operationsTimeout
+                "existingSoftwareVersion", existingSwVersion,
+                "newSoftwareVersion", newSwVersion,
+                "operationTimeout", operationsTimeout
         ));
     }
 
@@ -529,10 +559,10 @@ public class ChangeManagementTest extends VidBaseTestCase {
         Assert.assertEquals(Get.byId(Constants.ChangeManagement.newModalConfigUpdateInputId + "-label").getText(), fileName);
         Assert.assertTrue(Get.byId(Constants.generalSubmitButtonId).isEnabled());
         assertThatVidToPortalCallbackDataIsOk("VNF Config Update", ImmutableMap.of(
-            "configUpdateFile",
-            "{\"request-parameters\":{\"vm\":[{\"vnfc\":["
-                + "{\"vnfc-name\":\"ibcx0001vm001dbg001\",\"vnfc-function-code\":\"dbg\"}],\"vm-name\":\"ibcx0001vm001\"},"
-                + "{\"vnfc\":[{\"vnfc-name\":\"ibcx0001vm002dbg001\"}],\"vm-name\":\"ibcx0001vm002\"}]},\"configuration-parameters\":{\"node0_hostname\":\"dbtx0001vm001\"}}"
+                "configUpdateFile",
+                "{\"request-parameters\":{\"vm\":[{\"vnfc\":["
+                        + "{\"vnfc-name\":\"ibcx0001vm001dbg001\",\"vnfc-function-code\":\"dbg\"}],\"vm-name\":\"ibcx0001vm001\"},"
+                        + "{\"vnfc\":[{\"vnfc-name\":\"ibcx0001vm002dbg001\"}],\"vm-name\":\"ibcx0001vm002\"}]},\"configuration-parameters\":{\"node0_hostname\":\"dbtx0001vm001\"}}"
         ));
     }
 
@@ -602,28 +632,28 @@ public class ChangeManagementTest extends VidBaseTestCase {
         String modelInvariantId = "72e465fe-71b1-4e7b-b5ed-9496118ff7a8";
         String vnfInstanceId = "8e5e3ba1-3fe6-4d86-966e-f9f03dab4855";
 
-            assertThat(errorMessage, startsWith(SCHEDULE_ERROR_PREFIX));
-            assertThat(errorMessage.replace(SCHEDULE_ERROR_PREFIX, ""), jsonEquals(
+        assertThat(errorMessage, startsWith(SCHEDULE_ERROR_PREFIX));
+        assertThat(errorMessage.replace(SCHEDULE_ERROR_PREFIX, ""), jsonEquals(
                 ImmutableMap.of(
-                    "widgetName", "Portal-Common-Scheduler",
-                    "widgetParameter", "",
-                    "widgetData", ImmutableMap.builder()
-                        .put("vnfNames", ImmutableList.of(ImmutableMap.of(
-                            "id", vnfInstanceId,
-                            "invariant-id", modelInvariantId
-                        )))
-                        .put("workflowParameters", emptyMap())
-                        .put("subscriberId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb")
-                        .put("fromVNFVersion", "" + "76e908e0-5201-44d2-a3e2-9e6128d05820" + "")
-                        .put("workflow", "" + workflowName + "")
-                        .put("policyYN", "Y")
-                        .put("sniroYN", "Y")
-                        .put("testApi", "VNF_API")
-                        .put("vnfType", "vMobileDNS")
-                        .putAll(workflowParams)
-                    .build()
-                    )
-                ).when(Option.IGNORING_EXTRA_FIELDS));
+                        "widgetName", "Portal-Common-Scheduler",
+                        "widgetParameter", "",
+                        "widgetData", ImmutableMap.builder()
+                                .put("vnfNames", ImmutableList.of(ImmutableMap.of(
+                                        "id", vnfInstanceId,
+                                        "invariant-id", modelInvariantId
+                                )))
+                                .put("workflowParameters", emptyMap())
+                                .put("subscriberId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb")
+                                .put("fromVNFVersion", "" + "76e908e0-5201-44d2-a3e2-9e6128d05820" + "")
+                                .put("workflow", "" + workflowName + "")
+                                .put("policyYN", "Y")
+                                .put("sniroYN", "Y")
+                                .put("testApi", "VNF_API")
+                                .put("vnfType", "vMobileDNS")
+                                .putAll(workflowParams)
+                                .build()
+                )
+        ).when(Option.IGNORING_EXTRA_FIELDS));
 
 
         Click.byId(Constants.generalCancelButtonId);