Changes suggested in the Code review.

application-manager-new
Menaka Madushanka 9 years ago
parent eb77b572e7
commit 0333007b1f

@ -28,6 +28,7 @@ import org.openqa.selenium.support.ui.WebDriverWait;
* This class contains the constants and common methods used in pages. * This class contains the constants and common methods used in pages.
*/ */
public class UIUtils { public class UIUtils {
public static long webDriverTimeOut = 10; public static long webDriverTimeOut = 10;
public static long webDriverTime = 60; public static long webDriverTime = 60;
public static int threadTimeout = 1000; public static int threadTimeout = 1000;

@ -40,6 +40,7 @@ import java.util.List;
* 4. Delete the device. * 4. Delete the device.
*/ */
public class DevicesPage { public class DevicesPage {
Log log = LogFactory.getLog(DevicesPage.class); Log log = LogFactory.getLog(DevicesPage.class);
private WebDriver driver; private WebDriver driver;
private UIElementMapper uiElementMapper; private UIElementMapper uiElementMapper;
@ -98,7 +99,6 @@ public class DevicesPage {
*/ */
private String getLink(WebElement element, String... lookupText) { private String getLink(WebElement element, String... lookupText) {
String link = element.getAttribute("href"); String link = element.getAttribute("href");
log.info("Link -----------------------> " + link);
boolean check = true; boolean check = true;
for (String s : lookupText) { for (String s : lookupText) {
if (!link.contains(s)) { if (!link.contains(s)) {
@ -107,4 +107,5 @@ public class DevicesPage {
} }
return check ? link : null; return check ? link : null;
} }
} }

@ -35,6 +35,7 @@ import java.io.IOException;
* This page lists the all device types which are currently installed in the IOT server. * This page lists the all device types which are currently installed in the IOT server.
*/ */
public class EnrollDevicePage { public class EnrollDevicePage {
private WebDriver driver; private WebDriver driver;
private UIElementMapper uiElementMapper; private UIElementMapper uiElementMapper;
private Log log = LogFactory.getLog(EnrollDevicePage.class); private Log log = LogFactory.getLog(EnrollDevicePage.class);

@ -21,6 +21,7 @@ package org.wso2.iot.integration.ui.pages.graphs;
* Class to store graph data * Class to store graph data
*/ */
public class Graph { public class Graph {
private String graphId; private String graphId;
private String yAxis; private String yAxis;
private String xAxis; 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, return String.format("The graph for graph id : %s, X - axis : %s, Y - axis : %s, legend : %s ", graphId,
xAxis, yAxis, legend); xAxis, yAxis, legend);
} }
} }

@ -25,12 +25,13 @@ import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait; 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.UIElementMapper;
import org.wso2.iot.integration.ui.pages.UIUtils;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit; 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 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. * This simplifies iterating through the DOM every time finding for an element when having multiple graphs.
*/ */
public HashMap<String, Graph> getGraphMap() { public Map<String, Graph> getGraphMap() {
HashMap<String, Graph> graphMap = new HashMap<>(); HashMap<String, Graph> graphMap = new HashMap<>();
WebDriverWait wait = new WebDriverWait(driver, UIUtils.webDriverTimeOut); WebDriverWait wait = new WebDriverWait(driver, UIUtils.webDriverTimeOut);
wait.until(ExpectedConditions.visibilityOf(driver.findElement(By.xpath( wait.until(ExpectedConditions.visibilityOf(driver.findElement(By.xpath(
@ -78,7 +79,6 @@ public class GraphHandler {
By.tagName("span")).getText(); By.tagName("span")).getText();
g.setLegend(legend); g.setLegend(legend);
graphMap.put(key, g); graphMap.put(key, g);
log.info(g.toString());
} }
return graphMap; return graphMap;
} }
@ -90,7 +90,7 @@ public class GraphHandler {
try { try {
graphs = this.graphDiv.findElements(By.xpath("//*[contains(@class, \"chartWrapper\")]")); graphs = this.graphDiv.findElements(By.xpath("//*[contains(@class, \"chartWrapper\")]"));
} catch (NoSuchElementException e) { } 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(); return graphs.size();
} }
@ -106,7 +106,6 @@ public class GraphHandler {
for (int i = 0; i < graphs.size() && graphs.size() > 0; i++) { for (int i = 0; i < graphs.size() && graphs.size() > 0; i++) {
WebElement element = graphs.get(i); WebElement element = graphs.get(i);
if (element.getAttribute("id").toLowerCase().replace(" ", "").contains(graphId.toLowerCase())) { if (element.getAttribute("id").toLowerCase().replace(" ", "").contains(graphId.toLowerCase())) {
log.info(">>>>>>>>>>>>>>>>>>> Graph for id: " + graphId + " is present ");
return element; return element;
} }
} }
@ -124,7 +123,7 @@ public class GraphHandler {
WebElement graphContainer = getGraph(graph, uiElementMapper.getElement("iot.stat.graph.class.name")); WebElement graphContainer = getGraph(graph, uiElementMapper.getElement("iot.stat.graph.class.name"));
return graphContainer != null && graphContainer.findElement(By.tagName("path")).isDisplayed(); return graphContainer != null && graphContainer.findElement(By.tagName("path")).isDisplayed();
} catch (NoSuchElementException e) { } catch (NoSuchElementException e) {
log.error("No element found. " + e.getMessage()); log.error(String.format("No element found. \n %s", e.getMessage()));
return false; return false;
} }
} }
@ -145,7 +144,6 @@ public class GraphHandler {
values = graphContainer.findElement(By.tagName("path")).getAttribute("d").split(","); values = graphContainer.findElement(By.tagName("path")).getAttribute("d").split(",");
for (String value : values) { for (String value : values) {
if (value.contains(val)) { if (value.contains(val)) {
log.info("Graph values : " + value);
return true; return true;
} }
} }
@ -155,7 +153,8 @@ public class GraphHandler {
/** /**
* This method returns the WebElement for graph with the given class name. * 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. * @param className : Class name of the graph needed.
* @return the WebElement which defined by the given class name. Null if no element is found. * @return the WebElement which defined by the given class name. Null if no element is found.
*/ */

@ -88,4 +88,5 @@ public class DeviceAddGroupPage {
return driver.findElement(By.xpath( return driver.findElement(By.xpath(
uiElementMapper.getElement("iot.device.groups.add.emptyfrom.error"))).getText(); uiElementMapper.getElement("iot.device.groups.add.emptyfrom.error"))).getText();
} }
} }

@ -32,6 +32,7 @@ import java.util.List;
* This class represents the Groups page. * This class represents the Groups page.
*/ */
public class DeviceGroupsPage { public class DeviceGroupsPage {
private WebDriver driver; private WebDriver driver;
private UIElementMapper uiElementMapper; private UIElementMapper uiElementMapper;
@ -73,4 +74,5 @@ public class DeviceGroupsPage {
} }
return false; return false;
} }
} }

@ -34,6 +34,7 @@ import java.io.IOException;
* This class represents the IOT server home page. * This class represents the IOT server home page.
*/ */
public class IOTHomePage { public class IOTHomePage {
private WebDriver driver; private WebDriver driver;
private UIElementMapper uiElementMapper; private UIElementMapper uiElementMapper;

@ -37,6 +37,7 @@ import java.io.IOException;
* *
*/ */
public class LoginPage { public class LoginPage {
private static final Log log = LogFactory.getLog(LoginPage.class); private static final Log log = LogFactory.getLog(LoginPage.class);
private WebDriver driver; private WebDriver driver;
private UIElementMapper uiElementMapper; private UIElementMapper uiElementMapper;
@ -100,4 +101,5 @@ public class LoginPage {
registerLink.click(); registerLink.click();
return new NewUserRegisterPage(driver); return new NewUserRegisterPage(driver);
} }
} }

@ -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. * This device is a virtual device, which allows users to change Temperature and Level values and put an order.
*/ */
public class ConnectedCupDeviceInterface { public class ConnectedCupDeviceInterface {
private Log log = LogFactory.getLog(ConnectedCupDeviceInterface.class); private Log log = LogFactory.getLog(ConnectedCupDeviceInterface.class);
private WebDriver driver; private WebDriver driver;
private UIElementMapper uiElementMapper; private UIElementMapper uiElementMapper;
@ -109,4 +110,5 @@ public class ConnectedCupDeviceInterface {
Action action = move.dragAndDropBy(slider, 0, val).build(); Action action = move.dragAndDropBy(slider, 0, val).build();
action.perform(); action.perform();
} }
} }

@ -33,6 +33,7 @@ import java.io.IOException;
* download the device agent. * download the device agent.
*/ */
public class ConnectedCupDeviceTypeViewPage { public class ConnectedCupDeviceTypeViewPage {
private WebDriver driver; private WebDriver driver;
private UIElementMapper uiElementMapper; private UIElementMapper uiElementMapper;
@ -78,4 +79,5 @@ public class ConnectedCupDeviceTypeViewPage {
return driver.findElement(By.xpath( return driver.findElement(By.xpath(
uiElementMapper.getElement("iot.sample.connectedcup.page.title"))).getText().contains("Connected Cup"); uiElementMapper.getElement("iot.sample.connectedcup.page.title"))).getText().contains("Connected Cup");
} }
} }

@ -31,6 +31,7 @@ import org.wso2.iot.integration.ui.pages.graphs.GraphHandler;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
/** /**
@ -43,7 +44,8 @@ import java.util.concurrent.TimeUnit;
* In this class, device operations and device stats are validated. * In this class, device operations and device stats are validated.
*/ */
public class ConnectedCupDeviceViewPage { public class ConnectedCupDeviceViewPage {
private HashMap<String, Graph> graphMap = new HashMap<>();
private Map<String, Graph> graphMap = new HashMap<>();
private Log log = LogFactory.getLog(ConnectedCupDeviceViewPage.class); private Log log = LogFactory.getLog(ConnectedCupDeviceViewPage.class);
private WebDriver driverServer; private WebDriver driverServer;
private WebDriver driverDevice; 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. * @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) { public boolean graphAxisName(String axis, String graphId, String axisName) {
log.info(graphMap.toString());
if (graphMap.size() != 0) { if (graphMap.size() != 0) {
if (axis.toLowerCase().contains("x")) { if (axis.toLowerCase().contains("x")) {
return graphMap.get(graphId).getxAxis().contains(axisName); 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. * @return : True if legend contains the expected value. False otherwise or there are no graphs present.
*/ */
public boolean graphLegendName(String graphId, String legend) { public boolean graphLegendName(String graphId, String legend) {
log.info(graphMap.toString());
if (graphMap.size() != 0) { if (graphMap.size() != 0) {
if (graphMap.get(graphId) != null){ if (graphMap.get(graphId) != null){
return graphMap.get(graphId).getLegend().contains(legend); return graphMap.get(graphId).getLegend().contains(legend);
@ -150,7 +149,7 @@ public class ConnectedCupDeviceViewPage {
if (graph != null) { if (graph != null) {
return handler.isPathAvailable(graph); return handler.isPathAvailable(graph);
} else { } 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; return false;
} }
} }
@ -167,8 +166,9 @@ public class ConnectedCupDeviceViewPage {
if (graph != null) { if (graph != null) {
return handler.isPathGetValues(graph, value); return handler.isPathGetValues(graph, value);
} else { } 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; return false;
} }
} }
} }

@ -32,6 +32,7 @@ import java.io.IOException;
* This class represents the add user page of the IOT server. * This class represents the add user page of the IOT server.
*/ */
public class AddUserPage { public class AddUserPage {
private WebDriver driver; private WebDriver driver;
private UIElementMapper uiElementMapper; private UIElementMapper uiElementMapper;
@ -75,4 +76,5 @@ public class AddUserPage {
return new UserAddedConfirmationPage(driver); return new UserAddedConfirmationPage(driver);
} }
} }

@ -30,6 +30,7 @@ import org.wso2.iot.integration.ui.pages.UIElementMapper;
* This class represents the Edit user page of the IOT server * This class represents the Edit user page of the IOT server
*/ */
public class EditUserPage { public class EditUserPage {
private static final Log log = LogFactory.getLog(EditUserPage.class); private static final Log log = LogFactory.getLog(EditUserPage.class);
private WebDriver driver; private WebDriver driver;
private UIElementMapper uiElementMapper; private UIElementMapper uiElementMapper;
@ -47,4 +48,5 @@ public class EditUserPage {
public void editUser(String password, String firstName, String lastName) { public void editUser(String password, String firstName, String lastName) {
driver.findElement(By.xpath(uiElementMapper.getElement("iot.user.add.input.password.xpath"))); driver.findElement(By.xpath(uiElementMapper.getElement("iot.user.add.input.password.xpath")));
} }
} }

@ -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. * User registration page has the registration form for new users to enter the required data and the submit button.
*/ */
public class NewUserRegisterPage { public class NewUserRegisterPage {
private WebDriver driver; private WebDriver driver;
private WebElement firstNameField; private WebElement firstNameField;
private WebElement lastNameField; private WebElement lastNameField;
@ -126,4 +127,5 @@ public class NewUserRegisterPage {
passwordField.clear(); passwordField.clear();
passwordConfirmationField.clear(); passwordConfirmationField.clear();
} }
} }

@ -33,4 +33,5 @@ public class UserAddedConfirmationPage {
driver.findElement(By.xpath(uiElementMapper.getElement("iot.admin.addUser.view.btn.xpath"))).click(); driver.findElement(By.xpath(uiElementMapper.getElement("iot.admin.addUser.view.btn.xpath"))).click();
} }
} }

@ -31,6 +31,7 @@ import java.io.IOException;
* Class to represent the user listing page. * Class to represent the user listing page.
*/ */
public class UserListingPage { public class UserListingPage {
private WebDriver driver; private WebDriver driver;
private UIElementMapper uiElementMapper; private UIElementMapper uiElementMapper;
@ -63,4 +64,5 @@ public class UserListingPage {
return new UserListingPage(driver); return new UserListingPage(driver);
} }
} }

@ -29,6 +29,7 @@ import org.wso2.iot.integration.ui.pages.UIElementMapper;
* Class to represent the user view. * Class to represent the user view.
*/ */
public class ViewUserPage { public class ViewUserPage {
private static final Log log = LogFactory.getLog(ViewUserPage.class); private static final Log log = LogFactory.getLog(ViewUserPage.class);
private WebDriver driver; private WebDriver driver;
private UIElementMapper uiElementMapper; private UIElementMapper uiElementMapper;
@ -42,4 +43,5 @@ public class ViewUserPage {
throw new IllegalStateException("This is not the User view page"); throw new IllegalStateException("This is not the User view page");
} }
} }
} }

@ -31,69 +31,92 @@ public class Constants {
public static final String GROUP_NAME = "group1"; public static final String GROUP_NAME = "group1";
public static final String GROUP_DESCRIPTION = "This is a test group"; 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 ALERT_NOT_PRESENT = "Alert is not present.";
public static final String CARBON_HOME = "carbon.home"; 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 String BUILD_SUCCESS_MSG = "BUILD SUCCESS";
public static final int IOT_RESTART_THREAD_TIMEOUT = 30; 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_X_AXIS = "x";
public static final String IOT_GRAPH_Y_AXIS = "y"; public static final String IOT_GRAPH_Y_AXIS = "y";
public static final String IOT_CONNECTED_CUP_TEMPERATURE_ID = "Temperature"; public static class ConnectedCup {
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 COFFEE_LEVEl = "35";
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 TEMPERATURE = "53";
public static final String COFFEE_LEVEL_ID = "Coffee Level";
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 COFFEE_LEVEL_LEGEND = "Coffee Level";
public static final String IOT_CONNECTED_CUP_COFFEE_LEVEL_GRAPH_ID = "coffeelevel"; public static final String COFFEE_LEVEL_GRAPH_ID = "coffeelevel";
public static final String IOT_CONNECTED_CUP_COFFEE_LEVEL_Y_AXIS = "Coffeelevel"; public static final String COFFEE_LEVEL_Y_AXIS = "Coffeelevel";
public static final String IOT_CONNECTED_CUP_COFFEE_LEVEL_X_AXIS = "time"; public static final String COFFEE_LEVEL_X_AXIS = "time";
public static final String TEMPERATURE_ID = "Temperature";
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 TEMPERATURE_LEGEND = "Temperature";
public static final String IOT_TEST_GROUP_SAMPLE_VERIFY = "iot.sample.install.verify"; public static final String TEMPERATURE_GRAPH_ID = "temperature";
public static final String IOT_TEST_GROUP_SAMPLE_ENROLL = "iot.sample.enroll"; public static final String TEMPERATURE_Y_AXIS = "Temperature";
public static final String IOT_TEST_GROUP_SAMPLE_ENROLL_VERIFY = "iot.sample.enroll.verify"; public static final String TEMPERATURE_X_AXIS = "time";
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 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";
}
} }

@ -30,6 +30,7 @@ import java.rmi.RemoteException;
public class IOTIntegrationUIBaseTestCase { public class IOTIntegrationUIBaseTestCase {
protected AutomationContext automationContext; protected AutomationContext automationContext;
protected void init() throws IOException, XMLStreamException, XPathExpressionException { protected void init() throws IOException, XMLStreamException, XPathExpressionException {
@ -61,4 +62,5 @@ public class IOTIntegrationUIBaseTestCase {
protected String getLoginURL() throws XPathExpressionException { protected String getLoginURL() throws XPathExpressionException {
return HomePageGenerator.getProductHomeURL(automationContext); return HomePageGenerator.getProductHomeURL(automationContext);
} }
} }

@ -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. * So the failing scenario is sending the form with empty group name.
*/ */
public class DeviceGroupFailTest extends IOTIntegrationUIBaseTestCase { public class DeviceGroupFailTest extends IOTIntegrationUIBaseTestCase {
private WebDriver driver; private WebDriver driver;
@BeforeClass(alwaysRun = true) @BeforeClass(alwaysRun = true)
@ -55,4 +56,5 @@ public class DeviceGroupFailTest extends IOTIntegrationUIBaseTestCase {
public void tearDown() throws Exception { public void tearDown() throws Exception {
driver.quit(); driver.quit();
} }
} }

@ -37,6 +37,7 @@ import java.io.IOException;
* Test cases for grouping feature of IOT server. * Test cases for grouping feature of IOT server.
*/ */
public class DeviceGroupTest extends IOTIntegrationUIBaseTestCase { public class DeviceGroupTest extends IOTIntegrationUIBaseTestCase {
private WebDriver driver; private WebDriver driver;
private IOTAdminDashboard adminDashboard; private IOTAdminDashboard adminDashboard;
@ -65,4 +66,5 @@ public class DeviceGroupTest extends IOTIntegrationUIBaseTestCase {
public void tearDown() throws Exception { public void tearDown() throws Exception {
driver.quit(); driver.quit();
} }
} }

@ -67,21 +67,21 @@ public class LoginFormValidationTest extends IOTIntegrationUIBaseTestCase {
if (!alertUserName.isDisplayed()) Assert.assertTrue(false, "Alert for user name is not present."); 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."); if (!alertPassword.isDisplayed()) Assert.assertTrue(false, "Alert for password is not present.");
Assert.assertEquals(alertUserName.getText(), Constants.LOGIN_USER_NAME_ERROR); Assert.assertEquals(alertUserName.getText(), Constants.User.Login.USER_NAME_ERROR);
Assert.assertEquals(alertPassword.getText(), Constants.LOGIN_PASSWORD_ERROR); Assert.assertEquals(alertPassword.getText(), Constants.User.Login.PASSWORD_ERROR);
} }
@Test(description = "Test for incorrect username") @Test(description = "Test for incorrect username")
public void incorrectUserNameTest() throws Exception { public void incorrectUserNameTest() throws Exception {
clearForm(); clearForm();
userNameField.sendKeys(Constants.LOGIN_WRONG_USER_NAME); userNameField.sendKeys(Constants.User.Login.WRONG_USER_NAME);
passwordField.sendKeys(automationContext.getSuperTenant().getTenantAdmin().getPassword()); passwordField.sendKeys(automationContext.getSuperTenant().getTenantAdmin().getPassword());
loginButton.click(); loginButton.click();
WebElement alert = driver.findElement(By.xpath(uiElementMapper.getElement("iot.user.login.incorrect.xpath"))); WebElement alert = driver.findElement(By.xpath(uiElementMapper.getElement("iot.user.login.incorrect.xpath")));
if (alert.isDisplayed()) { if (alert.isDisplayed()) {
Assert.assertEquals(alert.getText(), Constants.LOGIN_FAILED_ERROR); Assert.assertEquals(alert.getText(), Constants.User.Login.FAILED_ERROR);
} else { } else {
Assert.assertTrue(false, Constants.ALERT_NOT_PRESENT); Assert.assertTrue(false, Constants.ALERT_NOT_PRESENT);
} }
@ -92,12 +92,12 @@ public class LoginFormValidationTest extends IOTIntegrationUIBaseTestCase {
public void incorrectPasswordTest() throws Exception { public void incorrectPasswordTest() throws Exception {
clearForm(); clearForm();
userNameField.sendKeys(automationContext.getSuperTenant().getTenantAdmin().getPassword()); userNameField.sendKeys(automationContext.getSuperTenant().getTenantAdmin().getPassword());
passwordField.sendKeys(Constants.LOGIN_WRONG_USER_PASSWORD); passwordField.sendKeys(Constants.User.Login.WRONG_USER_PASSWORD);
loginButton.click(); loginButton.click();
WebElement alert = driver.findElement(By.xpath(uiElementMapper.getElement("iot.user.login.incorrect.xpath"))); WebElement alert = driver.findElement(By.xpath(uiElementMapper.getElement("iot.user.login.incorrect.xpath")));
if (alert.isDisplayed()) { if (alert.isDisplayed()) {
Assert.assertEquals(alert.getText(), Constants.LOGIN_FAILED_ERROR); Assert.assertEquals(alert.getText(), Constants.User.Login.FAILED_ERROR);
} else { } else {
Assert.assertTrue(false, Constants.ALERT_NOT_PRESENT); Assert.assertTrue(false, Constants.ALERT_NOT_PRESENT);
} }
@ -108,12 +108,12 @@ public class LoginFormValidationTest extends IOTIntegrationUIBaseTestCase {
public void shortPasswordTest() throws Exception { public void shortPasswordTest() throws Exception {
clearForm(); clearForm();
userNameField.sendKeys(automationContext.getSuperTenant().getTenantAdmin().getUserName()); userNameField.sendKeys(automationContext.getSuperTenant().getTenantAdmin().getUserName());
passwordField.sendKeys(Constants.LOGIN_SHORT_PASSWORD); passwordField.sendKeys(Constants.User.Login.SHORT_PASSWORD);
loginButton.click(); loginButton.click();
WebElement alert = driver.findElement(By.id(uiElementMapper.getElement("iot.user.login.password.error"))); WebElement alert = driver.findElement(By.id(uiElementMapper.getElement("iot.user.login.password.error")));
if (alert.isDisplayed()) { if (alert.isDisplayed()) {
Assert.assertEquals(alert.getText(), Constants.LOGIN_SHORT_PASSWORD_ERROR); Assert.assertEquals(alert.getText(), Constants.User.Login.SHORT_PASSWORD_ERROR);
} else { } else {
Assert.assertTrue(false, Constants.ALERT_NOT_PRESENT); Assert.assertTrue(false, Constants.ALERT_NOT_PRESENT);
} }
@ -135,4 +135,5 @@ public class LoginFormValidationTest extends IOTIntegrationUIBaseTestCase {
public void tearDown() throws Exception { public void tearDown() throws Exception {
driver.quit(); driver.quit();
} }
} }

@ -35,6 +35,7 @@ import java.io.IOException;
* Test Login as Admin * Test Login as Admin
*/ */
public class LoginTest extends IOTIntegrationUIBaseTestCase { public class LoginTest extends IOTIntegrationUIBaseTestCase {
private WebDriver driver; private WebDriver driver;
@BeforeClass(alwaysRun = true) @BeforeClass(alwaysRun = true)
@ -57,4 +58,5 @@ public class LoginTest extends IOTIntegrationUIBaseTestCase {
public void tearDown(){ public void tearDown(){
driver.quit(); driver.quit();
} }
} }

@ -38,6 +38,7 @@ import java.io.IOException;
* Test cases to verify the enrolment process. * Test cases to verify the enrolment process.
*/ */
public class SampleEnrollmentTest extends IOTIntegrationUIBaseTestCase { public class SampleEnrollmentTest extends IOTIntegrationUIBaseTestCase {
private WebDriver driver; private WebDriver driver;
private ConnectedCupDeviceTypeViewPage connectedCupDeviceTypeViewPage; private ConnectedCupDeviceTypeViewPage connectedCupDeviceTypeViewPage;
@ -52,14 +53,14 @@ public class SampleEnrollmentTest extends IOTIntegrationUIBaseTestCase {
} }
@Test(description = "Verify the pop up modal is displayed.", @Test(description = "Verify the pop up modal is displayed.",
groups = Constants.IOT_TEST_GROUP_SAMPLE_ENROLL, groups = Constants.TestSample.ENROLL,
dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_INSTALL_VERIFY) dependsOnGroups = Constants.TestSample.INSTALL_VERIFY)
public void enrollDevicePopUpModalTest() throws InterruptedException, IOException { public void enrollDevicePopUpModalTest() throws InterruptedException, IOException {
Assert.assertTrue(connectedCupDeviceTypeViewPage.isPopUpPresent()); Assert.assertTrue(connectedCupDeviceTypeViewPage.isPopUpPresent());
} }
@Test(description = "Test case for device enrolment", @Test(description = "Test case for device enrolment",
groups = Constants.IOT_TEST_GROUP_SAMPLE_ENROLL, groups = Constants.TestSample.ENROLL,
dependsOnMethods = {"enrollDevicePopUpModalTest"}) dependsOnMethods = {"enrollDevicePopUpModalTest"})
public void enrollDeviceTest() throws InterruptedException { public void enrollDeviceTest() throws InterruptedException {
Assert.assertTrue(connectedCupDeviceTypeViewPage.enrollDevice(Constants.IOT_CONNECTED_CUP_NAME)); Assert.assertTrue(connectedCupDeviceTypeViewPage.enrollDevice(Constants.IOT_CONNECTED_CUP_NAME));

@ -38,6 +38,7 @@ import java.io.IOException;
* Test cases to check whether the sample is enrolled correctly. * Test cases to check whether the sample is enrolled correctly.
*/ */
public class SampleEnrolmentVerificationTest extends IOTIntegrationUIBaseTestCase { public class SampleEnrolmentVerificationTest extends IOTIntegrationUIBaseTestCase {
private WebDriver webDriver; private WebDriver webDriver;
private DevicesPage devicesPage; private DevicesPage devicesPage;
private ConnectedCupDeviceViewPage connectedCupDeviceViewPage; private ConnectedCupDeviceViewPage connectedCupDeviceViewPage;
@ -52,15 +53,15 @@ public class SampleEnrolmentVerificationTest extends IOTIntegrationUIBaseTestCas
} }
@Test(description = "Verify enrolment of the sample device", @Test(description = "Verify enrolment of the sample device",
groups = Constants.IOT_TEST_GROUP_SAMPLE_ENROLL_VERIFY, groups = Constants.TestSample.ENROLL_VERIFY,
dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_ENROLL) dependsOnGroups = Constants.TestSample.ENROLL)
public void verifyEnrollmentTest() { public void verifyEnrollmentTest() {
Assert.assertTrue(devicesPage.isDeviceEnrolled(Constants.IOT_CONNECTED_CUP_NAME)); Assert.assertTrue(devicesPage.isDeviceEnrolled(Constants.IOT_CONNECTED_CUP_NAME));
} }
@Test(description = "Verify navigation to device view", @Test(description = "Verify navigation to device view",
dependsOnMethods = "verifyEnrollmentTest", dependsOnMethods = "verifyEnrollmentTest",
groups = Constants.IOT_TEST_GROUP_SAMPLE_ENROLL_VERIFY) groups = Constants.TestSample.ENROLL_VERIFY)
public void verifyNavigationTest() throws IOException { public void verifyNavigationTest() throws IOException {
connectedCupDeviceViewPage = devicesPage.viewDevice(Constants.IOT_CONNECTED_CUP_NAME); connectedCupDeviceViewPage = devicesPage.viewDevice(Constants.IOT_CONNECTED_CUP_NAME);
Assert.assertNotNull(connectedCupDeviceViewPage); Assert.assertNotNull(connectedCupDeviceViewPage);
@ -77,4 +78,5 @@ public class SampleEnrolmentVerificationTest extends IOTIntegrationUIBaseTestCas
public void tearDown() { public void tearDown() {
webDriver.quit(); webDriver.quit();
} }
} }

@ -42,10 +42,11 @@ import java.io.IOException;
* 3. Test the stat graphs * 3. Test the stat graphs
*/ */
public class SampleFunctionalityTest extends IOTIntegrationUIBaseTestCase { public class SampleFunctionalityTest extends IOTIntegrationUIBaseTestCase {
private WebDriver driverDevice; private WebDriver driverDevice;
private WebDriver driverServer; private WebDriver driverServer;
private ConnectedCupDeviceInterface sampleViewPage; private ConnectedCupDeviceInterface sampleViewPage;
private ConnectedCupDeviceViewPage connectedCupDeviceViewPage; private ConnectedCupDeviceViewPage deviceViewPage;
@BeforeClass(alwaysRun = true) @BeforeClass(alwaysRun = true)
public void setUp() throws XPathExpressionException, XMLStreamException, IOException { public void setUp() throws XPathExpressionException, XMLStreamException, IOException {
@ -55,130 +56,132 @@ public class SampleFunctionalityTest extends IOTIntegrationUIBaseTestCase {
LoginUtils.login(driverServer, automationContext, getWebAppURL()); LoginUtils.login(driverServer, automationContext, getWebAppURL());
driverServer.get(getWebAppURL() + Constants.IOT_DEVICES_URL); driverServer.get(getWebAppURL() + Constants.IOT_DEVICES_URL);
DevicesPage devicesPage = new DevicesPage(driverServer); DevicesPage devicesPage = new DevicesPage(driverServer);
connectedCupDeviceViewPage = devicesPage.viewDevice(Constants.IOT_CONNECTED_CUP_NAME); deviceViewPage = devicesPage.viewDevice(Constants.IOT_CONNECTED_CUP_NAME);
driverDevice.get(connectedCupDeviceViewPage.getDeviceLink());
//Opens the connected cup device interface in the browser.
driverDevice.get(deviceViewPage.getDeviceLink());
sampleViewPage = new ConnectedCupDeviceInterface(driverDevice); sampleViewPage = new ConnectedCupDeviceInterface(driverDevice);
} }
@Test(description = "Set the temperature level.", @Test(description = "Set the temperature level.",
groups = Constants.IOT_TEST_GROUP_SAMPLE_VERIFY, groups = Constants.TestSample.VERIFY,
dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_ENROLL_VERIFY) dependsOnGroups = Constants.TestSample.ENROLL_VERIFY)
public void setTemperatureTest() { 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.", @Test(description = "Set the coffee level.",
groups = Constants.IOT_TEST_GROUP_SAMPLE_VERIFY, groups = Constants.TestSample.VERIFY,
dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_ENROLL_VERIFY) dependsOnGroups = Constants.TestSample.ENROLL_VERIFY)
public void setCoffeeLevelTest() throws IOException { 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.", @Test(description = "Verify order coffee function.",
groups = Constants.IOT_TEST_GROUP_SAMPLE_VERIFY, groups = Constants.TestSample.VERIFY,
dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_ENROLL_VERIFY) dependsOnGroups = Constants.TestSample.ENROLL_VERIFY)
public void orderCoffeeTest() throws IOException, InterruptedException { public void orderCoffeeTest() throws IOException, InterruptedException {
Assert.assertTrue(sampleViewPage.orderCoffee()); Assert.assertTrue(sampleViewPage.orderCoffee());
} }
@Test(description = "Test the graphs are present in device view.", @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"}) dependsOnMethods = {"setTemperatureTest", "setCoffeeLevelTest", "orderCoffeeTest"})
public void verifyGraphs() throws IOException { 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.", @Test(description = "Test the Y axis name of Temperature graph.",
groups = {Constants.IOT_TEST_GROUP_SAMPLE_VERIFY, groups = {Constants.TestSample.VERIFY,
Constants.IOT_TEST_GROUP_SAMPLE_TEMPERATURE}, Constants.TestSample.TEMPERATURE},
dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_ENROLL_VERIFY, dependsOnGroups = Constants.TestSample.ENROLL_VERIFY,
dependsOnMethods = {"verifyGraphs"}) dependsOnMethods = {"verifyGraphs"})
public void temperatureGraphYAxisNameTest() throws IOException { public void temperatureGraphYAxisNameTest() throws IOException {
Assert.assertTrue(connectedCupDeviceViewPage.graphAxisName(Constants.IOT_GRAPH_Y_AXIS, Assert.assertTrue(deviceViewPage.graphAxisName(Constants.IOT_GRAPH_Y_AXIS,
Constants.IOT_CONNECTED_CUP_TEMPERATURE_ID, Constants.ConnectedCup.TEMPERATURE_ID,
Constants.IOT_CONNECTED_CUP_TEMPERATURE_Y_AXIS)); Constants.ConnectedCup.TEMPERATURE_Y_AXIS));
} }
@Test(description = "Test the X axis name of Temperature graph.", @Test(description = "Test the X axis name of Temperature graph.",
groups = {Constants.IOT_TEST_GROUP_SAMPLE_VERIFY, groups = {Constants.TestSample.VERIFY,
Constants.IOT_TEST_GROUP_SAMPLE_TEMPERATURE}, Constants.TestSample.TEMPERATURE},
dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_ENROLL_VERIFY, dependsOnGroups = Constants.TestSample.ENROLL_VERIFY,
dependsOnMethods = {"verifyGraphs"}) dependsOnMethods = {"verifyGraphs"})
public void temperatureGraphXAxisNameTest() throws IOException { public void temperatureGraphXAxisNameTest() throws IOException {
Assert.assertTrue(connectedCupDeviceViewPage.graphAxisName(Constants.IOT_GRAPH_X_AXIS, Assert.assertTrue(deviceViewPage.graphAxisName(Constants.IOT_GRAPH_X_AXIS,
Constants.IOT_CONNECTED_CUP_TEMPERATURE_ID, Constants.ConnectedCup.TEMPERATURE_ID,
Constants.IOT_CONNECTED_CUP_TEMPERATURE_X_AXIS)); Constants.ConnectedCup.TEMPERATURE_X_AXIS));
} }
@Test(description = "Test the whether the Coffee Level graph legend is present.", @Test(description = "Test the whether the Coffee Level graph legend is present.",
groups = {Constants.IOT_TEST_GROUP_SAMPLE_VERIFY, groups = {Constants.TestSample.VERIFY,
Constants.IOT_TEST_GROUP_SAMPLE_TEMPERATURE}, Constants.TestSample.TEMPERATURE},
dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_ENROLL_VERIFY, dependsOnGroups = Constants.TestSample.ENROLL_VERIFY,
dependsOnMethods = {"verifyGraphs"}) dependsOnMethods = {"verifyGraphs"})
public void temperatureGraphLegendTest() { public void temperatureGraphLegendTest() {
Assert.assertTrue(connectedCupDeviceViewPage.graphLegendName(Constants.IOT_CONNECTED_CUP_TEMPERATURE_ID, Assert.assertTrue(deviceViewPage.graphLegendName(Constants.ConnectedCup.TEMPERATURE_ID,
Constants.IOT_CONNECTED_CUP_TEMPERATURE_LEGEND)); Constants.ConnectedCup.TEMPERATURE_LEGEND));
} }
@Test(description = "Test the whether the Temperature graph path is visible.", @Test(description = "Test the whether the Temperature graph path is visible.",
groups = {Constants.IOT_TEST_GROUP_SAMPLE_VERIFY, groups = {Constants.TestSample.VERIFY,
Constants.IOT_TEST_GROUP_SAMPLE_TEMPERATURE}, Constants.TestSample.TEMPERATURE},
dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_ENROLL_VERIFY, dependsOnGroups = Constants.TestSample.ENROLL_VERIFY,
dependsOnMethods = {"verifyGraphs"}) dependsOnMethods = {"verifyGraphs"})
public void temperatureGraphPathTest() { 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.", @Test(description = "Test the whether the Temperature graph gets values.",
groups = {Constants.IOT_TEST_GROUP_SAMPLE_VERIFY, groups = {Constants.TestSample.VERIFY,
Constants.IOT_TEST_GROUP_SAMPLE_TEMPERATURE}, Constants.TestSample.TEMPERATURE},
dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_ENROLL_VERIFY, dependsOnGroups = Constants.TestSample.ENROLL_VERIFY,
dependsOnMethods = {"verifyGraphs"}) dependsOnMethods = {"verifyGraphs"})
public void temperatureGraphDataPublisherTest() { public void temperatureGraphDataPublisherTest() {
Assert.assertTrue(connectedCupDeviceViewPage.checkGraphValues(Constants.IOT_CONNECTED_CUP_TEMPERATURE_GRAPH_ID, Assert.assertTrue(deviceViewPage.checkGraphValues(Constants.ConnectedCup.TEMPERATURE_GRAPH_ID,
Constants.IOT_CONNECTED_CUP_TEMPERATURE)); Constants.ConnectedCup.TEMPERATURE));
} }
@Test(description = "Test the Y axis name of Coffee Level graph.", @Test(description = "Test the Y axis name of Coffee Level graph.",
groups = Constants.IOT_TEST_GROUP_SAMPLE_COFFEELEVEL, groups = Constants.TestSample.COFFEE_LEVEL,
dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_TEMPERATURE) dependsOnGroups = Constants.TestSample.TEMPERATURE)
public void coffeeLevelGraphYAxisNameTest() { public void coffeeLevelGraphYAxisNameTest() {
Assert.assertTrue(connectedCupDeviceViewPage.graphAxisName(Constants.IOT_GRAPH_Y_AXIS, Assert.assertTrue(deviceViewPage.graphAxisName(Constants.IOT_GRAPH_Y_AXIS,
Constants.IOT_CONNECTED_CUP_COFFEE_LEVEL_ID, Constants.ConnectedCup .COFFEE_LEVEL_ID,
Constants.IOT_CONNECTED_CUP_COFFEE_LEVEL_Y_AXIS)); Constants.ConnectedCup.COFFEE_LEVEL_Y_AXIS));
} }
@Test(description = "Test the X axis name of Coffee Level graph.", @Test(description = "Test the X axis name of Coffee Level graph.",
groups = Constants.IOT_TEST_GROUP_SAMPLE_COFFEELEVEL, groups = Constants.TestSample.COFFEE_LEVEL,
dependsOnGroups = {Constants.IOT_TEST_GROUP_SAMPLE_ENROLL_VERIFY, dependsOnGroups = {Constants.TestSample.ENROLL_VERIFY,
Constants.IOT_TEST_GROUP_SAMPLE_TEMPERATURE}) Constants.TestSample.TEMPERATURE})
public void coffeeLevelGraphXAxisNameTest() { public void coffeeLevelGraphXAxisNameTest() {
Assert.assertTrue(connectedCupDeviceViewPage.graphAxisName(Constants.IOT_GRAPH_X_AXIS, Assert.assertTrue(deviceViewPage.graphAxisName(Constants.IOT_GRAPH_X_AXIS,
Constants.IOT_CONNECTED_CUP_COFFEE_LEVEL_ID, Constants.ConnectedCup.COFFEE_LEVEL_ID,
Constants.IOT_CONNECTED_CUP_COFFEE_LEVEL_X_AXIS)); Constants.ConnectedCup.COFFEE_LEVEL_X_AXIS));
} }
@Test(description = "Test the whether the Coffee Level graph legend is present.", @Test(description = "Test the whether the Coffee Level graph legend is present.",
groups = Constants.IOT_TEST_GROUP_SAMPLE_COFFEELEVEL, groups = Constants.TestSample.COFFEE_LEVEL,
dependsOnGroups = {Constants.IOT_TEST_GROUP_SAMPLE_TEMPERATURE}) dependsOnGroups = {Constants.TestSample.TEMPERATURE})
public void coffeeLevelGraphLegendTest() throws IOException { public void coffeeLevelGraphLegendTest() throws IOException {
Assert.assertTrue(connectedCupDeviceViewPage.graphLegendName(Constants.IOT_CONNECTED_CUP_COFFEE_LEVEL_ID, Assert.assertTrue(deviceViewPage.graphLegendName(Constants.ConnectedCup.COFFEE_LEVEL_ID,
Constants.IOT_CONNECTED_CUP_COFFEE_LEVEL_LEGEND)); Constants.ConnectedCup.COFFEE_LEVEL_LEGEND));
} }
@Test(description = "Test the whether the Coffee Level graph path is visible.", @Test(description = "Test the whether the Coffee Level graph path is visible.",
groups = Constants.IOT_TEST_GROUP_SAMPLE_COFFEELEVEL, groups = Constants.TestSample.COFFEE_LEVEL,
dependsOnGroups = {Constants.IOT_TEST_GROUP_SAMPLE_TEMPERATURE}) dependsOnGroups = {Constants.TestSample.TEMPERATURE})
public void coffeeLevelGraphPathTest() { 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.", @Test(description = "Test the whether the Coffee Level graph gets values.",
groups = Constants.IOT_TEST_GROUP_SAMPLE_COFFEELEVEL, groups = Constants.TestSample.COFFEE_LEVEL,
dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_TEMPERATURE) dependsOnGroups = Constants.TestSample.TEMPERATURE)
public void coffeeLevelGraphDataPublisherTest() { public void coffeeLevelGraphDataPublisherTest() {
Assert.assertTrue(connectedCupDeviceViewPage.checkGraphValues(Constants.IOT_CONNECTED_CUP_COFFEE_LEVEL_GRAPH_ID, Assert.assertTrue(deviceViewPage.checkGraphValues(Constants.ConnectedCup.COFFEE_LEVEL_GRAPH_ID,
Constants.IOT_CONNECTED_CUP_LEVEl)); Constants.ConnectedCup.COFFEE_LEVEl));
} }
@AfterClass(alwaysRun = true) @AfterClass(alwaysRun = true)
@ -186,4 +189,5 @@ public class SampleFunctionalityTest extends IOTIntegrationUIBaseTestCase {
driverServer.quit(); driverServer.quit();
driverDevice.quit(); driverDevice.quit();
} }
} }

@ -76,7 +76,7 @@ public class SampleInstallationTest extends IOTIntegrationUIBaseTestCase {
} }
@Test(description = "Verify the sample build process", @Test(description = "Verify the sample build process",
groups = Constants.IOT_TEST_GROUP_SAMPLE_INSTALL) groups = Constants.TestSample.SAMPLE_INSTALL)
public void sampleBuildTest() throws IOException { public void sampleBuildTest() throws IOException {
String connectedCupDir = carbonHome + File.separator + "samples" + File.separator + "connectedcup"; String connectedCupDir = carbonHome + File.separator + "samples" + File.separator + "connectedcup";
log.info("Connected cup Sample: " + connectedCupDir); log.info("Connected cup Sample: " + connectedCupDir);
@ -102,7 +102,7 @@ public class SampleInstallationTest extends IOTIntegrationUIBaseTestCase {
} }
@Test(description = "Verify the sample installation process", @Test(description = "Verify the sample installation process",
groups = Constants.IOT_TEST_GROUP_SAMPLE_INSTALL, groups = Constants.TestSample.SAMPLE_INSTALL,
dependsOnMethods = {"sampleBuildTest"}) dependsOnMethods = {"sampleBuildTest"})
public void sampleInstallationTest() throws IOException { public void sampleInstallationTest() throws IOException {
@ -127,7 +127,7 @@ public class SampleInstallationTest extends IOTIntegrationUIBaseTestCase {
} }
@Test(description = "Test restarting the server", @Test(description = "Test restarting the server",
groups = Constants.IOT_TEST_GROUP_SAMPLE_INSTALL, groups = Constants.TestSample.SAMPLE_INSTALL,
dependsOnMethods = {"sampleInstallationTest"}) dependsOnMethods = {"sampleInstallationTest"})
public void serverRestartTest() { public void serverRestartTest() {
ServerConfigurationManager serverManager; ServerConfigurationManager serverManager;
@ -199,21 +199,18 @@ public class SampleInstallationTest extends IOTIntegrationUIBaseTestCase {
Future<?> f = service.submit(r); Future<?> f = service.submit(r);
f.get(Constants.IOT_RESTART_THREAD_TIMEOUT, TimeUnit.MINUTES); f.get(Constants.IOT_RESTART_THREAD_TIMEOUT, TimeUnit.MINUTES);
} } catch (final InterruptedException e) {
catch (final InterruptedException e) {
log.error("Interrupted "+e.getMessage()); log.error("Interrupted "+e.getMessage());
Assert.assertTrue(false); Assert.assertTrue(false);
} } catch (final TimeoutException e) {
catch (final TimeoutException e) {
log.error("Timeout " + e.getMessage()); log.error("Timeout " + e.getMessage());
Assert.assertTrue(false); Assert.assertTrue(false);
} } catch (final ExecutionException e) {
catch (final ExecutionException e) {
log.error("Execution failed " + e.getMessage()); log.error("Execution failed " + e.getMessage());
Assert.assertTrue(false); Assert.assertTrue(false);
} } finally {
finally {
service.shutdown(); service.shutdown();
} }
} }
} }

@ -50,8 +50,8 @@ public class SampleInstallationVerification extends IOTIntegrationUIBaseTestCase
} }
@Test(description = "Verify the sample is available in Virtual devices section.", @Test(description = "Verify the sample is available in Virtual devices section.",
groups = Constants.IOT_TEST_GROUP_SAMPLE_INSTALL_VERIFY, groups = Constants.TestSample.INSTALL_VERIFY,
dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_INSTALL) dependsOnGroups = Constants.TestSample.SAMPLE_INSTALL)
public void installationVerificationTest() throws IOException { public void installationVerificationTest() throws IOException {
EnrollDevicePage enrollDevicePage = adminDashboard.enrollNewDevice(); EnrollDevicePage enrollDevicePage = adminDashboard.enrollNewDevice();
Assert.assertTrue(enrollDevicePage.isInstalled()); Assert.assertTrue(enrollDevicePage.isInstalled());
@ -61,4 +61,5 @@ public class SampleInstallationVerification extends IOTIntegrationUIBaseTestCase
public void teardown() { public void teardown() {
driver.quit(); driver.quit();
} }
} }

@ -94,10 +94,10 @@ public class AddUserFormValidationTest extends IOTIntegrationUIBaseTestCase {
public void shortUserNameTest() { public void shortUserNameTest() {
clearForm(); clearForm();
firstNameField.sendKeys(Constants.ADD_USER_FIRST_NAME); firstNameField.sendKeys(Constants.User.Add.FIRST_NAME);
lastNameField.sendKeys(Constants.ADD_USER_LAST_NAME); lastNameField.sendKeys(Constants.User.Add.LAST_NAME);
emailField.sendKeys(Constants.ADD_USER_EMAIL); emailField.sendKeys(Constants.User.Add.EMAIL);
userNameField.sendKeys(Constants.ADD_USER_SHORT_USER_NAME); userNameField.sendKeys(Constants.User.Add.SHORT_USER_NAME);
addUserButton.click(); addUserButton.click();
@ -108,7 +108,7 @@ public class AddUserFormValidationTest extends IOTIntegrationUIBaseTestCase {
Assert.assertTrue(false, "Alert for short user name is not displayed."); 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") @Test(description = "Test for empty first name")
@ -116,9 +116,9 @@ public class AddUserFormValidationTest extends IOTIntegrationUIBaseTestCase {
clearForm(); clearForm();
firstNameField.sendKeys(""); firstNameField.sendKeys("");
lastNameField.sendKeys(Constants.ADD_USER_LAST_NAME); lastNameField.sendKeys(Constants.User.Add.LAST_NAME);
emailField.sendKeys(Constants.ADD_USER_EMAIL); emailField.sendKeys(Constants.User.Add.EMAIL);
userNameField.sendKeys(Constants.ADD_USER_USER_NAME); userNameField.sendKeys(Constants.User.Add.USER_NAME);
addUserButton.click(); addUserButton.click();
@ -129,17 +129,17 @@ public class AddUserFormValidationTest extends IOTIntegrationUIBaseTestCase {
Assert.assertTrue(false, "Alert for First name is not displayed."); 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") @Test(description = "Test for empty last name")
public void emptyLastNameTest() { public void emptyLastNameTest() {
clearForm(); clearForm();
firstNameField.sendKeys(Constants.ADD_USER_FIRST_NAME); firstNameField.sendKeys(Constants.User.Add.FIRST_NAME);
lastNameField.sendKeys(""); lastNameField.sendKeys("");
emailField.sendKeys(Constants.ADD_USER_EMAIL); emailField.sendKeys(Constants.User.Add.EMAIL);
userNameField.sendKeys(Constants.ADD_USER_USER_NAME); userNameField.sendKeys(Constants.User.Add.USER_NAME);
addUserButton.click(); addUserButton.click();
@ -150,17 +150,17 @@ public class AddUserFormValidationTest extends IOTIntegrationUIBaseTestCase {
Assert.assertTrue(false, "Alert for Last name is not displayed."); 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") @Test(description = "Test for empty email name")
public void emptyEmailTest() { public void emptyEmailTest() {
clearForm(); clearForm();
firstNameField.sendKeys(Constants.ADD_USER_FIRST_NAME); firstNameField.sendKeys(Constants.User.Add.FIRST_NAME);
lastNameField.sendKeys(Constants.ADD_USER_LAST_NAME); lastNameField.sendKeys(Constants.User.Add.LAST_NAME);
emailField.sendKeys(""); emailField.sendKeys("");
userNameField.sendKeys(Constants.ADD_USER_USER_NAME); userNameField.sendKeys(Constants.User.Add.USER_NAME);
addUserButton.click(); addUserButton.click();
@ -171,17 +171,17 @@ public class AddUserFormValidationTest extends IOTIntegrationUIBaseTestCase {
Assert.assertTrue(false, "Alert for E-mail is not displayed."); 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") @Test(description = "Test for incorrect email")
public void incorrectEmailTest() { public void incorrectEmailTest() {
clearForm(); clearForm();
firstNameField.sendKeys(Constants.ADD_USER_FIRST_NAME); firstNameField.sendKeys(Constants.User.Add.FIRST_NAME);
lastNameField.sendKeys(Constants.ADD_USER_LAST_NAME); lastNameField.sendKeys(Constants.User.Add.LAST_NAME);
emailField.sendKeys(Constants.ADD_USER_EMAIL_ERROR); emailField.sendKeys(Constants.User.Add.EMAIL_ERROR);
userNameField.sendKeys(Constants.ADD_USER_USER_NAME); userNameField.sendKeys(Constants.User.Add.USER_NAME);
addUserButton.click(); addUserButton.click();
@ -192,7 +192,7 @@ public class AddUserFormValidationTest extends IOTIntegrationUIBaseTestCase {
Assert.assertTrue(false, "Alert for incorrect E-mail is not displayed."); 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() { private void clearForm() {
@ -206,4 +206,5 @@ public class AddUserFormValidationTest extends IOTIntegrationUIBaseTestCase {
public void tearDown() { public void tearDown() {
driver.quit(); driver.quit();
} }
} }

@ -68,4 +68,5 @@ public class AdminFunctionsTest extends IOTIntegrationUIBaseTestCase {
public void tearDown() throws Exception { public void tearDown() throws Exception {
driver.quit(); driver.quit();
} }
} }

@ -38,6 +38,7 @@ import java.io.IOException;
* Test for registering a new user and login * Test for registering a new user and login
*/ */
public class NewUserRegistrationTest extends IOTIntegrationUIBaseTestCase { public class NewUserRegistrationTest extends IOTIntegrationUIBaseTestCase {
private WebDriver driver; private WebDriver driver;
@BeforeClass(alwaysRun = true) @BeforeClass(alwaysRun = true)
@ -51,15 +52,15 @@ public class NewUserRegistrationTest extends IOTIntegrationUIBaseTestCase {
public void userRegisterTest() throws IOException { public void userRegisterTest() throws IOException {
LoginPage login = new LoginPage(driver); LoginPage login = new LoginPage(driver);
NewUserRegisterPage registerTest = login.registerNewUser(); NewUserRegisterPage registerTest = login.registerNewUser();
LoginPage loginPage = registerTest.registerUser(Constants.REGISTER_USER_FIRST_NAME, LoginPage loginPage = registerTest.registerUser(Constants.User.Register.FIRST_NAME,
Constants.REGISTER_USER_LAST_NAME, Constants.User.Register.LAST_NAME,
Constants.REGISTER_USER_EMAIL, Constants.User.Register.EMAIL,
Constants.REGISTER_USER_USER_NAME, Constants.User.Register.USER_NAME,
Constants.REGISTER_USER_PASSWORD, Constants.User.Register.PASSWORD,
Constants.REGISTER_USER_CONFIRM_PASSWORD); Constants.User.Register.CONFIRM_PASSWORD);
IOTHomePage homePage = loginPage.loginAsUser(Constants.REGISTER_USER_USER_NAME, IOTHomePage homePage = loginPage.loginAsUser(Constants.User.Register.USER_NAME,
Constants.REGISTER_USER_PASSWORD); Constants.User.Register.PASSWORD);
Assert.assertTrue(homePage.checkUserName()); Assert.assertTrue(homePage.checkUserName());
} }
@ -68,11 +69,12 @@ public class NewUserRegistrationTest extends IOTIntegrationUIBaseTestCase {
public void logoutTest() throws IOException { public void logoutTest() throws IOException {
IOTHomePage homePage = new IOTHomePage(driver); IOTHomePage homePage = new IOTHomePage(driver);
homePage.logout(); homePage.logout();
Assert.assertEquals(driver.getTitle(), Constants.IOT_SERVER_LOGIN_PAGE_TITLE); Assert.assertEquals(driver.getTitle(), Constants.User.Login.PAGE_TITLE);
} }
@AfterClass(alwaysRun = true) @AfterClass(alwaysRun = true)
public void tearDown() throws Exception { public void tearDown() throws Exception {
driver.quit(); driver.quit();
} }
} }

@ -42,6 +42,7 @@ import java.io.IOException;
* - Password, username length * - Password, username length
*/ */
public class RegistrationFormValidationTest extends IOTIntegrationUIBaseTestCase { public class RegistrationFormValidationTest extends IOTIntegrationUIBaseTestCase {
private WebDriver driver; private WebDriver driver;
private UIElementMapper uiElementMapper; private UIElementMapper uiElementMapper;
private NewUserRegisterPage registerPage; private NewUserRegisterPage registerPage;
@ -140,4 +141,5 @@ public class RegistrationFormValidationTest extends IOTIntegrationUIBaseTestCase
public void tearDown() { public void tearDown() {
driver.quit(); driver.quit();
} }
} }

Loading…
Cancel
Save