falcon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rag...@apache.org
Subject falcon git commit: FALCON-1201: Feed Setup tests for testing header and default scenario contributed by Namit Maheshwari
Date Tue, 12 May 2015 21:45:58 GMT
Repository: falcon
Updated Branches:
  refs/heads/master d9233f741 -> 7edb89d86


FALCON-1201: Feed Setup tests for testing header and default scenario contributed by Namit
Maheshwari


Project: http://git-wip-us.apache.org/repos/asf/falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/falcon/commit/7edb89d8
Tree: http://git-wip-us.apache.org/repos/asf/falcon/tree/7edb89d8
Diff: http://git-wip-us.apache.org/repos/asf/falcon/diff/7edb89d8

Branch: refs/heads/master
Commit: 7edb89d863631e81adefba2ab87650ee148b42b5
Parents: d9233f7
Author: Raghav Kumar Gautam <raghav@apache.org>
Authored: Tue May 12 14:45:50 2015 -0700
Committer: Raghav Kumar Gautam <raghav@apache.org>
Committed: Tue May 12 14:45:50 2015 -0700

----------------------------------------------------------------------
 falcon-regression/CHANGES.txt                   |   2 +
 .../ui/search/AbstractSearchPage.java           |   8 +
 .../regression/ui/search/FeedWizardPage.java    | 363 +++++++++++++++++++
 .../regression/ui/search/NewFeedPage.java       |  44 ---
 .../falcon/regression/ui/search/PageHeader.java |   4 +-
 .../regression/searchUI/FeedSetupTest.java      | 123 +++++++
 6 files changed, 498 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/falcon/blob/7edb89d8/falcon-regression/CHANGES.txt
----------------------------------------------------------------------
diff --git a/falcon-regression/CHANGES.txt b/falcon-regression/CHANGES.txt
index 56827be..2e9297a 100644
--- a/falcon-regression/CHANGES.txt
+++ b/falcon-regression/CHANGES.txt
@@ -5,6 +5,8 @@ Trunk (Unreleased)
   INCOMPATIBLE CHANGES
 
   NEW FEATURES
+   FALCON-1201 Feed Setup tests for testing header and default scenario (Namit Maheshwari)
+
    FALCON-1198 Test buttons available on search results page (Ruslan Ostafiychuk)
 
    FALCON-1187 Test that changes made via API are reflected on UI (Ruslan Ostafiychuk

http://git-wip-us.apache.org/repos/asf/falcon/blob/7edb89d8/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/AbstractSearchPage.java
----------------------------------------------------------------------
diff --git a/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/AbstractSearchPage.java
b/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/AbstractSearchPage.java
index eaaeba2..161d545 100644
--- a/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/AbstractSearchPage.java
+++ b/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/AbstractSearchPage.java
@@ -53,4 +53,12 @@ public abstract class AbstractSearchPage extends Page {
      * A rough check to make sure that we are indeed on the correct page.
      */
     public abstract void checkPage();
+
+    // Utility method to enter the data slowly on an element
+    public void sendKeysSlowly(WebElement webElement, String data){
+        for (String str : data.split("")) {
+            webElement.sendKeys(str);
+        }
+
+    }
 }

http://git-wip-us.apache.org/repos/asf/falcon/blob/7edb89d8/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/FeedWizardPage.java
----------------------------------------------------------------------
diff --git a/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/FeedWizardPage.java
b/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/FeedWizardPage.java
new file mode 100644
index 0000000..6eed4ce
--- /dev/null
+++ b/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/FeedWizardPage.java
@@ -0,0 +1,363 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.falcon.regression.ui.search;
+
+import org.apache.falcon.regression.Entities.FeedMerlin;
+import org.apache.falcon.regression.core.util.UIAssert;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.FindBy;
+import org.openqa.selenium.support.FindBys;
+import org.openqa.selenium.support.ui.Select;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/** Page object of the Feed creation page. */
+public class FeedWizardPage extends AbstractSearchPage {
+
+    @FindBys({
+        @FindBy(className = "mainUIView"),
+        @FindBy(className = "feedForm")
+    })
+    private WebElement feedBox;
+
+    @FindBys({
+            @FindBy(className = "mainUIView"),
+            @FindBy(className = "feedForm"),
+            @FindBy(className = "nextBtn")
+    })
+    private WebElement nextButton;
+
+    @FindBys({
+            @FindBy(xpath = "//button[contains(.,'add tag')]")
+    })
+    private WebElement addTagButton;
+
+    @FindBys({
+            @FindBy(xpath = "//button[contains(.,'add property')]")
+    })
+    private WebElement addPropertyButton;
+
+    @FindBys({
+            @FindBy(id = "feed.step5")
+    })
+    private WebElement saveFeedButton;
+
+    public FeedWizardPage(WebDriver driver) {
+        super(driver);
+    }
+
+    @Override
+    public void checkPage() {
+        UIAssert.assertDisplayed(feedBox, "Feed box");
+    }
+
+    private WebElement getFeedName() {
+        return feedBox.findElement(By.xpath("//input[@ng-model='feed.name']"));
+    }
+    private WebElement getFeedDescription() {
+        return feedBox.findElement(By.xpath("//input[@ng-model='feed.description']"));
+    }
+    private WebElement getFeedTagKey(int index) {
+        return feedBox.findElements(By.xpath("//input[@ng-model='tag.key']")).get(index);
+    }
+    private WebElement getFeedTagValue(int index) {
+        return feedBox.findElements(By.xpath("//input[@ng-model='tag.value']")).get(index);
+    }
+    private WebElement getFeedGroups() {
+        return feedBox.findElement(By.xpath("//input[@ng-model='feed.groups']"));
+    }
+    private WebElement getFeedACLOwner() {
+        return feedBox.findElement(By.xpath("//input[@ng-model='feed.ACL.owner']"));
+    }
+    private WebElement getFeedACLGroup() {
+        return feedBox.findElement(By.xpath("//input[@ng-model='feed.ACL.group']"));
+    }
+    private WebElement getFeedACLPermissions() {
+        return feedBox.findElement(By.xpath("//input[@ng-model='feed.ACL.permission']"));
+    }
+    private WebElement getFeedSchemaLocation() {
+        return feedBox.findElement(By.xpath("//input[@ng-model='feed.schema.location']"));
+    }
+    private WebElement getFeedSchemaProvider() {
+        return feedBox.findElement(By.xpath("//input[@ng-model='feed.schema.provider']"));
+    }
+
+    private WebElement getFeedFrequencyQuantity() {
+        return feedBox.findElement(By.xpath("//input[@ng-model='feed.frequency.quantity']"));
+    }
+    private WebElement getFeedFrequencyUnit() {
+        return feedBox.findElement(By.xpath("//select[@ng-model='feed.frequency.unit']"));
+    }
+    private WebElement getFeedLateArrivalCheckBox() {
+        return feedBox.findElement(By.xpath("//input[@ng-model='feed.lateArrival.active']"));
+    }
+    private WebElement getFeedLateArrivalCutOffQuantity() {
+        return feedBox.findElement(By.xpath("//input[@ng-model='feed.lateArrival.cutOff.quantity']"));
+    }
+    private WebElement getFeedLateArrivalCutOffUnit() {
+        return feedBox.findElement(By.xpath("//select[@ng-model='feed.lateArrival.cutOff.unit']"));
+    }
+    private WebElement getFeedAvailabilityFlag() {
+        return feedBox.findElement(By.xpath("//input[@ng-model='feed.availabilityFlag']"));
+    }
+    private Select getFeedTimeZone() {
+        return new Select(feedBox.findElement(By.xpath("//time-zone-select[@ng-model='feed.timezone']/select")));
+    }
+    private WebElement getFeedPropertyKey(int index) {
+        return feedBox.findElements(By.xpath("//input[@ng-model='property.key']")).get(index);
+    }
+    private WebElement getFeedPropertyValue(int index) {
+        return feedBox.findElements(By.xpath(
+            "//div[@ng-repeat='property in feed.customProperties']/*/input[@ng-model='property.value']")).get(index);
+    }
+
+    private WebElement getFeedPath(int index) {
+        return feedBox.findElements(By.xpath("//input[@ng-model='location.path']")).get(index);
+    }
+
+    private Select getFeedClusterSource() {
+        return new Select(feedBox.findElement(By.id("clusterNameSelect")));
+    }
+
+    private WebElement getFeedClusterRetentionLimit() {
+        return feedBox.findElement(By.xpath("//input[@ng-model='cluster.retention.quantity']"));
+    }
+
+    private WebElement getFeedClusterRetentionUnit() {
+        return feedBox.findElement(By.xpath("//select[@ng-model='cluster.retention.unit']"));
+    }
+
+    private WebElement getFeedClusterValidityStartDate() {
+        return feedBox.findElement(By.xpath("//input[@ng-model='cluster.validity.start.date']"));
+    }
+
+    private WebElement getFeedClusterValidityHour(int index) {
+        return feedBox.findElements(By.xpath("//input[@ng-model='hours']")).get(index);
+    }
+
+    private WebElement getFeedClusterValidityMinutes(int index) {
+        return feedBox.findElements(By.xpath("//input[@ng-model='minutes']")).get(index);
+    }
+
+    private WebElement getFeedClusterValidityMeridian(int index) {
+        return feedBox.findElements(By.xpath("//td[@ng-show='showMeridian']/button")).get(index);
+    }
+
+    private WebElement getFeedClusterValidityEndDate() {
+        return feedBox.findElement(By.xpath("//input[@ng-model='cluster.validity.end.date']"));
+    }
+
+    public void setFeedName(String name){
+        sendKeysSlowly(getFeedName(), name);
+    }
+    public void setFeedDescription(String description){
+        getFeedDescription().sendKeys(description);
+    }
+    public void setFeedTagKey(int index, String tagKey){
+        getFeedTagKey(index).sendKeys(tagKey);
+    }
+    public void setFeedTagValue(int index, String tagValue){
+        getFeedTagValue(index).sendKeys(tagValue);
+    }
+    // Tags are in the format, "first=yes","second=yes","third=yes". Need a separate method
to handle this
+    public void setFeedTags(String tagsStr){
+        if (tagsStr == null){
+            return;
+        }
+        String[] tags = tagsStr.split(",");
+        for (int i=0; i < tags.length; i++){
+            String[] keyValue = tags[i].split("=");
+            setFeedTagKey(i, keyValue[0]);
+            setFeedTagValue(i, keyValue[1]);
+            if (tags.length > i+1){
+                addTagButton.click();
+            }
+        }
+    }
+
+    public void setFeedGroups(String feedGroups){
+        getFeedGroups().sendKeys(feedGroups);
+    }
+    public void setFeedACLOwner(String feedACLOwner){
+        getFeedACLOwner().clear();
+        getFeedACLOwner().sendKeys(feedACLOwner);
+    }
+    public void setFeedACLGroup(String feedACLGroup){
+        getFeedACLGroup().clear();
+        getFeedACLGroup().sendKeys(feedACLGroup);
+    }
+    public void setFeedACLPermissions(String feedACLPermissions){
+        getFeedACLPermissions().clear();
+        getFeedACLPermissions().sendKeys(feedACLPermissions);
+    }
+    public void setFeedSchemaLocation(String feedSchemaLocation){
+        sendKeysSlowly(getFeedSchemaLocation(), feedSchemaLocation);
+    }
+    public void setFeedSchemaProvider(String feedSchemaProvider){
+        sendKeysSlowly(getFeedSchemaProvider(), feedSchemaProvider);
+    }
+
+    public void setFeedFrequencyQuantity(String frequencyQuantity){
+        getFeedFrequencyQuantity().sendKeys(frequencyQuantity);
+    }
+    public void setFeedFrequencyUnit(String frequencyUnit){
+        getFeedFrequencyUnit().sendKeys(frequencyUnit);
+    }
+    public void setFeedLateArrivalCheckBox(){
+        getFeedLateArrivalCheckBox().click();
+    }
+    public void setFeedLateArrivalCutOffQuantity(int lateArrivalCutOffQuantity){
+        getFeedLateArrivalCutOffQuantity().sendKeys(Integer.toString(lateArrivalCutOffQuantity));
+    }
+    public void setFeedLateArrivalCutOffUnit(String lateArrivalCutOffUnit){
+        getFeedLateArrivalCutOffUnit().sendKeys(lateArrivalCutOffUnit);
+    }
+    public void setFeedAvailabilityFlag(String availabilityFlag){
+        getFeedAvailabilityFlag().sendKeys(availabilityFlag);
+    }
+    public void setFeedTimeZone(){
+        String timeZone = "GMT+00:00";
+        getFeedTimeZone().selectByValue(timeZone);
+    }
+    public void setFeedPropertyKey(int index, String propertyKey){
+        getFeedPropertyKey(index).sendKeys(propertyKey);
+    }
+    public void setFeedPropertyValue(int index, String propertyValue){
+        getFeedPropertyValue(index).sendKeys(propertyValue);
+    }
+
+    public void setFeedPath(int index, String path){
+        getFeedPath(index).sendKeys(path);
+    }
+
+    public void setFeedClusterSource(String clusterSource){
+        getFeedClusterSource().selectByVisibleText(clusterSource);
+    }
+
+    public void setFeedClusterRetentionLimit(String clusterRetentionLimit){
+        getFeedClusterRetentionLimit().clear();
+        sendKeysSlowly(getFeedClusterRetentionLimit(), clusterRetentionLimit);
+    }
+
+    public void setFeedClusterRetentionUnit(String clusterRetentionUnit){
+        getFeedClusterRetentionUnit().sendKeys(clusterRetentionUnit);
+    }
+
+    public void setFeedClusterValidityStartDate(String clusterValidityStartDate){
+        getFeedClusterValidityStartDate().clear();
+        sendKeysSlowly(getFeedClusterValidityStartDate(), clusterValidityStartDate);
+    }
+    public void setFeedClusterValidityHour(int index, String clusterValidityHour){
+        getFeedClusterValidityHour(index).clear();
+        getFeedClusterValidityHour(index).sendKeys(clusterValidityHour);
+    }
+    public void setFeedClusterValidityMinutes(int index, String clusterValidityMinutes){
+        getFeedClusterValidityMinutes(index).clear();
+        getFeedClusterValidityMinutes(index).sendKeys(clusterValidityMinutes);
+    }
+    public void setFeedClusterValidityMeridian(int index, String clusterValidityMeridian){
+        // Toggle AM PM, if clusterValidityMeridian value is not equal to AM PM Button text
+        if (!clusterValidityMeridian.equalsIgnoreCase(getFeedClusterValidityMeridian(index).getText())){
+            getFeedClusterValidityMeridian(index).click();
+        }
+    }
+    public void setFeedClusterValidityEndDate(String clusterValidityEndDate){
+        getFeedClusterValidityEndDate().clear();
+        sendKeysSlowly(getFeedClusterValidityEndDate(), clusterValidityEndDate);
+    }
+
+    // Enter feed info on Page 1 of FeedSetup Wizard
+    public void setFeedGeneralInfo(FeedMerlin feed) {
+        setFeedName(feed.getName());
+        setFeedDescription(feed.getDescription());
+        setFeedTags(feed.getTags());
+        setFeedGroups(feed.getGroups());
+        setFeedACLOwner(feed.getACL().getOwner());
+        setFeedACLGroup(feed.getACL().getGroup());
+        setFeedACLPermissions(feed.getACL().getPermission());
+        setFeedSchemaLocation(feed.getSchema().getLocation());
+        setFeedSchemaProvider(feed.getSchema().getProvider());
+    }
+
+    // Enter feed info on Page 2 of FeedSetup Wizard
+    public void setFeedPropertiesInfo(FeedMerlin feed){
+        setFeedFrequencyQuantity(feed.getFrequency().getFrequency());
+        setFeedFrequencyUnit(feed.getFrequency().getTimeUnit().toString());
+        setFeedLateArrivalCheckBox();
+        setFeedLateArrivalCutOffQuantity(feed.getLateArrival().getCutOff().getFrequencyAsInt());
+        setFeedLateArrivalCutOffUnit(feed.getLateArrival().getCutOff().getTimeUnit().toString());
+        setFeedAvailabilityFlag(feed.getAvailabilityFlag());
+        setFeedTimeZone();
+        setFeedPropertyKey(0, feed.getProperties().getProperties().get(0).getName());
+        setFeedPropertyValue(0, feed.getProperties().getProperties().get(0).getValue());
+        addPropertyButton.click();
+        setFeedPropertyKey(1, feed.getProperties().getProperties().get(1).getName());
+        setFeedPropertyValue(1, feed.getProperties().getProperties().get(1).getValue());
+    }
+
+    // Enter feed info on Page 3 of FeedSetup Wizard
+    public void setFeedLocationInfo(FeedMerlin feed){
+        setFeedPath(0, feed.getLocations().getLocations().get(0).getPath());
+        setFeedPath(1, feed.getLocations().getLocations().get(1).getPath());
+        setFeedPath(2, feed.getLocations().getLocations().get(2).getPath());
+
+    }
+
+    // Enter feed info on Page 4 of FeedSetup Wizard
+    public void setFeedClustersInfo(FeedMerlin feed){
+        setFeedClusterSource(feed.getClusters().getClusters().get(0).getName());
+        setFeedLocationInfo(feed);
+        Date startDate = feed.getClusters().getClusters().get(0).getValidity().getStart();
+        Date endDate = feed.getClusters().getClusters().get(0).getValidity().getEnd();
+        setFeedClusterValidityStartDate(new SimpleDateFormat("MM/dd/yyyy").format(startDate));
+        setFeedClusterValidityHour(0, new SimpleDateFormat("h").format(startDate));
+        setFeedClusterValidityMinutes(0, new SimpleDateFormat("m").format(startDate));
+        setFeedClusterValidityMeridian(0, new SimpleDateFormat("a").format(startDate));
+        setFeedClusterValidityEndDate(new SimpleDateFormat("MM/dd/yyyy").format(endDate));
+        setFeedClusterValidityHour(1, new SimpleDateFormat("h").format(endDate));
+        setFeedClusterValidityMinutes(1, new SimpleDateFormat("m").format(endDate));
+        setFeedClusterValidityMeridian(1, new SimpleDateFormat("a").format(endDate));
+        /*
+        The merlin feed has 9000 months.
+        The UI only support till two digits.
+        Need to send hardcoded value of 99,
+        instead of feed.getClusters().getClusters().get(0).getRetention().getLimit().getFrequency()
+        */
+        setFeedClusterRetentionLimit("99");
+        setFeedClusterRetentionUnit(feed.getClusters().getClusters().get(0)
+            .getRetention().getLimit().getTimeUnit().name());
+    }
+
+    // setFeed method runs the default feed setup wizard, entering data on each page
+    public void setFeed(FeedMerlin feed){
+        setFeedGeneralInfo(feed);
+        nextButton.click();
+        setFeedPropertiesInfo(feed);
+        nextButton.click();
+        setFeedLocationInfo(feed);
+        nextButton.click();
+        setFeedClustersInfo(feed);
+        nextButton.click();
+        saveFeedButton.click();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/falcon/blob/7edb89d8/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/NewFeedPage.java
----------------------------------------------------------------------
diff --git a/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/NewFeedPage.java
b/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/NewFeedPage.java
deleted file mode 100644
index 4863da3..0000000
--- a/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/NewFeedPage.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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 org.apache.falcon.regression.ui.search;
-
-import org.apache.falcon.regression.core.util.UIAssert;
-import org.openqa.selenium.WebDriver;
-import org.openqa.selenium.WebElement;
-import org.openqa.selenium.support.FindBy;
-import org.openqa.selenium.support.FindBys;
-
-/** Page object of the Feed creation page. */
-public class NewFeedPage extends AbstractSearchPage {
-
-    @FindBys({
-        @FindBy(className = "mainUIView"),
-        @FindBy(className = "feedForm")
-    })
-    private WebElement feedBox;
-
-    public NewFeedPage(WebDriver driver) {
-        super(driver);
-    }
-
-    @Override
-    public void checkPage() {
-        UIAssert.assertDisplayed(feedBox, "Feed box");
-    }
-}

http://git-wip-us.apache.org/repos/asf/falcon/blob/7edb89d8/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/PageHeader.java
----------------------------------------------------------------------
diff --git a/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/PageHeader.java
b/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/PageHeader.java
index b9d766f..0a41a5e 100644
--- a/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/PageHeader.java
+++ b/falcon-regression/merlin/src/main/java/org/apache/falcon/regression/ui/search/PageHeader.java
@@ -174,12 +174,12 @@ public class PageHeader {
         return clusterPage;
     }
 
-    public NewFeedPage doCreateFeed() {
+    public FeedWizardPage doCreateFeed() {
         UIAssert.assertDisplayed(feedCreateButton, "Feed create button");
         Assert.assertEquals(feedCreateButton.getText(), "Feed",
             "Unexpected text on create feed button");
         feedCreateButton.click();
-        final NewFeedPage feedPage = PageFactory.initElements(driver, NewFeedPage.class);
+        final FeedWizardPage feedPage = PageFactory.initElements(driver, FeedWizardPage.class);
         feedPage.checkPage();
         return feedPage;
     }

http://git-wip-us.apache.org/repos/asf/falcon/blob/7edb89d8/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/searchUI/FeedSetupTest.java
----------------------------------------------------------------------
diff --git a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/searchUI/FeedSetupTest.java
b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/searchUI/FeedSetupTest.java
new file mode 100644
index 0000000..8920f41
--- /dev/null
+++ b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/searchUI/FeedSetupTest.java
@@ -0,0 +1,123 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.falcon.regression.searchUI;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.falcon.regression.Entities.FeedMerlin;
+import org.apache.falcon.regression.core.bundle.Bundle;
+import org.apache.falcon.regression.core.helpers.ColoHelper;
+import org.apache.falcon.regression.core.response.ServiceResponse;
+import org.apache.falcon.regression.core.util.AssertUtil;
+import org.apache.falcon.regression.core.util.BundleUtil;
+import org.apache.falcon.regression.testHelper.BaseUITestClass;
+import org.apache.falcon.regression.ui.search.FeedWizardPage;
+import org.apache.falcon.regression.ui.search.LoginPage;
+import org.apache.falcon.regression.ui.search.SearchPage;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.log4j.Logger;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+
+/** UI tests for Feed Setup Wizard. */
+@Test(groups = "search-ui")
+public class FeedSetupTest extends BaseUITestClass{
+    private static final Logger LOGGER = Logger.getLogger(FeedSetupTest.class);
+    private FeedWizardPage feedWizardPage = null;
+    private SearchPage searchPage = null;
+
+    private ColoHelper cluster = servers.get(0);
+    private FileSystem clusterFS = serverFS.get(0);
+    private String baseTestHDFSDir = cleanAndGetTestDir();
+    private String aggregateWorkflowDir = baseTestHDFSDir + "/aggregator";
+    private String feedInputPath = baseTestHDFSDir + "/input" + MINUTE_DATE_PATTERN;
+    private FeedMerlin feed;
+    private String[] tags = {"first=yes", "second=yes", "third=yes", "wrong=no"};
+
+    private String getRandomTags() {
+        List<String> tagsList = new ArrayList<>();
+        Random r = new Random();
+        if (r.nextInt(4) == 0) {
+            tagsList.add(tags[0]);
+        }
+        if (r.nextInt(3) == 0) {
+            tagsList.add(tags[1]);
+        }
+        if (r.nextInt(2) == 0) {
+            tagsList.add(tags[2]);
+        }
+        return StringUtils.join(tagsList, ',');
+    }
+
+    @BeforeMethod(alwaysRun = true)
+    public void setup() throws Exception{
+        openBrowser();
+        searchPage = LoginPage.open(getDriver()).doDefaultLogin();
+        feedWizardPage = searchPage.getPageHeader().doCreateFeed();
+        Bundle bundle = BundleUtil.readELBundle();
+        bundle.generateUniqueBundle(this);
+        bundle = new Bundle(bundle, cluster);
+        bundle.setInputFeedDataPath(feedInputPath);
+        bundle.submitClusters(prism);
+        feed = FeedMerlin.fromString(bundle.getInputFeedFromBundle());
+    }
+
+    @AfterMethod(alwaysRun = true)
+    public void tearDown() throws IOException {
+        removeTestClassEntities();
+        closeBrowser();
+    }
+
+    /*
+    Check that buttons (logout, entities, uploadXml, help, Falcon) are present, and
+    names are correct. Check the user name on header. "Create an entity"/
+    "upload an entity" headers. Check that each button navigates user to correct page
+     */
+    @Test
+    public void testHeader() throws Exception {
+        feedWizardPage.getPageHeader().checkHeader();
+    }
+
+    /*
+    Run full feed creation scenario.
+     */
+    @Test
+    public void testWizardDefaultScenario() throws Exception {
+        // Set few values in feed, if they are null (Currently null in the FeedMerlin)
+        if (feed.getTags() == null){
+            feed.setTags(getRandomTags());
+        }
+        if (feed.getGroups() == null){
+            feed.setGroups("groups");
+        }
+        if (feed.getAvailabilityFlag() == null){
+            feed.setAvailabilityFlag("_SUCCESS");
+        }
+        feedWizardPage.setFeed(feed);
+        //Check the response to validate if the feed creation went successfully
+        ServiceResponse response = prism.getFeedHelper().getEntityDefinition(feed.toString());
+        AssertUtil.assertSucceeded(response);
+    }
+
+}


Mime
View raw message