diff --git a/src/main/java/io/cdap/e2e/pages/actions/CdfConnectionActions.java b/src/main/java/io/cdap/e2e/pages/actions/CdfConnectionActions.java index fbe1fc720..11c3ff42e 100644 --- a/src/main/java/io/cdap/e2e/pages/actions/CdfConnectionActions.java +++ b/src/main/java/io/cdap/e2e/pages/actions/CdfConnectionActions.java @@ -119,14 +119,14 @@ public static void waitTillConnectionDataLoadingCompletes(long timeoutInSeconds) /** * Select data row for connection - * + *

* Based on the connection type - table with rows containing data (i.e.bucket, dataset, table, directory names etc.) * will be displayed. * To select data for the connection use this method with its name as parameter. * Example : For GCS pass actual bucket name as parameter. */ private static void selectConnectionDataRow(String dataRow) { - waitTillConnectionDataLoadingCompletes (ConstantsUtil.DEFAULT_TIMEOUT_SECONDS); + waitTillConnectionDataLoadingCompletes(ConstantsUtil.DEFAULT_TIMEOUT_SECONDS); ElementHelper.sendKeys(CdfConnectionLocators.searchDirectoryInput, dataRow); WaitHelper.waitForTextToBePresentInElementValue(CdfConnectionLocators.searchDirectoryInput, dataRow); int attempts = 0; @@ -146,15 +146,13 @@ private static void selectConnectionDataRow(String dataRow) { /** * Select data for connection using name - * + *

* Example : * For GCS, table with bucket names will be displayed. * To select bucket for the connection use this method with bucket name as parameter. - * * Once bucket name is selected - in next table all directories inside bucket will be displayed. * To select directory use this method with directory name as parameter. * - * * @param dataName If dataName is present in {@link ConstantsUtil#DEFAULT_PLUGIN_PROPERTIES_FILE} as a key * then actual dataName to select is fetched from it * else dataName used as it is. @@ -169,7 +167,7 @@ public static void selectConnectionDataWithName(String dataName) { /** * Select data rows for connection traversing through directories using provided path - * + *

* Example GCS dataPath: "testdata/GCS_CSV_TEST.csv" * First "testdata" directory inside bucket will be selected * and then in next datatable, file "GCS_CSV_TEST.csv" will be selected. @@ -191,11 +189,11 @@ public static void selectConnectionDataWithPath(String dataPath) { /** * Click SELECT button inside connection data row using name - * + *

* Example : * For BQ, table with dataset names will be displayed. * To click on SELECT button of dataset row use this method with dataset name as parameter. - * + *

* Once SELECT button is clicked, steps to select source/target BQ table will be skipped. * * @param dataName If dataName is present in {@link ConstantsUtil#DEFAULT_PLUGIN_PROPERTIES_FILE} as a key @@ -331,7 +329,7 @@ public static void verifyConnectionIsNotPresent(String connectionType, String co ConstantsUtil.DEFAULT_TIMEOUT_SECONDS); Assert.assertTrue("Connection " + connectionName + " should not be present" , !ElementHelper.isElementDisplayed(CdfConnectionLocators.locatorOfConnection(connectionType, - actualConnectionName), 5)); + actualConnectionName), 5)); } /** diff --git a/src/main/java/io/cdap/e2e/pages/actions/CdfStudioActions.java b/src/main/java/io/cdap/e2e/pages/actions/CdfStudioActions.java index 098325e16..d29d0644b 100644 --- a/src/main/java/io/cdap/e2e/pages/actions/CdfStudioActions.java +++ b/src/main/java/io/cdap/e2e/pages/actions/CdfStudioActions.java @@ -21,6 +21,7 @@ import io.cdap.e2e.utils.AssertionHelper; import io.cdap.e2e.utils.ConstantsUtil; import io.cdap.e2e.utils.ElementHelper; +import io.cdap.e2e.utils.FileImportUtil; import io.cdap.e2e.utils.SeleniumDriver; import io.cdap.e2e.utils.SeleniumHelper; import io.cdap.e2e.utils.WaitHelper; @@ -31,6 +32,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.net.URISyntaxException; + /** * Represents Cdf Studio Page Actions */ @@ -280,6 +283,7 @@ public static void clickPreviewLogsButton() { /** * Verify the Pipeline Preview Run's status in logs + * * @param status */ public static void verifyPipelinePreviewStatusInLogs(String status) { @@ -498,11 +502,36 @@ public static void closeStatusBanner() { /** * Click on the element and move. + * * @param pluginName plugin title. - * @param xOffset horizontal move offset. - * @param yOffset vertical move offset. + * @param xOffset horizontal move offset. + * @param yOffset vertical move offset. */ public static void movePlugin(String pluginName, int xOffset, int yOffset) { ElementHelper.dragAndDropByOffset(CdfStudioLocators.locatePluginNodeInCanvas(pluginName), xOffset, yOffset); } + + /** + * Click on the Upload Button + */ + public static void clickOnAddEntityButton() { + ElementHelper.clickOnElement(CdfStudioLocators.addEntityButton); + } + + /** + * Clicks on the "Fix All" button if displayed. + */ + public static void clickOnFixAllButtonIfDisplayed() { + ElementHelper.clickIfDisplayed(CdfStudioLocators.fixAllButton()); + } + + /** + * Imports a pipeline from the specified file path. + * @param filePath The path to the file containing the pipeline to be imported. + **/ + public static void importPipeline(String filePath) throws URISyntaxException { + WaitHelper.waitForElementToBeDisplayed(CdfStudioLocators.importPipelineButton); + FileImportUtil.uploadFile(CdfStudioLocators.importPipelineInputTag(), filePath); + clickOnFixAllButtonIfDisplayed(); + } } diff --git a/src/main/java/io/cdap/e2e/pages/locators/CdfStudioLocators.java b/src/main/java/io/cdap/e2e/pages/locators/CdfStudioLocators.java index 0a6795c7a..eff785632 100644 --- a/src/main/java/io/cdap/e2e/pages/locators/CdfStudioLocators.java +++ b/src/main/java/io/cdap/e2e/pages/locators/CdfStudioLocators.java @@ -265,4 +265,19 @@ public static By locatorOfLoadingSpinnerOnValidateButton() { @Deprecated @FindBy(how = How.XPATH, using = "//*[@data-cy='plugin-validation-error-msg']") public static WebElement pluginValidationErrorMsg; + + @FindBy(how = How.XPATH, using = "//img[@id='resource-center-btn']") + public static WebElement addEntityButton; + + @FindBy(how = How.XPATH, using = "//*[@id='import-pipeline']") + public static WebElement importPipelineButton; + + public static By fixAllButton() { + return By.xpath("//button[@data-cy='fix-all-btn']"); + } + + public static WebElement importPipelineInputTag() { + return SeleniumDriver.getDriver().findElement(By.xpath + ("//input[@id='resource-center-import-pipeline']")); + } } diff --git a/src/main/java/io/cdap/e2e/utils/FileImportUtil.java b/src/main/java/io/cdap/e2e/utils/FileImportUtil.java new file mode 100644 index 000000000..c1c2b82d2 --- /dev/null +++ b/src/main/java/io/cdap/e2e/utils/FileImportUtil.java @@ -0,0 +1,37 @@ +/* + * Copyright © 2022 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.utils; + +import io.cdap.e2e.pages.locators.CdfStudioLocators; +import org.openqa.selenium.WebElement; + +import java.net.URISyntaxException; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Objects; + +/** + * File Import Util + */ +public class FileImportUtil { + + public static void uploadFile(WebElement uploadButtonLocator, String filePath) throws URISyntaxException { + Path resourcePath = Paths.get(Objects.requireNonNull + (CdfStudioLocators.class.getResource("/" + filePath)).toURI()); + uploadButtonLocator.sendKeys(resourcePath.toString()); + } +} diff --git a/src/main/java/stepsdesign/PipelineSteps.java b/src/main/java/stepsdesign/PipelineSteps.java index 4a35ee8a3..c916fc143 100644 --- a/src/main/java/stepsdesign/PipelineSteps.java +++ b/src/main/java/stepsdesign/PipelineSteps.java @@ -35,6 +35,7 @@ import org.slf4j.LoggerFactory; import java.io.IOException; +import java.net.URISyntaxException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -715,4 +716,20 @@ public void waitTillTheReviewAssessmentPageIsLoadedInReplication() { public void waitTillTheConfigureAdvancedPropertiesPageIsLoadedInReplication() { CdfPluginPropertiesActions.waitTillTheConfigureAdvancedPropertiesPageLoaded(); } + + @Then("Click on the Plus Green Button to import the pipelines") + public void clickOnPlusGreenButton () { + CdfStudioActions.clickOnAddEntityButton(); + } + + @Then("Select the file for importing the pipeline for the plugin {string}") + public void selectFileForImport(String path) throws URISyntaxException { + CdfStudioActions.importPipeline(PluginPropertyUtils.pluginProp(path)); + } + + @Then("Rename the pipeline") + public void renameThePipeline() { + pipelineName = "TestPipeline-" + RandomStringUtils.randomAlphanumeric(10); + CdfStudioActions.fillPipelineNameAndSave(pipelineName); + } }