diff --git a/src/main/java/io/cdap/e2e/pages/actions/WranglerActions.java b/src/main/java/io/cdap/e2e/pages/actions/WranglerActions.java new file mode 100644 index 000000000..88aa76163 --- /dev/null +++ b/src/main/java/io/cdap/e2e/pages/actions/WranglerActions.java @@ -0,0 +1,316 @@ +/* + * 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 io.cdap.e2e.pages.actions; + +import io.cdap.e2e.pages.locators.WranglerLocators; +import io.cdap.e2e.utils.ElementHelper; +import io.cdap.e2e.utils.PluginPropertyUtils; +import io.cdap.e2e.utils.SeleniumDriver; +import io.cdap.e2e.utils.SeleniumHelper; +import io.cdap.e2e.utils.WaitHelper; +import org.openqa.selenium.Keys; +import org.openqa.selenium.interactions.Actions; +import org.openqa.selenium.support.ui.Select; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * CDF wrangler related actions. + */ +public class WranglerActions { + private static final Logger logger = LoggerFactory.getLogger(WranglerActions.class); + + static { + SeleniumHelper.getPropertiesLocators(WranglerLocators.class); + } + + /** + * Selects a directive for a specific column by clicking on the transformation button and the directive option. + * + * @param columnName The name of the column on which the directive will be applied. + * @param directive The directive to be selected for the column. + */ + public static void selectDirective(String columnName, String directive) { + ElementHelper.clickOnElement(WranglerLocators.locateTransformationButton(columnName)); + String pluginPropertyDirective = PluginPropertyUtils.getPluginPropertyElementTestId(directive); + ElementHelper.clickOnElement(WranglerLocators.locateDirectivesTitle(pluginPropertyDirective)); + } + + /** + * Selects a directive for a specific column with an additional option and performs the respective action. + * + * @param columnName The name of the column on which the directive will be applied. + * @param directive The directive to be selected for the column. + * @param option The additional option that modifies the directive. + * @throws InterruptedException If interrupted while waiting. + */ + public static void selectDirectiveAndOption(String columnName, String directive, String option) + throws InterruptedException { + ElementHelper.clickOnElement(WranglerLocators.locateTransformationButton(columnName)); + String pluginPropertyDirective = PluginPropertyUtils.getPluginPropertyElementTestId(directive); + switch (directive) { + + case "CustomTransform": + ElementHelper.clickOnElement(WranglerLocators.locateDirectivesTitle(pluginPropertyDirective)); + ElementHelper.sendKeysToTextarea(WranglerLocators.filterTextArea, option); + ElementHelper.clickOnElement(WranglerLocators.applyButton); + break; + + case "Filter": + case "Sendtoerror": + ElementHelper.clickOnElement(WranglerLocators.locateDirectivesTitle(pluginPropertyDirective)); + Select selectDropdown = new Select(WranglerLocators.filterSelect); + ElementHelper.scrollToElementUsingJsExecutor(WranglerLocators.selectDirectiveOption(option)); + selectDropdown.selectByVisibleText(option); + ElementHelper.clickOnElement(WranglerLocators.applyButton); + break; + + case "FillNullOrEmptyCells": + case "CopyColumn": + ElementHelper.clickOnElement(WranglerLocators.locateDirectivesTitle(pluginPropertyDirective)); + ElementHelper.replaceElementValue(WranglerLocators.enterText, option); + ElementHelper.clickOnElement(WranglerLocators.applyButton); + break; + + case "Hash": + ElementHelper.hoverOverElement(WranglerLocators.scrollButton); + WaitHelper.waitForElementToBeDisplayed(WranglerLocators.scrollButtonDisabled); + ElementHelper.clickOnElement(WranglerLocators.locateDirectivesTitle(pluginPropertyDirective)); + Select select = new Select(WranglerLocators.filterSelect); + ElementHelper.scrollToElementUsingJsExecutor(WranglerLocators.selectDirectiveOption(option)); + select.selectByVisibleText(option); + ElementHelper.clickOnElement(WranglerLocators.applyButton); + break; + + case "Decode": + case "Encode": + ElementHelper.hoverOverElement(WranglerLocators.scrollButton); + WaitHelper.waitForElementToBeDisplayed(WranglerLocators.scrollButtonDisabled); + if (directive.equals("Encode")) { + ElementHelper.clickOnElement(WranglerLocators.encodeDirective); + } else { + ElementHelper.clickOnElement(WranglerLocators.decodeDirective); + } + ElementHelper.clickOnElement(WranglerLocators.selectDirectiveOption(option)); + break; + + default: + ElementHelper.clickOnElement(WranglerLocators.locateDirectivesTitle(pluginPropertyDirective)); + ElementHelper.clickOnElement(WranglerLocators.selectDirectiveOption(option)); + } + + } + + /** + * Selects a directive with three options and performs the action depending on the directive type. + * + * @param columnName The name of the column on which the directive will be applied. + * @param directive The directive to be selected for the column. + * @param directiveType The specific type of directive. + * @param text The text to be entered for the directive. + * @throws InterruptedException If interrupted while waiting. + */ + public static void selectDirectiveTypeWithDropdownAndText(String columnName, String directive, String directiveType, + String text) throws + InterruptedException { + ElementHelper.clickOnElement(WranglerLocators.locateTransformationButton(columnName)); + String pluginPropertyDirective = PluginPropertyUtils.getPluginPropertyElementTestId(directive); + ElementHelper.clickOnElement(WranglerLocators.locateDirectivesTitle(pluginPropertyDirective)); + + if (pluginPropertyDirective.equals("findAndReplace")) { + ElementHelper.sendKeys(WranglerLocators.enterOldValue, directiveType); + ElementHelper.sendKeys(WranglerLocators.enterNewValue, text); + ElementHelper.clickOnElement(WranglerLocators.replaceAllButton); + } else { + + switch (directiveType) { + + case "value contains": + case "value is": + case "value starts with": + case "value ends with": + case "value matches regex": + Select select = new Select(WranglerLocators.filterSelect); + select.selectByVisibleText(directiveType); + ElementHelper.sendKeysToTextarea(WranglerLocators.enterText, text); + break; + + case "Custom condition": + Select selectCustom = new Select(WranglerLocators.filterSelect); + selectCustom.selectByVisibleText(directiveType); + ElementHelper.sendKeysToTextarea(WranglerLocators.filterTextArea, text); + break; + } + } + } + + + public static void selectDirectiveTypeWithThreeOptions(String columnName, String directive, String directiveType, + String option) + throws InterruptedException { + ElementHelper.clickOnElement(WranglerLocators.locateTransformationButton(columnName)); + String pluginPropertyDirective = PluginPropertyUtils.getPluginPropertyElementTestId(directive); + ElementHelper.clickOnElement(WranglerLocators.locateDirectivesTitle(pluginPropertyDirective)); + ElementHelper.clickOnElement(WranglerLocators.selectDirectiveOption(directiveType)); + + switch (directiveType) { + case "Decimal": + ElementHelper.sendKeys(WranglerLocators.scaleText, option); + ElementHelper.clickOnElement(WranglerLocators.applyButtonUppercase); + break; + + case "Character count": + ElementHelper.replaceElementValue(WranglerLocators.enterText, option); + ElementHelper.clickOnElement(WranglerLocators.applyButton); + break; + + case "Fixed length": + ElementHelper.sendKeys(WranglerLocators.columnWidths, option); + ElementHelper.clickOnElement(WranglerLocators.applyButton); + break; + + case "XML to JSON": + case "JSON": + ElementHelper.replaceElementValue(WranglerLocators.enterDepth, option); + ElementHelper.clickOnElement(WranglerLocators.applyButton); + break; + + case "Excel": + ElementHelper.replaceElementValue(WranglerLocators.excelSheetNumber, option); + ElementHelper.clickOnElement(WranglerLocators.applyButton); + break; + + case "Using patterns": + ElementHelper.clickOnElement(WranglerLocators.selectPattern); + ElementHelper.clickOnElement(WranglerLocators.selectOptionForPatterns(option)); + ElementHelper.clickOnElement(WranglerLocators.extractButton); + break; + + default: + ElementHelper.clickOnElement(WranglerLocators.selectRadioButton(option)); + ElementHelper.clickOnElement(WranglerLocators.applyButton); + } + } + + /** + * Selects a directive with four options and performs the necessary action based on the directive type and input. + * + * @param columnName The name of the column on which the directive will be applied. + * @param directive The directive to be selected for the column. + * @param directiveType The type of directive being applied. + * @param option The additional option to modify the directive. + * @param text The text to be input for the directive. + * @throws InterruptedException If interrupted while waiting. + */ + public static void selectDirectiveTypeWithFourOption(String columnName, String directive, String directiveType, + String option, String text) + throws InterruptedException { + ElementHelper.clickOnElement(WranglerLocators.locateTransformationButton(columnName)); + String pluginPropertyDirective = PluginPropertyUtils.getPluginPropertyElementTestId(directive); + ElementHelper.clickOnElement(WranglerLocators.locateDirectivesTitle(pluginPropertyDirective)); + switch (directiveType) { + case "Concatenate": + ElementHelper.clickOnElement(WranglerLocators.selectDirectiveOption(directiveType)); + ElementHelper.sendKeys(WranglerLocators.enterText, text); + Select selectDropdown = new Select(WranglerLocators.filterSelect); + selectDropdown.selectByVisibleText(option); + ElementHelper.clickOnElementUsingJsExecutor(WranglerLocators.selectDirectiveOption(option)); + break; + + case "Datetime": + case "Simple date": + if (option.equals("Custom format")) { + ElementHelper.clickOnElement(WranglerLocators.selectDirectiveOption(directiveType)); + ElementHelper.clickOnElement(WranglerLocators.selectRadioButton(option)); + ElementHelper.sendKeys(WranglerLocators.customDate, text); + } + break; + case "Always": + Select select = new Select(WranglerLocators.filterSelect); + select.selectByVisibleText(directiveType); + ElementHelper.sendKeysToTextarea(WranglerLocators.enterCounterName, text); + ElementHelper.replaceElementValue(WranglerLocators.incrementCount, option); + break; + } + ElementHelper.clickOnElement(WranglerLocators.applyButton); + } + + /** + * Selects a directive with five options and performs the action based on the directive and the provided options. + * + * @param columnName The name of the column on which the directive will be applied. + * @param directive The directive to be selected for the column. + * @param option1 The first option to modify the directive. + * @param option2 The second option to modify the directive. + * @param option3 The third option to modify the directive. + * @param option4 The fourth option to modify the directive. + * @throws InterruptedException If interrupted while waiting. + */ + public static void selectDirectiveTypeWithFiveOption(String columnName, String directive, String option1, + String option2, String option3, String option4) + throws InterruptedException { + ElementHelper.clickOnElement(WranglerLocators.locateTransformationButton(columnName)); + String pluginPropertyDirective = PluginPropertyUtils.getPluginPropertyElementTestId(directive); + ElementHelper.clickOnElement(WranglerLocators.locateDirectivesTitle(pluginPropertyDirective)); + switch (directive) { + case "SetCounter": + Select select = new Select(WranglerLocators.filterSelect); + select.selectByVisibleText(option1); + ElementHelper.sendKeysToTextarea(WranglerLocators.filterTextArea, option2); + ElementHelper.sendKeysToTextarea(WranglerLocators.enterCounterName, option4); + ElementHelper.replaceElementValue(WranglerLocators.incrementCount, option3); + break; + + case "DefineVariable": + ElementHelper.sendKeysToTextarea(WranglerLocators.variableName, option4); + Select selectColumnName = new Select(WranglerLocators.selectColumn); + selectColumnName.selectByVisibleText(option3); + Select selectVar = new Select(WranglerLocators.selectRow); + selectVar.selectByVisibleText(option1); + if (option1.equals("Custom condition")) { + ElementHelper.sendKeysToTextarea(WranglerLocators.filterTextArea, option2); + } else { + ElementHelper.sendKeysToTextarea(WranglerLocators.variableValue, option2); + } + break; + } + ElementHelper.clickOnElement(WranglerLocators.applyButton); + } + + /** + * Enters a directive command directly into the command line. + * + * @param directive The directive to be entered into the command line. + * @throws InterruptedException If interrupted while waiting. + */ + public static void enterDirectiveFromCommandLine(String directive) throws InterruptedException { + ElementHelper.sendKeys(WranglerLocators.directiveCommandLine, directive); + Actions act = new Actions(SeleniumDriver.getDriver()); + act.sendKeys(new CharSequence[]{Keys.ENTER}).perform(); + WaitHelper.waitForElementToBeClickable(WranglerLocators.directiveCommandLine); + } + + /** + * Selects checkboxes for two columns in the UI. + * + * @param column1 The first column's name to select its checkbox. + * @param column2 The second column's name to select its checkbox. + */ + public static void selectCheckboxOnTwoColumns(String column1, String column2) { + ElementHelper.clickOnElement(WranglerLocators.locateCheckboxOfColumn(column1)); + ElementHelper.clickOnElement(WranglerLocators.locateCheckboxOfColumn(column2)); + } +} diff --git a/src/main/java/io/cdap/e2e/pages/locators/WranglerLocators.java b/src/main/java/io/cdap/e2e/pages/locators/WranglerLocators.java new file mode 100644 index 000000000..198641ad8 --- /dev/null +++ b/src/main/java/io/cdap/e2e/pages/locators/WranglerLocators.java @@ -0,0 +1,149 @@ +/* + * 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 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; + +/** + * CDF wrangler related locators. + */ +public class WranglerLocators { + @FindBy(how = How.XPATH, using = "//div[@data-testid='common-components-scrollableList-scrollDownButton']") + public static WebElement scrollButton; + + @FindBy(how = How.XPATH, using = "//div[@class='scroll-down-container text-center disabled']" + + "[@data-testid='common-components-scrollableList-scrollDownButton']") + public static WebElement scrollButtonDisabled; + + @FindBy(how = How.XPATH, using = "//div[@data-testid='features-dataprep-directives-changeDataType-submenu-decimal" + + "-scaleInput']/input") + public static WebElement scaleText; + + @FindBy(how = How.XPATH, using = "//button[contains(text(),'Extract')]") + public static WebElement extractButton; + + @FindBy(how = How.XPATH, using = "//button[@data-testid='features-dataprep-directives-findAndReplace-applyButton']") + public static WebElement replaceAllButton; + + @FindBy(how = How.XPATH, using = "//input[@data-testid='features-dataprep-workspace-cli-input']") + public static WebElement directiveCommandLine; + + @FindBy(how = How.XPATH, using = "//input[@data-testid='features-dataprep-directives-defineVariable" + + "-variableNameInput']") + public static WebElement variableName; + + @FindBy(how = How.XPATH, using = "//button[@data-testid='features-dataprep-directives-changeDataType-submenu" + + "-decimal-applyButton']") + public static WebElement applyButtonUppercase; + + @FindBy(how = How.XPATH, using = "//button[contains(text(), 'Apply')]") + public static WebElement applyButton; + + @FindBy(how = How.XPATH, using = "//input[@data-testid='features-dataprep-directives-defineVariable-" + + "conditionTextInput']") + public static WebElement variableValue; + + @FindBy(how = How.XPATH, using = "//input[@data-testid='features-dataprep-directives-parse-modal-excel-" + + "sheetNumberInput']") + public static WebElement excelSheetNumber; + + @FindBy(how = How.XPATH, using = "//button[@data-testid='features-dataprep-directives-extractFields-modal-" + + "patterns-patternsSelector']") + public static WebElement selectPattern; + + @FindBy(how = How.XPATH, using = "//div[contains(@class, 'level-popover')]//input") + public static WebElement enterText; + + @FindBy(how = How.XPATH, using = "//input[@data-testid='features-dataprep-directives-findAndReplace-oldValueInput']") + public static WebElement enterOldValue; + + @FindBy(how = How.XPATH, using = "//div[@data-testid='features-dataprep-directives-encodeDecode-title-Encode']") + public static WebElement encodeDirective; + + @FindBy(how = How.XPATH, using = "//div[@data-testid='features-dataprep-directives-encodeDecode-title-Decode']") + public static WebElement decodeDirective; + + @FindBy(how = How.XPATH, using = "//input[@data-testid='features-dataprep-directives-findAndReplace-newValueInput']") + public static WebElement enterNewValue; + + @FindBy(how = How.XPATH, using = "//div[contains(@class, 'level-popover')]//textarea") + public static WebElement filterTextArea; + + @FindBy(how = How.XPATH, using = "//div[contains(@class, 'level-popover')]//select") + public static WebElement filterSelect; + + @FindBy(how = How.XPATH, using = "//input[@data-testid='features-dataprep-directives-parse-modal-singleField-" + + "mainFieldInput']") + public static WebElement columnWidths; + + @FindBy(how = How.XPATH, using = "//select[@data-testid='features-dataprep-directives-defineVariable-" + + "columnSelector']") + public static WebElement selectColumn; + + @FindBy(how = How.XPATH, using = "//select[@data-testid='features-dataprep-directives-defineVariable-" + + "conditionSelector']") + public static WebElement selectRow; + + @FindBy(how = How.XPATH, using = "//input[@placeholder='Enter depth']") + public static WebElement enterDepth; + + @FindBy(how = How.XPATH, using = "//input[@data-testid='features-dataprep-directives-parse-modal-dateFormats-" + + "customFormatInput']") + public static WebElement customDate; + + @FindBy(how = How.XPATH, using = "//input[@data-testid='features-dataprep-directives-setCounter-counterNameInput']") + public static WebElement enterCounterName; + + @FindBy(how = How.XPATH, using = "//input[@data-testid='features-dataprep-directives-setCounter-" + + "counterIncrementInput']") + public static WebElement incrementCount; + + public static WebElement locateTransformationButton(String columnName) { + return SeleniumDriver.getDriver() + .findElement(By.xpath("//th[@id='column-" + columnName + "']//button[@data-testid='features-dataprep-workspace" + + "-dataTable-head-directivesDropdown-toggleButton']")); + } + + public static WebElement locateDirectivesTitle(String directiveName) { + return SeleniumDriver.getDriver() + .findElement(By.xpath("//div[@data-testid='features-dataprep-" + + "directives-" + directiveName + "-title']")); + } + + public static WebElement locateCheckboxOfColumn(String columnName) { + return SeleniumDriver.getDriver() + .findElement(By.xpath("//th[@id='column-" + columnName + "']/descendant::span[@data-testid='" + + "features-dataprep-workspace-dataTable-head-columnSelectToggle']")); + } + + public static WebElement selectDirectiveOption(String option) { + return SeleniumDriver.getDriver().findElement(By.xpath("//*[text()='" + option + "']")); + } + + public static WebElement selectRadioButton(String optionType) { + return SeleniumDriver.getDriver().findElement(By.xpath("//span[contains(text(),'" + optionType + "')]")); + } + + public static WebElement selectOptionForPatterns(String optionType) { + return SeleniumDriver.getDriver().findElement(By.xpath("//button[@data-testid='features-dataprep-" + + "directives-extractFields-modal-patterns-" + + "patternsOption-" + optionType + "']")); + } +} diff --git a/src/main/java/io/cdap/e2e/utils/ConstantsUtil.java b/src/main/java/io/cdap/e2e/utils/ConstantsUtil.java index 90c3643bf..dd982aaf1 100644 --- a/src/main/java/io/cdap/e2e/utils/ConstantsUtil.java +++ b/src/main/java/io/cdap/e2e/utils/ConstantsUtil.java @@ -53,6 +53,7 @@ public class ConstantsUtil { public static final String DEFAULT_PLUGIN_PROPERTIES_FILE = "pluginParameters.properties"; public static final String DEFAULT_ERROR_PROPERTIES_FILE = "errorMessage.properties"; public static final String DEFAULT_DATACY_ATTRIBUTES_FILE = "pluginDataCyAttributes.properties"; + public static final String DEFAULT_DATATESTID_ATTRIBUTES_FILE = "pluginDataTestIdAttributes.properties"; public static final String VALIDATION_SUCCESS_MESSAGE = "validationSuccessMessage"; public static final String VALIDATION_ERROR_MESSAGE = "validationErrorMessage"; public static final String INVALID_CREDENTIALS_ERROR_MESSAGE = "invalid.property.credentials"; diff --git a/src/main/java/io/cdap/e2e/utils/PluginPropertyUtils.java b/src/main/java/io/cdap/e2e/utils/PluginPropertyUtils.java index 6237cc426..44689bab8 100644 --- a/src/main/java/io/cdap/e2e/utils/PluginPropertyUtils.java +++ b/src/main/java/io/cdap/e2e/utils/PluginPropertyUtils.java @@ -33,6 +33,7 @@ public class PluginPropertyUtils { private static final Logger logger = LoggerFactory.getLogger(PluginPropertyUtils.class); protected static Properties pluginProperties = new Properties(); private static final Properties pluginPropertyDataCyAttributes = new Properties(); + private static final Properties pluginPropertyDataTestIdAttributes = new Properties(); static { try { @@ -53,6 +54,13 @@ public class PluginPropertyUtils { } catch (Exception e) { logger.error("Error while reading " + ConstantsUtil.DEFAULT_DATACY_ATTRIBUTES_FILE + " file " + e.getMessage()); } + try { + pluginPropertyDataTestIdAttributes.load + (PluginPropertyUtils.class.getResourceAsStream("/" + ConstantsUtil.DEFAULT_DATATESTID_ATTRIBUTES_FILE)); + } catch (Exception e) { + logger.error("Error while reading " + ConstantsUtil.DEFAULT_DATATESTID_ATTRIBUTES_FILE + + " file " + e.getMessage()); + } } public static String pluginProp(String property) { @@ -75,6 +83,10 @@ public static String getPluginPropertyDataCyAttribute(String property) { return pluginPropertyDataCyAttributes.getProperty(property); } + public static String getPluginPropertyDataTestIdAttribute(String property) { + return pluginPropertyDataTestIdAttributes.getProperty(property); + } + /** * @param property * @deprecated Use @@ -139,4 +151,13 @@ public static WebElement getInputPluginPropertyElement(String pluginProperty) { return CdfPluginPropertiesLocators.locatePropertyInput(pluginPropertyDataCyAttribute); } + + public static String getPluginPropertyElementTestId(String pluginProperty) { + String pluginPropertyDataTestIdAttribute = PluginPropertyUtils.getPluginPropertyDataTestIdAttribute(pluginProperty); + if (pluginPropertyDataTestIdAttribute == null) { + pluginPropertyDataTestIdAttribute = pluginProperty; + } + + return pluginPropertyDataTestIdAttribute; + } } diff --git a/src/main/java/stepsdesign/WranglerSteps.java b/src/main/java/stepsdesign/WranglerSteps.java new file mode 100644 index 000000000..3f052a094 --- /dev/null +++ b/src/main/java/stepsdesign/WranglerSteps.java @@ -0,0 +1,86 @@ +/* + * 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.WranglerActions; +import io.cdap.e2e.pages.locators.WranglerLocators; +import io.cdap.e2e.utils.CdfHelper; +import io.cdap.e2e.utils.SeleniumHelper; +import io.cucumber.java.en.Then; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * CDF wrangler related steps. + */ +public class WranglerSteps implements CdfHelper { + private static final Logger logger = LoggerFactory.getLogger(WranglerSteps.class); + + static { + SeleniumHelper.getPropertiesLocators(WranglerLocators.class); + } + + @Then("Expand dropdown column: {string} and apply directive: {string}") + public static void selectDirective(String columnName, String directive) { + WranglerActions.selectDirective(columnName, directive); + } + + @Then("Expand dropdown column: {string} and apply directive: {string} as {string}") + public static void selectDirectiveAndEnterOption(String columnName, String directive, String text) + throws InterruptedException { + WranglerActions.selectDirectiveAndOption(columnName, directive, text); + } + + @Then("Enter directive from CLI {string}") + public static void enterDirectiveFromUserInput(String directive) throws InterruptedException { + WranglerActions.enterDirectiveFromCommandLine(directive); + } + + @Then("Expand dropdown column: {string} and apply directive: {string} as {string} with: {string} option") + public static void selectDirectiveWithThreeOption(String columnName, String directive, String option, + String optionType) + throws InterruptedException { + WranglerActions.selectDirectiveTypeWithThreeOptions(columnName, directive, option, optionType); + } + + @Then("Select checkbox on two columns: {string} and {string}") + public static void selectDirectiveOnTwoColumns(String column1, String column2) + throws InterruptedException { + WranglerActions.selectCheckboxOnTwoColumns(column1, column2); + } + + @Then("Expand dropdown column: {string} and apply directive: {string} and select: {string} and enter: {string}") + public static void selectDirectiveDropdownAndText(String columnName, String directive, String option, + String optionType) throws InterruptedException { + WranglerActions.selectDirectiveTypeWithDropdownAndText(columnName, directive, option, optionType); + } + + @Then("Expand dropdown column: {string} and apply directive: {string} with directive type: {string} and select: " + + "{string} and enter: {string}") + public static void selectFourOptions(String columnName, String directive, String option, String text, + String dropdown) + throws InterruptedException { + WranglerActions.selectDirectiveTypeWithFourOption(columnName, directive, option, text, dropdown); + } + + @Then("Expand dropdown column: {string} and apply directive:{string} and select {string} with condition: {string} " + + "with option: {string} and name: {string}") + public static void selectFiveOptions(String columnName, String directive, String option1, String option2, + String option3, String option4) + throws InterruptedException { + WranglerActions.selectDirectiveTypeWithFiveOption(columnName, directive, option1, option2, option3, option4); + } +}