e2e test for instantiation template
[vid.git] / vid-automation / src / main / java / vid / automation / test / test / NewServiceInstanceTest.java
index 8a5a2f1..eb3406f 100644 (file)
@@ -11,6 +11,7 @@ import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOw
 import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOOrchestrationRequestGet.COMPLETE;
 import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOOrchestrationRequestGet.DEFAULT_SERVICE_INSTANCE_ID;
 import static org.testng.Assert.assertEquals;
+import static org.testng.AssertJUnit.assertNotNull;
 import static org.testng.AssertJUnit.assertTrue;
 import static vid.automation.test.infra.Features.FLAG_1902_VNF_GROUPING;
 import static vid.automation.test.infra.Features.FLAG_1908_COLLECTION_RESOURCE_NEW_INSTANTIATION_UI;
@@ -28,7 +29,6 @@ import static vid.automation.test.infra.ModelInfo.macroSriovNoDynamicFieldsEcomp
 import static vid.automation.test.infra.ModelInfo.macroSriovNoDynamicFieldsEcompNamingFalseFullModelDetailsVnfEcompNamingFalse;
 import static vid.automation.test.infra.ModelInfo.macroSriovWithDynamicFieldsEcompNamingFalsePartialModelDetailsVnfEcompNamingFalse;
 import static vid.automation.test.infra.ModelInfo.macroSriovWithDynamicFieldsEcompNamingTruePartialModelDetails;
-import static vid.automation.test.infra.ModelInfo.pasqualeVmxVpeBvService488Annotations;
 import static vid.automation.test.infra.ModelInfo.transportWithPnfsService;
 import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.APPEND;
 import static vid.automation.test.services.SimulatorApi.registerExpectationFromPreset;
@@ -48,13 +48,11 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.UUID;
 import java.util.stream.Collectors;
 import org.apache.commons.lang3.mutable.MutableInt;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.hamcrest.Matchers;
-import org.jetbrains.annotations.NotNull;
 import org.onap.sdc.ci.tests.datatypes.UserCredentials;
 import org.onap.sdc.ci.tests.utilities.GeneralUIUtils;
 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetL3NetworksByCloudRegionSpecificState;
@@ -106,7 +104,7 @@ import vid.automation.test.test.NewServiceInstanceTest.ServiceData.IS_GENERATED_
 import vid.automation.test.utils.ReadFile;
 
 @FeatureTogglingTest(FLAG_ENABLE_WEBPACK_MODERN_UI)
-public class NewServiceInstanceTest extends CreateInstanceDialogBaseTest {
+public class NewServiceInstanceTest extends ModernUITestBase {
 
     public static final String COMPLETED = "COMPLETED";
     private static final String IN_PROGRESS = "IN_PROGRESS";
@@ -378,12 +376,10 @@ public class NewServiceInstanceTest extends CreateInstanceDialogBaseTest {
 
         // Wizard pages of Network and VPN
         Click.byTestIdOnceItsAvailable("10a74149-c9d7-4918-bbcf-d5fb9b1799ce", 20);
-        Click.byTestId("setMembersBtn");
-        GeneralUIUtils.ultimateWait();
+        clickToCloseModal("setMembersBtn");
 
         Click.byTestIdOnceItsAvailable("120d39fb-3627-473d-913c-d228dd0f8e5b", 20);
-        Click.byTestId("setMembersBtn");
-        GeneralUIUtils.ultimateWait();
+        clickToCloseModal("setMembersBtn");
 
         Assert.assertEquals(Get.byTestId("node-type-indicator").getText(),"VRF");
 
@@ -538,7 +534,7 @@ public class NewServiceInstanceTest extends CreateInstanceDialogBaseTest {
     private void editVfModuleAndJustSetName(String vfModuleName, String vfModuleUUID) {
         hoverAndClickEditButton(vfModuleUUID + "-" + vfModuleName);
         Input.text("VF instance name ZERO", "instanceName");
-        Click.byTestId(VNF_SET_BUTTON_TEST_ID);
+        clickToCloseModal(VNF_SET_BUTTON_TEST_ID);
     }
 
     @Test
@@ -1209,7 +1205,7 @@ public class NewServiceInstanceTest extends CreateInstanceDialogBaseTest {
         }
 
         vidBasePage.screenshotDeployDialog("createVnf-" + serviceInstanceName);
-        Click.byTestId(VNF_SET_BUTTON_TEST_ID);
+        clickToCloseModal(VNF_SET_BUTTON_TEST_ID);
         if (isNetwork) {
             return;
         }
@@ -1224,8 +1220,7 @@ public class NewServiceInstanceTest extends CreateInstanceDialogBaseTest {
 
             Assert.assertTrue(Get.isOptionSelectedInMultiSelect(Constants.OwningEntity.PLATFORM_MULTI_SELECT_TEST_ID, "platform"));
 
-            Click.byTestId(Constants.CANCEL_BUTTON_TEST_ID);
-            GeneralUIUtils.ultimateWait();
+            clickToCloseModal(Constants.CANCEL_BUTTON_TEST_ID);
         } else {
             toggleItemInTree(Constants.DrawingBoard.AVAILABLE_MODELS_TREE);
         }
@@ -1345,7 +1340,12 @@ public class NewServiceInstanceTest extends CreateInstanceDialogBaseTest {
         uploadSupplementaryFile("sample.json", true, browseASDCPage, setButtonTestId);
 
         browseASDCPage.screenshotDeployDialog("createVfModule-" + serviceInstanceName);
-        Click.byTestId(setButtonTestId);
+        clickToCloseModal(setButtonTestId);
+    }
+
+    private void clickToCloseModal(String setOrCancelButtonTestId) {
+        Click.byTestId(setOrCancelButtonTestId);
+        GeneralUIUtils.ultimateWait();
     }
 
     private void clickEditVfModule(ServiceData serviceData) {
@@ -1382,12 +1382,13 @@ public class NewServiceInstanceTest extends CreateInstanceDialogBaseTest {
         }
     }
 
-    @NotNull
-    private String uuid() {
-        return UUID.randomUUID().toString();
+    public void validateDynamicFields(List<String> dynamicFields) {
+        for (String field : dynamicFields) {
+            WebElement fieldElement = GeneralUIUtils.findByText(field);
+            assertNotNull("couldn't find dynamic field: " + field, fieldElement);
+        }
     }
 
-
     private void assertNotificationAreaVisibilityBehaviourAndSetBulkSize(int size) {
         WebElement webElement = Get.byId("notification-area");
         Assert.assertNull(webElement, "notification area should be invisible if only 1 qty.");
@@ -1398,22 +1399,6 @@ public class NewServiceInstanceTest extends CreateInstanceDialogBaseTest {
         Assert.assertNotNull(webElement, "notification area should be visible if more then 1 qty.");
     }
 
-    //@Step("prepare service preset")
-    private void prepareServicePreset(ModelInfo modelInfo, boolean deploy) {
-        String subscriberId = "e433710f-9217-458d-a79d-1c7aff376d89";
-
-        if (deploy) {
-            registerExpectationForServiceDeployment(
-                ImmutableList.of(
-                    modelInfo,
-                    pasqualeVmxVpeBvService488Annotations
-                ),
-                subscriberId, null);
-        } else {
-            registerExpectationForServiceBrowseAndDesign(ImmutableList.of(modelInfo), subscriberId);
-        }
-    }
-
     static class ServiceData {
 
         ServiceData(String modelUuid, List<String> dynamicFields, IS_GENERATED_NAMING isServiceGeneratedNaming,