http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-integration/src/test/java/org/apache/zeppelin/integration/ParagraphActionsIT.java ---------------------------------------------------------------------- diff --git a/zeppelin-integration/src/test/java/org/apache/zeppelin/integration/ParagraphActionsIT.java b/zeppelin-integration/src/test/java/org/apache/zeppelin/integration/ParagraphActionsIT.java index 416d44e..5615812 100644 --- a/zeppelin-integration/src/test/java/org/apache/zeppelin/integration/ParagraphActionsIT.java +++ b/zeppelin-integration/src/test/java/org/apache/zeppelin/integration/ParagraphActionsIT.java @@ -17,7 +17,6 @@ package org.apache.zeppelin.integration; - import org.apache.commons.lang.StringUtils; import org.apache.zeppelin.AbstractZeppelinIT; import org.apache.zeppelin.WebDriverManager; @@ -39,9 +38,7 @@ import org.slf4j.LoggerFactory; public class ParagraphActionsIT extends AbstractZeppelinIT { private static final Logger LOG = LoggerFactory.getLogger(ParagraphActionsIT.class); - - @Rule - public ErrorCollector collector = new ErrorCollector(); + @Rule public ErrorCollector collector = new ErrorCollector(); @Before public void startUp() { @@ -59,57 +56,89 @@ public class ParagraphActionsIT extends AbstractZeppelinIT { createNewNote(); Actions action = new Actions(driver); waitForParagraph(1, "READY"); - Integer oldNosOfParas = driver.findElements(By.xpath("//div[@ng-controller=\"ParagraphCtrl\"]")).size(); - collector.checkThat("Before Insert New : the number of paragraph ", - oldNosOfParas, - CoreMatchers.equalTo(1)); + Integer oldNosOfParas = + driver.findElements(By.xpath("//div[@ng-controller=\"ParagraphCtrl\"]")).size(); + collector.checkThat( + "Before Insert New : the number of paragraph ", oldNosOfParas, CoreMatchers.equalTo(1)); driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click(); - driver.findElement(By.xpath(getParagraphXPath(1) + "//ul/li/a[@ng-click=\"insertNew('below')\"]")).click(); + driver + .findElement( + By.xpath(getParagraphXPath(1) + "//ul/li/a[@ng-click=\"insertNew('below')\"]")) + .click(); waitForParagraph(2, "READY"); - Integer newNosOfParas = driver.findElements(By.xpath("//div[@ng-controller=\"ParagraphCtrl\"]")).size(); - collector.checkThat("After Insert New (using Insert New button) : number of paragraph", + Integer newNosOfParas = + driver.findElements(By.xpath("//div[@ng-controller=\"ParagraphCtrl\"]")).size(); + collector.checkThat( + "After Insert New (using Insert New button) : number of paragraph", oldNosOfParas + 1, CoreMatchers.equalTo(newNosOfParas)); driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click(); - driver.findElement(By.xpath(getParagraphXPath(1) + "//ul/li/a[@ng-click='removeParagraph(paragraph)']")).click(); + driver + .findElement( + By.xpath(getParagraphXPath(1) + "//ul/li/a[@ng-click='removeParagraph(paragraph)']")) + .click(); ZeppelinITUtils.sleep(1000, false); - driver.findElement(By.xpath("//div[@class='modal-dialog'][contains(.,'delete this paragraph')]" + - "//div[@class='modal-footer']//button[contains(.,'OK')]")).click(); + driver + .findElement( + By.xpath( + "//div[@class='modal-dialog'][contains(.,'delete this paragraph')]" + + "//div[@class='modal-footer']//button[contains(.,'OK')]")) + .click(); ZeppelinITUtils.sleep(1000, false); setTextOfParagraph(1, " original paragraph "); - WebElement newPara = driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class,'new-paragraph')][1]")); + WebElement newPara = + driver.findElement( + By.xpath(getParagraphXPath(1) + "//div[contains(@class,'new-paragraph')][1]")); action.moveToElement(newPara).click().build().perform(); ZeppelinITUtils.sleep(1000, false); waitForParagraph(1, "READY"); - collector.checkThat("Paragraph is created above", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'editor')]")).getText(), + collector.checkThat( + "Paragraph is created above", + driver + .findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'editor')]")) + .getText(), CoreMatchers.equalTo(StringUtils.EMPTY)); setTextOfParagraph(1, " this is above "); - newPara = driver.findElement(By.xpath(getParagraphXPath(2) + "//div[contains(@class,'new-paragraph')][2]")); + newPara = + driver.findElement( + By.xpath(getParagraphXPath(2) + "//div[contains(@class,'new-paragraph')][2]")); action.moveToElement(newPara).click().build().perform(); waitForParagraph(3, "READY"); - collector.checkThat("Paragraph is created below", - driver.findElement(By.xpath(getParagraphXPath(3) + "//div[contains(@class, 'editor')]")).getText(), + collector.checkThat( + "Paragraph is created below", + driver + .findElement(By.xpath(getParagraphXPath(3) + "//div[contains(@class, 'editor')]")) + .getText(), CoreMatchers.equalTo(StringUtils.EMPTY)); setTextOfParagraph(3, " this is below "); - collector.checkThat("The output field of paragraph1 contains", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'editor')]")).getText(), + collector.checkThat( + "The output field of paragraph1 contains", + driver + .findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'editor')]")) + .getText(), CoreMatchers.equalTo(" this is above ")); - collector.checkThat("The output field paragraph2 contains", - driver.findElement(By.xpath(getParagraphXPath(2) + "//div[contains(@class, 'editor')]")).getText(), + collector.checkThat( + "The output field paragraph2 contains", + driver + .findElement(By.xpath(getParagraphXPath(2) + "//div[contains(@class, 'editor')]")) + .getText(), CoreMatchers.equalTo(" original paragraph ")); - collector.checkThat("The output field paragraph3 contains", - driver.findElement(By.xpath(getParagraphXPath(3) + "//div[contains(@class, 'editor')]")).getText(), + collector.checkThat( + "The output field paragraph3 contains", + driver + .findElement(By.xpath(getParagraphXPath(3) + "//div[contains(@class, 'editor')]")) + .getText(), CoreMatchers.equalTo(" this is below ")); - collector.checkThat("The current number of paragraphs after creating paragraph above and below", + collector.checkThat( + "The current number of paragraphs after creating paragraph above and below", driver.findElements(By.xpath("//div[@ng-controller=\"ParagraphCtrl\"]")).size(), CoreMatchers.equalTo(3)); @@ -118,7 +147,6 @@ public class ParagraphActionsIT extends AbstractZeppelinIT { } catch (Exception e) { handleException("Exception in ParagraphActionsIT while testCreateNewButton ", e); } - } @Test @@ -128,24 +156,29 @@ public class ParagraphActionsIT extends AbstractZeppelinIT { waitForParagraph(1, "READY"); driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click(); - driver.findElement(By.xpath(getParagraphXPath(1) + "//ul/li/a[@ng-click=\"insertNew('below')\"]")) + driver + .findElement( + By.xpath(getParagraphXPath(1) + "//ul/li/a[@ng-click=\"insertNew('below')\"]")) .click(); waitForParagraph(2, "READY"); - Integer oldNosOfParas = driver.findElements(By.xpath - ("//div[@ng-controller=\"ParagraphCtrl\"]")).size(); - collector.checkThat("Before Remove : Number of paragraphs are ", - oldNosOfParas, - CoreMatchers.equalTo(2)); + Integer oldNosOfParas = + driver.findElements(By.xpath("//div[@ng-controller=\"ParagraphCtrl\"]")).size(); + collector.checkThat( + "Before Remove : Number of paragraphs are ", oldNosOfParas, CoreMatchers.equalTo(2)); driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click(); - clickAndWait(By.xpath(getParagraphXPath(1) + "//ul/li/a[@ng-click='removeParagraph(paragraph)']")); + clickAndWait( + By.xpath(getParagraphXPath(1) + "//ul/li/a[@ng-click='removeParagraph(paragraph)']")); - clickAndWait(By.xpath("//div[@class='modal-dialog'][contains(.,'delete this paragraph')" + - "]//div[@class='modal-footer']//button[contains(.,'OK')]")); + clickAndWait( + By.xpath( + "//div[@class='modal-dialog'][contains(.,'delete this paragraph')" + + "]//div[@class='modal-footer']//button[contains(.,'OK')]")); - Integer newNosOfParas = driver.findElements(By.xpath - ("//div[@ng-controller=\"ParagraphCtrl\"]")).size(); - collector.checkThat("After Remove : Number of paragraphs are", + Integer newNosOfParas = + driver.findElements(By.xpath("//div[@ng-controller=\"ParagraphCtrl\"]")).size(); + collector.checkThat( + "After Remove : Number of paragraphs are", newNosOfParas, CoreMatchers.equalTo(oldNosOfParas - 1)); deleteTestNotebook(driver); @@ -164,45 +197,63 @@ public class ParagraphActionsIT extends AbstractZeppelinIT { setTextOfParagraph(1, "1"); driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click(); - driver.findElement(By.xpath(getParagraphXPath(1) + "//ul/li/a[@ng-click=\"insertNew('below')\"]")).click(); - + driver + .findElement( + By.xpath(getParagraphXPath(1) + "//ul/li/a[@ng-click=\"insertNew('below')\"]")) + .click(); waitForParagraph(2, "READY"); setTextOfParagraph(2, "2"); - - collector.checkThat("The paragraph1 value contains", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'editor')]")).getText(), + collector.checkThat( + "The paragraph1 value contains", + driver + .findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'editor')]")) + .getText(), CoreMatchers.equalTo("1")); - collector.checkThat("The paragraph1 value contains", - driver.findElement(By.xpath(getParagraphXPath(2) + "//div[contains(@class, 'editor')]")).getText(), + collector.checkThat( + "The paragraph1 value contains", + driver + .findElement(By.xpath(getParagraphXPath(2) + "//div[contains(@class, 'editor')]")) + .getText(), CoreMatchers.equalTo("2")); driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click(); clickAndWait(By.xpath(getParagraphXPath(1) + "//ul/li/a[@ng-click='moveDown(paragraph)']")); - collector.checkThat("The paragraph1 value contains", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'editor')]")).getText(), + collector.checkThat( + "The paragraph1 value contains", + driver + .findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'editor')]")) + .getText(), CoreMatchers.equalTo("2")); - collector.checkThat("The paragraph1 value contains", - driver.findElement(By.xpath(getParagraphXPath(2) + "//div[contains(@class, 'editor')]")).getText(), + collector.checkThat( + "The paragraph1 value contains", + driver + .findElement(By.xpath(getParagraphXPath(2) + "//div[contains(@class, 'editor')]")) + .getText(), CoreMatchers.equalTo("1")); driver.findElement(By.xpath(getParagraphXPath(2) + "//span[@class='icon-settings']")).click(); clickAndWait(By.xpath(getParagraphXPath(2) + "//ul/li/a[@ng-click='moveUp(paragraph)']")); - collector.checkThat("The paragraph1 value contains", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'editor')]")).getText(), + collector.checkThat( + "The paragraph1 value contains", + driver + .findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'editor')]")) + .getText(), CoreMatchers.equalTo("1")); - collector.checkThat("The paragraph1 value contains", - driver.findElement(By.xpath(getParagraphXPath(2) + "//div[contains(@class, 'editor')]")).getText(), + collector.checkThat( + "The paragraph1 value contains", + driver + .findElement(By.xpath(getParagraphXPath(2) + "//div[contains(@class, 'editor')]")) + .getText(), CoreMatchers.equalTo("2")); deleteTestNotebook(driver); } catch (Exception e) { handleException("Exception in ParagraphActionsIT while testMoveUpAndDown ", e); } - } @Test @@ -214,20 +265,32 @@ public class ParagraphActionsIT extends AbstractZeppelinIT { setTextOfParagraph(1, "println (\"abcd\")"); driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click(); - clickAndWait(By.xpath(getParagraphXPath(1) + "//ul/li/a[@ng-click='toggleEnableDisable(paragraph)']")); - collector.checkThat("The play button class was ", - driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-control-play shortcut-icon']")).isDisplayed(), CoreMatchers.equalTo(false) - ); + clickAndWait( + By.xpath(getParagraphXPath(1) + "//ul/li/a[@ng-click='toggleEnableDisable(paragraph)']")); + collector.checkThat( + "The play button class was ", + driver + .findElement( + By.xpath( + getParagraphXPath(1) + "//span[@class='icon-control-play shortcut-icon']")) + .isDisplayed(), + CoreMatchers.equalTo(false)); - driver.findElement(By.xpath(".//*[@id='main']//button[contains(@ng-click, 'runAllParagraphs')]")).sendKeys(Keys.ENTER); + driver + .findElement( + By.xpath(".//*[@id='main']//button[contains(@ng-click, 'runAllParagraphs')]")) + .sendKeys(Keys.ENTER); ZeppelinITUtils.sleep(1000, false); - driver.findElement(By.xpath("//div[@class='modal-dialog'][contains(.,'Run all paragraphs?')]" + - "//div[@class='modal-footer']//button[contains(.,'OK')]")).click(); + driver + .findElement( + By.xpath( + "//div[@class='modal-dialog'][contains(.,'Run all paragraphs?')]" + + "//div[@class='modal-footer']//button[contains(.,'OK')]")) + .click(); ZeppelinITUtils.sleep(2000, false); - collector.checkThat("Paragraph status is ", - getParagraphStatus(1), CoreMatchers.equalTo("READY") - ); + collector.checkThat( + "Paragraph status is ", getParagraphStatus(1), CoreMatchers.equalTo("READY")); deleteTestNotebook(driver); @@ -236,10 +299,11 @@ public class ParagraphActionsIT extends AbstractZeppelinIT { } } -// @Test + // @Test public void testRunOnSelectionChange() throws Exception { try { - String xpathToRunOnSelectionChangeCheckbox = getParagraphXPath(1) + "//ul/li/form/input[contains(@ng-checked, 'true')]"; + String xpathToRunOnSelectionChangeCheckbox = + getParagraphXPath(1) + "//ul/li/form/input[contains(@ng-checked, 'true')]"; String xpathToDropdownMenu = getParagraphXPath(1) + "//select"; String xpathToResultText = getParagraphXPath(1) + "//div[contains(@id,\"_html\")]"; @@ -252,37 +316,52 @@ public class ParagraphActionsIT extends AbstractZeppelinIT { // 1. 'RunOnSelectionChange' is true by default driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click(); - collector.checkThat("'Run on selection change' checkbox will be shown under dropdown menu ", - driver.findElement(By.xpath(getParagraphXPath(1) + "//ul/li/form/input[contains(@ng-click, 'turnOnAutoRun(paragraph)')]")).isDisplayed(), - CoreMatchers.equalTo(true)); + collector.checkThat( + "'Run on selection change' checkbox will be shown under dropdown menu ", + driver + .findElement( + By.xpath( + getParagraphXPath(1) + + "//ul/li/form/input[contains(@ng-click, 'turnOnAutoRun(paragraph)')]")) + .isDisplayed(), + CoreMatchers.equalTo(true)); Select dropDownMenu = new Select(driver.findElement(By.xpath((xpathToDropdownMenu)))); dropDownMenu.selectByVisibleText("2"); waitForParagraph(1, "FINISHED"); - collector.checkThat("If 'RunOnSelectionChange' is true, the paragraph result will be updated right after click any options in the dropdown menu ", - driver.findElement(By.xpath(xpathToResultText)).getText(), - CoreMatchers.equalTo("My selection is 2")); + collector.checkThat( + "If 'RunOnSelectionChange' is true, the paragraph result will be updated right after click any options in the dropdown menu ", + driver.findElement(By.xpath(xpathToResultText)).getText(), + CoreMatchers.equalTo("My selection is 2")); // 2. set 'RunOnSelectionChange' to false driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click(); driver.findElement(By.xpath(xpathToRunOnSelectionChangeCheckbox)).click(); - collector.checkThat("If 'Run on selection change' checkbox is unchecked, 'paragraph.config.runOnSelectionChange' will be false ", - driver.findElement(By.xpath(getParagraphXPath(1) + "//ul/li/span[contains(@ng-if, 'paragraph.config.runOnSelectionChange == false')]")).isDisplayed(), - CoreMatchers.equalTo(true)); + collector.checkThat( + "If 'Run on selection change' checkbox is unchecked, 'paragraph.config.runOnSelectionChange' will be false ", + driver + .findElement( + By.xpath( + getParagraphXPath(1) + + "//ul/li/span[contains(@ng-if, 'paragraph.config.runOnSelectionChange == false')]")) + .isDisplayed(), + CoreMatchers.equalTo(true)); Select sameDropDownMenu = new Select(driver.findElement(By.xpath((xpathToDropdownMenu)))); sameDropDownMenu.selectByVisibleText("1"); waitForParagraph(1, "FINISHED"); - collector.checkThat("If 'RunOnSelectionChange' is false, the paragraph result won't be updated even if we select any options in the dropdown menu ", - driver.findElement(By.xpath(xpathToResultText)).getText(), - CoreMatchers.equalTo("My selection is 2")); + collector.checkThat( + "If 'RunOnSelectionChange' is false, the paragraph result won't be updated even if we select any options in the dropdown menu ", + driver.findElement(By.xpath(xpathToResultText)).getText(), + CoreMatchers.equalTo("My selection is 2")); // run paragraph manually by pressing ENTER driver.findElement(By.xpath(xpathToDropdownMenu)).sendKeys(Keys.ENTER); waitForParagraph(1, "FINISHED"); - collector.checkThat("Even if 'RunOnSelectionChange' is set as false, still can run the paragraph by pressing ENTER ", - driver.findElement(By.xpath(xpathToResultText)).getText(), - CoreMatchers.equalTo("My selection is 1")); + collector.checkThat( + "Even if 'RunOnSelectionChange' is set as false, still can run the paragraph by pressing ENTER ", + driver.findElement(By.xpath(xpathToResultText)).getText(), + CoreMatchers.equalTo("My selection is 1")); } catch (Exception e) { handleException("Exception in ParagraphActionsIT while testRunOnSelectionChange ", e); @@ -297,18 +376,22 @@ public class ParagraphActionsIT extends AbstractZeppelinIT { waitForParagraph(1, "READY"); String xpathToOutputField = getParagraphXPath(1) + "//div[contains(@id,\"_text\")]"; setTextOfParagraph(1, "println (\"abcd\")"); - collector.checkThat("Before Run Output field contains ", + collector.checkThat( + "Before Run Output field contains ", driver.findElements(By.xpath(xpathToOutputField)).size(), CoreMatchers.equalTo(0)); runParagraph(1); waitForParagraph(1, "FINISHED"); - collector.checkThat("After Run Output field contains ", + collector.checkThat( + "After Run Output field contains ", driver.findElement(By.xpath(xpathToOutputField)).getText(), CoreMatchers.equalTo("abcd")); driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click(); - clickAndWait(By.xpath(getParagraphXPath(1) + - "//ul/li/a[@ng-click='clearParagraphOutput(paragraph)']")); - collector.checkThat("After Clear Output field contains ", + clickAndWait( + By.xpath( + getParagraphXPath(1) + "//ul/li/a[@ng-click='clearParagraphOutput(paragraph)']")); + collector.checkThat( + "After Clear Output field contains ", driver.findElements(By.xpath(xpathToOutputField)).size(), CoreMatchers.equalTo(0)); deleteTestNotebook(driver); @@ -324,16 +407,24 @@ public class ParagraphActionsIT extends AbstractZeppelinIT { createNewNote(); waitForParagraph(1, "READY"); - collector.checkThat("Default Width is 12 ", + collector.checkThat( + "Default Width is 12 ", driver.findElement(By.xpath("//div[contains(@class,'col-md-12')]")).isDisplayed(), CoreMatchers.equalTo(true)); for (Integer newWidth = 1; newWidth <= 11; newWidth++) { clickAndWait(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")); String visibleText = newWidth.toString(); - new Select(driver.findElement(By.xpath(getParagraphXPath(1) - + "//ul/li/a/select[(@ng-model='paragraph.config.colWidth')]"))).selectByVisibleText(visibleText); - collector.checkThat("New Width is : " + newWidth, - driver.findElement(By.xpath("//div[contains(@class,'col-md-" + newWidth + "')]")).isDisplayed(), + new Select( + driver.findElement( + By.xpath( + getParagraphXPath(1) + + "//ul/li/a/select[(@ng-model='paragraph.config.colWidth')]"))) + .selectByVisibleText(visibleText); + collector.checkThat( + "New Width is : " + newWidth, + driver + .findElement(By.xpath("//div[contains(@class,'col-md-" + newWidth + "')]")) + .isDisplayed(), CoreMatchers.equalTo(true)); } deleteTestNotebook(driver); @@ -347,18 +438,29 @@ public class ParagraphActionsIT extends AbstractZeppelinIT { try { createNewNote(); waitForParagraph(1, "READY"); - Float height = Float.valueOf(driver.findElement(By.xpath("//div[contains(@class,'ace_content')]")) - .getCssValue("height").replace("px", "")); + Float height = + Float.valueOf( + driver + .findElement(By.xpath("//div[contains(@class,'ace_content')]")) + .getCssValue("height") + .replace("px", "")); for (Integer newFontSize = 10; newFontSize <= 20; newFontSize++) { clickAndWait(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")); String visibleText = newFontSize.toString(); - new Select(driver.findElement(By.xpath(getParagraphXPath(1) - + "//ul/li/a/select[(@ng-model='paragraph.config.fontSize')]"))).selectByVisibleText(visibleText); - Float newHeight = Float.valueOf(driver.findElement(By.xpath("//div[contains(@class,'ace_content')]")) - .getCssValue("height").replace("px", "")); - collector.checkThat("New Font size is : " + newFontSize, - newHeight > height, - CoreMatchers.equalTo(true)); + new Select( + driver.findElement( + By.xpath( + getParagraphXPath(1) + + "//ul/li/a/select[(@ng-model='paragraph.config.fontSize')]"))) + .selectByVisibleText(visibleText); + Float newHeight = + Float.valueOf( + driver + .findElement(By.xpath("//div[contains(@class,'ace_content')]")) + .getCssValue("height") + .replace("px", "")); + collector.checkThat( + "New Font size is : " + newFontSize, newHeight > height, CoreMatchers.equalTo(true)); height = newHeight; } deleteTestNotebook(driver); @@ -376,55 +478,70 @@ public class ParagraphActionsIT extends AbstractZeppelinIT { String xpathToTitle = getParagraphXPath(1) + "//div[contains(@class, 'title')]/div"; String xpathToSettingIcon = getParagraphXPath(1) + "//span[@class='icon-settings']"; - String xpathToShowTitle = getParagraphXPath(1) + "//ul/li/a[@ng-show='!paragraph.config.title']"; - String xpathToHideTitle = getParagraphXPath(1) + "//ul/li/a[@ng-show='paragraph.config.title']"; + String xpathToShowTitle = + getParagraphXPath(1) + "//ul/li/a[@ng-show='!paragraph.config.title']"; + String xpathToHideTitle = + getParagraphXPath(1) + "//ul/li/a[@ng-show='paragraph.config.title']"; ZeppelinITUtils.turnOffImplicitWaits(driver); Integer titleElems = driver.findElements(By.xpath(xpathToTitle)).size(); - collector.checkThat("Before Show Title : The title doesn't exist", - titleElems, - CoreMatchers.equalTo(0)); + collector.checkThat( + "Before Show Title : The title doesn't exist", titleElems, CoreMatchers.equalTo(0)); ZeppelinITUtils.turnOnImplicitWaits(driver); clickAndWait(By.xpath(xpathToSettingIcon)); - collector.checkThat("Before Show Title : The title option in option panel of paragraph is labeled as", + collector.checkThat( + "Before Show Title : The title option in option panel of paragraph is labeled as", driver.findElement(By.xpath(xpathToShowTitle)).getText(), - CoreMatchers.allOf(CoreMatchers.endsWith("Show title"), CoreMatchers.containsString("Ctrl+"), - CoreMatchers.anyOf(CoreMatchers.containsString("Option"), CoreMatchers.containsString("Alt")), + CoreMatchers.allOf( + CoreMatchers.endsWith("Show title"), + CoreMatchers.containsString("Ctrl+"), + CoreMatchers.anyOf( + CoreMatchers.containsString("Option"), CoreMatchers.containsString("Alt")), CoreMatchers.containsString("+T"))); clickAndWait(By.xpath(xpathToShowTitle)); - collector.checkThat("After Show Title : The title field contains", + collector.checkThat( + "After Show Title : The title field contains", driver.findElement(By.xpath(xpathToTitle)).getText(), CoreMatchers.equalTo("Untitled")); clickAndWait(By.xpath(xpathToSettingIcon)); - collector.checkThat("After Show Title : The title option in option panel of paragraph is labeled as", + collector.checkThat( + "After Show Title : The title option in option panel of paragraph is labeled as", driver.findElement(By.xpath(xpathToHideTitle)).getText(), - CoreMatchers.allOf(CoreMatchers.endsWith("Hide title"), CoreMatchers.containsString("Ctrl+"), - CoreMatchers.anyOf(CoreMatchers.containsString("Option"), CoreMatchers.containsString("Alt")), + CoreMatchers.allOf( + CoreMatchers.endsWith("Hide title"), + CoreMatchers.containsString("Ctrl+"), + CoreMatchers.anyOf( + CoreMatchers.containsString("Option"), CoreMatchers.containsString("Alt")), CoreMatchers.containsString("+T"))); clickAndWait(By.xpath(xpathToHideTitle)); ZeppelinITUtils.turnOffImplicitWaits(driver); titleElems = driver.findElements(By.xpath(xpathToTitle)).size(); - collector.checkThat("After Hide Title : The title field is hidden", - titleElems, - CoreMatchers.equalTo(0)); + collector.checkThat( + "After Hide Title : The title field is hidden", titleElems, CoreMatchers.equalTo(0)); ZeppelinITUtils.turnOnImplicitWaits(driver); driver.findElement(By.xpath(xpathToSettingIcon)).click(); driver.findElement(By.xpath(xpathToShowTitle)).click(); - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'title')]")).click(); - driver.findElement(By.xpath(getParagraphXPath(1) + "//input")).sendKeys("NEW TITLE" + Keys.ENTER); + driver + .findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'title')]")) + .click(); + driver + .findElement(By.xpath(getParagraphXPath(1) + "//input")) + .sendKeys("NEW TITLE" + Keys.ENTER); ZeppelinITUtils.sleep(500, false); - collector.checkThat("After Editing the Title : The title field contains ", + collector.checkThat( + "After Editing the Title : The title field contains ", driver.findElement(By.xpath(xpathToTitle)).getText(), CoreMatchers.equalTo("NEW TITLE")); driver.navigate().refresh(); ZeppelinITUtils.sleep(1000, false); - collector.checkThat("After Page Refresh : The title field contains ", + collector.checkThat( + "After Page Refresh : The title field contains ", driver.findElement(By.xpath(xpathToTitle)).getText(), CoreMatchers.equalTo("NEW TITLE")); deleteTestNotebook(driver); @@ -432,7 +549,6 @@ public class ParagraphActionsIT extends AbstractZeppelinIT { } catch (Exception e) { handleException("Exception in ParagraphActionsIT while testTitleButton ", e); } - } @Test @@ -441,36 +557,49 @@ public class ParagraphActionsIT extends AbstractZeppelinIT { createNewNote(); waitForParagraph(1, "READY"); - String xpathToLineNumberField = getParagraphXPath(1) + "//div[contains(@class, 'ace_gutter-layer')]"; - String xpathToShowLineNumberButton = getParagraphXPath(1) + "//ul/li/a[@ng-click='showLineNumbers(paragraph)']"; - String xpathToHideLineNumberButton = getParagraphXPath(1) + "//ul/li/a[@ng-click='hideLineNumbers(paragraph)']"; - - collector.checkThat("Before \"Show line number\" the Line Number is Enabled ", + String xpathToLineNumberField = + getParagraphXPath(1) + "//div[contains(@class, 'ace_gutter-layer')]"; + String xpathToShowLineNumberButton = + getParagraphXPath(1) + "//ul/li/a[@ng-click='showLineNumbers(paragraph)']"; + String xpathToHideLineNumberButton = + getParagraphXPath(1) + "//ul/li/a[@ng-click='hideLineNumbers(paragraph)']"; + + collector.checkThat( + "Before \"Show line number\" the Line Number is Enabled ", driver.findElement(By.xpath(xpathToLineNumberField)).isDisplayed(), CoreMatchers.equalTo(false)); driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click(); - collector.checkThat("Before \"Show line number\" The option panel in paragraph has button labeled ", + collector.checkThat( + "Before \"Show line number\" The option panel in paragraph has button labeled ", driver.findElement(By.xpath(xpathToShowLineNumberButton)).getText(), - CoreMatchers.allOf(CoreMatchers.endsWith("Show line numbers"), CoreMatchers.containsString("Ctrl+"), - CoreMatchers.anyOf(CoreMatchers.containsString("Option"), CoreMatchers.containsString("Alt")), + CoreMatchers.allOf( + CoreMatchers.endsWith("Show line numbers"), + CoreMatchers.containsString("Ctrl+"), + CoreMatchers.anyOf( + CoreMatchers.containsString("Option"), CoreMatchers.containsString("Alt")), CoreMatchers.containsString("+M"))); - clickAndWait(By.xpath(xpathToShowLineNumberButton)); - collector.checkThat("After \"Show line number\" the Line Number is Enabled ", + collector.checkThat( + "After \"Show line number\" the Line Number is Enabled ", driver.findElement(By.xpath(xpathToLineNumberField)).isDisplayed(), CoreMatchers.equalTo(true)); clickAndWait(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")); - collector.checkThat("After \"Show line number\" The option panel in paragraph has button labeled ", + collector.checkThat( + "After \"Show line number\" The option panel in paragraph has button labeled ", driver.findElement(By.xpath(xpathToHideLineNumberButton)).getText(), - CoreMatchers.allOf(CoreMatchers.endsWith("Hide line numbers"), CoreMatchers.containsString("Ctrl+"), - CoreMatchers.anyOf(CoreMatchers.containsString("Option"), CoreMatchers.containsString("Alt")), + CoreMatchers.allOf( + CoreMatchers.endsWith("Hide line numbers"), + CoreMatchers.containsString("Ctrl+"), + CoreMatchers.anyOf( + CoreMatchers.containsString("Option"), CoreMatchers.containsString("Alt")), CoreMatchers.containsString("+M"))); clickAndWait(By.xpath(xpathToHideLineNumberButton)); - collector.checkThat("After \"Hide line number\" the Line Number is Enabled", + collector.checkThat( + "After \"Hide line number\" the Line Number is Enabled", driver.findElement(By.xpath(xpathToLineNumberField)).isDisplayed(), CoreMatchers.equalTo(false)); deleteTestNotebook(driver); @@ -480,7 +609,7 @@ public class ParagraphActionsIT extends AbstractZeppelinIT { } } -// @Test + // @Test public void testEditOnDoubleClick() throws Exception { try { createNewNote(); @@ -497,12 +626,24 @@ public class ParagraphActionsIT extends AbstractZeppelinIT { runParagraph(1); waitForParagraph(1, "FINISHED"); - collector.checkThat("Markdown editor is hidden after run ", - driver.findElements(By.xpath(getParagraphXPath(1) + "//div[contains(@ng-if, 'paragraph.config.editorHide')]")).size(), + collector.checkThat( + "Markdown editor is hidden after run ", + driver + .findElements( + By.xpath( + getParagraphXPath(1) + + "//div[contains(@ng-if, 'paragraph.config.editorHide')]")) + .size(), CoreMatchers.equalTo(0)); - collector.checkThat("Markdown editor is shown after run ", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@ng-show, 'paragraph.config.tableHide')]")).isDisplayed(), + collector.checkThat( + "Markdown editor is shown after run ", + driver + .findElement( + By.xpath( + getParagraphXPath(1) + + "//div[contains(@ng-show, 'paragraph.config.tableHide')]")) + .isDisplayed(), CoreMatchers.equalTo(true)); // to check if editOnDblClick field is fetched correctly after refresh @@ -511,12 +652,24 @@ public class ParagraphActionsIT extends AbstractZeppelinIT { action.doubleClick(driver.findElement(By.xpath(getParagraphXPath(1)))).perform(); ZeppelinITUtils.sleep(1000, false); - collector.checkThat("Markdown editor is shown after double click ", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@ng-if, 'paragraph.config.editorHide')]")).isDisplayed(), + collector.checkThat( + "Markdown editor is shown after double click ", + driver + .findElement( + By.xpath( + getParagraphXPath(1) + + "//div[contains(@ng-if, 'paragraph.config.editorHide')]")) + .isDisplayed(), CoreMatchers.equalTo(true)); - collector.checkThat("Markdown editor is hidden after double click ", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@ng-show, 'paragraph.config.tableHide')]")).isDisplayed(), + collector.checkThat( + "Markdown editor is hidden after double click ", + driver + .findElement( + By.xpath( + getParagraphXPath(1) + + "//div[contains(@ng-show, 'paragraph.config.tableHide')]")) + .isDisplayed(), CoreMatchers.equalTo(false)); deleteTestNotebook(driver); @@ -535,22 +688,37 @@ public class ParagraphActionsIT extends AbstractZeppelinIT { runParagraph(1); waitForParagraph(1, "FINISHED"); - collector.checkThat("Output text is equal to value specified initially", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), - CoreMatchers.equalTo("Hello world")); + collector.checkThat( + "Output text is equal to value specified initially", + driver + .findElement( + By.xpath( + getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")) + .getText(), + CoreMatchers.equalTo("Hello world")); driver.findElement(By.xpath(getParagraphXPath(1) + "//input")).clear(); driver.findElement(By.xpath(getParagraphXPath(1) + "//input")).sendKeys("Zeppelin"); - collector.checkThat("After new data in text input form, output should not be changed", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), - CoreMatchers.equalTo("Hello world")); + collector.checkThat( + "After new data in text input form, output should not be changed", + driver + .findElement( + By.xpath( + getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")) + .getText(), + CoreMatchers.equalTo("Hello world")); runParagraph(1); waitForParagraph(1, "FINISHED"); - collector.checkThat("Only after running the paragraph, we can see the newly updated output", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), - CoreMatchers.equalTo("Hello Zeppelin")); + collector.checkThat( + "Only after running the paragraph, we can see the newly updated output", + driver + .findElement( + By.xpath( + getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")) + .getText(), + CoreMatchers.equalTo("Hello Zeppelin")); deleteTestNotebook(driver); @@ -564,30 +732,50 @@ public class ParagraphActionsIT extends AbstractZeppelinIT { try { createNewNote(); - setTextOfParagraph(1, "%spark println(\"Howdy \"+z.select(\"names\", Seq((\"1\",\"Alice\"), " + - "(\"2\",\"Bob\"),(\"3\",\"stranger\"))))"); + setTextOfParagraph( + 1, + "%spark println(\"Howdy \"+z.select(\"names\", Seq((\"1\",\"Alice\"), " + + "(\"2\",\"Bob\"),(\"3\",\"stranger\"))))"); runParagraph(1); waitForParagraph(1, "FINISHED"); - collector.checkThat("Output text should not display any of the options in select form", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), - CoreMatchers.equalTo("Howdy 1")); - - Select dropDownMenu = new Select(driver.findElement(By.xpath("(" + (getParagraphXPath(1) + "//select)[1]")))); + collector.checkThat( + "Output text should not display any of the options in select form", + driver + .findElement( + By.xpath( + getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")) + .getText(), + CoreMatchers.equalTo("Howdy 1")); + + Select dropDownMenu = + new Select(driver.findElement(By.xpath("(" + (getParagraphXPath(1) + "//select)[1]")))); dropDownMenu.selectByVisibleText("Alice"); - collector.checkThat("After selection in drop down menu, output should display the newly selected option", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), - CoreMatchers.equalTo("Howdy 1")); + collector.checkThat( + "After selection in drop down menu, output should display the newly selected option", + driver + .findElement( + By.xpath( + getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")) + .getText(), + CoreMatchers.equalTo("Howdy 1")); driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click(); - clickAndWait(By.xpath(getParagraphXPath(1) + "//ul/li/form/input[contains(@ng-checked, 'true')]")); + clickAndWait( + By.xpath(getParagraphXPath(1) + "//ul/li/form/input[contains(@ng-checked, 'true')]")); - Select sameDropDownMenu = new Select(driver.findElement(By.xpath("(" + (getParagraphXPath(1) + "//select)[1]")))); + Select sameDropDownMenu = + new Select(driver.findElement(By.xpath("(" + (getParagraphXPath(1) + "//select)[1]")))); sameDropDownMenu.selectByVisibleText("Bob"); - collector.checkThat("After 'Run on selection change' checkbox is unchecked, the paragraph should not run if selecting a different option", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), - CoreMatchers.equalTo("Howdy 1")); + collector.checkThat( + "After 'Run on selection change' checkbox is unchecked, the paragraph should not run if selecting a different option", + driver + .findElement( + By.xpath( + getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")) + .getText(), + CoreMatchers.equalTo("Howdy 1")); deleteTestNotebook(driver); @@ -601,38 +789,60 @@ public class ParagraphActionsIT extends AbstractZeppelinIT { try { createNewNote(); - setTextOfParagraph(1, "%spark val options = Seq((\"han\",\"Han\"), (\"leia\",\"Leia\"), " + - "(\"luke\",\"Luke\")); println(\"Greetings \"+z.checkbox(\"skywalkers\",options).mkString(\" and \"))"); + setTextOfParagraph( + 1, + "%spark val options = Seq((\"han\",\"Han\"), (\"leia\",\"Leia\"), " + + "(\"luke\",\"Luke\")); println(\"Greetings \"+z.checkbox(\"skywalkers\",options).mkString(\" and \"))"); runParagraph(1); waitForParagraph(1, "FINISHED"); - collector.checkThat("Output text should display all of the options included in check boxes", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), - CoreMatchers.containsString("Greetings han and leia and luke")); + collector.checkThat( + "Output text should display all of the options included in check boxes", + driver + .findElement( + By.xpath( + getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")) + .getText(), + CoreMatchers.containsString("Greetings han and leia and luke")); - WebElement firstCheckbox = driver.findElement(By.xpath("(" + getParagraphXPath(1) + "//input[@type='checkbox'])[1]")); + WebElement firstCheckbox = + driver.findElement( + By.xpath("(" + getParagraphXPath(1) + "//input[@type='checkbox'])[1]")); firstCheckbox.click(); - collector.checkThat("After unchecking one of the boxes, we can see the newly updated output without the option we unchecked", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), - CoreMatchers.containsString("Greetings leia and luke")); + collector.checkThat( + "After unchecking one of the boxes, we can see the newly updated output without the option we unchecked", + driver + .findElement( + By.xpath( + getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")) + .getText(), + CoreMatchers.containsString("Greetings leia and luke")); driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click(); - clickAndWait(By.xpath(getParagraphXPath(1) + "//ul/li/form/input[contains(@ng-checked, 'true')]")); + clickAndWait( + By.xpath(getParagraphXPath(1) + "//ul/li/form/input[contains(@ng-checked, 'true')]")); - WebElement secondCheckbox = driver.findElement(By.xpath("(" + getParagraphXPath(1) + "//input[@type='checkbox'])[2]")); + WebElement secondCheckbox = + driver.findElement( + By.xpath("(" + getParagraphXPath(1) + "//input[@type='checkbox'])[2]")); secondCheckbox.click(); - collector.checkThat("After 'Run on selection change' checkbox is unchecked, the paragraph should not run if check box state is modified", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), - CoreMatchers.containsString("Greetings leia and luke")); + collector.checkThat( + "After 'Run on selection change' checkbox is unchecked, the paragraph should not run if check box state is modified", + driver + .findElement( + By.xpath( + getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")) + .getText(), + CoreMatchers.containsString("Greetings leia and luke")); runParagraph(1); waitForParagraph(1, "FINISHED"); - deleteTestNotebook(driver); } catch (Exception e) { - handleException("Exception in ParagraphActionsIT while testSingleDynamicFormCheckboxForm ", e); + handleException( + "Exception in ParagraphActionsIT while testSingleDynamicFormCheckboxForm ", e); } } @@ -641,36 +851,57 @@ public class ParagraphActionsIT extends AbstractZeppelinIT { try { createNewNote(); - setTextOfParagraph(1, "%spark println(\"Howdy \"+z.select(\"fruits\", Seq((\"1\",\"Apple\")," + - "(\"2\",\"Orange\"),(\"3\",\"Peach\")))); println(\"Howdy \"+z.select(\"planets\", " + - "Seq((\"1\",\"Venus\"),(\"2\",\"Earth\"),(\"3\",\"Mars\"))))"); + setTextOfParagraph( + 1, + "%spark println(\"Howdy \"+z.select(\"fruits\", Seq((\"1\",\"Apple\")," + + "(\"2\",\"Orange\"),(\"3\",\"Peach\")))); println(\"Howdy \"+z.select(\"planets\", " + + "Seq((\"1\",\"Venus\"),(\"2\",\"Earth\"),(\"3\",\"Mars\"))))"); runParagraph(1); waitForParagraph(1, "FINISHED"); - collector.checkThat("Output text should not display any of the options in select form", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), - CoreMatchers.equalTo("Howdy 1\nHowdy 1")); - - Select dropDownMenu = new Select(driver.findElement(By.xpath("(" + (getParagraphXPath(1) + "//select)[1]")))); + collector.checkThat( + "Output text should not display any of the options in select form", + driver + .findElement( + By.xpath( + getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")) + .getText(), + CoreMatchers.equalTo("Howdy 1\nHowdy 1")); + + Select dropDownMenu = + new Select(driver.findElement(By.xpath("(" + (getParagraphXPath(1) + "//select)[1]")))); dropDownMenu.selectByVisibleText("Apple"); - collector.checkThat("After selection in drop down menu, output should display the new option we selected", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), - CoreMatchers.equalTo("Howdy 1\nHowdy 1")); + collector.checkThat( + "After selection in drop down menu, output should display the new option we selected", + driver + .findElement( + By.xpath( + getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")) + .getText(), + CoreMatchers.equalTo("Howdy 1\nHowdy 1")); driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click(); - clickAndWait(By.xpath(getParagraphXPath(1) + "//ul/li/form/input[contains(@ng-checked, 'true')]")); + clickAndWait( + By.xpath(getParagraphXPath(1) + "//ul/li/form/input[contains(@ng-checked, 'true')]")); - Select sameDropDownMenu = new Select(driver.findElement(By.xpath("(" + (getParagraphXPath(1) + "//select)[2]")))); + Select sameDropDownMenu = + new Select(driver.findElement(By.xpath("(" + (getParagraphXPath(1) + "//select)[2]")))); sameDropDownMenu.selectByVisibleText("Earth"); waitForParagraph(1, "FINISHED"); - collector.checkThat("After 'Run on selection change' checkbox is unchecked, the paragraph should not run if selecting a different option", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), - CoreMatchers.equalTo("Howdy 1\nHowdy 1")); + collector.checkThat( + "After 'Run on selection change' checkbox is unchecked, the paragraph should not run if selecting a different option", + driver + .findElement( + By.xpath( + getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")) + .getText(), + CoreMatchers.equalTo("Howdy 1\nHowdy 1")); deleteTestNotebook(driver); } catch (Exception e) { - handleException("Exception in ParagraphActionsIT while testMultipleDynamicFormsSameType ", e); + handleException( + "Exception in ParagraphActionsIT while testMultipleDynamicFormsSameType ", e); } } @@ -683,27 +914,49 @@ public class ParagraphActionsIT extends AbstractZeppelinIT { runParagraph(1); waitForParagraph(1, "FINISHED"); - collector.checkThat("Output text is equal to value specified initially", driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), CoreMatchers.equalTo("Hello world")); + collector.checkThat( + "Output text is equal to value specified initially", + driver + .findElement( + By.xpath( + getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")) + .getText(), + CoreMatchers.equalTo("Hello world")); driver.findElement(By.xpath(getNoteFormsXPath() + "//input")).clear(); driver.findElement(By.xpath(getNoteFormsXPath() + "//input")).sendKeys("Zeppelin"); driver.findElement(By.xpath(getNoteFormsXPath() + "//input")).sendKeys(Keys.RETURN); - collector.checkThat("After new data in text input form, output should not be changed", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), + collector.checkThat( + "After new data in text input form, output should not be changed", + driver + .findElement( + By.xpath( + getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")) + .getText(), CoreMatchers.equalTo("Hello world")); runParagraph(1); waitForParagraph(1, "FINISHED"); - collector.checkThat("Only after running the paragraph, we can see the newly updated output", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), + collector.checkThat( + "Only after running the paragraph, we can see the newly updated output", + driver + .findElement( + By.xpath( + getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")) + .getText(), CoreMatchers.equalTo("Hello Zeppelin")); setTextOfParagraph(2, "%spark println(\"Hello \"+z.noteTextbox(\"name\", \"world\")) "); runParagraph(2); waitForParagraph(2, "FINISHED"); - collector.checkThat("Running the another paragraph with same form, we can see value from note form", - driver.findElement(By.xpath(getParagraphXPath(2) + "//div[contains(@class, 'text plainTextContent')]")).getText(), - CoreMatchers.equalTo("Hello Zeppelin")); + collector.checkThat( + "Running the another paragraph with same form, we can see value from note form", + driver + .findElement( + By.xpath( + getParagraphXPath(2) + "//div[contains(@class, 'text plainTextContent')]")) + .getText(), + CoreMatchers.equalTo("Hello Zeppelin")); deleteTestNotebook(driver); @@ -717,37 +970,62 @@ public class ParagraphActionsIT extends AbstractZeppelinIT { try { createNewNote(); - setTextOfParagraph(1, "%spark println(\"Howdy \"+z.noteSelect(\"names\", Seq((\"1\",\"Alice\"), " + - "(\"2\",\"Bob\"),(\"3\",\"stranger\"))))"); + setTextOfParagraph( + 1, + "%spark println(\"Howdy \"+z.noteSelect(\"names\", Seq((\"1\",\"Alice\"), " + + "(\"2\",\"Bob\"),(\"3\",\"stranger\"))))"); runParagraph(1); waitForParagraph(1, "FINISHED"); - collector.checkThat("Output text should not display any of the options in select form", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), + collector.checkThat( + "Output text should not display any of the options in select form", + driver + .findElement( + By.xpath( + getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")) + .getText(), CoreMatchers.equalTo("Howdy ")); - Select dropDownMenu = new Select(driver.findElement(By.xpath("(" + (getNoteFormsXPath() + "//select)[1]")))); + Select dropDownMenu = + new Select(driver.findElement(By.xpath("(" + (getNoteFormsXPath() + "//select)[1]")))); dropDownMenu.selectByVisibleText("Bob"); - collector.checkThat("After selection in drop down menu, output should not be changed", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), + collector.checkThat( + "After selection in drop down menu, output should not be changed", + driver + .findElement( + By.xpath( + getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")) + .getText(), CoreMatchers.equalTo("Howdy ")); runParagraph(1); waitForParagraph(1, "FINISHED"); - collector.checkThat("After run paragraph again, we can see the newly updated output", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), + collector.checkThat( + "After run paragraph again, we can see the newly updated output", + driver + .findElement( + By.xpath( + getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")) + .getText(), CoreMatchers.equalTo("Howdy 2")); - setTextOfParagraph(2, "%spark println(\"Howdy \"+z.noteSelect(\"names\", Seq((\"1\",\"Alice\"), " + - "(\"2\",\"Bob\"),(\"3\",\"stranger\"))))"); + setTextOfParagraph( + 2, + "%spark println(\"Howdy \"+z.noteSelect(\"names\", Seq((\"1\",\"Alice\"), " + + "(\"2\",\"Bob\"),(\"3\",\"stranger\"))))"); runParagraph(2); waitForParagraph(2, "FINISHED"); - collector.checkThat("Running the another paragraph with same form, we can see value from note form", - driver.findElement(By.xpath(getParagraphXPath(2) + "//div[contains(@class, 'text plainTextContent')]")).getText(), + collector.checkThat( + "Running the another paragraph with same form, we can see value from note form", + driver + .findElement( + By.xpath( + getParagraphXPath(2) + "//div[contains(@class, 'text plainTextContent')]")) + .getText(), CoreMatchers.equalTo("Howdy 2")); deleteTestNotebook(driver); @@ -762,36 +1040,61 @@ public class ParagraphActionsIT extends AbstractZeppelinIT { try { createNewNote(); - setTextOfParagraph(1, "%spark val options = Seq((\"han\",\"Han\"), (\"leia\",\"Leia\"), " + - "(\"luke\",\"Luke\")); println(\"Greetings \"+z.noteCheckbox(\"skywalkers\",options).mkString(\" and \"))"); + setTextOfParagraph( + 1, + "%spark val options = Seq((\"han\",\"Han\"), (\"leia\",\"Leia\"), " + + "(\"luke\",\"Luke\")); println(\"Greetings \"+z.noteCheckbox(\"skywalkers\",options).mkString(\" and \"))"); runParagraph(1); waitForParagraph(1, "FINISHED"); - collector.checkThat("Output text should display all of the options included in check boxes", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), + collector.checkThat( + "Output text should display all of the options included in check boxes", + driver + .findElement( + By.xpath( + getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")) + .getText(), CoreMatchers.containsString("Greetings han and leia and luke")); - WebElement firstCheckbox = driver.findElement(By.xpath("(" + getNoteFormsXPath() + "//input[@type='checkbox'])[1]")); + WebElement firstCheckbox = + driver.findElement(By.xpath("(" + getNoteFormsXPath() + "//input[@type='checkbox'])[1]")); firstCheckbox.click(); - collector.checkThat("After unchecking one of the boxes, output should not be changed", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), + collector.checkThat( + "After unchecking one of the boxes, output should not be changed", + driver + .findElement( + By.xpath( + getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")) + .getText(), CoreMatchers.containsString("Greetings han and leia and luke")); runParagraph(1); waitForParagraph(1, "FINISHED"); - collector.checkThat("After run paragraph again, we can see the newly updated output", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), + collector.checkThat( + "After run paragraph again, we can see the newly updated output", + driver + .findElement( + By.xpath( + getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")) + .getText(), CoreMatchers.containsString("Greetings leia and luke")); - setTextOfParagraph(2, "%spark val options = Seq((\"han\",\"Han\"), (\"leia\",\"Leia\"), " + - "(\"luke\",\"Luke\")); println(\"Greetings \"+z.noteCheckbox(\"skywalkers\",options).mkString(\" and \"))"); + setTextOfParagraph( + 2, + "%spark val options = Seq((\"han\",\"Han\"), (\"leia\",\"Leia\"), " + + "(\"luke\",\"Luke\")); println(\"Greetings \"+z.noteCheckbox(\"skywalkers\",options).mkString(\" and \"))"); runParagraph(2); waitForParagraph(2, "FINISHED"); - collector.checkThat("Running the another paragraph with same form, we can see value from note form", - driver.findElement(By.xpath(getParagraphXPath(2) + "//div[contains(@class, 'text plainTextContent')]")).getText(), + collector.checkThat( + "Running the another paragraph with same form, we can see value from note form", + driver + .findElement( + By.xpath( + getParagraphXPath(2) + "//div[contains(@class, 'text plainTextContent')]")) + .getText(), CoreMatchers.containsString("Greetings leia and luke")); deleteTestNotebook(driver); @@ -806,19 +1109,28 @@ public class ParagraphActionsIT extends AbstractZeppelinIT { try { createNewNote(); - setTextOfParagraph(1, "%spark println(z.noteTextbox(\"name\", \"note\") + \" \" + z.textbox(\"name\", \"paragraph\")) "); + setTextOfParagraph( + 1, + "%spark println(z.noteTextbox(\"name\", \"note\") + \" \" + z.textbox(\"name\", \"paragraph\")) "); runParagraph(1); waitForParagraph(1, "FINISHED"); - collector.checkThat("After run paragraph, we can see computed output from two forms", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), + collector.checkThat( + "After run paragraph, we can see computed output from two forms", + driver + .findElement( + By.xpath( + getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")) + .getText(), CoreMatchers.equalTo("note paragraph")); deleteTestNotebook(driver); } catch (Exception e) { - handleException("Exception in ParagraphActionsIT while testWithNoteAndParagraphDynamicFormTextInput ", e); + handleException( + "Exception in ParagraphActionsIT while testWithNoteAndParagraphDynamicFormTextInput ", + e); } } }
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-integration/src/test/java/org/apache/zeppelin/integration/PersonalizeActionsIT.java ---------------------------------------------------------------------- diff --git a/zeppelin-integration/src/test/java/org/apache/zeppelin/integration/PersonalizeActionsIT.java b/zeppelin-integration/src/test/java/org/apache/zeppelin/integration/PersonalizeActionsIT.java index 3133564..6cf5c6a 100644 --- a/zeppelin-integration/src/test/java/org/apache/zeppelin/integration/PersonalizeActionsIT.java +++ b/zeppelin-integration/src/test/java/org/apache/zeppelin/integration/PersonalizeActionsIT.java @@ -16,9 +16,11 @@ */ package org.apache.zeppelin.integration; +import java.io.File; +import java.io.IOException; +import org.apache.commons.io.FileUtils; import org.apache.commons.lang.StringUtils; import org.apache.zeppelin.AbstractZeppelinIT; -import org.apache.zeppelin.integration.AuthenticationIT; import org.apache.zeppelin.WebDriverManager; import org.apache.zeppelin.ZeppelinITUtils; import org.apache.zeppelin.conf.ZeppelinConfiguration; @@ -28,50 +30,43 @@ import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ErrorCollector; - import org.openqa.selenium.By; +import org.openqa.selenium.TimeoutException; import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.WebDriverWait; import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.TimeoutException; +import org.openqa.selenium.support.ui.WebDriverWait; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.apache.commons.io.FileUtils; -import java.io.File; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; - -import static org.junit.Assert.assertTrue; - public class PersonalizeActionsIT extends AbstractZeppelinIT { private static final Logger LOG = LoggerFactory.getLogger(PersonalizeActionsIT.class); - @Rule - public ErrorCollector collector = new ErrorCollector(); + @Rule public ErrorCollector collector = new ErrorCollector(); static String shiroPath; - static String authShiro = "[users]\n" + - "admin = password1, admin\n" + - "user1 = password2, user\n" + - "[main]\n" + - "sessionManager = org.apache.shiro.web.session.mgt.DefaultWebSessionManager\n" + - "securityManager.sessionManager = $sessionManager\n" + - "securityManager.sessionManager.globalSessionTimeout = 86400000\n" + - "shiro.loginUrl = /api/login\n" + - "[roles]\n" + - "admin = *\n" + - "user = *\n" + - "[urls]\n" + - "/api/version = anon\n" + - "/** = authc"; + static String authShiro = + "[users]\n" + + "admin = password1, admin\n" + + "user1 = password2, user\n" + + "[main]\n" + + "sessionManager = org.apache.shiro.web.session.mgt.DefaultWebSessionManager\n" + + "securityManager.sessionManager = $sessionManager\n" + + "securityManager.sessionManager.globalSessionTimeout = 86400000\n" + + "shiro.loginUrl = /api/login\n" + + "[roles]\n" + + "admin = *\n" + + "user = *\n" + + "[urls]\n" + + "/api/version = anon\n" + + "/** = authc"; static String originalShiro = ""; @BeforeClass public static void startUp() { try { - System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_HOME.getVarName(), new File("../").getAbsolutePath()); + System.setProperty( + ZeppelinConfiguration.ConfVars.ZEPPELIN_HOME.getVarName(), + new File("../").getAbsolutePath()); ZeppelinConfiguration conf = ZeppelinConfiguration.create(); shiroPath = conf.getRelativeDir(String.format("%s/shiro.ini", conf.getConfDir())); File file = new File(shiroPath); @@ -117,8 +112,9 @@ public class PersonalizeActionsIT extends AbstractZeppelinIT { AuthenticationIT authenticationIT = new AuthenticationIT(); PersonalizeActionsIT personalizeActionsIT = new PersonalizeActionsIT(); authenticationIT.authenticationUser("admin", "password1"); - By locator = By.xpath("//div[contains(@class, \"col-md-4\")]/div/h5/a[contains(.,'Create new" + - " note')]"); + By locator = + By.xpath( + "//div[contains(@class, \"col-md-4\")]/div/h5/a[contains(.,'Create new" + " note')]"); WebDriverWait wait = new WebDriverWait(driver, MAX_BROWSER_TIMEOUT_SEC); WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(locator)); if (element.isDisplayed()) { @@ -127,13 +123,23 @@ public class PersonalizeActionsIT extends AbstractZeppelinIT { String noteId = driver.getCurrentUrl().substring(driver.getCurrentUrl().lastIndexOf("/") + 1); waitForParagraph(1, "READY"); personalizeActionsIT.setParagraphText("Before"); - collector.checkThat("The output field paragraph contains", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'markdown-body')]")).getText(), + collector.checkThat( + "The output field paragraph contains", + driver + .findElement( + By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'markdown-body')]")) + .getText(), CoreMatchers.equalTo("Before")); - pollingWait(By.xpath("//*[@id='actionbar']" + - "//button[contains(@uib-tooltip, 'Switch to personal mode')]"), MAX_BROWSER_TIMEOUT_SEC).click(); - clickAndWait(By.xpath("//div[@class='modal-dialog'][contains(.,'Do you want to personalize your analysis?')" + - "]//div[@class='modal-footer']//button[contains(.,'OK')]")); + pollingWait( + By.xpath( + "//*[@id='actionbar']" + + "//button[contains(@uib-tooltip, 'Switch to personal mode')]"), + MAX_BROWSER_TIMEOUT_SEC) + .click(); + clickAndWait( + By.xpath( + "//div[@class='modal-dialog'][contains(.,'Do you want to personalize your analysis?')" + + "]//div[@class='modal-footer']//button[contains(.,'OK')]")); authenticationIT.logoutUser("admin"); // step 2 : (user1) make sure it is on personalized mode and 'Before' in result of paragraph @@ -142,17 +148,28 @@ public class PersonalizeActionsIT extends AbstractZeppelinIT { wait = new WebDriverWait(driver, MAX_BROWSER_TIMEOUT_SEC); element = wait.until(ExpectedConditions.visibilityOfElementLocated(locator)); if (element.isDisplayed()) { - pollingWait(By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + noteId + "')]"), - MAX_BROWSER_TIMEOUT_SEC).click(); + pollingWait( + By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + noteId + "')]"), + MAX_BROWSER_TIMEOUT_SEC) + .click(); } - collector.checkThat("The personalized mode enables", - driver.findElement(By.xpath("//*[@id='actionbar']" + - "//button[contains(@class, 'btn btn-default btn-xs ng-scope ng-hide')]")).getAttribute("uib-tooltip"), + collector.checkThat( + "The personalized mode enables", + driver + .findElement( + By.xpath( + "//*[@id='actionbar']" + + "//button[contains(@class, 'btn btn-default btn-xs ng-scope ng-hide')]")) + .getAttribute("uib-tooltip"), CoreMatchers.equalTo("Switch to personal mode (owner can change)")); waitForParagraph(1, "READY"); runParagraph(1); - collector.checkThat("The output field paragraph contains", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'markdown-body')]")).getText(), + collector.checkThat( + "The output field paragraph contains", + driver + .findElement( + By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'markdown-body')]")) + .getText(), CoreMatchers.equalTo("Before")); authenticationIT.logoutUser("user1"); @@ -161,12 +178,19 @@ public class PersonalizeActionsIT extends AbstractZeppelinIT { locator = By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + noteId + "')]"); element = wait.until(ExpectedConditions.visibilityOfElementLocated(locator)); if (element.isDisplayed()) { - pollingWait(By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + noteId + "')]"), MAX_BROWSER_TIMEOUT_SEC).click(); + pollingWait( + By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + noteId + "')]"), + MAX_BROWSER_TIMEOUT_SEC) + .click(); } waitForParagraph(1, "FINISHED"); personalizeActionsIT.setParagraphText("After"); - collector.checkThat("The output field paragraph contains", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'markdown-body')]")).getText(), + collector.checkThat( + "The output field paragraph contains", + driver + .findElement( + By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'markdown-body')]")) + .getText(), CoreMatchers.equalTo("After")); authenticationIT.logoutUser("admin"); @@ -175,10 +199,17 @@ public class PersonalizeActionsIT extends AbstractZeppelinIT { locator = By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + noteId + "')]"); element = wait.until(ExpectedConditions.visibilityOfElementLocated(locator)); if (element.isDisplayed()) { - pollingWait(By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + noteId + "')]"), MAX_BROWSER_TIMEOUT_SEC).click(); + pollingWait( + By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + noteId + "')]"), + MAX_BROWSER_TIMEOUT_SEC) + .click(); } - collector.checkThat("The output field paragraph contains", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'markdown-body')]")).getText(), + collector.checkThat( + "The output field paragraph contains", + driver + .findElement( + By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'markdown-body')]")) + .getText(), CoreMatchers.equalTo("Before")); authenticationIT.logoutUser("user1"); } catch (Exception e) { @@ -189,42 +220,58 @@ public class PersonalizeActionsIT extends AbstractZeppelinIT { @Test public void testGraphAction() throws Exception { try { - // step 1 : (admin) create a new note, run a paragraph, change active graph to 'Bar chart', turn on personalized mode + // step 1 : (admin) create a new note, run a paragraph, change active graph to 'Bar chart', + // turn on personalized mode AuthenticationIT authenticationIT = new AuthenticationIT(); authenticationIT.authenticationUser("admin", "password1"); - By locator = By.xpath("//div[contains(@class, \"col-md-4\")]/div/h5/a[contains(.,'Create new" + - " note')]"); + By locator = + By.xpath( + "//div[contains(@class, \"col-md-4\")]/div/h5/a[contains(.,'Create new" + " note')]"); WebDriverWait wait = new WebDriverWait(driver, MAX_BROWSER_TIMEOUT_SEC); WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(locator)); if (element.isDisplayed()) { createNewNote(); } String noteId = driver.getCurrentUrl().substring(driver.getCurrentUrl().lastIndexOf("/") + 1); - setTextOfParagraph(1, "print(s\"\"\"%table\\n" + - "name\\tsize\\n" + - "sun\\t100\\n" + - "moon\\t10\"\"\")"); + setTextOfParagraph( + 1, "print(s\"\"\"%table\\n" + "name\\tsize\\n" + "sun\\t100\\n" + "moon\\t10\"\"\")"); runParagraph(1); try { waitForParagraph(1, "FINISHED"); } catch (TimeoutException e) { waitForParagraph(1, "ERROR"); - collector.checkThat("Exception in PersonalizeActionsIT while testGraphAction, status of 1st Spark Paragraph ", - "ERROR", CoreMatchers.equalTo("FINISHED")); + collector.checkThat( + "Exception in PersonalizeActionsIT while testGraphAction, status of 1st Spark Paragraph ", + "ERROR", + CoreMatchers.equalTo("FINISHED")); } - pollingWait(By.xpath(getParagraphXPath(1) + - "//button[contains(@uib-tooltip, 'Bar Chart')]"), MAX_BROWSER_TIMEOUT_SEC).click(); - collector.checkThat("The output of graph mode is changed", - driver.findElement(By.xpath(getParagraphXPath(1) + "//button[contains(@class," + - "'btn btn-default btn-sm ng-binding ng-scope active')]//i")).getAttribute("class"), + pollingWait( + By.xpath(getParagraphXPath(1) + "//button[contains(@uib-tooltip, 'Bar Chart')]"), + MAX_BROWSER_TIMEOUT_SEC) + .click(); + collector.checkThat( + "The output of graph mode is changed", + driver + .findElement( + By.xpath( + getParagraphXPath(1) + + "//button[contains(@class," + + "'btn btn-default btn-sm ng-binding ng-scope active')]//i")) + .getAttribute("class"), CoreMatchers.equalTo("fa fa-bar-chart")); - pollingWait(By.xpath("//*[@id='actionbar']" + - "//button[contains(@uib-tooltip, 'Switch to personal mode')]"), MAX_BROWSER_TIMEOUT_SEC).click(); - clickAndWait(By.xpath("//div[@class='modal-dialog'][contains(.,'Do you want to personalize your analysis?')" + - "]//div[@class='modal-footer']//button[contains(.,'OK')]")); + pollingWait( + By.xpath( + "//*[@id='actionbar']" + + "//button[contains(@uib-tooltip, 'Switch to personal mode')]"), + MAX_BROWSER_TIMEOUT_SEC) + .click(); + clickAndWait( + By.xpath( + "//div[@class='modal-dialog'][contains(.,'Do you want to personalize your analysis?')" + + "]//div[@class='modal-footer']//button[contains(.,'OK')]")); authenticationIT.logoutUser("admin"); // step 2 : (user1) make sure it is on personalized mode and active graph is 'Bar chart', @@ -233,24 +280,45 @@ public class PersonalizeActionsIT extends AbstractZeppelinIT { locator = By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + noteId + "')]"); element = wait.until(ExpectedConditions.visibilityOfElementLocated(locator)); if (element.isDisplayed()) { - pollingWait(By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + noteId + "')]"), - MAX_BROWSER_TIMEOUT_SEC).click(); + pollingWait( + By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + noteId + "')]"), + MAX_BROWSER_TIMEOUT_SEC) + .click(); } - collector.checkThat("The personalized mode enables", - driver.findElement(By.xpath("//*[@id='actionbar']" + - "//button[contains(@class, 'btn btn-default btn-xs ng-scope ng-hide')]")).getAttribute("uib-tooltip"), + collector.checkThat( + "The personalized mode enables", + driver + .findElement( + By.xpath( + "//*[@id='actionbar']" + + "//button[contains(@class, 'btn btn-default btn-xs ng-scope ng-hide')]")) + .getAttribute("uib-tooltip"), CoreMatchers.equalTo("Switch to personal mode (owner can change)")); - collector.checkThat("Make sure the output of graph mode is", - driver.findElement(By.xpath(getParagraphXPath(1) + "//button[contains(@class," + - "'btn btn-default btn-sm ng-binding ng-scope active')]//i")).getAttribute("class"), + collector.checkThat( + "Make sure the output of graph mode is", + driver + .findElement( + By.xpath( + getParagraphXPath(1) + + "//button[contains(@class," + + "'btn btn-default btn-sm ng-binding ng-scope active')]//i")) + .getAttribute("class"), CoreMatchers.equalTo("fa fa-bar-chart")); - pollingWait(By.xpath(getParagraphXPath(1) + - "//button[contains(@uib-tooltip, 'Table')]"), MAX_BROWSER_TIMEOUT_SEC).click(); - collector.checkThat("The output of graph mode is not changed", - driver.findElement(By.xpath(getParagraphXPath(1) + "//button[contains(@class," + - "'btn btn-default btn-sm ng-binding ng-scope active')]//i")).getAttribute("class"), + pollingWait( + By.xpath(getParagraphXPath(1) + "//button[contains(@uib-tooltip, 'Table')]"), + MAX_BROWSER_TIMEOUT_SEC) + .click(); + collector.checkThat( + "The output of graph mode is not changed", + driver + .findElement( + By.xpath( + getParagraphXPath(1) + + "//button[contains(@class," + + "'btn btn-default btn-sm ng-binding ng-scope active')]//i")) + .getAttribute("class"), CoreMatchers.equalTo("fa fa-bar-chart")); authenticationIT.logoutUser("user1"); @@ -262,11 +330,13 @@ public class PersonalizeActionsIT extends AbstractZeppelinIT { @Test public void testDynamicFormAction() throws Exception { try { - // step 1 : (admin) login, create a new note, run a paragraph with data of spark tutorial, logout. + // step 1 : (admin) login, create a new note, run a paragraph with data of spark tutorial, + // logout. AuthenticationIT authenticationIT = new AuthenticationIT(); authenticationIT.authenticationUser("admin", "password1"); - By locator = By.xpath("//div[contains(@class, \"col-md-4\")]/div/h5/a[contains(.,'Create new" + - " note')]"); + By locator = + By.xpath( + "//div[contains(@class, \"col-md-4\")]/div/h5/a[contains(.,'Create new" + " note')]"); WebDriverWait wait = new WebDriverWait(driver, MAX_BROWSER_TIMEOUT_SEC); WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(locator)); if (element.isDisplayed()) { @@ -279,19 +349,29 @@ public class PersonalizeActionsIT extends AbstractZeppelinIT { waitForParagraph(1, "FINISHED"); } catch (TimeoutException e) { waitForParagraph(1, "ERROR"); - collector.checkThat("Exception in PersonalizeActionsIT while testDynamicFormAction, status of 1st Spark Paragraph ", - "ERROR", CoreMatchers.equalTo("FINISHED")); + collector.checkThat( + "Exception in PersonalizeActionsIT while testDynamicFormAction, status of 1st Spark Paragraph ", + "ERROR", + CoreMatchers.equalTo("FINISHED")); } - collector.checkThat("The output of graph mode is changed", - driver.findElement(By.xpath(getParagraphXPath(1) + - "//input[contains(@name, 'name')]")).getAttribute("value"), + collector.checkThat( + "The output of graph mode is changed", + driver + .findElement(By.xpath(getParagraphXPath(1) + "//input[contains(@name, 'name')]")) + .getAttribute("value"), CoreMatchers.equalTo("Before")); - pollingWait(By.xpath("//*[@id='actionbar']" + - "//button[contains(@uib-tooltip, 'Switch to personal mode')]"), MAX_BROWSER_TIMEOUT_SEC).click(); - clickAndWait(By.xpath("//div[@class='modal-dialog'][contains(.,'Do you want to personalize your analysis?')" + - "]//div[@class='modal-footer']//button[contains(.,'OK')]")); + pollingWait( + By.xpath( + "//*[@id='actionbar']" + + "//button[contains(@uib-tooltip, 'Switch to personal mode')]"), + MAX_BROWSER_TIMEOUT_SEC) + .click(); + clickAndWait( + By.xpath( + "//div[@class='modal-dialog'][contains(.,'Do you want to personalize your analysis?')" + + "]//div[@class='modal-footer']//button[contains(.,'OK')]")); authenticationIT.logoutUser("admin"); // step 2 : (user1) make sure it is on personalized mode and dynamic form value is 'Before', @@ -300,35 +380,55 @@ public class PersonalizeActionsIT extends AbstractZeppelinIT { locator = By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + noteId + "')]"); element = wait.until(ExpectedConditions.visibilityOfElementLocated(locator)); if (element.isDisplayed()) { - pollingWait(By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + noteId + "')]"), - MAX_BROWSER_TIMEOUT_SEC).click(); + pollingWait( + By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + noteId + "')]"), + MAX_BROWSER_TIMEOUT_SEC) + .click(); } - collector.checkThat("The personalized mode enables", - driver.findElement(By.xpath("//*[@id='actionbar']" + - "//button[contains(@class, 'btn btn-default btn-xs ng-scope ng-hide')]")).getAttribute("uib-tooltip"), + collector.checkThat( + "The personalized mode enables", + driver + .findElement( + By.xpath( + "//*[@id='actionbar']" + + "//button[contains(@class, 'btn btn-default btn-xs ng-scope ng-hide')]")) + .getAttribute("uib-tooltip"), CoreMatchers.equalTo("Switch to personal mode (owner can change)")); - collector.checkThat("The output of graph mode is changed", - driver.findElement(By.xpath(getParagraphXPath(1) + - "//input[contains(@name, 'name')]")).getAttribute("value"), + collector.checkThat( + "The output of graph mode is changed", + driver + .findElement(By.xpath(getParagraphXPath(1) + "//input[contains(@name, 'name')]")) + .getAttribute("value"), CoreMatchers.equalTo("Before")); - pollingWait(By.xpath(getParagraphXPath(1) + - "//input[contains(@name, 'name')]"), MAX_BROWSER_TIMEOUT_SEC).clear(); - pollingWait(By.xpath(getParagraphXPath(1) + - "//input[contains(@name, 'name')]"), MAX_BROWSER_TIMEOUT_SEC).sendKeys("After"); + pollingWait( + By.xpath(getParagraphXPath(1) + "//input[contains(@name, 'name')]"), + MAX_BROWSER_TIMEOUT_SEC) + .clear(); + pollingWait( + By.xpath(getParagraphXPath(1) + "//input[contains(@name, 'name')]"), + MAX_BROWSER_TIMEOUT_SEC) + .sendKeys("After"); runParagraph(1); try { waitForParagraph(1, "FINISHED"); } catch (TimeoutException e) { waitForParagraph(1, "ERROR"); - collector.checkThat("Exception in PersonalizeActionsIT while testDynamicFormAction, status of 1st Spark Paragraph ", - "ERROR", CoreMatchers.equalTo("FINISHED")); + collector.checkThat( + "Exception in PersonalizeActionsIT while testDynamicFormAction, status of 1st Spark Paragraph ", + "ERROR", + CoreMatchers.equalTo("FINISHED")); } - collector.checkThat("The output of graph mode is changed", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), + collector.checkThat( + "The output of graph mode is changed", + driver + .findElement( + By.xpath( + getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")) + .getText(), CoreMatchers.equalTo("Status: Before")); authenticationIT.logoutUser("user1");
