From ef9c3dfe7097e38e30c4e1b782b1bb853c2078ee Mon Sep 17 00:00:00 2001 From: Menaka Madushanka Date: Thu, 10 Mar 2016 20:19:37 +0530 Subject: [PATCH] Added comments and code restructured. --- .../iot/integration/ui/pages/UIConstants.java | 45 -------------- .../ui/pages/graphs/GraphHandler.java | 6 ++ .../ui/pages/home/IOTHomePage.java | 3 +- .../integration/ui/pages/login/LoginPage.java | 13 ----- ....java => ConnectedCupDeviceInterface.java} | 26 ++++++++- .../ConnectedCupDeviceTypeViewPage.java | 15 ++++- .../samples/ConnectedCupDeviceViewPage.java | 58 +++++++++++++++++-- .../ui/pages/samples/SampleAnalyticsPage.java | 3 - .../ui/test/samples/SampleEnrollmentTest.java | 12 +++- .../SampleEnrolmentVerificationTest.java | 7 ++- .../test/samples/SampleFunctionalityTest.java | 13 ++--- .../test/samples/SampleInstallationTest.java | 23 ++++++-- .../SampleInstallationVerification.java | 3 + 13 files changed, 138 insertions(+), 89 deletions(-) delete mode 100644 modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/UIConstants.java rename modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/samples/{VirtualSampleViewPage.java => ConnectedCupDeviceInterface.java} (80%) diff --git a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/UIConstants.java b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/UIConstants.java deleted file mode 100644 index d5ea1e86..00000000 --- a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/UIConstants.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. 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.wso2.iot.integration.ui.pages; - -import org.apache.commons.logging.Log; -import org.openqa.selenium.By; -import org.openqa.selenium.NoSuchElementException; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; - -public class UIConstants { - public static long webDriverTimeOut = 10; - public static long webDriverTime = 60; - public static int threadTimeout = 1000; - - public static boolean isElementPresent(Log log, WebDriver driver, By by) { - try { - WebDriverWait wait = new WebDriverWait(driver, webDriverTime); - wait.until(ExpectedConditions.presenceOfElementLocated(by)); - driver.findElement(by); - return true; - } catch (NoSuchElementException e) { - log.error(by.toString() + " is not present"); - return false; - } - - } - -} diff --git a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/graphs/GraphHandler.java b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/graphs/GraphHandler.java index e178517c..f76f5b60 100644 --- a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/graphs/GraphHandler.java +++ b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/graphs/GraphHandler.java @@ -153,6 +153,12 @@ public class GraphHandler { return false; } + /** + * This method returns the WebElement for graph with the given class name. + * @param graph : Outer container of the graphs + * @param className : Class name of the graph needed. + * @return the WebElement which defined by the given class name. Null if no element is found. + */ private WebElement getGraph(WebElement graph, String className) { List elements = graph.findElements(By.tagName("div")); for (WebElement e : elements) { diff --git a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/home/IOTHomePage.java b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/home/IOTHomePage.java index aa6a8a71..16d19ccd 100644 --- a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/home/IOTHomePage.java +++ b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/home/IOTHomePage.java @@ -31,8 +31,7 @@ import org.wso2.iot.integration.ui.pages.login.LoginPage; import java.io.IOException; /** - * In IOT server, this page is the Devices page for users. - * For admin this is the dashboard. + * This class represents the IOT server home page. */ public class IOTHomePage { private WebDriver driver; diff --git a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/login/LoginPage.java b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/login/LoginPage.java index 066df88a..310cb0f8 100644 --- a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/login/LoginPage.java +++ b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/login/LoginPage.java @@ -100,17 +100,4 @@ public class LoginPage { registerLink.click(); return new NewUserRegisterPage(driver); } - - public void validateForm(String username, String password) { - WebDriverWait wait = new WebDriverWait(driver, UIUtils.webDriverTimeOut); - wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath( - uiElementMapper.getElement("iot.user.login.input.username.xpath")))); - wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath( - uiElementMapper.getElement("iot.user.login.input.password.xpath")))); - userNameField.clear(); - passwordField.clear(); - userNameField.sendKeys(username); - passwordField.sendKeys(password); - loginButton.click(); - } } diff --git a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/samples/VirtualSampleViewPage.java b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/samples/ConnectedCupDeviceInterface.java similarity index 80% rename from modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/samples/VirtualSampleViewPage.java rename to modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/samples/ConnectedCupDeviceInterface.java index 42924e54..d1e0ce96 100644 --- a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/samples/VirtualSampleViewPage.java +++ b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/samples/ConnectedCupDeviceInterface.java @@ -32,12 +32,16 @@ import org.wso2.iot.integration.ui.pages.UIElementMapper; import java.io.IOException; import java.util.concurrent.TimeUnit; -public class VirtualSampleViewPage { - private Log log = LogFactory.getLog(VirtualSampleViewPage.class); +/** + * Class to represent the Connected cup device interface. + * This device is a virtual device, which allows users to change Temperature and Level values and put an order. + */ +public class ConnectedCupDeviceInterface { + private Log log = LogFactory.getLog(ConnectedCupDeviceInterface.class); private WebDriver driver; private UIElementMapper uiElementMapper; - public VirtualSampleViewPage(WebDriver driver) throws IOException { + public ConnectedCupDeviceInterface(WebDriver driver) throws IOException { this.driver = driver; this.uiElementMapper = UIElementMapper.getInstance(); WebDriverWait webDriverWait = new WebDriverWait(driver, UIUtils.webDriverTimeOut); @@ -46,6 +50,9 @@ public class VirtualSampleViewPage { } } + /** + * Method to perform the order coffee functionality. + */ public boolean orderCoffee() { if (UIUtils.isElementPresent(log, driver, By.xpath( uiElementMapper.getElement("iot.sample.orderCoffee.xpath")))) { @@ -57,6 +64,10 @@ public class VirtualSampleViewPage { return false; } + /** + * Method to change the temperature level. + * @param temp : The value to be set. + */ public boolean changeTemperature(String temp) { if (UIUtils.isElementPresent(log, driver, By.xpath( uiElementMapper.getElement("iot.sample.temperature.xpath")))) { @@ -68,6 +79,10 @@ public class VirtualSampleViewPage { return false; } + /** + * Method to change the Coffee level. + * @param level : The value to be set. + */ public boolean changeCoffeeLevel(String level) { if (UIUtils.isElementPresent(log, driver, By.xpath( uiElementMapper.getElement("iot.sample.coffee.level.xpath")))) { @@ -80,6 +95,11 @@ public class VirtualSampleViewPage { return false; } + /** + * This method performs the slider change action of the web interface. + * @param slider : The element of the slider to be changed. + * @param val : Value to be set. + */ private void moveSlider(WebElement slider, int val) { Actions move = new Actions(driver); Action action = move.dragAndDropBy(slider, 0, val).build(); diff --git a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/samples/ConnectedCupDeviceTypeViewPage.java b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/samples/ConnectedCupDeviceTypeViewPage.java index bb61adc0..85b42f1a 100644 --- a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/samples/ConnectedCupDeviceTypeViewPage.java +++ b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/samples/ConnectedCupDeviceTypeViewPage.java @@ -26,6 +26,10 @@ import org.wso2.iot.integration.ui.pages.UIElementMapper; import java.io.IOException; +/** + * This class represents the Device Type View page of the Connected cup device, which has the functionality for + * download the device agent. + */ public class ConnectedCupDeviceTypeViewPage { private WebDriver driver; private UIElementMapper uiElementMapper; @@ -40,6 +44,9 @@ public class ConnectedCupDeviceTypeViewPage { } } + /** + * This method verifies that the pop up modal for inserting a name for device is present. + */ public boolean isPopUpPresent() throws InterruptedException { WebElement createInstanceBtn = driver.findElement(By.xpath( uiElementMapper.getElement("iot.sample.connectedcup.createInstanceBtn.xpath"))); @@ -50,7 +57,13 @@ public class ConnectedCupDeviceTypeViewPage { return driver.findElement(By.xpath(uiElementMapper.getElement("iot.sample.modal.popup.xpath"))).isDisplayed(); } - public boolean enrollDevice(String name) throws InterruptedException { + /** + * This method performs the enrolment process of the connected cup device. After clicking the Download button in + * the popup, user should be navigated to the device type view page again. + * This method checks the navigation and return true if navigation is correct. + * @param name : Name for the device. + */ + public boolean enrollDevice(String name) { WebElement nameField = driver.findElement(By.xpath( uiElementMapper.getElement("iot.sample.connectedcup.createInstance.nameField.xpath"))); diff --git a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/samples/ConnectedCupDeviceViewPage.java b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/samples/ConnectedCupDeviceViewPage.java index bee9a422..d22d5a55 100644 --- a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/samples/ConnectedCupDeviceViewPage.java +++ b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/samples/ConnectedCupDeviceViewPage.java @@ -32,6 +32,15 @@ import org.wso2.iot.integration.ui.pages.graphs.GraphHandler; import java.io.IOException; import java.util.HashMap; +/** + * This class represents the Connected cup device view page. + * In this page, there are following elements. + * 1. Device overview. (Whether the device is active or not) + * 2. Device operations. (Operations which are performed on the device) + * 3. Device Stats + * + * In this class, device operations and device stats are validated. + */ public class ConnectedCupDeviceViewPage { private HashMap graphMap = new HashMap<>(); private Log log = LogFactory.getLog(ConnectedCupDeviceViewPage.class); @@ -55,16 +64,24 @@ public class ConnectedCupDeviceViewPage { graphMap = handler.getGraphMap(); } - public VirtualSampleViewPage gotoDevice() throws IOException { + /** + * This method executes Connected cup sample web app. + */ + public ConnectedCupDeviceInterface gotoDevice() throws IOException { WebDriverWait wait = new WebDriverWait(driverServer, UIUtils.webDriverTime); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath( uiElementMapper.getElement("iot.sample.connectedcup.gotodevice.xpath")))); String link = driverServer.findElement(By.xpath( uiElementMapper.getElement("iot.sample.connectedcup.gotodevice.xpath"))).getAttribute("href"); driverDevice.get(link); - return new VirtualSampleViewPage(driverDevice); + return new ConnectedCupDeviceInterface(driverDevice); } + + /** + * Gets the connected cup device web app URL. + * @return : Link of the connected cup device web app. + */ public String getDeviceLink() { WebDriverWait wait = new WebDriverWait(driverServer, UIUtils.webDriverTime); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath( @@ -73,11 +90,25 @@ public class ConnectedCupDeviceViewPage { uiElementMapper.getElement("iot.sample.connectedcup.gotodevice.xpath"))).getAttribute("href"); } - public boolean isGraphsAvailable(int count) throws IOException { + + /** + * This method checks whether there are expected number of graphs are available in the UI. + * @param count : Number of graphs expected. + * @return : True if there are count number of graphs. False otherwise. + */ + public boolean isGraphsAvailable(int count) { return handler.getGraphCount() == count; } - public boolean graphAxisName(String axis, String graphId, String axisName) throws IOException { + + /** + * Checks whether the selected graph axes represent the given values. + * @param axis : Graph axis. X or Y + * @param graphId : Id of the graph + * @param axisName : Name which is expected to be displayed. + * @return : True if given axis contains the expected title. False otherwise or, there are no graphs present. + */ + public boolean graphAxisName(String axis, String graphId, String axisName) { log.info(graphMap.toString()); if (graphMap.size() != 0) { @@ -90,7 +121,13 @@ public class ConnectedCupDeviceViewPage { return false; } - public boolean graphLegendName(String graphId, String legend) throws IOException { + /** + * Check the legend of the selected graph have the expected title. + * @param graphId : Id of the graph. + * @param legend : Expected value to be displayed in the legend. + * @return : True if legend contains the expected value. False otherwise or there are no graphs present. + */ + public boolean graphLegendName(String graphId, String legend) { log.info(graphMap.toString()); if (graphMap.size() != 0) { try { @@ -102,6 +139,11 @@ public class ConnectedCupDeviceViewPage { return false; } + /** + * Method to check the graph path is displayed in the UI for given graph. + * @param graphId : Id of the graph. + * @return : True of path is displayed. False otherwise or no graphs are present. + */ public boolean checkGraphPath(String graphId) { WebElement graph = handler.getGraphById(graphId); if (graph != null) { @@ -112,6 +154,12 @@ public class ConnectedCupDeviceViewPage { } } + /** + * Method to verify that the graphs get readings from the device. + * @param graphId : Id of the graph. + * @param value : Value which is expected to be displayed in the graph. + * @return : True if the value is displayed in the graph. False otherwise or graph is null. + */ public boolean checkGraphValues(String graphId, String value) { WebElement graph = handler.getGraphById(graphId); if (graph != null) { diff --git a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/samples/SampleAnalyticsPage.java b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/samples/SampleAnalyticsPage.java index 1530918d..98cfac95 100644 --- a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/samples/SampleAnalyticsPage.java +++ b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/samples/SampleAnalyticsPage.java @@ -1,7 +1,4 @@ package org.wso2.iot.integration.ui.pages.samples; -/** - * Created by menaka on 3/4/16. - */ public class SampleAnalyticsPage { } diff --git a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/samples/SampleEnrollmentTest.java b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/samples/SampleEnrollmentTest.java index bf198f55..13c97402 100644 --- a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/samples/SampleEnrollmentTest.java +++ b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/samples/SampleEnrollmentTest.java @@ -17,6 +17,9 @@ import javax.xml.stream.XMLStreamException; import javax.xml.xpath.XPathExpressionException; import java.io.IOException; +/** + * Test cases to verify the enrolment process. + */ public class SampleEnrollmentTest extends IOTIntegrationUIBaseTestCase { private WebDriver driver; private ConnectedCupDeviceTypeViewPage connectedCupDeviceTypeViewPage; @@ -31,13 +34,16 @@ public class SampleEnrollmentTest extends IOTIntegrationUIBaseTestCase { connectedCupDeviceTypeViewPage = enrollDevicePage.gotoConnectedCupDeviceTypeViewPage(); } - @Test(description = "Verify the pop up modal is displayed.", groups = {"iot.enroll"}, dependsOnGroups = {"iot.install"}) + @Test(description = "Verify the pop up modal is displayed.", + groups = {"iot.enroll"}, + dependsOnGroups = {"iot.install"}) public void enrollDevicePopUpModalTest() throws InterruptedException, IOException { Assert.assertTrue(connectedCupDeviceTypeViewPage.isPopUpPresent()); } - @Test(description = "Test case for device enrolment", groups = {"iot.enroll"}, dependsOnMethods = - {"enrollDevicePopUpModalTest"}) + @Test(description = "Test case for device enrolment", + groups = {"iot.enroll"}, + dependsOnMethods = {"enrollDevicePopUpModalTest"}) public void enrollDeviceTest() throws InterruptedException { Assert.assertTrue(connectedCupDeviceTypeViewPage.enrollDevice(Constants.IOT_CONNECTED_CUP_NAME)); } diff --git a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/samples/SampleEnrolmentVerificationTest.java b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/samples/SampleEnrolmentVerificationTest.java index 0d5d2fc9..2dc50424 100644 --- a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/samples/SampleEnrolmentVerificationTest.java +++ b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/samples/SampleEnrolmentVerificationTest.java @@ -28,12 +28,15 @@ import org.wso2.carbon.iot.integration.web.ui.test.LoginUtils; import org.wso2.iot.integration.ui.pages.IOTIntegrationUIBaseTestCase; import org.wso2.iot.integration.ui.pages.devices.DevicesPage; import org.wso2.iot.integration.ui.pages.samples.ConnectedCupDeviceViewPage; -import org.wso2.iot.integration.ui.pages.samples.VirtualSampleViewPage; +import org.wso2.iot.integration.ui.pages.samples.ConnectedCupDeviceInterface; import javax.xml.stream.XMLStreamException; import javax.xml.xpath.XPathExpressionException; import java.io.IOException; +/** + * Test cases to check whether the sample is enrolled correctly. + */ public class SampleEnrolmentVerificationTest extends IOTIntegrationUIBaseTestCase { private WebDriver webDriver; private DevicesPage devicesPage; @@ -66,7 +69,7 @@ public class SampleEnrolmentVerificationTest extends IOTIntegrationUIBaseTestCas @Test(description = "Verify sample functions", dependsOnMethods = {"verifyNavigationTest"}) public void sampleStartUpTest() throws IOException { - VirtualSampleViewPage sampleViewPage = connectedCupDeviceViewPage.gotoDevice(); + ConnectedCupDeviceInterface sampleViewPage = connectedCupDeviceViewPage.gotoDevice(); Assert.assertNotNull(sampleViewPage); } diff --git a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/samples/SampleFunctionalityTest.java b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/samples/SampleFunctionalityTest.java index c86756c2..92ad6d92 100644 --- a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/samples/SampleFunctionalityTest.java +++ b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/samples/SampleFunctionalityTest.java @@ -28,12 +28,11 @@ import org.wso2.carbon.iot.integration.web.ui.test.LoginUtils; import org.wso2.iot.integration.ui.pages.IOTIntegrationUIBaseTestCase; import org.wso2.iot.integration.ui.pages.devices.DevicesPage; import org.wso2.iot.integration.ui.pages.samples.ConnectedCupDeviceViewPage; -import org.wso2.iot.integration.ui.pages.samples.VirtualSampleViewPage; +import org.wso2.iot.integration.ui.pages.samples.ConnectedCupDeviceInterface; import javax.xml.stream.XMLStreamException; import javax.xml.xpath.XPathExpressionException; import java.io.IOException; -import java.util.concurrent.TimeUnit; /** * Test cases for test the functionality of the connected cup sample. @@ -45,7 +44,7 @@ import java.util.concurrent.TimeUnit; public class SampleFunctionalityTest extends IOTIntegrationUIBaseTestCase { private WebDriver driverDevice; private WebDriver driverServer; - private VirtualSampleViewPage sampleViewPage; + private ConnectedCupDeviceInterface sampleViewPage; private ConnectedCupDeviceViewPage connectedCupDeviceViewPage; @BeforeClass(alwaysRun = true) @@ -58,7 +57,7 @@ public class SampleFunctionalityTest extends IOTIntegrationUIBaseTestCase { DevicesPage devicesPage = new DevicesPage(driverServer); connectedCupDeviceViewPage = devicesPage.viewDevice(Constants.IOT_CONNECTED_CUP_NAME); driverDevice.get(connectedCupDeviceViewPage.getDeviceLink()); - sampleViewPage = new VirtualSampleViewPage(driverDevice); + sampleViewPage = new ConnectedCupDeviceInterface(driverDevice); } @Test(description = "Set the temperature level.", @@ -113,7 +112,7 @@ public class SampleFunctionalityTest extends IOTIntegrationUIBaseTestCase { groups = {"iot.sample.verify", "sample.temp"}, dependsOnGroups = {"iot.enroll.verify"}, dependsOnMethods = {"verifyGraphs"}) - public void temperatureGraphLegendTest() throws IOException { + public void temperatureGraphLegendTest() { Assert.assertTrue(connectedCupDeviceViewPage.graphLegendName(Constants.IOT_CONNECTED_CUP_TEMPERATURE_ID, Constants.IOT_CONNECTED_CUP_TEMPERATURE_LEGEND)); } @@ -138,7 +137,7 @@ public class SampleFunctionalityTest extends IOTIntegrationUIBaseTestCase { @Test(description = "Test the Y axis name of Coffee Level graph.", groups = {"iot.sample.coffee"}, dependsOnGroups = {"sample.temp"}) - public void coffeeLevelGraphYAxisNameTest() throws IOException { + public void coffeeLevelGraphYAxisNameTest() { Assert.assertTrue(connectedCupDeviceViewPage.graphAxisName(Constants.IOT_GRAPH_Y_AXIS, Constants.IOT_CONNECTED_CUP_COFFEE_LEVEL_ID, Constants.IOT_CONNECTED_CUP_COFFEE_LEVEL_Y_AXIS)); @@ -147,7 +146,7 @@ public class SampleFunctionalityTest extends IOTIntegrationUIBaseTestCase { @Test(description = "Test the X axis name of Coffee Level graph.", groups = {"iot.sample.coffee"}, dependsOnGroups = {"iot.enroll.verify", "sample.temp"}) - public void coffeeLevelGraphXAxisNameTest() throws IOException { + public void coffeeLevelGraphXAxisNameTest() { Assert.assertTrue(connectedCupDeviceViewPage.graphAxisName(Constants.IOT_GRAPH_X_AXIS, Constants.IOT_CONNECTED_CUP_COFFEE_LEVEL_ID, Constants.IOT_CONNECTED_CUP_COFFEE_LEVEL_X_AXIS)); diff --git a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/samples/SampleInstallationTest.java b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/samples/SampleInstallationTest.java index aeb46021..ce5fd048 100644 --- a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/samples/SampleInstallationTest.java +++ b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/samples/SampleInstallationTest.java @@ -75,7 +75,8 @@ public class SampleInstallationTest extends IOTIntegrationUIBaseTestCase { logViewerClient = new LogViewerClient(getBackendURL(), getSessionCookie(automationContext)); } - @Test(groups = {"iot.sample"}, description = "Verify the sample build process") + @Test(groups = {"iot.sample"}, + description = "Verify the sample build process") public void sampleBuildTest() throws IOException { String connectedCupDir = carbonHome + File.separator + "samples" + File.separator + "connectedcup"; log.info("Connected cup Sample: " + connectedCupDir); @@ -100,8 +101,9 @@ public class SampleInstallationTest extends IOTIntegrationUIBaseTestCase { } } - @Test(groups = {"iot.sample"}, description = "Verify the sample installation process", dependsOnMethods = - {"sampleBuildTest"}) + @Test(groups = {"iot.sample"}, + description = "Verify the sample installation process", + dependsOnMethods = {"sampleBuildTest"}) public void sampleInstallationTest() throws IOException { log.info("CARBON_HOME: " + System.getProperty("carbon.home")); @@ -124,8 +126,9 @@ public class SampleInstallationTest extends IOTIntegrationUIBaseTestCase { } } - @Test(groups = {"iot.sample"}, description = "Test restarting the server", dependsOnMethods = - {"sampleInstallationTest"}) + @Test(groups = {"iot.sample"}, + description = "Test restarting the server", + dependsOnMethods = {"sampleInstallationTest"}) public void serverRestartTest() { ServerConfigurationManager serverManager; try { @@ -148,6 +151,11 @@ public class SampleInstallationTest extends IOTIntegrationUIBaseTestCase { } } + /** + * Wait for a given message to be printed in terminal. Used for processes. + * @param inputStream : Input stream of the process + * @param message : The message which is to be look for + */ private boolean waitForMessage(InputStream inputStream, String message) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(inputStream)); String line; @@ -161,6 +169,11 @@ public class SampleInstallationTest extends IOTIntegrationUIBaseTestCase { return status; } + /** + * Wait until the server restarts. + * This method looks for "Mgt console URL:" to be appeared in the terminal. + * If it does not appear within the given timeout an Exception will be thrown. + */ private void waitForRestart() { ExecutorService service = Executors.newSingleThreadExecutor(); try { diff --git a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/samples/SampleInstallationVerification.java b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/samples/SampleInstallationVerification.java index 52990dfc..912ae293 100644 --- a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/samples/SampleInstallationVerification.java +++ b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/samples/SampleInstallationVerification.java @@ -32,6 +32,9 @@ import javax.xml.stream.XMLStreamException; import javax.xml.xpath.XPathExpressionException; import java.io.IOException; +/** + * Test cases to verify the sample installation is successful and device type is installed correctly. + */ public class SampleInstallationVerification extends IOTIntegrationUIBaseTestCase { private WebDriver driver;