diff options
Diffstat (limited to 'vid-automation/src/main/java/vid/automation/test/test/CreateInstanceDialogBaseTest.java')
-rw-r--r-- | vid-automation/src/main/java/vid/automation/test/test/CreateInstanceDialogBaseTest.java | 144 |
1 files changed, 143 insertions, 1 deletions
diff --git a/vid-automation/src/main/java/vid/automation/test/test/CreateInstanceDialogBaseTest.java b/vid-automation/src/main/java/vid/automation/test/test/CreateInstanceDialogBaseTest.java index ff7dc344..b486d27d 100644 --- a/vid-automation/src/main/java/vid/automation/test/test/CreateInstanceDialogBaseTest.java +++ b/vid-automation/src/main/java/vid/automation/test/test/CreateInstanceDialogBaseTest.java @@ -4,9 +4,21 @@ import org.junit.Assert; import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; import org.openqa.selenium.WebElement; import vid.automation.test.Constants; +import vid.automation.test.infra.Click; +import vid.automation.test.infra.Exists; +import vid.automation.test.infra.Get; +import vid.automation.test.infra.SelectOption; import vid.automation.test.model.Service; +import vid.automation.test.model.ServiceModel; +import vid.automation.test.sections.ViewEditPage; + +import java.util.ArrayList; +import java.util.List; public class CreateInstanceDialogBaseTest extends VidBaseTestCase { + + private ViewEditPage viewEditPage= new ViewEditPage(); + void assertServiceMetadata(String expectedMetadata, String actualMetadata) { WebElement serviceNameElem = GeneralUIUtils.getWebElementByTestID(actualMetadata); String actualServiceName = serviceNameElem.getText(); @@ -23,7 +35,7 @@ public class CreateInstanceDialogBaseTest extends VidBaseTestCase { assertServiceMetadata(expectedService.description, Constants.SERVICE_DESCRIPTION); } - void assertThatServiceCreationDialogIsVisible() { + public void assertThatServiceCreationDialogIsVisible() { boolean byText = GeneralUIUtils.findAndWaitByText(Constants.BrowseASDC.CREATE_SERVICE_INSTANCE, 15); Assert.assertTrue(byText); } @@ -32,4 +44,134 @@ public class CreateInstanceDialogBaseTest extends VidBaseTestCase { boolean byText = GeneralUIUtils.findAndWaitByText(Constants.BrowseASDC.SERVICE_INSTANCE_CREATED_SUCCESSFULLY_TEXT, 100); Assert.assertTrue(Constants.BrowseASDC.SERVICE_INSTANCE_CREATION_FAILED_MESSAGE, byText); } + + void validateVnfCreationDialog(ServiceModel expectedServiceInstance) { + GeneralUIUtils.ultimateWait(); + validateNodeTemplateCreationDialog(expectedServiceInstance); + assertServiceMetadata(expectedServiceInstance.resourceName, Constants.CreateNewInstance.RESOURCE_NAME); + assertServiceMetadata(expectedServiceInstance.nfType, Constants.CreateNewInstance.NF_TYPE); + assertServiceMetadata(expectedServiceInstance.nfRole, Constants.CreateNewInstance.NF_ROLE); + assertServiceMetadata(expectedServiceInstance.nfFunction, Constants.CreateNewInstance.NF_FUNCTION); + assertServiceMetadata(expectedServiceInstance.nfNamingCode, Constants.CreateNewInstance.NF_NAMING_CODE); + } + + void validateNodeTemplateCreationDialog(ServiceModel expectedServiceInstance){ + GeneralUIUtils.ultimateWait(); + assertServiceMetadata(expectedServiceInstance.serviceName, Constants.SERVICE_NAME); + assertServiceMetadata(expectedServiceInstance.subscriberName, Constants.SUBSCRIBER_NAME); + assertServiceMetadata(expectedServiceInstance.serviceInstanceName, Constants.SERVICE_INSTANCE_NAME); + assertServiceMetadata(expectedServiceInstance.modelName, Constants.CreateNewInstance.MODEL_NAME); + assertServiceMetadata(expectedServiceInstance.modelInvariantUuid, Constants.CreateNewInstance.MODEL_INVARIANT_UUID); + assertServiceMetadata(expectedServiceInstance.modelVersion, Constants.CreateNewInstance.MODEL_VERSION); + assertServiceMetadata(expectedServiceInstance.modelUuid, Constants.CreateNewInstance.MODEL_UUID); + assertServiceMetadata(expectedServiceInstance.modelCustomizationUuid, Constants.CreateNewInstance.MODEL_CUSTOMIZATION_UUID); + } + + private String fillDetailsInDialogWithGeneratedName(String name, String lcpRegion, String tenant, String suppressRollback, + String legacyRegion, ArrayList<String> permittedTenants) + { + String generatedInstanceName = viewEditPage.generateInstanceName(name); + return fillDetailsInDialog(generatedInstanceName, lcpRegion, tenant, suppressRollback, legacyRegion, permittedTenants); + } + + private String fillDetailsInDialog(String name, String lcpRegion, String tenant, String suppressRollback, + String legacyRegion, ArrayList<String> permittedTenants) + { + viewEditPage.setInstanceName(name); + viewEditPage.selectLCPRegion(lcpRegion); + assertDropdownPermittedItemsByValue(permittedTenants, Constants.ViewEdit.TENANT_OPTION_CLASS); + viewEditPage.selectTenant(tenant); + viewEditPage.selectSuppressRollback(suppressRollback); + viewEditPage.setLegacyRegion(legacyRegion); + return name; + } + + + protected String addVFModule(String name, String lcpRegion, String tenant, String suppressRollback, + String legacyRegion, ArrayList<String> permittedTenants,ServiceModel expectedServiceInstance) { + viewEditPage.selectVfModuleToAdd(name); + if(expectedServiceInstance != null) { + validateNodeTemplateCreationDialog(expectedServiceInstance); + } + String instanceName = fillDetailsInDialogWithGeneratedName(Constants.INSTANCE_NAME_SELECT_TESTS_ID, lcpRegion, tenant, suppressRollback, legacyRegion, permittedTenants); + viewEditPage.clickConfirmButton(); + assertSuccessfulVFModuleCreation(); + viewEditPage.clickCloseButton(); + GeneralUIUtils.ultimateWait(); + return instanceName; + } + + protected void addVolumeGroup (String name, String lcpRegion, String tenant, String suppressRollback, + String legacyRegion, ArrayList<String> permittedTenants, ServiceModel expectedServiceInstance) { + viewEditPage.selectVolumeGroupToAdd(name); + if(expectedServiceInstance != null) { + validateNodeTemplateCreationDialog(expectedServiceInstance); + } + fillDetailsInDialogWithGeneratedName(Constants.ViewEdit.VOLUME_GROUP_INSTANCE_NAME_PREFIX, lcpRegion, tenant, suppressRollback, legacyRegion, permittedTenants); + viewEditPage.clickConfirmButton(); + assertSuccessfulVolumeGroupCreation(); + viewEditPage.clickCloseButton(); + GeneralUIUtils.ultimateWait(); + } + + protected void addVNF(String name, String lcpRegion, String tenant, String suppressRollback, + String legacyRegion, String productFamily, String platform, ArrayList<String> permittedTenants, List<String> lobs, ServiceModel serviceModel, String instanceName) { + openAndFillVnfPopup(name, lcpRegion, tenant, suppressRollback, legacyRegion, productFamily, platform,permittedTenants, lobs, serviceModel, instanceName); + viewEditPage.clickConfirmButton(); + successConfirmVnfAndClosePopup(); + + } + + protected void openAndFillVnfPopup(String name, String lcpRegion, String tenant, String suppressRollback, + String legacyRegion, String productFamily, String platform, ArrayList<String> permittedTenants, List<String> lobs, ServiceModel serviceModel, String instanceName) { + viewEditPage.selectNodeInstanceToAdd(name); + GeneralUIUtils.ultimateWait(); + if(serviceModel != null) { + validateVnfCreationDialog(serviceModel); + } + viewEditPage.selectProductFamily(productFamily); + if(platform != null) { + SelectOption.byTestIdAndVisibleText(platform, Constants.OwningEntity.PLATFORM_SELECT_TEST_ID); + } + else { + Click.onFirstSelectOptionById(Constants.OwningEntity.PLATFORM_SELECT_TEST_ID); + } + if(lobs != null) { + SelectOption.selectOptionsFromMultiselectById(Constants.OwningEntity.LOB_SELECT_TEST_ID, lobs); + } + fillDetailsInDialog(instanceName, lcpRegion, tenant, suppressRollback, legacyRegion, permittedTenants); + } + + protected void successConfirmVnfAndClosePopup() { + assertSuccessfulVNFCreation(); + viewEditPage.clickCloseButton(); + GeneralUIUtils.ultimateWait(); + } + + protected void assertConfirmShowMissingDataErrorOnCurrentPopup(String field) { + viewEditPage.clickConfirmButton(); + boolean byclassAndText = Exists.byClassAndText(Constants.ViewEdit.ERROR_CLASS, String.format(Constants.MISSING_DATA, field)); + Assert.assertFalse(field + " " + Constants.REQUIRED, byclassAndText); + } + + protected void cancelPopup() { + viewEditPage.clickCancelButtonByTestID(); + GeneralUIUtils.ultimateWait(); + } + + + + public static void AssertUnselectedOptionInMultiselectById(String multiSelectId, String unselectedOption){ + Click.byId(multiSelectId); + WebElement element = Get.byClassAndText(Constants.MULTI_SELECT_UNSELECTED_CLASS, unselectedOption); + Assert.assertTrue("The option "+ unselectedOption +" is already selected",element != null); + Click.byId(multiSelectId); + } + + public void validateDynamicFields(List<String> dynamicFields) { + for (String field : dynamicFields) { + WebElement fieldElement = GeneralUIUtils.findByText(field); + Assert.assertNotNull("couldn't find dynamic field: " + field, fieldElement); + } + } } |