diff --git a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/UIUtils.java b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/UIUtils.java index dba918f2..09346afb 100644 --- a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/UIUtils.java +++ b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/UIUtils.java @@ -28,6 +28,7 @@ import org.openqa.selenium.support.ui.WebDriverWait; * This class contains the constants and common methods used in pages. */ public class UIUtils { + public static long webDriverTimeOut = 10; public static long webDriverTime = 60; public static int threadTimeout = 1000; diff --git a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/devices/DevicesPage.java b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/devices/DevicesPage.java index 9c9b10bb..c87dafa3 100644 --- a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/devices/DevicesPage.java +++ b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/devices/DevicesPage.java @@ -40,6 +40,7 @@ import java.util.List; * 4. Delete the device. */ public class DevicesPage { + Log log = LogFactory.getLog(DevicesPage.class); private WebDriver driver; private UIElementMapper uiElementMapper; @@ -98,7 +99,6 @@ public class DevicesPage { */ private String getLink(WebElement element, String... lookupText) { String link = element.getAttribute("href"); - log.info("Link -----------------------> " + link); boolean check = true; for (String s : lookupText) { if (!link.contains(s)) { @@ -107,4 +107,5 @@ public class DevicesPage { } return check ? link : null; } + } diff --git a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/devices/EnrollDevicePage.java b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/devices/EnrollDevicePage.java index 3e68e9c2..a6c55025 100644 --- a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/devices/EnrollDevicePage.java +++ b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/devices/EnrollDevicePage.java @@ -35,6 +35,7 @@ import java.io.IOException; * This page lists the all device types which are currently installed in the IOT server. */ public class EnrollDevicePage { + private WebDriver driver; private UIElementMapper uiElementMapper; private Log log = LogFactory.getLog(EnrollDevicePage.class); diff --git a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/graphs/Graph.java b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/graphs/Graph.java index 483558de..1058f2f6 100644 --- a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/graphs/Graph.java +++ b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/graphs/Graph.java @@ -21,6 +21,7 @@ package org.wso2.iot.integration.ui.pages.graphs; * Class to store graph data */ public class Graph { + private String graphId; private String yAxis; private String xAxis; @@ -59,4 +60,5 @@ public class Graph { return String.format("The graph for graph id : %s, X - axis : %s, Y - axis : %s, legend : %s ", graphId, xAxis, yAxis, legend); } + } 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 8a5e25aa..6efcde09 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 @@ -25,12 +25,13 @@ import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; -import org.wso2.iot.integration.ui.pages.UIUtils; import org.wso2.iot.integration.ui.pages.UIElementMapper; +import org.wso2.iot.integration.ui.pages.UIUtils; import java.io.IOException; import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.concurrent.TimeUnit; /** @@ -59,7 +60,7 @@ public class GraphHandler { * This method is to get all the elements of graphs and store in a Hash map. * This simplifies iterating through the DOM every time finding for an element when having multiple graphs. */ - public HashMap getGraphMap() { + public Map getGraphMap() { HashMap graphMap = new HashMap<>(); WebDriverWait wait = new WebDriverWait(driver, UIUtils.webDriverTimeOut); wait.until(ExpectedConditions.visibilityOf(driver.findElement(By.xpath( @@ -78,7 +79,6 @@ public class GraphHandler { By.tagName("span")).getText(); g.setLegend(legend); graphMap.put(key, g); - log.info(g.toString()); } return graphMap; } @@ -90,7 +90,7 @@ public class GraphHandler { try { graphs = this.graphDiv.findElements(By.xpath("//*[contains(@class, \"chartWrapper\")]")); } catch (NoSuchElementException e) { - log.info("Graph element not found"); + log.error(String.format("Graph element is not found. \n %s", e.getMessage())); } return graphs.size(); } @@ -106,7 +106,6 @@ public class GraphHandler { for (int i = 0; i < graphs.size() && graphs.size() > 0; i++) { WebElement element = graphs.get(i); if (element.getAttribute("id").toLowerCase().replace(" ", "").contains(graphId.toLowerCase())) { - log.info(">>>>>>>>>>>>>>>>>>> Graph for id: " + graphId + " is present "); return element; } } @@ -124,7 +123,7 @@ public class GraphHandler { WebElement graphContainer = getGraph(graph, uiElementMapper.getElement("iot.stat.graph.class.name")); return graphContainer != null && graphContainer.findElement(By.tagName("path")).isDisplayed(); } catch (NoSuchElementException e) { - log.error("No element found. " + e.getMessage()); + log.error(String.format("No element found. \n %s", e.getMessage())); return false; } } @@ -145,7 +144,6 @@ public class GraphHandler { values = graphContainer.findElement(By.tagName("path")).getAttribute("d").split(","); for (String value : values) { if (value.contains(val)) { - log.info("Graph values : " + value); return true; } } @@ -155,7 +153,8 @@ public class GraphHandler { /** * This method returns the WebElement for graph with the given class name. - * @param graph : Outer container of the graphs + * + * @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. */ diff --git a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/groups/DeviceAddGroupPage.java b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/groups/DeviceAddGroupPage.java index ca7160c4..1db9969d 100644 --- a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/groups/DeviceAddGroupPage.java +++ b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/groups/DeviceAddGroupPage.java @@ -88,4 +88,5 @@ public class DeviceAddGroupPage { return driver.findElement(By.xpath( uiElementMapper.getElement("iot.device.groups.add.emptyfrom.error"))).getText(); } + } diff --git a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/groups/DeviceGroupsPage.java b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/groups/DeviceGroupsPage.java index 620c2ee0..8a6d6ac5 100644 --- a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/groups/DeviceGroupsPage.java +++ b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/groups/DeviceGroupsPage.java @@ -32,6 +32,7 @@ import java.util.List; * This class represents the Groups page. */ public class DeviceGroupsPage { + private WebDriver driver; private UIElementMapper uiElementMapper; @@ -73,4 +74,5 @@ public class DeviceGroupsPage { } return false; } + } 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 cb345ef0..28998e05 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 @@ -34,6 +34,7 @@ import java.io.IOException; * This class represents the IOT server home page. */ public class IOTHomePage { + private WebDriver driver; private UIElementMapper uiElementMapper; 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 310cb0f8..8a23e407 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 @@ -37,6 +37,7 @@ import java.io.IOException; * */ public class LoginPage { + private static final Log log = LogFactory.getLog(LoginPage.class); private WebDriver driver; private UIElementMapper uiElementMapper; @@ -100,4 +101,5 @@ public class LoginPage { registerLink.click(); return new NewUserRegisterPage(driver); } + } diff --git a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/samples/ConnectedCupDeviceInterface.java b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/samples/ConnectedCupDeviceInterface.java index a4124980..2ea11f7a 100644 --- a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/samples/ConnectedCupDeviceInterface.java +++ b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/samples/ConnectedCupDeviceInterface.java @@ -37,6 +37,7 @@ import java.util.concurrent.TimeUnit; * 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; @@ -109,4 +110,5 @@ public class ConnectedCupDeviceInterface { Action action = move.dragAndDropBy(slider, 0, val).build(); action.perform(); } -} \ No newline at end of file + +} 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 eddc3734..2fa4e605 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 @@ -33,6 +33,7 @@ import java.io.IOException; * download the device agent. */ public class ConnectedCupDeviceTypeViewPage { + private WebDriver driver; private UIElementMapper uiElementMapper; @@ -78,4 +79,5 @@ public class ConnectedCupDeviceTypeViewPage { return driver.findElement(By.xpath( uiElementMapper.getElement("iot.sample.connectedcup.page.title"))).getText().contains("Connected Cup"); } + } 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 ce3fb960..5631a564 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 @@ -31,6 +31,7 @@ import org.wso2.iot.integration.ui.pages.graphs.GraphHandler; import java.io.IOException; import java.util.HashMap; +import java.util.Map; import java.util.concurrent.TimeUnit; /** @@ -43,7 +44,8 @@ import java.util.concurrent.TimeUnit; * In this class, device operations and device stats are validated. */ public class ConnectedCupDeviceViewPage { - private HashMap graphMap = new HashMap<>(); + + private Map graphMap = new HashMap<>(); private Log log = LogFactory.getLog(ConnectedCupDeviceViewPage.class); private WebDriver driverServer; private WebDriver driverDevice; @@ -108,8 +110,6 @@ public class ConnectedCupDeviceViewPage { * @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) { if (axis.toLowerCase().contains("x")) { return graphMap.get(graphId).getxAxis().contains(axisName); @@ -128,7 +128,6 @@ public class ConnectedCupDeviceViewPage { * @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) { if (graphMap.get(graphId) != null){ return graphMap.get(graphId).getLegend().contains(legend); @@ -150,7 +149,7 @@ public class ConnectedCupDeviceViewPage { if (graph != null) { return handler.isPathAvailable(graph); } else { - log.error(String.format("Graph for Id %s is not present......", graphId)); + log.error(String.format("Graph for Id %s is not present.", graphId)); return false; } } @@ -167,8 +166,9 @@ public class ConnectedCupDeviceViewPage { if (graph != null) { return handler.isPathGetValues(graph, value); } else { - log.error(String.format("Graph for Id %s is not present......", graphId)); + log.error(String.format("Graph for Id %s is not present.", graphId)); return false; } } + } diff --git a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/uesr/AddUserPage.java b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/uesr/AddUserPage.java index f5972b00..02fce92f 100644 --- a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/uesr/AddUserPage.java +++ b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/uesr/AddUserPage.java @@ -32,6 +32,7 @@ import java.io.IOException; * This class represents the add user page of the IOT server. */ public class AddUserPage { + private WebDriver driver; private UIElementMapper uiElementMapper; @@ -75,4 +76,5 @@ public class AddUserPage { return new UserAddedConfirmationPage(driver); } + } \ No newline at end of file diff --git a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/uesr/EditUserPage.java b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/uesr/EditUserPage.java index 4a2b18af..dcba72e6 100644 --- a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/uesr/EditUserPage.java +++ b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/uesr/EditUserPage.java @@ -30,6 +30,7 @@ import org.wso2.iot.integration.ui.pages.UIElementMapper; * This class represents the Edit user page of the IOT server */ public class EditUserPage { + private static final Log log = LogFactory.getLog(EditUserPage.class); private WebDriver driver; private UIElementMapper uiElementMapper; @@ -47,4 +48,5 @@ public class EditUserPage { public void editUser(String password, String firstName, String lastName) { driver.findElement(By.xpath(uiElementMapper.getElement("iot.user.add.input.password.xpath"))); } + } diff --git a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/uesr/NewUserRegisterPage.java b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/uesr/NewUserRegisterPage.java index 86d821f7..90582de4 100644 --- a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/uesr/NewUserRegisterPage.java +++ b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/uesr/NewUserRegisterPage.java @@ -33,6 +33,7 @@ import java.io.IOException; * User registration page has the registration form for new users to enter the required data and the submit button. */ public class NewUserRegisterPage { + private WebDriver driver; private WebElement firstNameField; private WebElement lastNameField; @@ -126,4 +127,5 @@ public class NewUserRegisterPage { passwordField.clear(); passwordConfirmationField.clear(); } + } diff --git a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/uesr/UserAddedConfirmationPage.java b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/uesr/UserAddedConfirmationPage.java index 6e5d55a0..a32087e4 100644 --- a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/uesr/UserAddedConfirmationPage.java +++ b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/uesr/UserAddedConfirmationPage.java @@ -33,4 +33,5 @@ public class UserAddedConfirmationPage { driver.findElement(By.xpath(uiElementMapper.getElement("iot.admin.addUser.view.btn.xpath"))).click(); } + } diff --git a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/uesr/UserListingPage.java b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/uesr/UserListingPage.java index b5a7b117..7d6fe4e1 100644 --- a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/uesr/UserListingPage.java +++ b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/uesr/UserListingPage.java @@ -31,6 +31,7 @@ import java.io.IOException; * Class to represent the user listing page. */ public class UserListingPage { + private WebDriver driver; private UIElementMapper uiElementMapper; @@ -63,4 +64,5 @@ public class UserListingPage { return new UserListingPage(driver); } + } diff --git a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/uesr/ViewUserPage.java b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/uesr/ViewUserPage.java index 6fd63613..a4d3964e 100644 --- a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/uesr/ViewUserPage.java +++ b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/uesr/ViewUserPage.java @@ -29,6 +29,7 @@ import org.wso2.iot.integration.ui.pages.UIElementMapper; * Class to represent the user view. */ public class ViewUserPage { + private static final Log log = LogFactory.getLog(ViewUserPage.class); private WebDriver driver; private UIElementMapper uiElementMapper; @@ -42,4 +43,5 @@ public class ViewUserPage { throw new IllegalStateException("This is not the User view page"); } } + } diff --git a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/common/Constants.java b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/common/Constants.java index d5cc5726..da35a066 100644 --- a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/common/Constants.java +++ b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/common/Constants.java @@ -31,69 +31,92 @@ public class Constants { public static final String GROUP_NAME = "group1"; public static final String GROUP_DESCRIPTION = "This is a test group"; - public static final String LOGIN_USER_NAME_ERROR = "Please enter a username"; - public static final String LOGIN_PASSWORD_ERROR = "Please provide a password"; - public static final String LOGIN_FAILED_ERROR = "Incorrect username or password.!"; - public static final String LOGIN_SHORT_PASSWORD_ERROR = "Your password must be at least 3 characters long"; - - public static final String LOGIN_WRONG_USER_NAME = "admnnn"; - public static final String LOGIN_WRONG_USER_PASSWORD = "admmmm"; - public static final String LOGIN_SHORT_PASSWORD = "ad"; - - public static final String ADD_USER_FIRST_NAME = "User"; - public static final String ADD_USER_LAST_NAME = "User"; - public static final String ADD_USER_EMAIL = "user@wso2.com"; - public static final String ADD_USER_EMAIL_ERROR = "user.com"; - public static final String ADD_USER_USER_NAME = "user"; - public static final String ADD_USER_SHORT_USER_NAME = "us"; - - public static final String REGISTER_USER_FIRST_NAME = "Firstname"; - public static final String REGISTER_USER_LAST_NAME = "Lastname"; - public static final String REGISTER_USER_USER_NAME = "testUser"; - public static final String REGISTER_USER_PASSWORD = "testPassword"; - public static final String REGISTER_USER_CONFIRM_PASSWORD = "testPassword"; - public static final String REGISTER_USER_EMAIL = "userName@wso2.com"; - - public static final String IOT_SERVER_LOGIN_PAGE_TITLE = "Login | IoT Server"; - - public static final String ADD_USER_SHORT_USER_NAME_ERROR_MSG = "Username must be between 3 and 30 characters long."; - public static final String ADD_USER_FIRST_NAME_ERROR_MSG = "Firstname is a required field. It cannot be empty."; - public static final String ADD_USER_LAST_NAME_ERROR_MSG = "Lastname is a required field. It cannot be empty."; - public static final String ADD_USER_NO_EMAIL_ERROR_MSG = "Email is a required field. It cannot be empty."; - public static final String ADD_USER_WRONG_EMAIL_ERROR_MSG = "Provided email is invalid. Please check."; - public static final String ALERT_NOT_PRESENT = "Alert is not present."; public static final String CARBON_HOME = "carbon.home"; - public static final String OS_NAME = "os.name"; + public static final String OS_NAME = "os.name"; public static final String BUILD_SUCCESS_MSG = "BUILD SUCCESS"; public static final int IOT_RESTART_THREAD_TIMEOUT = 30; - public static final String IOT_CONNECTED_CUP_LEVEl = "35"; - public static final String IOT_CONNECTED_CUP_TEMPERATURE = "53"; - public static final String IOT_GRAPH_X_AXIS = "x"; public static final String IOT_GRAPH_Y_AXIS = "y"; - public static final String IOT_CONNECTED_CUP_TEMPERATURE_ID = "Temperature"; - public static final String IOT_CONNECTED_CUP_TEMPERATURE_LEGEND = "Temperature"; - public static final String IOT_CONNECTED_CUP_TEMPERATURE_GRAPH_ID = "temperature"; - public static final String IOT_CONNECTED_CUP_TEMPERATURE_Y_AXIS = "Temperature"; - public static final String IOT_CONNECTED_CUP_TEMPERATURE_X_AXIS = "time"; - - public static final String IOT_CONNECTED_CUP_COFFEE_LEVEL_ID = "Coffee Level"; - public static final String IOT_CONNECTED_CUP_COFFEE_LEVEL_LEGEND = "Coffee Level"; - public static final String IOT_CONNECTED_CUP_COFFEE_LEVEL_GRAPH_ID = "coffeelevel"; - public static final String IOT_CONNECTED_CUP_COFFEE_LEVEL_Y_AXIS = "Coffeelevel"; - public static final String IOT_CONNECTED_CUP_COFFEE_LEVEL_X_AXIS = "time"; - - public static final String IOT_TEST_GROUP_SAMPLE_INSTALL = "iot.sample"; - public static final String IOT_TEST_GROUP_SAMPLE_INSTALL_VERIFY = "iot.sample.install"; - public static final String IOT_TEST_GROUP_SAMPLE_VERIFY = "iot.sample.install.verify"; - public static final String IOT_TEST_GROUP_SAMPLE_ENROLL = "iot.sample.enroll"; - public static final String IOT_TEST_GROUP_SAMPLE_ENROLL_VERIFY = "iot.sample.enroll.verify"; - public static final String IOT_TEST_GROUP_SAMPLE_TEMPERATURE = "iot.sample.temp"; - public static final String IOT_TEST_GROUP_SAMPLE_COFFEELEVEL = "iot.sample.level"; + public static class ConnectedCup { + + public static final String COFFEE_LEVEl = "35"; + + public static final String TEMPERATURE = "53"; + public static final String COFFEE_LEVEL_ID = "Coffee Level"; + + public static final String COFFEE_LEVEL_LEGEND = "Coffee Level"; + public static final String COFFEE_LEVEL_GRAPH_ID = "coffeelevel"; + public static final String COFFEE_LEVEL_Y_AXIS = "Coffeelevel"; + public static final String COFFEE_LEVEL_X_AXIS = "time"; + public static final String TEMPERATURE_ID = "Temperature"; + + public static final String TEMPERATURE_LEGEND = "Temperature"; + public static final String TEMPERATURE_GRAPH_ID = "temperature"; + public static final String TEMPERATURE_Y_AXIS = "Temperature"; + public static final String TEMPERATURE_X_AXIS = "time"; + + } + + public static class User { + + public static class Login { + + public static final String USER_NAME_ERROR = "Please enter a username"; + public static final String PASSWORD_ERROR = "Please provide a password"; + public static final String FAILED_ERROR = "Incorrect username or password.!"; + public static final String SHORT_PASSWORD_ERROR = "Your password must be at least 3 characters long"; + public static final String WRONG_USER_NAME = "admnnn"; + public static final String WRONG_USER_PASSWORD = "admmmm"; + public static final String SHORT_PASSWORD = "ad"; + public static final String PAGE_TITLE = "Login | IoT Server"; + + } + + public static class Add { + + public static final String FIRST_NAME = "User"; + public static final String LAST_NAME = "User"; + public static final String EMAIL = "user@wso2.com"; + public static final String EMAIL_ERROR = "user.com"; + public static final String USER_NAME = "user"; + public static final String SHORT_USER_NAME = "us"; + public static final String SHORT_USER_NAME_ERROR_MSG = "Username must be between 3 and 30 characters long."; + public static final String FIRST_NAME_ERROR_MSG = "Firstname is a required field. It cannot be empty."; + public static final String LAST_NAME_ERROR_MSG = "Lastname is a required field. It cannot be empty."; + public static final String NO_EMAIL_ERROR_MSG = "Email is a required field. It cannot be empty."; + public static final String WRONG_EMAIL_ERROR_MSG = "Provided email is invalid. Please check."; + + } + + public static class Register { + + public static final String FIRST_NAME = "Firstname"; + public static final String LAST_NAME = "Lastname"; + public static final String USER_NAME = "testUser"; + public static final String PASSWORD = "testPassword"; + public static final String CONFIRM_PASSWORD = "testPassword"; + public static final String EMAIL = "userName@wso2.com"; + + } + + } + + public static class TestSample { + + public static final String SAMPLE_INSTALL = "iot.sample"; + public static final String INSTALL_VERIFY = "iot.sample.install"; + public static final String VERIFY = "iot.sample.install.verify"; + public static final String ENROLL = "iot.sample.enroll"; + public static final String ENROLL_VERIFY = "iot.sample.enroll.verify"; + public static final String TEMPERATURE = "iot.sample.temp"; + public static final String COFFEE_LEVEL = "iot.sample.level"; + + } + } diff --git a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/common/IOTIntegrationUIBaseTestCase.java b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/common/IOTIntegrationUIBaseTestCase.java index 14d77b32..f0de6e10 100644 --- a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/common/IOTIntegrationUIBaseTestCase.java +++ b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/common/IOTIntegrationUIBaseTestCase.java @@ -30,6 +30,7 @@ import java.rmi.RemoteException; public class IOTIntegrationUIBaseTestCase { + protected AutomationContext automationContext; protected void init() throws IOException, XMLStreamException, XPathExpressionException { @@ -61,4 +62,5 @@ public class IOTIntegrationUIBaseTestCase { protected String getLoginURL() throws XPathExpressionException { return HomePageGenerator.getProductHomeURL(automationContext); } + } diff --git a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/group/DeviceGroupFailTest.java b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/group/DeviceGroupFailTest.java index 1ad58c34..57f899b6 100644 --- a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/group/DeviceGroupFailTest.java +++ b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/group/DeviceGroupFailTest.java @@ -34,6 +34,7 @@ import org.wso2.iot.integration.ui.pages.groups.DeviceAddGroupPage; * So the failing scenario is sending the form with empty group name. */ public class DeviceGroupFailTest extends IOTIntegrationUIBaseTestCase { + private WebDriver driver; @BeforeClass(alwaysRun = true) @@ -55,4 +56,5 @@ public class DeviceGroupFailTest extends IOTIntegrationUIBaseTestCase { public void tearDown() throws Exception { driver.quit(); } + } diff --git a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/group/DeviceGroupTest.java b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/group/DeviceGroupTest.java index 9c4bc9a2..d3e52f21 100644 --- a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/group/DeviceGroupTest.java +++ b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/group/DeviceGroupTest.java @@ -37,6 +37,7 @@ import java.io.IOException; * Test cases for grouping feature of IOT server. */ public class DeviceGroupTest extends IOTIntegrationUIBaseTestCase { + private WebDriver driver; private IOTAdminDashboard adminDashboard; @@ -65,4 +66,5 @@ public class DeviceGroupTest extends IOTIntegrationUIBaseTestCase { public void tearDown() throws Exception { driver.quit(); } + } diff --git a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/login/LoginFormValidationTest.java b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/login/LoginFormValidationTest.java index bf34c201..b727101e 100644 --- a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/login/LoginFormValidationTest.java +++ b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/login/LoginFormValidationTest.java @@ -67,21 +67,21 @@ public class LoginFormValidationTest extends IOTIntegrationUIBaseTestCase { if (!alertUserName.isDisplayed()) Assert.assertTrue(false, "Alert for user name is not present."); if (!alertPassword.isDisplayed()) Assert.assertTrue(false, "Alert for password is not present."); - Assert.assertEquals(alertUserName.getText(), Constants.LOGIN_USER_NAME_ERROR); - Assert.assertEquals(alertPassword.getText(), Constants.LOGIN_PASSWORD_ERROR); + Assert.assertEquals(alertUserName.getText(), Constants.User.Login.USER_NAME_ERROR); + Assert.assertEquals(alertPassword.getText(), Constants.User.Login.PASSWORD_ERROR); } @Test(description = "Test for incorrect username") public void incorrectUserNameTest() throws Exception { clearForm(); - userNameField.sendKeys(Constants.LOGIN_WRONG_USER_NAME); + userNameField.sendKeys(Constants.User.Login.WRONG_USER_NAME); passwordField.sendKeys(automationContext.getSuperTenant().getTenantAdmin().getPassword()); loginButton.click(); WebElement alert = driver.findElement(By.xpath(uiElementMapper.getElement("iot.user.login.incorrect.xpath"))); if (alert.isDisplayed()) { - Assert.assertEquals(alert.getText(), Constants.LOGIN_FAILED_ERROR); + Assert.assertEquals(alert.getText(), Constants.User.Login.FAILED_ERROR); } else { Assert.assertTrue(false, Constants.ALERT_NOT_PRESENT); } @@ -92,12 +92,12 @@ public class LoginFormValidationTest extends IOTIntegrationUIBaseTestCase { public void incorrectPasswordTest() throws Exception { clearForm(); userNameField.sendKeys(automationContext.getSuperTenant().getTenantAdmin().getPassword()); - passwordField.sendKeys(Constants.LOGIN_WRONG_USER_PASSWORD); + passwordField.sendKeys(Constants.User.Login.WRONG_USER_PASSWORD); loginButton.click(); WebElement alert = driver.findElement(By.xpath(uiElementMapper.getElement("iot.user.login.incorrect.xpath"))); if (alert.isDisplayed()) { - Assert.assertEquals(alert.getText(), Constants.LOGIN_FAILED_ERROR); + Assert.assertEquals(alert.getText(), Constants.User.Login.FAILED_ERROR); } else { Assert.assertTrue(false, Constants.ALERT_NOT_PRESENT); } @@ -108,12 +108,12 @@ public class LoginFormValidationTest extends IOTIntegrationUIBaseTestCase { public void shortPasswordTest() throws Exception { clearForm(); userNameField.sendKeys(automationContext.getSuperTenant().getTenantAdmin().getUserName()); - passwordField.sendKeys(Constants.LOGIN_SHORT_PASSWORD); + passwordField.sendKeys(Constants.User.Login.SHORT_PASSWORD); loginButton.click(); WebElement alert = driver.findElement(By.id(uiElementMapper.getElement("iot.user.login.password.error"))); if (alert.isDisplayed()) { - Assert.assertEquals(alert.getText(), Constants.LOGIN_SHORT_PASSWORD_ERROR); + Assert.assertEquals(alert.getText(), Constants.User.Login.SHORT_PASSWORD_ERROR); } else { Assert.assertTrue(false, Constants.ALERT_NOT_PRESENT); } @@ -135,4 +135,5 @@ public class LoginFormValidationTest extends IOTIntegrationUIBaseTestCase { public void tearDown() throws Exception { driver.quit(); } + } diff --git a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/login/LoginTest.java b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/login/LoginTest.java index f55f4326..4bdf52ed 100644 --- a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/login/LoginTest.java +++ b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/login/LoginTest.java @@ -35,6 +35,7 @@ import java.io.IOException; * Test Login as Admin */ public class LoginTest extends IOTIntegrationUIBaseTestCase { + private WebDriver driver; @BeforeClass(alwaysRun = true) @@ -57,4 +58,5 @@ public class LoginTest extends IOTIntegrationUIBaseTestCase { public void tearDown(){ driver.quit(); } + } 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 a9dfef07..c906eb26 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 @@ -38,6 +38,7 @@ import java.io.IOException; * Test cases to verify the enrolment process. */ public class SampleEnrollmentTest extends IOTIntegrationUIBaseTestCase { + private WebDriver driver; private ConnectedCupDeviceTypeViewPage connectedCupDeviceTypeViewPage; @@ -52,14 +53,14 @@ public class SampleEnrollmentTest extends IOTIntegrationUIBaseTestCase { } @Test(description = "Verify the pop up modal is displayed.", - groups = Constants.IOT_TEST_GROUP_SAMPLE_ENROLL, - dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_INSTALL_VERIFY) + groups = Constants.TestSample.ENROLL, + dependsOnGroups = Constants.TestSample.INSTALL_VERIFY) public void enrollDevicePopUpModalTest() throws InterruptedException, IOException { Assert.assertTrue(connectedCupDeviceTypeViewPage.isPopUpPresent()); } @Test(description = "Test case for device enrolment", - groups = Constants.IOT_TEST_GROUP_SAMPLE_ENROLL, + groups = Constants.TestSample.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 22b36e67..1dc592bc 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 @@ -38,6 +38,7 @@ 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; private ConnectedCupDeviceViewPage connectedCupDeviceViewPage; @@ -52,15 +53,15 @@ public class SampleEnrolmentVerificationTest extends IOTIntegrationUIBaseTestCas } @Test(description = "Verify enrolment of the sample device", - groups = Constants.IOT_TEST_GROUP_SAMPLE_ENROLL_VERIFY, - dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_ENROLL) + groups = Constants.TestSample.ENROLL_VERIFY, + dependsOnGroups = Constants.TestSample.ENROLL) public void verifyEnrollmentTest() { Assert.assertTrue(devicesPage.isDeviceEnrolled(Constants.IOT_CONNECTED_CUP_NAME)); } @Test(description = "Verify navigation to device view", dependsOnMethods = "verifyEnrollmentTest", - groups = Constants.IOT_TEST_GROUP_SAMPLE_ENROLL_VERIFY) + groups = Constants.TestSample.ENROLL_VERIFY) public void verifyNavigationTest() throws IOException { connectedCupDeviceViewPage = devicesPage.viewDevice(Constants.IOT_CONNECTED_CUP_NAME); Assert.assertNotNull(connectedCupDeviceViewPage); @@ -77,4 +78,5 @@ public class SampleEnrolmentVerificationTest extends IOTIntegrationUIBaseTestCas public void tearDown() { webDriver.quit(); } + } 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 a4993d55..d8bde532 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 @@ -42,10 +42,11 @@ import java.io.IOException; * 3. Test the stat graphs */ public class SampleFunctionalityTest extends IOTIntegrationUIBaseTestCase { + private WebDriver driverDevice; private WebDriver driverServer; private ConnectedCupDeviceInterface sampleViewPage; - private ConnectedCupDeviceViewPage connectedCupDeviceViewPage; + private ConnectedCupDeviceViewPage deviceViewPage; @BeforeClass(alwaysRun = true) public void setUp() throws XPathExpressionException, XMLStreamException, IOException { @@ -55,130 +56,132 @@ public class SampleFunctionalityTest extends IOTIntegrationUIBaseTestCase { LoginUtils.login(driverServer, automationContext, getWebAppURL()); driverServer.get(getWebAppURL() + Constants.IOT_DEVICES_URL); DevicesPage devicesPage = new DevicesPage(driverServer); - connectedCupDeviceViewPage = devicesPage.viewDevice(Constants.IOT_CONNECTED_CUP_NAME); - driverDevice.get(connectedCupDeviceViewPage.getDeviceLink()); + deviceViewPage = devicesPage.viewDevice(Constants.IOT_CONNECTED_CUP_NAME); + + //Opens the connected cup device interface in the browser. + driverDevice.get(deviceViewPage.getDeviceLink()); sampleViewPage = new ConnectedCupDeviceInterface(driverDevice); } @Test(description = "Set the temperature level.", - groups = Constants.IOT_TEST_GROUP_SAMPLE_VERIFY, - dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_ENROLL_VERIFY) + groups = Constants.TestSample.VERIFY, + dependsOnGroups = Constants.TestSample.ENROLL_VERIFY) public void setTemperatureTest() { - Assert.assertTrue(sampleViewPage.changeTemperature(Constants.IOT_CONNECTED_CUP_TEMPERATURE)); + Assert.assertTrue(sampleViewPage.changeTemperature(Constants.ConnectedCup.TEMPERATURE)); } @Test(description = "Set the coffee level.", - groups = Constants.IOT_TEST_GROUP_SAMPLE_VERIFY, - dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_ENROLL_VERIFY) + groups = Constants.TestSample.VERIFY, + dependsOnGroups = Constants.TestSample.ENROLL_VERIFY) public void setCoffeeLevelTest() throws IOException { - Assert.assertTrue(sampleViewPage.changeCoffeeLevel(Constants.IOT_CONNECTED_CUP_LEVEl)); + Assert.assertTrue(sampleViewPage.changeCoffeeLevel(Constants.ConnectedCup.COFFEE_LEVEl)); } @Test(description = "Verify order coffee function.", - groups = Constants.IOT_TEST_GROUP_SAMPLE_VERIFY, - dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_ENROLL_VERIFY) + groups = Constants.TestSample.VERIFY, + dependsOnGroups = Constants.TestSample.ENROLL_VERIFY) public void orderCoffeeTest() throws IOException, InterruptedException { Assert.assertTrue(sampleViewPage.orderCoffee()); } @Test(description = "Test the graphs are present in device view.", - groups = Constants.IOT_TEST_GROUP_SAMPLE_VERIFY, + groups = Constants.TestSample.VERIFY, dependsOnMethods = {"setTemperatureTest", "setCoffeeLevelTest", "orderCoffeeTest"}) public void verifyGraphs() throws IOException { - Assert.assertTrue(connectedCupDeviceViewPage.isGraphsAvailable(2)); + Assert.assertTrue(deviceViewPage.isGraphsAvailable(2)); } @Test(description = "Test the Y axis name of Temperature graph.", - groups = {Constants.IOT_TEST_GROUP_SAMPLE_VERIFY, - Constants.IOT_TEST_GROUP_SAMPLE_TEMPERATURE}, - dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_ENROLL_VERIFY, + groups = {Constants.TestSample.VERIFY, + Constants.TestSample.TEMPERATURE}, + dependsOnGroups = Constants.TestSample.ENROLL_VERIFY, dependsOnMethods = {"verifyGraphs"}) public void temperatureGraphYAxisNameTest() throws IOException { - Assert.assertTrue(connectedCupDeviceViewPage.graphAxisName(Constants.IOT_GRAPH_Y_AXIS, - Constants.IOT_CONNECTED_CUP_TEMPERATURE_ID, - Constants.IOT_CONNECTED_CUP_TEMPERATURE_Y_AXIS)); + Assert.assertTrue(deviceViewPage.graphAxisName(Constants.IOT_GRAPH_Y_AXIS, + Constants.ConnectedCup.TEMPERATURE_ID, + Constants.ConnectedCup.TEMPERATURE_Y_AXIS)); } @Test(description = "Test the X axis name of Temperature graph.", - groups = {Constants.IOT_TEST_GROUP_SAMPLE_VERIFY, - Constants.IOT_TEST_GROUP_SAMPLE_TEMPERATURE}, - dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_ENROLL_VERIFY, + groups = {Constants.TestSample.VERIFY, + Constants.TestSample.TEMPERATURE}, + dependsOnGroups = Constants.TestSample.ENROLL_VERIFY, dependsOnMethods = {"verifyGraphs"}) public void temperatureGraphXAxisNameTest() throws IOException { - Assert.assertTrue(connectedCupDeviceViewPage.graphAxisName(Constants.IOT_GRAPH_X_AXIS, - Constants.IOT_CONNECTED_CUP_TEMPERATURE_ID, - Constants.IOT_CONNECTED_CUP_TEMPERATURE_X_AXIS)); + Assert.assertTrue(deviceViewPage.graphAxisName(Constants.IOT_GRAPH_X_AXIS, + Constants.ConnectedCup.TEMPERATURE_ID, + Constants.ConnectedCup.TEMPERATURE_X_AXIS)); } @Test(description = "Test the whether the Coffee Level graph legend is present.", - groups = {Constants.IOT_TEST_GROUP_SAMPLE_VERIFY, - Constants.IOT_TEST_GROUP_SAMPLE_TEMPERATURE}, - dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_ENROLL_VERIFY, + groups = {Constants.TestSample.VERIFY, + Constants.TestSample.TEMPERATURE}, + dependsOnGroups = Constants.TestSample.ENROLL_VERIFY, dependsOnMethods = {"verifyGraphs"}) public void temperatureGraphLegendTest() { - Assert.assertTrue(connectedCupDeviceViewPage.graphLegendName(Constants.IOT_CONNECTED_CUP_TEMPERATURE_ID, - Constants.IOT_CONNECTED_CUP_TEMPERATURE_LEGEND)); + Assert.assertTrue(deviceViewPage.graphLegendName(Constants.ConnectedCup.TEMPERATURE_ID, + Constants.ConnectedCup.TEMPERATURE_LEGEND)); } @Test(description = "Test the whether the Temperature graph path is visible.", - groups = {Constants.IOT_TEST_GROUP_SAMPLE_VERIFY, - Constants.IOT_TEST_GROUP_SAMPLE_TEMPERATURE}, - dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_ENROLL_VERIFY, + groups = {Constants.TestSample.VERIFY, + Constants.TestSample.TEMPERATURE}, + dependsOnGroups = Constants.TestSample.ENROLL_VERIFY, dependsOnMethods = {"verifyGraphs"}) public void temperatureGraphPathTest() { - Assert.assertTrue(connectedCupDeviceViewPage.checkGraphPath(Constants.IOT_CONNECTED_CUP_TEMPERATURE_GRAPH_ID)); + Assert.assertTrue(deviceViewPage.checkGraphPath(Constants.ConnectedCup.TEMPERATURE_GRAPH_ID)); } @Test(description = "Test the whether the Temperature graph gets values.", - groups = {Constants.IOT_TEST_GROUP_SAMPLE_VERIFY, - Constants.IOT_TEST_GROUP_SAMPLE_TEMPERATURE}, - dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_ENROLL_VERIFY, + groups = {Constants.TestSample.VERIFY, + Constants.TestSample.TEMPERATURE}, + dependsOnGroups = Constants.TestSample.ENROLL_VERIFY, dependsOnMethods = {"verifyGraphs"}) public void temperatureGraphDataPublisherTest() { - Assert.assertTrue(connectedCupDeviceViewPage.checkGraphValues(Constants.IOT_CONNECTED_CUP_TEMPERATURE_GRAPH_ID, - Constants.IOT_CONNECTED_CUP_TEMPERATURE)); + Assert.assertTrue(deviceViewPage.checkGraphValues(Constants.ConnectedCup.TEMPERATURE_GRAPH_ID, + Constants.ConnectedCup.TEMPERATURE)); } @Test(description = "Test the Y axis name of Coffee Level graph.", - groups = Constants.IOT_TEST_GROUP_SAMPLE_COFFEELEVEL, - dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_TEMPERATURE) + groups = Constants.TestSample.COFFEE_LEVEL, + dependsOnGroups = Constants.TestSample.TEMPERATURE) 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)); + Assert.assertTrue(deviceViewPage.graphAxisName(Constants.IOT_GRAPH_Y_AXIS, + Constants.ConnectedCup .COFFEE_LEVEL_ID, + Constants.ConnectedCup.COFFEE_LEVEL_Y_AXIS)); } @Test(description = "Test the X axis name of Coffee Level graph.", - groups = Constants.IOT_TEST_GROUP_SAMPLE_COFFEELEVEL, - dependsOnGroups = {Constants.IOT_TEST_GROUP_SAMPLE_ENROLL_VERIFY, - Constants.IOT_TEST_GROUP_SAMPLE_TEMPERATURE}) + groups = Constants.TestSample.COFFEE_LEVEL, + dependsOnGroups = {Constants.TestSample.ENROLL_VERIFY, + Constants.TestSample.TEMPERATURE}) 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)); + Assert.assertTrue(deviceViewPage.graphAxisName(Constants.IOT_GRAPH_X_AXIS, + Constants.ConnectedCup.COFFEE_LEVEL_ID, + Constants.ConnectedCup.COFFEE_LEVEL_X_AXIS)); } @Test(description = "Test the whether the Coffee Level graph legend is present.", - groups = Constants.IOT_TEST_GROUP_SAMPLE_COFFEELEVEL, - dependsOnGroups = {Constants.IOT_TEST_GROUP_SAMPLE_TEMPERATURE}) + groups = Constants.TestSample.COFFEE_LEVEL, + dependsOnGroups = {Constants.TestSample.TEMPERATURE}) public void coffeeLevelGraphLegendTest() throws IOException { - Assert.assertTrue(connectedCupDeviceViewPage.graphLegendName(Constants.IOT_CONNECTED_CUP_COFFEE_LEVEL_ID, - Constants.IOT_CONNECTED_CUP_COFFEE_LEVEL_LEGEND)); + Assert.assertTrue(deviceViewPage.graphLegendName(Constants.ConnectedCup.COFFEE_LEVEL_ID, + Constants.ConnectedCup.COFFEE_LEVEL_LEGEND)); } @Test(description = "Test the whether the Coffee Level graph path is visible.", - groups = Constants.IOT_TEST_GROUP_SAMPLE_COFFEELEVEL, - dependsOnGroups = {Constants.IOT_TEST_GROUP_SAMPLE_TEMPERATURE}) + groups = Constants.TestSample.COFFEE_LEVEL, + dependsOnGroups = {Constants.TestSample.TEMPERATURE}) public void coffeeLevelGraphPathTest() { - Assert.assertTrue(connectedCupDeviceViewPage.checkGraphPath(Constants.IOT_CONNECTED_CUP_COFFEE_LEVEL_GRAPH_ID)); + Assert.assertTrue(deviceViewPage.checkGraphPath(Constants.ConnectedCup.COFFEE_LEVEL_GRAPH_ID)); } @Test(description = "Test the whether the Coffee Level graph gets values.", - groups = Constants.IOT_TEST_GROUP_SAMPLE_COFFEELEVEL, - dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_TEMPERATURE) + groups = Constants.TestSample.COFFEE_LEVEL, + dependsOnGroups = Constants.TestSample.TEMPERATURE) public void coffeeLevelGraphDataPublisherTest() { - Assert.assertTrue(connectedCupDeviceViewPage.checkGraphValues(Constants.IOT_CONNECTED_CUP_COFFEE_LEVEL_GRAPH_ID, - Constants.IOT_CONNECTED_CUP_LEVEl)); + Assert.assertTrue(deviceViewPage.checkGraphValues(Constants.ConnectedCup.COFFEE_LEVEL_GRAPH_ID, + Constants.ConnectedCup.COFFEE_LEVEl)); } @AfterClass(alwaysRun = true) @@ -186,4 +189,5 @@ public class SampleFunctionalityTest extends IOTIntegrationUIBaseTestCase { driverServer.quit(); driverDevice.quit(); } + } 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 a64560a6..5d5f1c79 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 @@ -76,7 +76,7 @@ public class SampleInstallationTest extends IOTIntegrationUIBaseTestCase { } @Test(description = "Verify the sample build process", - groups = Constants.IOT_TEST_GROUP_SAMPLE_INSTALL) + groups = Constants.TestSample.SAMPLE_INSTALL) public void sampleBuildTest() throws IOException { String connectedCupDir = carbonHome + File.separator + "samples" + File.separator + "connectedcup"; log.info("Connected cup Sample: " + connectedCupDir); @@ -102,7 +102,7 @@ public class SampleInstallationTest extends IOTIntegrationUIBaseTestCase { } @Test(description = "Verify the sample installation process", - groups = Constants.IOT_TEST_GROUP_SAMPLE_INSTALL, + groups = Constants.TestSample.SAMPLE_INSTALL, dependsOnMethods = {"sampleBuildTest"}) public void sampleInstallationTest() throws IOException { @@ -127,7 +127,7 @@ public class SampleInstallationTest extends IOTIntegrationUIBaseTestCase { } @Test(description = "Test restarting the server", - groups = Constants.IOT_TEST_GROUP_SAMPLE_INSTALL, + groups = Constants.TestSample.SAMPLE_INSTALL, dependsOnMethods = {"sampleInstallationTest"}) public void serverRestartTest() { ServerConfigurationManager serverManager; @@ -199,21 +199,18 @@ public class SampleInstallationTest extends IOTIntegrationUIBaseTestCase { Future f = service.submit(r); f.get(Constants.IOT_RESTART_THREAD_TIMEOUT, TimeUnit.MINUTES); - } - catch (final InterruptedException e) { + } catch (final InterruptedException e) { log.error("Interrupted "+e.getMessage()); Assert.assertTrue(false); - } - catch (final TimeoutException e) { + } catch (final TimeoutException e) { log.error("Timeout " + e.getMessage()); Assert.assertTrue(false); - } - catch (final ExecutionException e) { + } catch (final ExecutionException e) { log.error("Execution failed " + e.getMessage()); Assert.assertTrue(false); - } - finally { + } finally { service.shutdown(); } } + } 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 0557ec0f..6c9d54c6 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 @@ -50,8 +50,8 @@ public class SampleInstallationVerification extends IOTIntegrationUIBaseTestCase } @Test(description = "Verify the sample is available in Virtual devices section.", - groups = Constants.IOT_TEST_GROUP_SAMPLE_INSTALL_VERIFY, - dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_INSTALL) + groups = Constants.TestSample.INSTALL_VERIFY, + dependsOnGroups = Constants.TestSample.SAMPLE_INSTALL) public void installationVerificationTest() throws IOException { EnrollDevicePage enrollDevicePage = adminDashboard.enrollNewDevice(); Assert.assertTrue(enrollDevicePage.isInstalled()); @@ -61,4 +61,5 @@ public class SampleInstallationVerification extends IOTIntegrationUIBaseTestCase public void teardown() { driver.quit(); } + } diff --git a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/user/AddUserFormValidationTest.java b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/user/AddUserFormValidationTest.java index 4b924065..44175b14 100644 --- a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/user/AddUserFormValidationTest.java +++ b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/user/AddUserFormValidationTest.java @@ -94,10 +94,10 @@ public class AddUserFormValidationTest extends IOTIntegrationUIBaseTestCase { public void shortUserNameTest() { clearForm(); - firstNameField.sendKeys(Constants.ADD_USER_FIRST_NAME); - lastNameField.sendKeys(Constants.ADD_USER_LAST_NAME); - emailField.sendKeys(Constants.ADD_USER_EMAIL); - userNameField.sendKeys(Constants.ADD_USER_SHORT_USER_NAME); + firstNameField.sendKeys(Constants.User.Add.FIRST_NAME); + lastNameField.sendKeys(Constants.User.Add.LAST_NAME); + emailField.sendKeys(Constants.User.Add.EMAIL); + userNameField.sendKeys(Constants.User.Add.SHORT_USER_NAME); addUserButton.click(); @@ -108,7 +108,7 @@ public class AddUserFormValidationTest extends IOTIntegrationUIBaseTestCase { Assert.assertTrue(false, "Alert for short user name is not displayed."); } - Assert.assertEquals(alert.getText(), Constants.ADD_USER_SHORT_USER_NAME_ERROR_MSG); + Assert.assertEquals(alert.getText(), Constants.User.Add.SHORT_USER_NAME_ERROR_MSG); } @Test(description = "Test for empty first name") @@ -116,9 +116,9 @@ public class AddUserFormValidationTest extends IOTIntegrationUIBaseTestCase { clearForm(); firstNameField.sendKeys(""); - lastNameField.sendKeys(Constants.ADD_USER_LAST_NAME); - emailField.sendKeys(Constants.ADD_USER_EMAIL); - userNameField.sendKeys(Constants.ADD_USER_USER_NAME); + lastNameField.sendKeys(Constants.User.Add.LAST_NAME); + emailField.sendKeys(Constants.User.Add.EMAIL); + userNameField.sendKeys(Constants.User.Add.USER_NAME); addUserButton.click(); @@ -129,17 +129,17 @@ public class AddUserFormValidationTest extends IOTIntegrationUIBaseTestCase { Assert.assertTrue(false, "Alert for First name is not displayed."); } - Assert.assertEquals(alert.getText(), Constants.ADD_USER_FIRST_NAME_ERROR_MSG); + Assert.assertEquals(alert.getText(), Constants.User.Add.FIRST_NAME_ERROR_MSG); } @Test(description = "Test for empty last name") public void emptyLastNameTest() { clearForm(); - firstNameField.sendKeys(Constants.ADD_USER_FIRST_NAME); + firstNameField.sendKeys(Constants.User.Add.FIRST_NAME); lastNameField.sendKeys(""); - emailField.sendKeys(Constants.ADD_USER_EMAIL); - userNameField.sendKeys(Constants.ADD_USER_USER_NAME); + emailField.sendKeys(Constants.User.Add.EMAIL); + userNameField.sendKeys(Constants.User.Add.USER_NAME); addUserButton.click(); @@ -150,17 +150,17 @@ public class AddUserFormValidationTest extends IOTIntegrationUIBaseTestCase { Assert.assertTrue(false, "Alert for Last name is not displayed."); } - Assert.assertEquals(alert.getText(), Constants.ADD_USER_LAST_NAME_ERROR_MSG); + Assert.assertEquals(alert.getText(), Constants.User.Add.LAST_NAME_ERROR_MSG); } @Test(description = "Test for empty email name") public void emptyEmailTest() { clearForm(); - firstNameField.sendKeys(Constants.ADD_USER_FIRST_NAME); - lastNameField.sendKeys(Constants.ADD_USER_LAST_NAME); + firstNameField.sendKeys(Constants.User.Add.FIRST_NAME); + lastNameField.sendKeys(Constants.User.Add.LAST_NAME); emailField.sendKeys(""); - userNameField.sendKeys(Constants.ADD_USER_USER_NAME); + userNameField.sendKeys(Constants.User.Add.USER_NAME); addUserButton.click(); @@ -171,17 +171,17 @@ public class AddUserFormValidationTest extends IOTIntegrationUIBaseTestCase { Assert.assertTrue(false, "Alert for E-mail is not displayed."); } - Assert.assertEquals(alert.getText(), Constants.ADD_USER_NO_EMAIL_ERROR_MSG); + Assert.assertEquals(alert.getText(), Constants.User.Add.NO_EMAIL_ERROR_MSG); } @Test(description = "Test for incorrect email") public void incorrectEmailTest() { clearForm(); - firstNameField.sendKeys(Constants.ADD_USER_FIRST_NAME); - lastNameField.sendKeys(Constants.ADD_USER_LAST_NAME); - emailField.sendKeys(Constants.ADD_USER_EMAIL_ERROR); - userNameField.sendKeys(Constants.ADD_USER_USER_NAME); + firstNameField.sendKeys(Constants.User.Add.FIRST_NAME); + lastNameField.sendKeys(Constants.User.Add.LAST_NAME); + emailField.sendKeys(Constants.User.Add.EMAIL_ERROR); + userNameField.sendKeys(Constants.User.Add.USER_NAME); addUserButton.click(); @@ -192,7 +192,7 @@ public class AddUserFormValidationTest extends IOTIntegrationUIBaseTestCase { Assert.assertTrue(false, "Alert for incorrect E-mail is not displayed."); } - Assert.assertEquals(alert.getText(), Constants.ADD_USER_WRONG_EMAIL_ERROR_MSG); + Assert.assertEquals(alert.getText(), Constants.User.Add.WRONG_EMAIL_ERROR_MSG); } private void clearForm() { @@ -206,4 +206,5 @@ public class AddUserFormValidationTest extends IOTIntegrationUIBaseTestCase { public void tearDown() { driver.quit(); } + } diff --git a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/user/AdminFunctionsTest.java b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/user/AdminFunctionsTest.java index 88a5114e..e25740e9 100644 --- a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/user/AdminFunctionsTest.java +++ b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/user/AdminFunctionsTest.java @@ -68,4 +68,5 @@ public class AdminFunctionsTest extends IOTIntegrationUIBaseTestCase { public void tearDown() throws Exception { driver.quit(); } + } diff --git a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/user/NewUserRegistrationTest.java b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/user/NewUserRegistrationTest.java index 1a77e7b3..3d66675f 100644 --- a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/user/NewUserRegistrationTest.java +++ b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/user/NewUserRegistrationTest.java @@ -38,6 +38,7 @@ import java.io.IOException; * Test for registering a new user and login */ public class NewUserRegistrationTest extends IOTIntegrationUIBaseTestCase { + private WebDriver driver; @BeforeClass(alwaysRun = true) @@ -51,15 +52,15 @@ public class NewUserRegistrationTest extends IOTIntegrationUIBaseTestCase { public void userRegisterTest() throws IOException { LoginPage login = new LoginPage(driver); NewUserRegisterPage registerTest = login.registerNewUser(); - LoginPage loginPage = registerTest.registerUser(Constants.REGISTER_USER_FIRST_NAME, - Constants.REGISTER_USER_LAST_NAME, - Constants.REGISTER_USER_EMAIL, - Constants.REGISTER_USER_USER_NAME, - Constants.REGISTER_USER_PASSWORD, - Constants.REGISTER_USER_CONFIRM_PASSWORD); + LoginPage loginPage = registerTest.registerUser(Constants.User.Register.FIRST_NAME, + Constants.User.Register.LAST_NAME, + Constants.User.Register.EMAIL, + Constants.User.Register.USER_NAME, + Constants.User.Register.PASSWORD, + Constants.User.Register.CONFIRM_PASSWORD); - IOTHomePage homePage = loginPage.loginAsUser(Constants.REGISTER_USER_USER_NAME, - Constants.REGISTER_USER_PASSWORD); + IOTHomePage homePage = loginPage.loginAsUser(Constants.User.Register.USER_NAME, + Constants.User.Register.PASSWORD); Assert.assertTrue(homePage.checkUserName()); } @@ -68,11 +69,12 @@ public class NewUserRegistrationTest extends IOTIntegrationUIBaseTestCase { public void logoutTest() throws IOException { IOTHomePage homePage = new IOTHomePage(driver); homePage.logout(); - Assert.assertEquals(driver.getTitle(), Constants.IOT_SERVER_LOGIN_PAGE_TITLE); + Assert.assertEquals(driver.getTitle(), Constants.User.Login.PAGE_TITLE); } @AfterClass(alwaysRun = true) public void tearDown() throws Exception { driver.quit(); } + } diff --git a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/user/RegistrationFormValidationTest.java b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/user/RegistrationFormValidationTest.java index 0c2244c8..60af0de3 100644 --- a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/user/RegistrationFormValidationTest.java +++ b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/user/RegistrationFormValidationTest.java @@ -42,6 +42,7 @@ import java.io.IOException; * - Password, username length */ public class RegistrationFormValidationTest extends IOTIntegrationUIBaseTestCase { + private WebDriver driver; private UIElementMapper uiElementMapper; private NewUserRegisterPage registerPage; @@ -140,4 +141,5 @@ public class RegistrationFormValidationTest extends IOTIntegrationUIBaseTestCase public void tearDown() { driver.quit(); } + }