From 67cb3df6526d46daf7498ebed535eef3e235c0cb Mon Sep 17 00:00:00 2001 From: Menaka Madushanka Date: Tue, 23 Feb 2016 18:44:11 +0530 Subject: [PATCH] Code formatting --- .../iot/integration/ui/pages/UIConstants.java | 5 +++ .../integration/ui/pages/UIElementMapper.java | 14 +++---- .../ui/pages/enroll/EnrollDevicePage.java | 2 +- .../ui/pages/groups/DeviceAddGroupPage.java | 12 ++---- .../ui/pages/groups/DeviceGroupsPage.java | 13 +++--- .../ui/pages/home/IOTAdminDashboard.java | 24 +++++------ .../ui/pages/home/IOTHomePage.java | 16 ++++--- .../integration/ui/pages/login/LoginPage.java | 3 +- .../ui/pages/uesr/AddUserPage.java | 23 +++++----- .../ui/pages/uesr/EditUserPage.java | 3 +- .../ui/pages/uesr/NewUserRegisterPage.java | 21 +++++----- .../pages/uesr/UserAddedConfirmationPage.java | 5 ++- .../ui/pages/uesr/UserListingPage.java | 20 +++------ .../ui/pages/uesr/ViewUserPage.java | 3 +- .../integration/web/ui/test/LoginUtils.java | 16 ++++--- .../ui/test/group/DeviceGroupFailTest.java | 2 +- .../web/ui/test/group/DeviceGroupTest.java | 6 +-- .../web/ui/test/login/LoginFailTest.java | 42 ++++++++----------- .../web/ui/test/login/LoginTest.java | 11 +++-- .../web/ui/test/user/AddUserFailTest.java | 27 ++++++------ .../web/ui/test/user/RegisterTest.java | 14 ++++--- ...a => RegistrationFormValidationTests.java} | 34 ++++++++------- .../web/ui/test/user/TestAdminFunctions.java | 15 ++++--- pom.xml | 5 ++- 24 files changed, 161 insertions(+), 175 deletions(-) create mode 100644 modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/UIConstants.java rename modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/user/{RegistrationFormTests.java => RegistrationFormValidationTests.java} (89%) diff --git a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/UIConstants.java b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/UIConstants.java new file mode 100644 index 00000000..c5508178 --- /dev/null +++ b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/UIConstants.java @@ -0,0 +1,5 @@ +package org.wso2.iot.integration.ui.pages; + +public class UIConstants { + public static long webDriverTimeOut = 10; +} diff --git a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/UIElementMapper.java b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/UIElementMapper.java index 697b22ad..c209d8cd 100644 --- a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/UIElementMapper.java +++ b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/UIElementMapper.java @@ -17,9 +17,6 @@ */ package org.wso2.iot.integration.ui.pages; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import java.io.IOException; import java.io.InputStream; import java.util.Properties; @@ -29,8 +26,7 @@ import java.util.Properties; */ public class UIElementMapper { - public static final Properties uiPropertiies = new Properties(); - private static final Log log = LogFactory.getLog(UIElementMapper.class); + public static final Properties uiProperties = new Properties(); private static UIElementMapper instance; private UIElementMapper(){ @@ -50,16 +46,16 @@ public class UIElementMapper { InputStream inputStream = UIElementMapper.class.getResourceAsStream("/mapper.properties"); if (inputStream.available() > 0) { - uiPropertiies.load(inputStream); + uiProperties.load(inputStream); inputStream.close(); - return uiPropertiies; + return uiProperties; } return null; } public String getElement (String key) { - if (uiPropertiies != null) { - return uiPropertiies.getProperty(key); + if (!uiProperties.isEmpty()) { + return uiProperties.getProperty(key); } return null; } diff --git a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/enroll/EnrollDevicePage.java b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/enroll/EnrollDevicePage.java index 54e485f3..4171cf85 100644 --- a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/enroll/EnrollDevicePage.java +++ b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/enroll/EnrollDevicePage.java @@ -32,7 +32,7 @@ public class EnrollDevicePage { private WebDriver driver; private UIElementMapper uiElementMapper; - public EnrollDevicePage(WebDriver driver) throws IOException{ + public EnrollDevicePage(WebDriver driver) throws IOException { this.driver = driver; this.uiElementMapper = UIElementMapper.getInstance(); } 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 8f579988..d3f7f635 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 @@ -17,12 +17,9 @@ */ package org.wso2.iot.integration.ui.pages.groups; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.WebDriverWait; import org.wso2.iot.integration.ui.pages.UIElementMapper; import java.io.IOException; @@ -34,29 +31,26 @@ import java.io.IOException; */ public class DeviceAddGroupPage { - private static final Log log = LogFactory.getLog(DeviceAddGroupPage.class); private WebDriver driver; private UIElementMapper uiElementMapper; public DeviceAddGroupPage(WebDriver driver) throws IOException { this.driver = driver; this.uiElementMapper = UIElementMapper.getInstance(); - WebDriverWait webDriverWait = new WebDriverWait(driver, 10); if (!driver.findElement(By.xpath - (uiElementMapper.getElement("iot.device.group.addNewGroup.xpath"))).getText().contains("ADD NEW GROUP")){ + (uiElementMapper.getElement("iot.device.group.addNewGroup.xpath"))).getText().contains("ADD NEW GROUP")) { throw new IllegalStateException("This is not the Add Group page"); } } /** - * @param name The group name that is need to be created. + * @param name The group name that is need to be created. * @param description the description for the group * @return The resultant page. - * @throws Exception */ - public DeviceGroupsPage addNewGroup (String name, String description) throws Exception{ + public DeviceGroupsPage addNewGroup(String name, String description) throws IOException { WebElement nameField = driver.findElement(By.id( uiElementMapper.getElement("iot.device.group.addGroupForm.name.id"))); 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 52c00778..56a7aca0 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 @@ -17,13 +17,12 @@ */ package org.wso2.iot.integration.ui.pages.groups; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.openqa.selenium.By; 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.UIConstants; import org.wso2.iot.integration.ui.pages.UIElementMapper; import java.io.IOException; @@ -31,14 +30,13 @@ import java.util.ArrayList; import java.util.List; public class DeviceGroupsPage { - private static final Log log = LogFactory.getLog(DeviceGroupsPage.class); private WebDriver driver; private UIElementMapper uiElementMapper; public DeviceGroupsPage(WebDriver driver) throws IOException { this.driver = driver; this.uiElementMapper = UIElementMapper.getInstance(); - WebDriverWait webDriverWait = new WebDriverWait(driver, 10); + WebDriverWait webDriverWait = new WebDriverWait(driver, UIConstants.webDriverTimeOut); if (!webDriverWait.until(ExpectedConditions.textToBePresentInElement(driver.findElement(By.xpath( uiElementMapper.getElement("iot.device.groups.view.header.xpath"))), "GROUPS"))) { @@ -46,20 +44,20 @@ public class DeviceGroupsPage { } } - public DeviceAddGroupPage addNewGroup() throws Exception { + public DeviceAddGroupPage addNewGroup() throws IOException { WebElement addNewGroupBtn = driver.findElement(By.xpath( uiElementMapper.getElement("iot.device.viewGroup.empty.addGroup.xpath"))); addNewGroupBtn.click(); return new DeviceAddGroupPage(driver); } - public boolean isGroupCreated (String groupName) { + public boolean isGroupCreated(String groupName) { WebElement table = driver.findElement(By.id(uiElementMapper.getElement("iot.device.table.id"))); List allGroupNames = table.findElements(By.tagName("h4")); List groupsList = new ArrayList<>(); for (WebElement name : allGroupNames) { - groupsList.add(name.getText()); + groupsList.add(name.getText()); } @@ -67,5 +65,4 @@ public class DeviceGroupsPage { } - } diff --git a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/home/IOTAdminDashboard.java b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/home/IOTAdminDashboard.java index a3731fc7..1f7ea304 100644 --- a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/home/IOTAdminDashboard.java +++ b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/home/IOTAdminDashboard.java @@ -36,17 +36,17 @@ import java.io.IOException; * This class represents the Admin Dashboard of the IOT server. * Server dashboard has following sections and functions. * 1. User Management - * - View users. - * - Add a new user + * - View users. + * - Add a new user * 2. Group Management. - * - View Groups. - * - Add a new group. + * - View Groups. + * - Add a new group. * 3. Device Management. - * - View enrolled devices. - * - Enroll a device. + * - View enrolled devices. + * - Enroll a device. * 3. Policy Management. - * - View Policies. - * - Create a policy. + * - View Policies. + * - Create a policy. */ public class IOTAdminDashboard { @@ -73,22 +73,22 @@ public class IOTAdminDashboard { return new LoginPage(driver); } - public DeviceAddGroupPage addGroup() throws Exception { + public DeviceAddGroupPage addGroup() throws IOException { driver.findElement(By.xpath(uiElementMapper.getElement("iot.device.group.addButton.xpath"))).click(); return new DeviceAddGroupPage(driver); } - public DeviceGroupsPage viewGroups() throws Exception { + public DeviceGroupsPage viewGroups() throws IOException { driver.findElement(By.xpath(uiElementMapper.getElement("iot.device.group.viewButton.xpath"))).click(); return new DeviceGroupsPage(driver); } - public AddUserPage addUser() throws Exception { + public AddUserPage addUser() throws IOException { driver.findElement(By.xpath(uiElementMapper.getElement("iot.admin.user.addButton.xpath"))).click(); return new AddUserPage(driver); } - public UserListingPage viewUser() throws Exception { + public UserListingPage viewUser() throws IOException { driver.findElement(By.xpath(uiElementMapper.getElement("iot.admin.user.viewButton.xpath"))).click(); return new UserListingPage(driver); } 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 ef3f0fc6..1c708ddd 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 @@ -17,13 +17,12 @@ */ package org.wso2.iot.integration.ui.pages.home; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.openqa.selenium.By; 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.UIConstants; import org.wso2.iot.integration.ui.pages.UIElementMapper; import org.wso2.iot.integration.ui.pages.enroll.EnrollDevicePage; import org.wso2.iot.integration.ui.pages.groups.DeviceAddGroupPage; @@ -36,7 +35,6 @@ import java.io.IOException; * For admin this is the dashboard. */ public class IOTHomePage { - private static final Log log = LogFactory.getLog(IOTHomePage.class); private WebDriver driver; private UIElementMapper uiElementMapper; @@ -44,19 +42,19 @@ public class IOTHomePage { this.driver = driver; this.uiElementMapper = UIElementMapper.getInstance(); // Check that we're on the right page. - WebDriverWait wait = new WebDriverWait(driver, 10); + WebDriverWait wait = new WebDriverWait(driver, UIConstants.webDriverTimeOut); if (!wait.until(ExpectedConditions.titleIs("Device Management | IoT Server"))) { throw new IllegalStateException("This is not the home page"); } } - public boolean checkUserName() throws Exception{ + public boolean checkUserName() { String name = driver.findElement(By.xpath(uiElementMapper.getElement("iot.user.registered.name"))).getText(); return name.contains(uiElementMapper.getElement("iot.user.login.username")); } //To logout - public LoginPage logout() throws Exception { + public LoginPage logout() throws IOException { driver.findElement(By.xpath(uiElementMapper.getElement("iot.user.registered.name"))).click(); WebElement logout = driver.findElement(By.xpath(uiElementMapper.getElement("iot.user.logout.link.xpath"))); logout.click(); @@ -64,7 +62,7 @@ public class IOTHomePage { } //To enroll devices as user - public EnrollDevicePage enrollNewDevice() throws Exception{ + public EnrollDevicePage enrollNewDevice() throws IOException { driver.findElement(By.xpath("iot.home.page.uuf-menu.xpath")).click(); driver.findElement(By.xpath("iot.home.page.uuf-menu.devicemgt.xpath")).click(); driver.findElement(By.xpath("iot.home.enrollDevice.xpath")).click(); @@ -72,12 +70,12 @@ public class IOTHomePage { } //To add new Device groups as user - public void goToGroupMgt() throws Exception { + public void goToGroupMgt() { driver.findElement(By.xpath("iot.home.page.uuf-menu.xpath")).click(); driver.findElement(By.xpath("iot.home.page.uuf-menu.groupmgt.xpath")).click(); } - public DeviceAddGroupPage addNewGroup() throws Exception { + public DeviceAddGroupPage addNewGroup() throws IOException { driver.findElement(By.xpath("iot.device.viewGroup.empty.addGroup.xpath")).click(); return new DeviceAddGroupPage(driver); } diff --git a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/login/LoginPage.java b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/login/LoginPage.java index b974bfab..dbad5c00 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 @@ -24,6 +24,7 @@ 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.UIConstants; import org.wso2.iot.integration.ui.pages.UIElementMapper; import org.wso2.iot.integration.ui.pages.home.IOTAdminDashboard; import org.wso2.iot.integration.ui.pages.home.IOTHomePage; @@ -43,7 +44,7 @@ public class LoginPage { public LoginPage(WebDriver driver) throws IOException { this.driver = driver; this.uiElementMapper = UIElementMapper.getInstance(); - WebDriverWait webDriverWait = new WebDriverWait(driver, 10); + WebDriverWait webDriverWait = new WebDriverWait(driver, UIConstants.webDriverTimeOut); if (!webDriverWait.until(ExpectedConditions.titleContains("Login | IoT Server"))) { throw new IllegalStateException("This is not the Login page"); 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 7d6b239a..78039256 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 @@ -1,43 +1,44 @@ package org.wso2.iot.integration.ui.pages.uesr; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.openqa.selenium.By; 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.UIConstants; import org.wso2.iot.integration.ui.pages.UIElementMapper; +import java.io.IOException; + /** * This class represents the add user page of the IOT server. */ public class AddUserPage { - private static final Log log = LogFactory.getLog(AddUserPage.class); private WebDriver driver; private UIElementMapper uiElementMapper; - public AddUserPage(WebDriver driver) throws Exception { + public AddUserPage(WebDriver driver) throws IOException { this.driver = driver; this.uiElementMapper = UIElementMapper.getInstance(); - WebDriverWait webDriverWait = new WebDriverWait(driver, 10); - if (!webDriverWait.until(ExpectedConditions.titleContains("User Management | IoT Server"))){ + WebDriverWait webDriverWait = new WebDriverWait(driver, UIConstants.webDriverTimeOut); + if (!webDriverWait.until(ExpectedConditions.titleContains("User Management | IoT Server"))) { throw new IllegalStateException("This is not the Add User page"); } } /** * Method to create a new user. - * @param userName The username for the user. + * + * @param userName The username for the user. * @param firstName The user's first name. * @param lastName The user's last name. - * @param email Email address of the user. + * @param email Email address of the user. * @return The user added confirmation page. - * @throws Exception */ - public UserAddedConfirmationPage createNewUser(String userName, String firstName, String lastName, String email) throws Exception { + public UserAddedConfirmationPage createNewUser(String userName, String firstName, String lastName, String email) + throws IOException { WebElement userNameField = driver.findElement(By.id( uiElementMapper.getElement("iot.admin.addUser.username.id"))); @@ -53,7 +54,7 @@ public class AddUserPage { lastNameField.sendKeys(lastName); emailField.sendKeys(email); - WebDriverWait wait = new WebDriverWait(driver, 10); + WebDriverWait wait = new WebDriverWait(driver, UIConstants.webDriverTimeOut); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath( uiElementMapper.getElement("iot.admin.addUser.add.btn.xpath")))); 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 e66b54e5..8e87f150 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 @@ -6,6 +6,7 @@ import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; +import org.wso2.iot.integration.ui.pages.UIConstants; import org.wso2.iot.integration.ui.pages.UIElementMapper; /** @@ -20,7 +21,7 @@ public class EditUserPage { this.driver = driver; this.uiElementMapper = UIElementMapper.getInstance(); - WebDriverWait webDriverWait = new WebDriverWait(driver, 10); + WebDriverWait webDriverWait = new WebDriverWait(driver, UIConstants.webDriverTimeOut); if (!webDriverWait.until(ExpectedConditions.titleContains("User Management | IoT Server"))){ throw new IllegalStateException("This is not the Edit User page"); } 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 407da339..a371e6cb 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 @@ -1,12 +1,11 @@ package org.wso2.iot.integration.ui.pages.uesr; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.openqa.selenium.By; 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.UIConstants; import org.wso2.iot.integration.ui.pages.UIElementMapper; import org.wso2.iot.integration.ui.pages.login.LoginPage; @@ -16,7 +15,6 @@ import java.io.IOException; * This class represents the new user registration page. */ public class NewUserRegisterPage { - private static final Log log = LogFactory.getLog(NewUserRegisterPage.class); private WebDriver driver; private UIElementMapper uiElementMapper; @@ -24,26 +22,27 @@ public class NewUserRegisterPage { this.driver = driver; this.uiElementMapper = UIElementMapper.getInstance(); // Check that we're on the right page. - WebDriverWait webDriverWait = new WebDriverWait(driver, 10); - if (!webDriverWait.until(ExpectedConditions.titleContains("Register | IoT Server"))){ + WebDriverWait webDriverWait = new WebDriverWait(driver, UIConstants.webDriverTimeOut); + if (!webDriverWait.until(ExpectedConditions.titleContains("Register | IoT Server"))) { throw new IllegalStateException("This is not the Register page"); } } /** * The method to register a new user. - * @param firstName First name of the user. - * @param lastName Last name of the user. - * @param email Email address of the user. - * @param userName User name for the user. This will be used to login to the server. - * @param password The password for the user. + * + * @param firstName First name of the user. + * @param lastName Last name of the user. + * @param email Email address of the user. + * @param userName User name for the user. This will be used to login to the server. + * @param password The password for the user. * @param confirmPassword Password confirmation. * @return After the user is created it navigates back to the login page. * @throws IOException */ public LoginPage registerUser(String firstName, String lastName, String email, String userName, String password, String - confirmPassword) throws IOException { + confirmPassword) throws IOException { WebElement firstNameField = driver.findElement(By.xpath( uiElementMapper.getElement("iot.user.add.input.firstname.xpath"))); WebElement lastNameField = driver.findElement(By.xpath( 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 6893b952..a137db69 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 @@ -6,6 +6,8 @@ import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.wso2.iot.integration.ui.pages.UIElementMapper; +import java.io.IOException; + /** * This class represents the confirmation page for adding a new user. */ @@ -14,7 +16,7 @@ public class UserAddedConfirmationPage { private WebDriver driver; private UIElementMapper uiElementMapper; - public UserAddedConfirmationPage(WebDriver driver) throws Exception { + public UserAddedConfirmationPage(WebDriver driver) throws IOException { this.driver = driver; this.uiElementMapper = UIElementMapper.getInstance(); @@ -23,5 +25,4 @@ public class UserAddedConfirmationPage { } - } 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 fe8c35bc..86df142a 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 @@ -17,39 +17,33 @@ */ package org.wso2.iot.integration.ui.pages.uesr; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.wso2.iot.integration.ui.pages.UIElementMapper; +import java.io.IOException; + /** * Class to represent the user listing page. */ public class UserListingPage { - private static final Log log = LogFactory.getLog(UserListingPage.class); private WebDriver driver; private UIElementMapper uiElementMapper; - public UserListingPage(WebDriver driver) throws Exception { + public UserListingPage(WebDriver driver) throws IOException { this.driver = driver; this.uiElementMapper = UIElementMapper.getInstance(); - - if (!driver.findElement(By.xpath(uiElementMapper.getElement("iot.admin.user.listing.page.subtitle.xpath"))) - .getText().contains("USERS")){ - throw new IllegalStateException("This is not the User Listing page"); - } } /** * @return After deleting a user, returns back to the user listing page. - * @throws Exception */ - public UserListingPage deleteUser() throws Exception { + //Don't use generic exceptions. + public UserListingPage deleteUser() throws IOException, InterruptedException { WebElement deleteBtn = driver.findElement(By.xpath( uiElementMapper.getElement("iot.admin.deleteUser.btn.xpath"))); - if (deleteBtn!=null){ + if (deleteBtn != null) { deleteBtn.click(); } else { return new UserListingPage(driver); @@ -60,6 +54,4 @@ 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 9d66ff0b..dc514154 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 @@ -5,6 +5,7 @@ import org.apache.commons.logging.LogFactory; import org.openqa.selenium.WebDriver; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; +import org.wso2.iot.integration.ui.pages.UIConstants; import org.wso2.iot.integration.ui.pages.UIElementMapper; /** @@ -19,7 +20,7 @@ public class ViewUserPage { this.driver = driver; this.uiElementMapper = UIElementMapper.getInstance(); - WebDriverWait webDriverWait = new WebDriverWait(driver, 10); + WebDriverWait webDriverWait = new WebDriverWait(driver, UIConstants.webDriverTimeOut); if (!webDriverWait.until(ExpectedConditions.titleContains("User Management | IoT Server"))){ 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/LoginUtils.java b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/LoginUtils.java index e0da2d9f..e1102919 100644 --- a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/LoginUtils.java +++ b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/LoginUtils.java @@ -19,32 +19,30 @@ package org.wso2.carbon.iot.integration.web.ui.test; import org.openqa.selenium.WebDriver; import org.wso2.carbon.automation.engine.context.AutomationContext; -import org.wso2.iot.integration.ui.pages.UIElementMapper; import org.wso2.iot.integration.ui.pages.login.LoginPage; +import javax.xml.xpath.XPathExpressionException; +import java.io.IOException; + /** * This class is used to login to the system as the Admin. */ public class LoginUtils { - private static UIElementMapper uiElementMapper; /** - * * This method is used to login as admin. * - * @param driver The selenium web driver + * @param driver The selenium web driver * @param automationContext Test Automation context - * @param webAppURL The server url - * @throws Exception + * @param webAppURL The server url */ public static void login(WebDriver driver, AutomationContext automationContext, - String webAppURL) throws Exception { - uiElementMapper = UIElementMapper.getInstance(); + String webAppURL) throws IOException, XPathExpressionException { driver.get(webAppURL + Constants.IOT_LOGIN_PATH); LoginPage test = new LoginPage(driver); test.loginAsAdmin(automationContext.getSuperTenant().getTenantAdmin().getUserName(), automationContext.getSuperTenant().getTenantAdmin().getPassword()); - } + } } 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 724ab175..4695bad1 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 @@ -45,7 +45,7 @@ public class DeviceGroupFailTest extends IOTIntegrationUIBaseTestCase { } @Test(description = "Test for empty group name.") - public void addNewGroupFailTest () throws Exception { + public void addNewGroupFailTest() throws Exception { driver.get(getWebAppURL() + Constants.IOT_GROUP_ADD_URL); DeviceAddGroupPage addGroupPage = new DeviceAddGroupPage(driver); 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 ee06fbc9..42e935c5 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 @@ -47,13 +47,13 @@ public class DeviceGroupTest extends IOTIntegrationUIBaseTestCase { } @Test(description = "Test for adding a new device group.") - public void addNewGroupTest () throws Exception { + public void addNewGroupTest() throws Exception { DeviceAddGroupPage addGroupPage = adminDashboard.addGroup(); addGroupPage.addNewGroup("group1", "This is test group"); } - @Test (description = "Check whether the created group exists", dependsOnMethods = {"addNewGroupTest"}) - public void isGroupCreatedTest () throws Exception { + @Test(description = "Check whether the created group exists", dependsOnMethods = {"addNewGroupTest"}) + public void isGroupCreatedTest() throws Exception { driver.get(getWebAppURL() + Constants.IOT_HOME_URL); DeviceGroupsPage groupsPage = adminDashboard.viewGroups(); Assert.assertTrue(groupsPage.isGroupCreated("group1")); diff --git a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/login/LoginFailTest.java b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/login/LoginFailTest.java index f426182d..f4c9709e 100644 --- a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/login/LoginFailTest.java +++ b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/login/LoginFailTest.java @@ -33,9 +33,9 @@ import org.wso2.iot.integration.ui.pages.UIElementMapper; /** * Test cases to test the incorrect login from submissions. * Ex: - * 1. Empty form - * 2. Incorrect username or password - * 3. short password + * 1. Empty form + * 2. Incorrect username or password + * 3. short password */ public class LoginFailTest extends IOTIntegrationUIBaseTestCase { @@ -46,7 +46,7 @@ public class LoginFailTest extends IOTIntegrationUIBaseTestCase { WebElement passwordField; WebElement loginButton; - @BeforeClass (alwaysRun = true) + @BeforeClass(alwaysRun = true) public void setup() throws Exception { super.init(); driver = BrowserManager.getWebDriver(); @@ -60,16 +60,14 @@ public class LoginFailTest extends IOTIntegrationUIBaseTestCase { loginButton.click(); - Assert.assertEquals(driver.findElement(By.id(uiElementMapper.getElement("iot.user.login.username.error"))) - .getText(), "Please enter a username"); - Assert.assertEquals(driver.findElement(By.id(uiElementMapper.getElement("iot.user.login.password.error"))) - .getText(), "Please provide a password"); - + Assert.assertEquals(driver.findElement(By.id(uiElementMapper.getElement("iot.user.login.username.error"))). + getText(), "Please enter a username"); + Assert.assertEquals(driver.findElement(By.id(uiElementMapper.getElement("iot.user.login.password.error"))). + getText(), "Please provide a password"); } - @Test (description = "Test for incorrect username") + @Test(description = "Test for incorrect username") public void incorrectUserNameTest() throws Exception { - clearForm(); userNameField.sendKeys("admin1"); @@ -77,12 +75,11 @@ public class LoginFailTest extends IOTIntegrationUIBaseTestCase { loginButton.click(); - Assert.assertEquals(driver.findElement(By.xpath(uiElementMapper.getElement("iot.user.login.incorrect.xpath"))) - .getText(), "Incorrect username or password.!"); - + Assert.assertEquals(driver.findElement(By.xpath(uiElementMapper.getElement("iot.user.login.incorrect.xpath"))). + getText(), "Incorrect username or password.!"); } - @Test (description = "Test for incorrect password") + @Test(description = "Test for incorrect password") public void incorrectPasswordTest() throws Exception { clearForm(); @@ -91,15 +88,13 @@ public class LoginFailTest extends IOTIntegrationUIBaseTestCase { loginButton.click(); - Assert.assertEquals(driver.findElement(By.xpath(uiElementMapper.getElement("iot.user.login.incorrect.xpath"))) - .getText(), "Incorrect username or password.!"); - + Assert.assertEquals(driver.findElement(By.xpath(uiElementMapper.getElement("iot.user.login.incorrect.xpath"))). + getText(), "Incorrect username or password.!"); } - @Test (description = "Test for short password") + @Test(description = "Test for short password") public void shortPasswordTest() throws Exception { - clearForm(); userNameField.sendKeys(automationContext.getSuperTenant().getTenantAdmin().getUserName()); @@ -107,12 +102,11 @@ public class LoginFailTest extends IOTIntegrationUIBaseTestCase { loginButton.click(); - Assert.assertEquals(driver.findElement(By.id(uiElementMapper.getElement("iot.user.login.password.error"))) - .getText(), "Your password must be at least 3 characters long"); - + Assert.assertEquals(driver.findElement(By.id(uiElementMapper.getElement("iot.user.login.password.error"))). + getText(), "Your password must be at least 3 characters long"); } - public void clearForm() throws Exception{ + public void clearForm() throws Exception { driver.get(getWebAppURL() + Constants.IOT_LOGIN_PATH); uiElementMapper = UIElementMapper.getInstance(); 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 f976afbb..399caa86 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 @@ -29,30 +29,29 @@ import org.wso2.iot.integration.ui.pages.login.LoginPage; /** * Test Login as Admin - * */ public class LoginTest extends IOTIntegrationUIBaseTestCase { private WebDriver driver; - @BeforeClass (alwaysRun = true) + @BeforeClass(alwaysRun = true) public void setup() throws Exception { super.init(); driver = BrowserManager.getWebDriver(); driver.get(getWebAppURL() + Constants.IOT_LOGIN_PATH); } - @Test (description = "Verify login to IOT server dashboard") + @Test(description = "Verify login to IOT server dashboard") public void testAdminLogin() throws Exception { LoginPage test = new LoginPage(driver); IOTAdminDashboard dashboard = test.loginAsAdmin( - automationContext.getSuperTenant().getTenantAdmin().getUserName(), - automationContext.getSuperTenant().getTenantAdmin().getPassword()); + automationContext.getSuperTenant().getTenantAdmin().getUserName(), + automationContext.getSuperTenant().getTenantAdmin().getPassword()); dashboard.logout(); - driver.close(); } @AfterClass(alwaysRun = true) public void tearDown() throws Exception { + driver.close(); driver.quit(); } } diff --git a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/user/AddUserFailTest.java b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/user/AddUserFailTest.java index 8809afbc..8ea6b5d0 100644 --- a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/user/AddUserFailTest.java +++ b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/user/AddUserFailTest.java @@ -24,21 +24,24 @@ import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import org.wso2.carbon.automation.engine.context.AutomationContext; import org.wso2.carbon.automation.extensions.selenium.BrowserManager; import org.wso2.carbon.iot.integration.web.ui.test.Constants; import org.wso2.carbon.iot.integration.web.ui.test.LoginUtils; import org.wso2.iot.integration.ui.pages.IOTIntegrationUIBaseTestCase; import org.wso2.iot.integration.ui.pages.UIElementMapper; +import javax.xml.stream.XMLStreamException; +import javax.xml.xpath.XPathExpressionException; +import java.io.IOException; + /** * Test cases for - * 1. Empty form submission - * 2. Short user name - * 3. Empty First Name - * 4. Empty Last Name - * 5. Empty email - * 6. Incorrect email + * 1. Empty form submission + * 2. Short user name + * 3. Empty First Name + * 4. Empty Last Name + * 5. Empty email + * 6. Incorrect email */ public class AddUserFailTest extends IOTIntegrationUIBaseTestCase { @@ -52,7 +55,7 @@ public class AddUserFailTest extends IOTIntegrationUIBaseTestCase { WebElement addUserButton; @BeforeClass(alwaysRun = true) - public void setup() throws Exception { + public void setup() throws XPathExpressionException, XMLStreamException, IOException { super.init(); driver = BrowserManager.getWebDriver(); LoginUtils.login(driver, automationContext, getWebAppURL()); @@ -82,7 +85,6 @@ public class AddUserFailTest extends IOTIntegrationUIBaseTestCase { Assert.assertEquals(driver.findElement(By.xpath( uiElementMapper.getElement("iot.admin.addUser.formError.xpath"))).getText(), "Username is a required field. It cannot be empty."); - } @Test(description = "Test for short user name") @@ -99,7 +101,6 @@ public class AddUserFailTest extends IOTIntegrationUIBaseTestCase { Assert.assertEquals(driver.findElement(By.xpath( uiElementMapper.getElement("iot.admin.addUser.formError.xpath"))).getText(), "Username must be between 3 and 30 characters long."); - } @Test(description = "Test for empty first name") @@ -116,7 +117,6 @@ public class AddUserFailTest extends IOTIntegrationUIBaseTestCase { Assert.assertEquals(driver.findElement(By.xpath( uiElementMapper.getElement("iot.admin.addUser.formError.xpath"))).getText(), "Firstname is a required field. It cannot be empty."); - } @Test(description = "Test for empty last name") @@ -132,7 +132,6 @@ public class AddUserFailTest extends IOTIntegrationUIBaseTestCase { Assert.assertEquals(driver.findElement(By.xpath( uiElementMapper.getElement("iot.admin.addUser.formError.xpath"))).getText(), "Lastname is a required field. It cannot be empty."); - } @Test(description = "Test for empty email name") @@ -149,7 +148,6 @@ public class AddUserFailTest extends IOTIntegrationUIBaseTestCase { Assert.assertEquals(driver.findElement(By.xpath( uiElementMapper.getElement("iot.admin.addUser.formError.xpath"))).getText(), "Email is a required field. It cannot be empty."); - } @Test(description = "Test for incorrect email") @@ -168,7 +166,8 @@ public class AddUserFailTest extends IOTIntegrationUIBaseTestCase { "Provided email is invalid. Please check."); } - public void clearForm() { + + private void clearForm() { firstNameField.clear(); lastNameField.clear(); emailField.clear(); diff --git a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/user/RegisterTest.java b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/user/RegisterTest.java index 5cf16e24..0094ce43 100644 --- a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/user/RegisterTest.java +++ b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/user/RegisterTest.java @@ -18,6 +18,7 @@ package org.wso2.carbon.iot.integration.web.ui.test.user; import org.openqa.selenium.WebDriver; +import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -29,23 +30,26 @@ import org.wso2.iot.integration.ui.pages.home.IOTHomePage; import org.wso2.iot.integration.ui.pages.login.LoginPage; import org.wso2.iot.integration.ui.pages.uesr.NewUserRegisterPage; +import javax.xml.stream.XMLStreamException; +import javax.xml.xpath.XPathExpressionException; +import java.io.IOException; + /** * Test for registering a new user and login - * */ public class RegisterTest extends IOTIntegrationUIBaseTestCase { private WebDriver driver; UIElementMapper uiElementMapper; @BeforeClass(alwaysRun = true) - public void setup() throws Exception { + public void setup() throws XPathExpressionException, XMLStreamException, IOException { super.init(); driver = BrowserManager.getWebDriver(); driver.get(getWebAppURL() + Constants.IOT_LOGIN_PATH); } @Test(description = "Verify new User registration") - public void testUserRegister() throws Exception { + public void userRegisterTest() throws IOException { LoginPage test = new LoginPage(driver); uiElementMapper = UIElementMapper.getInstance(); NewUserRegisterPage registerTest = test.registerNewUser(); @@ -60,9 +64,7 @@ public class RegisterTest extends IOTIntegrationUIBaseTestCase { IOTHomePage homePage = loginPage.loginAsUser(uiElementMapper.getElement("iot.user.add.username"), uiElementMapper.getElement("iot.user.add.password")); - if (!homePage.checkUserName()){ - throw new Exception("Incorrect user logged in"); - } + Assert.assertTrue(homePage.checkUserName()); homePage.logout(); diff --git a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/user/RegistrationFormTests.java b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/user/RegistrationFormValidationTests.java similarity index 89% rename from modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/user/RegistrationFormTests.java rename to modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/user/RegistrationFormValidationTests.java index 5cfb12f1..b14e9412 100644 --- a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/user/RegistrationFormTests.java +++ b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/user/RegistrationFormValidationTests.java @@ -31,14 +31,18 @@ import org.wso2.carbon.iot.integration.web.ui.test.Constants; import org.wso2.iot.integration.ui.pages.IOTIntegrationUIBaseTestCase; import org.wso2.iot.integration.ui.pages.UIElementMapper; +import javax.xml.stream.XMLStreamException; +import javax.xml.xpath.XPathExpressionException; +import java.io.IOException; + /** * These test cases check for following: - * - Submitting an empty form - * - Existing username - * - Non matching passwords - * - Password, username length + * - Submitting an empty form + * - Existing username + * - Non matching passwords + * - Password, username length */ -public class RegistrationFormTests extends IOTIntegrationUIBaseTestCase{ +public class RegistrationFormValidationTests extends IOTIntegrationUIBaseTestCase { private WebDriver driver; UIElementMapper uiElementMapper; @@ -51,7 +55,7 @@ public class RegistrationFormTests extends IOTIntegrationUIBaseTestCase{ WebElement registerButton; @BeforeClass(alwaysRun = true) - public void setup() throws Exception { + public void setup() throws XPathExpressionException, XMLStreamException, IOException { super.init(); driver = BrowserManager.getWebDriver(); driver.get(getWebAppURL() + Constants.IOT_USER_REGISTER_URL); @@ -78,7 +82,7 @@ public class RegistrationFormTests extends IOTIntegrationUIBaseTestCase{ } @Test(description = "Test for submitting an empty registration form") - public void emptyFormTest() throws Exception { + public void emptyFormTest() { clearForm(); firstNameField.sendKeys(""); lastNameField.sendKeys(""); @@ -109,8 +113,8 @@ public class RegistrationFormTests extends IOTIntegrationUIBaseTestCase{ "Please enter a user login password"); } - @Test (description = "Test for non matching passwords") - public void nonMatchingPasswordTest() throws Exception { + @Test(description = "Test for non matching passwords") + public void nonMatchingPasswordTest() { clearForm(); firstNameField.sendKeys("User"); @@ -126,8 +130,8 @@ public class RegistrationFormTests extends IOTIntegrationUIBaseTestCase{ "Please enter the same password as above"); } - @Test (description = "Test for email") - public void incorrectEmail() throws Exception { + @Test(description = "Test for email") + public void incorrectEmailTest() { clearForm(); firstNameField.sendKeys("User"); @@ -138,11 +142,10 @@ public class RegistrationFormTests extends IOTIntegrationUIBaseTestCase{ Assert.assertEquals(driver.findElement(By.id( uiElementMapper.getElement("iot.user.register.email.error"))).getText(), "Email is not valid. Please enter a correct email address."); - } - @Test (description = "Test for password length") - public void passwordLengthTest() throws Exception { + @Test(description = "Test for password length") + public void passwordLengthTest() { clearForm(); firstNameField.sendKeys("User"); @@ -156,11 +159,10 @@ public class RegistrationFormTests extends IOTIntegrationUIBaseTestCase{ Assert.assertEquals(driver.findElement(By.id( uiElementMapper.getElement("iot.user.register.password.error"))).getText(), "Password should be between 5 and 30 characters."); - } @AfterClass(alwaysRun = true) - public void tearDown() throws Exception { + 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/TestAdminFunctions.java b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/user/TestAdminFunctions.java index 95c0c301..fb0bb9ff 100644 --- a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/user/TestAdminFunctions.java +++ b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/user/TestAdminFunctions.java @@ -29,38 +29,41 @@ import org.wso2.iot.integration.ui.pages.home.IOTAdminDashboard; import org.wso2.iot.integration.ui.pages.uesr.AddUserPage; import org.wso2.iot.integration.ui.pages.uesr.UserListingPage; +import javax.xml.stream.XMLStreamException; +import javax.xml.xpath.XPathExpressionException; +import java.io.IOException; + /** * Test for check following admin capabilities. - * - Create a new User - * - Delete a user + * - Create a new User + * - Delete a user */ public class TestAdminFunctions extends IOTIntegrationUIBaseTestCase { private WebDriver driver; @BeforeClass(alwaysRun = true) - public void setup() throws Exception { + public void setup() throws IOException, XPathExpressionException, XMLStreamException { super.init(); driver = BrowserManager.getWebDriver(); LoginUtils.login(driver, automationContext, getWebAppURL()); } @Test(description = "Test for creating a new user") - public void createUserTest() throws Exception { + public void createUserTest() throws IOException { IOTAdminDashboard adminDashboard = new IOTAdminDashboard(driver); AddUserPage addUserPage = adminDashboard.addUser(); addUserPage.createNewUser("user1", "User", "User", "user@wso2.com"); } @Test(description = "Test for deleting a created user", dependsOnMethods = {"createUserTest"}) - public void deleteUserTest() throws Exception { + public void deleteUserTest() throws XPathExpressionException, IOException, InterruptedException { driver.get(getWebAppURL() + Constants.IOT_HOME_URL); IOTAdminDashboard adminDashboard = new IOTAdminDashboard(driver); UserListingPage userListingPage = adminDashboard.viewUser(); userListingPage.deleteUser(); } - @AfterClass(alwaysRun = true) public void tearDown() throws Exception { driver.quit(); diff --git a/pom.xml b/pom.xml index 52eb64dc..9df00635 100644 --- a/pom.xml +++ b/pom.xml @@ -307,7 +307,7 @@ org.wso2.iot org.wso2.carbon.iot.integration.ui.pages - ${carbon.device.mgt.plugin.version} + ${carbon.iot.device.mgt.version} test @@ -1049,6 +1049,9 @@ 1.1.0-SNAPSHOT [0.8.0, 2.0.0) + + 1.0.0-SNAPSHOT + 2.0.4-SNAPSHOT 2.0.0-SNAPSHOT