From 0598184e715229b34a247ac3469a1bcedc16cc0d Mon Sep 17 00:00:00 2001 From: suryakumari Date: Thu, 14 Sep 2023 21:08:59 +0530 Subject: [PATCH] sysadmin page locators actions and step definition addition --- .../e2e/pages/actions/CdfSysAdminActions.java | 365 ++++++++++++++++++ .../pages/locators/CdfSysAdminLocators.java | 140 +++++++ .../java/io/cdap/e2e/utils/ConstantsUtil.java | 1 + src/main/java/stepsdesign/SysadminSteps.java | 216 +++++++++++ 4 files changed, 722 insertions(+) create mode 100644 src/main/java/stepsdesign/SysadminSteps.java diff --git a/src/main/java/io/cdap/e2e/pages/actions/CdfSysAdminActions.java b/src/main/java/io/cdap/e2e/pages/actions/CdfSysAdminActions.java index 7fad43117..68c6c7c03 100644 --- a/src/main/java/io/cdap/e2e/pages/actions/CdfSysAdminActions.java +++ b/src/main/java/io/cdap/e2e/pages/actions/CdfSysAdminActions.java @@ -17,17 +17,24 @@ package io.cdap.e2e.pages.actions; import io.cdap.e2e.pages.locators.CdfSysAdminLocators; +import io.cdap.e2e.utils.AssertionHelper; +import io.cdap.e2e.utils.ConstantsUtil; import io.cdap.e2e.utils.ElementHelper; +import io.cdap.e2e.utils.JsonUtils; +import io.cdap.e2e.utils.PluginPropertyUtils; import io.cdap.e2e.utils.SeleniumHelper; +import io.cdap.e2e.utils.WaitHelper; import org.junit.Assert; import org.openqa.selenium.support.ui.Select; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Map; /** * Represents CdfSysAdminActions */ public class CdfSysAdminActions { + private static final Logger logger = LoggerFactory.getLogger(CdfSysAdminActions.class); public static CdfSysAdminLocators cdfSysAdminLocators; @@ -77,4 +84,362 @@ public static void verifySuccess() { } Assert.assertTrue(checkParam); } + + /** + * Click on the specific Menu + * + * @param menuName Operations, Reports or System Admin + */ + public static void clickOnMenu(String menuName) { + ElementHelper.clickOnElement(CdfSysAdminLocators.locateMenu(menuName)); + } + + /** + * Select the type of preferenceName to open in system admin + * + * @param preferenceName @data-cy attribute value of preference name. If preferenceName is present + * in {@link ConstantsUtil#DEFAULT_DATACY_ATTRIBUTES_FILE} then its data-cy + * is fetched from it else preferenceName is used as it is. + */ + public static void clickOnSystemAdminTabs(String preferenceName) { + String pluginPropertyDataCyAttribute = PluginPropertyUtils.getPluginPropertyDataCyAttribute( + preferenceName); + if (pluginPropertyDataCyAttribute == null) { + pluginPropertyDataCyAttribute = preferenceName; + } + ElementHelper.clickOnElement( + CdfSysAdminLocators.clickPreference(pluginPropertyDataCyAttribute)); + } + + /** + * Click on the Edit System Preferences in the system admin page + */ + public static void clickOnEditPreference() { + ElementHelper.clickOnElement(CdfSysAdminLocators.editSystemPreference); + } + + /** + * Select the Namespace option in the system admin page + */ + public static void selectNamespace() { + ElementHelper.clickOnElement(CdfSysAdminLocators.openNamespaceTab); + } + + /** + * Open Compute Profile option in the system admin page + */ + public static void clickOnComputeProfile() { + ElementHelper.clickOnElement(CdfSysAdminLocators.openSystemComputeProfile); + } + + /** + * Enter KeyValue Pairs For Preference Property + * + * @param preferenceProperty @data-cy attribute value of preference Property. If + * preferenceProperty is present in {@link ConstantsUtil#DEFAULT_DATACY_ATTRIBUTES_FILE} + * then its data-cy is fetched from it else preferenceProperty is used + * as it is. + * @param keyValuePair Actual json KeyValue Pairs string is fetched from {@link + * ConstantsUtil#DEFAULT_PLUGIN_PROPERTIES_FILE} with keyValuePair as + * key + */ + public static void enterKeyValuePreferences(String preferenceProperty, String keyValuePair) { + String pluginPropertyDataCyAttribute = PluginPropertyUtils.getPluginPropertyDataCyAttribute( + preferenceProperty); + if (pluginPropertyDataCyAttribute == null) { + pluginPropertyDataCyAttribute = preferenceProperty; + } + Map properties = + JsonUtils.convertKeyValueJsonArrayToMap(PluginPropertyUtils.pluginProp(keyValuePair)); + int index = 0; + for (Map.Entry entry : properties.entrySet()) { + if (index != 0) { + ElementHelper.clickOnElement(CdfSysAdminLocators.locateAddRowButtonProperty( + pluginPropertyDataCyAttribute, index - 1)); + } + ElementHelper.sendKeys(CdfSysAdminLocators.locateKeyProperty( + pluginPropertyDataCyAttribute, index), entry.getKey()); + ElementHelper.sendKeys(CdfSysAdminLocators.locateValueProperty( + pluginPropertyDataCyAttribute, index), entry.getValue()); + index++; + } + } + + /** + * Click on Save and Close button to save preference + */ + public static void clickOnSavePreference() { + ElementHelper.clickOnElement(CdfSysAdminLocators.clickSaveClose); + } + + /** + * Click on Reset button to reset preference + */ + public static void clickOnResetPreference() { + ElementHelper.clickOnElement(CdfSysAdminLocators.clickReset); + } + + /** + * Verify if System admin page is displayed + */ + public static void verifySystemAdminPageIsDisplayed() { + ElementHelper.isElementDisplayed(CdfSysAdminLocators.systemText); + } + + /** + * Verify if the added Preferences reset is successfully + */ + public static void verifyIfResetValidatedSuccessfully() { + WaitHelper.waitForElementToBeDisplayed(CdfSysAdminLocators.resetSuccessMsg); + String expectedMessage = PluginPropertyUtils.errorProp( + ConstantsUtil.RESET_VALIDATION_SUCCESS_MESSAGE); + AssertionHelper.verifyElementContainsText( + CdfSysAdminLocators.resetSuccessMsg, expectedMessage); + } + + /** + * Click on Delete to delete preference + */ + public static void deletePreference() { + ElementHelper.clickOnElement(CdfSysAdminLocators.clickDelete); + } + + /** + * Click on Reload Artifacts + */ + public static void clickReloadArtifacts() { + ElementHelper.clickOnElement(CdfSysAdminLocators.reloadSystemArtifacts); + } + + /** + * Click on Reload button to reload artifacts + */ + public static void clickOnReload() { + ElementHelper.clickOnElement(CdfSysAdminLocators.clickReload); + WaitHelper.waitForElementToBeOptionallyDisplayed( + CdfSysAdminLocators.locatorOfLoadingSpinnerOnReloadButton(), + ConstantsUtil.SMALL_TIMEOUT_SECONDS); + WaitHelper.waitForElementToBeHidden( + CdfSysAdminLocators.locatorOfLoadingSpinnerOnReloadButton(), + ConstantsUtil.DEFAULT_TIMEOUT_SECONDS); + } + + /** + * Click on Create Compute Profile button + */ + public static void clickCreateComputeProfile() { + ElementHelper.clickOnElement(CdfSysAdminLocators.createComputeProfile); + } + + /** + * Select on the type of Provisioner from list for Compute Profile in system admin + * + * @param provisionerName @data-cy attribute value of Provisioner. If Provisioner is present in + * {@link ConstantsUtil#DEFAULT_DATACY_ATTRIBUTES_FILE} then its data-cy is + * fetched from it else Provisioner is used as it is. + */ + public static void selectProvisioner(String provisionerName) { + String pluginPropertyDataCyAttribute = PluginPropertyUtils.getPluginPropertyDataCyAttribute( + provisionerName); + if (pluginPropertyDataCyAttribute == null) { + pluginPropertyDataCyAttribute = provisionerName; + } + ElementHelper.clickOnElement( + CdfSysAdminLocators.locateProvisionerInList(pluginPropertyDataCyAttribute)); + } + + /** + * Click on type of button to create Compute Profile in system admin + * + * @param buttonType @data-cy attribute value of button. If type of action is present in {@link + * ConstantsUtil#DEFAULT_DATACY_ATTRIBUTES_FILE} then its data-cy is fetched + * from it else type of action is used as it is. + */ + public static void clickCreateButtonComputeProfile(String buttonType) { + String pluginPropertyDataCyAttribute = PluginPropertyUtils.getPluginPropertyDataCyAttribute( + buttonType); + if (pluginPropertyDataCyAttribute == null) { + pluginPropertyDataCyAttribute = buttonType; + } + ElementHelper.clickOnElement( + CdfSysAdminLocators.locateButtonType(pluginPropertyDataCyAttribute)); + } + + /** + * Click on the Close button in compute profile properties page + */ + public static void clickCloseButton() { + ElementHelper.clickOnElement(CdfSysAdminLocators.closeButton); + } + + /** + * Verify Error message displayed on the footer/at the bottom of Compute Profile Properties page + * using the Error message location in the .properties file {@link ConstantsUtil#DEFAULT_ERROR_PROPERTIES_FILE} + * + * @param errorMessageLocation Expected error message location + */ + public static void verifyErrorMessageOnFooter(String errorMessageLocation) { + String expectedErrorMessage = PluginPropertyUtils.errorProp(errorMessageLocation); + AssertionHelper.verifyElementContainsText(CdfSysAdminLocators.errorMessageOnFooter, + expectedErrorMessage); + } + + /** + * Verify Error message displayed on the dialog box using the Error message location in the + * .properties file {@link ConstantsUtil#DEFAULT_ERROR_PROPERTIES_FILE} + * + * @param errorMessageLocation Expected error message location + */ + public static void verifyFailedErrorMessageOnDialogBox(String errorMessageLocation) { + String expectedErrorMessage = PluginPropertyUtils.errorProp(errorMessageLocation); + AssertionHelper.verifyElementContainsText(CdfSysAdminLocators.failMessage, + expectedErrorMessage); + } + + /** + * Click on Create Namespace button in system admin page + */ + public static void clickCreateNamespaceButton() { + ElementHelper.clickOnElement(CdfSysAdminLocators.createNewNamespace); + } + + /** + * Enter NamespaceName value in Add namespace + * + * @param value If value is present in {@link ConstantsUtil#DEFAULT_PLUGIN_PROPERTIES_FILE} as a + * key then its value is fetched from it else value is entered in the input as it + * is. + */ + public static void enterNamespaceName(String value) { + ElementHelper.sendKeys(CdfSysAdminLocators.namespaceName, + PluginPropertyUtils.pluginProp(value)); + } + + /** + * Enter NamespaceDescription value in Add namespace + * + * @param value If value is present in {@link ConstantsUtil#DEFAULT_PLUGIN_PROPERTIES_FILE} as a + * key then its value is fetched from it else value is entered in the input as it + * is. + */ + public static void enterNamespaceDescription(String value) { + ElementHelper.sendKeys(CdfSysAdminLocators.namespaceDescription, + PluginPropertyUtils.pluginProp(value)); + } + + /** + * Check whether Create Profile Properties Page is loaded + */ + public static void verifyCreateProfilePageLoaded() { + WaitHelper.waitForElementToBeOptionallyDisplayed(CdfSysAdminLocators.profilePropertiesPage(), + ConstantsUtil.DEFAULT_TIMEOUT_SECONDS); + } + + /** + * Check whether Profile created is present in System Compute Profile tab + * + * @param profileTitle any specific title created + */ + public static void verifyProvisionerPresentComputeProfile(String profileTitle) { + WaitHelper.waitForElementToBeOptionallyDisplayed(CdfSysAdminLocators. + locateProfileTitle(PluginPropertyUtils.pluginProp(profileTitle)), + ConstantsUtil.DEFAULT_TIMEOUT_SECONDS); + } + + /** + * Check whether Namespace created successfully + */ + public static void namespaceCreatedSuccessMessage() { + WaitHelper.waitForElementToBeDisplayed(CdfSysAdminLocators.locateNameSpaceSuccessMessage, + ConstantsUtil.DEFAULT_TIMEOUT_SECONDS); + } + + /** + * Click on Switch button to switch to created Namespace + */ + public static void clickOnSwitchToButton() { + ElementHelper.clickOnElement(CdfSysAdminLocators.switchToCreatedNamespace); + } + + /** + * Click on close button to close the Namespace window + */ + public static void clickOnCloseIconOnNamespaceWindow() { + ElementHelper.clickOnElement(CdfSysAdminLocators.closeNamespaceWindow); + } + + /** + * Check whether created Namespace is displayed in System Admin's Namespace tab + * + * @param namespaceName any specific title created + */ + public static void verifyCreatedNamespaceIsDisplayed(String namespaceName) { + WaitHelper.waitForElementToBeDisplayed(CdfSysAdminLocators.namespaceAdded + (PluginPropertyUtils.pluginProp(namespaceName))); + AssertionHelper.verifyElementDisplayed(CdfSysAdminLocators. + namespaceAdded(PluginPropertyUtils.pluginProp(namespaceName))); + } + + /** + * Click on Make HTTP calls + */ + public static void clickOnMakeHttpCalls() { + ElementHelper.clickOnElement(CdfSysAdminLocators.makeHttpCall); + } + + /** + * Click on EDIT button to add Namespace preferences + */ + public static void clickOnEditNamespacePreference() { + ElementHelper.clickOnElement(CdfSysAdminLocators.editPreferencesButton); + } + + /** + * Click on Hamburger Menu + */ + public static void clickOnHamburgerMenu() { + ElementHelper.clickOnElement(CdfSysAdminLocators.hamburgerMenu); + } + + /** + * Select the type of tab from hamburger menu list + * + * @param listName @data-cy attribute value from menu list. If Provisioner is present in + * {@link ConstantsUtil#DEFAULT_DATACY_ATTRIBUTES_FILE} then its data-cy is + * fetched from it else Provisioner is used as it is. + */ + public static void selectHamburgerMenuList(String listName) { + String pluginPropertyDataCyAttribute = PluginPropertyUtils.getPluginPropertyDataCyAttribute( + listName); + if (pluginPropertyDataCyAttribute == null) { + pluginPropertyDataCyAttribute = listName; + } + ElementHelper.clickOnElement( + CdfSysAdminLocators.locateMenuLink(pluginPropertyDataCyAttribute)); + } + + /** + * Click on Namespace tab links + * + * @param tabName @data-cy attribute value of tabName. If tabName is present in + * {@link ConstantsUtil#DEFAULT_DATACY_ATTRIBUTES_FILE} + * then its data-cy is fetched from it else tabName is used + * as it is. + * @param nameSpaceName Actual nameSpaceName is fetched from {@link + * ConstantsUtil#DEFAULT_PLUGIN_PROPERTIES_FILE} else nameSpaceName param is used as it is + */ + public static void clickOnNameSpaceAdminTabs(String tabName, String nameSpaceName) { + ElementHelper.clickOnElement( + CdfSysAdminLocators.nameSpaceModules(tabName, PluginPropertyUtils.pluginProp(nameSpaceName))); + } + + /** + * Select the request method from drop down + * + * @param requestMethod any specific value + */ + public static void selectRequestDropdownOption(String requestMethod) { + Select selectRequestMethod = new Select(CdfSysAdminLocators.requestMethod); + selectRequestMethod.selectByVisibleText(PluginPropertyUtils.pluginProp(requestMethod)); + } } diff --git a/src/main/java/io/cdap/e2e/pages/locators/CdfSysAdminLocators.java b/src/main/java/io/cdap/e2e/pages/locators/CdfSysAdminLocators.java index d173e0dfe..01f17ad34 100644 --- a/src/main/java/io/cdap/e2e/pages/locators/CdfSysAdminLocators.java +++ b/src/main/java/io/cdap/e2e/pages/locators/CdfSysAdminLocators.java @@ -16,6 +16,8 @@ package io.cdap.e2e.pages.locators; +import io.cdap.e2e.utils.SeleniumDriver; +import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.How; @@ -51,4 +53,142 @@ public class CdfSysAdminLocators { @FindBy(how = How.XPATH, using = "//*[@data-cy='Clear All']") public static WebElement clearAll; + @FindBy(how = How.XPATH, using = "//span//button[contains(@class, 'btn btn-secondary')]") + public static WebElement reloadSystemArtifacts; + @FindBy(how = How.XPATH, using = "//a[@href='/cdap/httpexecutor']") + public static WebElement makeHttpCall; + @FindBy(how = How.XPATH, using = "//*[@data-cy='system-prefs-accordion'][//*[contains(text(),'admin-config')]]") + public static WebElement systemText; + @FindBy(how = How.XPATH, using = "//button[@data-testid='create-namespace-btn']") + public static WebElement createNewNamespace; + @FindBy(how = How.XPATH, using = "//button[@data-testid='edit-system-prefs-btn']") + public static WebElement editSystemPreference; + @FindBy(how = How.XPATH, using = "//a[@href='/cdap/ns/system/profiles/create']") + public static WebElement createComputeProfile; + @FindBy(how = How.XPATH, using = "//div//label[@for='import-profile']") + public static WebElement clickImport; + @FindBy(how = How.XPATH, using = "//button[@data-testid='save-prefs-btn']") + public static WebElement clickSaveClose; + @FindBy(how = How.XPATH, using = "//div[@data-testid='create-namespace-name']//input") + public static WebElement namespaceName; + @FindBy(how = How.XPATH, using = "//input[@placeholder='Namespace description' and @type='text']") + public static WebElement namespaceDescription; + @FindBy(how = How.XPATH, using = "//div[@data-testid='namespaces-accordion']") + public static WebElement openNamespaceTab; + @FindBy(how = How.XPATH, using = "//div[contains(@class,'system-profiles')]") + public static WebElement openSystemComputeProfile; + @FindBy(how = How.XPATH, using = "//span[contains(@class,'reset')]") + public static WebElement clickReset; + @FindBy(how = How.XPATH, using = "//span[contains(@class,'success reset-success')]") + public static WebElement resetSuccessMsg; + @FindBy(how = How.XPATH, using = "//span//button[@type='submit' and @class='btn remove-row-btn btn-link']") + public static WebElement clickDelete; + @FindBy(how = How.XPATH, using = "//button[@data-testid='Reload']") + public static WebElement clickReload; + @FindBy(how = How.XPATH, using = "//*[contains(text(),'Close')]") + public static WebElement closeButton; + @FindBy(how = How.XPATH, using = "//div[contains(@class, 'error-section text-danger')]") + public static WebElement errorMessageOnFooter; + @FindBy(how = How.XPATH, using = "//div[contains(@class, 'card-action-feedback DANGER')]") + public static WebElement failMessage; + + public static WebElement locateMenu(String featureName) { + return SeleniumDriver.getDriver().findElement(By.xpath("//*[@data-cy='" + featureName + "']")); + } + + public static WebElement clickPreference(String preferences) { + String path = "//div[@data-cy='" + preferences + "']"; + return SeleniumDriver.getDriver().findElement(By.xpath(path)); + } + + public static WebElement locateKeyProperty(String pluginProperty, int row) { + String xpath = "//*[@data-cy='" + pluginProperty + "" + row + "']//input[@placeholder='key']"; + return SeleniumDriver.getDriver().findElement(By.xpath(xpath)); + } + + public static WebElement locateValueProperty(String pluginProperty, int row) { + String xpath = "//*[@data-cy='" + pluginProperty + "" + row + "']//input[@placeholder='value']"; + return SeleniumDriver.getDriver().findElement(By.xpath(xpath)); + } + + public static WebElement locateAddRowButtonProperty(String pluginProperty, int row) { + String xpath = + "//*[@data-cy='" + pluginProperty + "" + row + "']//span" + + "//button[@type='submit' and @class='btn add-row-btn btn-link']"; + return SeleniumDriver.getDriver().findElement(By.xpath(xpath)); + } + + public static WebElement locateDeleteRowButtonProperty(String pluginProperty, int row) { + String xpath = + "//*[@data-cy='" + pluginProperty + "" + row + "']//span" + + "//button[@type='submit' and @class='btn remove-row-btn btn-link']"; + return SeleniumDriver.getDriver().findElement(By.xpath(xpath)); + } + + public static By locatorOfLoadingSpinnerOnReloadButton() { + return By.xpath("//*[contains(@class, 'fa-spin')]"); + } + + public static WebElement locateProvisionerInList(String provisionerName) { + return SeleniumDriver.getDriver() + .findElement(By.xpath("//div[@data-cy='" + provisionerName + "']")); + } + + public static WebElement locateButtonType(String buttonType) { + return SeleniumDriver.getDriver() + .findElement(By.xpath("//button[@data-cy='" + buttonType + "']")); + } + + public static By profilePropertiesPage() { + return By.xpath("//h5[contains(text(), 'Create a profile')]"); + } + + public static WebElement locateAddedProfile(String profileName) { + String xpath = "//div[@data-cy='profile-list-" + profileName + "']"; + return SeleniumDriver.getDriver().findElement(By.xpath(xpath)); + } + + public static By locateProfileTitle(String profileName) { + return By.xpath("//div[@title='" + profileName + "']"); + } + + @FindBy(how = How.XPATH, using = "//*[@data-cy='wizard-result-icon-close-btn']") + public static WebElement closeNamespaceWindow; + + public static WebElement namespaceAdded(String nameSpace) { + String path = "//*[@href=\"/cdap/ns/" + nameSpace + "/details\"]"; + return SeleniumDriver.getDriver().findElement(By.xpath(path)); + } + + @FindBy(how = How.XPATH, using = "//a[contains(text(), 'Switch to')]") + public static WebElement switchToCreatedNamespace; + + @FindBy(how = How.XPATH, using = "//a[contains(text(), 'Go to homepage')]") + public static WebElement goToHomepage; + + @FindBy(how = How.XPATH, using = "//span[contains(@title, 'Successfully created the namespace')] ") + public static WebElement locateNameSpaceSuccessMessage; + + @FindBy(how = How.XPATH, using = "//span[contains(text(),'Edit')]") + public static WebElement editPreferencesButton; + + @FindBy(how = How.XPATH, using = "//*[@data-cy='navbar-hamburger-icon']") + public static WebElement hamburgerMenu; + + public static WebElement locateMenuLink(String menuLink) { + String xpath = "//*[@data-cy='navbar-" + menuLink + "-link']"; + return SeleniumDriver.getDriver().findElement(By.xpath(xpath)); + } + + public static WebElement nameSpaceModules(String module, String nameSpace) { + String path = "//*[@href=\"/cdap/ns/" + nameSpace + "/details/" + module + "\"]"; + return SeleniumDriver.getDriver().findElement(By.xpath(path)); + } + + public static By locateDropdownItem(String option) { + return By.xpath("//select//option[@value='" + option + "']"); + } + + @FindBy(how = How.XPATH, using = "//*[@data-cy='request-method-selector']") + public static WebElement requestMethod; } diff --git a/src/main/java/io/cdap/e2e/utils/ConstantsUtil.java b/src/main/java/io/cdap/e2e/utils/ConstantsUtil.java index 2f512497b..90c3643bf 100644 --- a/src/main/java/io/cdap/e2e/utils/ConstantsUtil.java +++ b/src/main/java/io/cdap/e2e/utils/ConstantsUtil.java @@ -64,6 +64,7 @@ public class ConstantsUtil { public static final String LOGS_SEPARATOR_MESSAGE = "---------------------------------------------------------" + "------------------------------MESSAGE----------------------------------------------------------------------" + "-----------------"; + public static final String RESET_VALIDATION_SUCCESS_MESSAGE = "validationResetSuccessMessage"; /* TODO: Remove FIRST_PLUGIN_IN_LIST constant once https://cdap.atlassian.net/browse/CDAP-18862 is fixed */ public static final String FIRST_PLUGIN_IN_LIST = "BigQuery"; /** diff --git a/src/main/java/stepsdesign/SysadminSteps.java b/src/main/java/stepsdesign/SysadminSteps.java new file mode 100644 index 000000000..faeb119a3 --- /dev/null +++ b/src/main/java/stepsdesign/SysadminSteps.java @@ -0,0 +1,216 @@ +/* + * Copyright © 2023 Cask Data, Inc. + * + * 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. + */ +package stepsdesign; + +import io.cdap.e2e.pages.actions.CdfSysAdminActions; +import io.cdap.e2e.utils.CdfHelper; +import io.cucumber.java.en.Then; +import io.cucumber.java.en.When; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * CDF sysadmin related step design. + */ +public class SysadminSteps implements CdfHelper { + + private static final Logger logger = LoggerFactory.getLogger(SysadminSteps.class); + + @When("Open {string} menu") + public static void openMenu(String menu) { + CdfSysAdminActions.clickOnMenu(menu); + } + + @Then("Select the Namespace from the System admin page") + public static void selectTheNamespace() { + CdfSysAdminActions.selectNamespace(); + } + + @Then("Click on the Compute Profile from the System admin page") + public static void clickOnComputeProfileSystemAdminPage() { + CdfSysAdminActions.clickOnComputeProfile(); + } + + @Then("Click on the Configuration link on the System admin page") + public static void clickOnConfigurationLinkOnTheSystemAdminPage() { + CdfSysAdminActions.clickConfigurationMenu(); + } + + @Then("Select {string} option from Configuration page") + public void openPageFromConfiguration(String pageName) { + CdfSysAdminActions.clickOnSystemAdminTabs(pageName); + } + + @Then("Click on edit system preferences") + public void clickOnEditSystemPreferences() { + CdfSysAdminActions.clickOnEditPreference(); + } + + @Then("Set system preferences with key: {string} and value: {string}") + public void setSystemPreferencesWithKeyAndValue(String pluginProperty, String keyValuePairs) { + CdfSysAdminActions.enterKeyValuePreferences(pluginProperty, keyValuePairs); + } + + @Then("Click on the Save & Close preferences button") + public void clickOnSaveAndClosePreferencesButton() { + CdfSysAdminActions.clickOnSavePreference(); + } + + @Then("Reset the preferences") + public void clickOnResetPreference() { + CdfSysAdminActions.clickOnResetPreference(); + } + + @Then("Verify the reset is successful for added preferences") + public void verifyIfResetValidatedSuccessfully() { + CdfSysAdminActions.verifyIfResetValidatedSuccessfully(); + } + + @Then("Verify the system admin page is navigated successfully") + public void verifySystemAdminPageIsOpened() { + CdfSysAdminActions.verifySystemAdminPageIsDisplayed(); + } + + @Then("Delete the preferences") + public void clickOnDeletePreference() { + CdfSysAdminActions.deletePreference(); + } + + @Then("Click on Reload System Artifacts from the System admin page") + public void clickOnReloadSystemArtifacts() { + CdfSysAdminActions.clickReloadArtifacts(); + } + + @Then("Click on Reload button on popup to reload the System Artifacts successfully") + public void clickOnReloadButton() { + CdfSysAdminActions.clickOnReload(); + } + + @Then("Click on create compute profile button") + public void createComputeProfile() { + CdfSysAdminActions.clickCreateComputeProfile(); + } + + @Then("Select a provisioner: {string} for the compute profile") + public void selectProvisionerForComputeProfile(String provisionerName) { + CdfSysAdminActions.selectProvisioner(provisionerName); + } + + @Then("Click on: {string} button in the properties") + public void clickOnButtonInTheProperties(String buttonType) { + CdfSysAdminActions.clickCreateButtonComputeProfile(buttonType); + } + + @Then("Click on close button of compute profile properties page") + public void closeButtonComputeProfile() { + CdfSysAdminActions.clickCloseButton(); + } + + @Then("Verify that the compute profile is displaying an error message: {string} on the footer") + public void verifyErrorMessageDisplayedOnFooter(String errorMessageLocation) { + CdfSysAdminActions.verifyErrorMessageOnFooter(errorMessageLocation); + } + + @Then("Verify the failed error message: {string} displayed on dialog box") + public void verifyFailedErrorMessageDisplayedOnDialogBox(String errorMessageLocation) { + CdfSysAdminActions.verifyFailedErrorMessageOnDialogBox(errorMessageLocation); + } + + @Then("Click on Create New Namespace button") + public void clickOnCreateNewNamespaceButton() { + CdfSysAdminActions.clickCreateNamespaceButton(); + } + + @Then("Enter the New Namespace Name with value: {string}") + public void enterNamespaceNameValue(String value) { + CdfSysAdminActions.enterNamespaceName(value); + } + + @Then("Enter the Namespace Description with value: {string}") + public void enterNamespaceDescriptionValue(String value) { + CdfSysAdminActions.enterNamespaceDescription(value); + } + + @Then("Verify the Create a Profile page is loaded for selected provisioner") + public void verifyTheCreateAProfilePageIsLoaded() { + CdfSysAdminActions.verifyCreateProfilePageLoaded(); + } + + @Then("Verify the created compute profile: {string} is displayed in system compute profile list") + public void verifyTheCreatedComputeProfile(String profile) { + CdfSysAdminActions.verifyProvisionerPresentComputeProfile(profile); + } + + @Then("Verify the namespace created success message displayed on confirmation window") + public void verifyNamespaceCreatedSuccessMessageDisplayed() { + CdfSysAdminActions.namespaceCreatedSuccessMessage(); + } + + @Then("Verify the created namespace: {string} is displayed in Namespace tab") + public void verifyCreatedNamespaceIsDisplayed(String namespace) { + CdfSysAdminActions.verifyCreatedNamespaceIsDisplayed(namespace); + } + + @Then("Click on close icon of successful namespace confirmation window") + public void closeWindowIcon() { + CdfSysAdminActions.clickOnCloseIconOnNamespaceWindow(); + } + + @Then("Click on Make HTTP calls from the System admin configuration page") + public void clickOnMakeHttpCalls() { + CdfSysAdminActions.clickOnMakeHttpCalls(); + } + + @Then("Click on send button") + public void clickOnSendButton() { + CdfSysAdminActions.sendRequest(); + } + + @Then("Verify the status code for success response") + public void verifyStatusCode() { + CdfSysAdminActions.verifySuccess(); + } + + @Then("Click on edit namespace preferences to set namespace preferences") + public void clickOnEditNameSpacePreferences() { + CdfSysAdminActions.clickOnEditNamespacePreference(); + } + + @Then("Click on the Hamburger menu on the left panel") + public static void clickOnTheHamburgerMenu() { + CdfSysAdminActions.clickOnHamburgerMenu(); + } + + @Then("Click {string} tab from Configuration page for {string} Namespace") + public void openNameSpaceAdminPageTabs(String tabName, String nameSpace) { + CdfSysAdminActions.clickOnNameSpaceAdminTabs(tabName, nameSpace); + } + + @Then("Select navigation item: {string} from the Hamburger menu list") + public void selectNavigationItemFromMenu(String tabName) { + CdfSysAdminActions.selectHamburgerMenuList(tabName); + } + + @Then("Click on the switch to namespace button") + public static void clickOnTheSwitchToButton() { + CdfSysAdminActions.clickOnSwitchToButton(); + } + + @Then("Select request dropdown property with option value: {string}") + public void selectDropdownPluginPropertyOptionValue(String option) { + CdfSysAdminActions.selectRequestDropdownOption(option); + } +}