Added constants.

merge-requests/1/head
Menaka Madushanka 9 years ago
parent e3f8956d29
commit d71b00d925

@ -35,7 +35,7 @@
<modules> <modules>
<!--<module>tests-artifacts</module>--> <!--<module>tests-artifacts</module>-->
<module>tests-common</module> <module>tests-common</module>
<module>tests-integration</module> <!--<module>tests-integration</module>-->
<!--<module>tests-ui-integration</module>--> <!--<module>tests-ui-integration</module>-->
<module>tests-iot-web-ui</module> <module>tests-iot-web-ui</module>
</modules> </modules>

@ -1,64 +0,0 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.iot.integration.ui.pages;
import org.wso2.carbon.authenticator.stub.LoginAuthenticationExceptionException;
import org.wso2.carbon.automation.engine.context.AutomationContext;
import org.wso2.carbon.automation.engine.context.TestUserMode;
import org.wso2.carbon.automation.test.utils.common.HomePageGenerator;
import org.wso2.carbon.integration.common.admin.client.AuthenticatorClient;
import javax.xml.stream.XMLStreamException;
import javax.xml.xpath.XPathExpressionException;
import java.io.IOException;
import java.rmi.RemoteException;
public class IOTIntegrationUIBaseTestCase {
protected AutomationContext automationContext;
protected void init() throws IOException, XMLStreamException, XPathExpressionException {
automationContext = new AutomationContext("IOT", "iot001", TestUserMode.SUPER_TENANT_ADMIN);
}
protected String getBackendURL() throws XPathExpressionException {
return automationContext.getContextUrls().getBackEndUrl();
}
protected String getWebAppURL() throws XPathExpressionException {
return automationContext.getContextUrls().getWebAppURL();
}
protected String getSessionCookie(AutomationContext context)
throws RemoteException, XPathExpressionException, LoginAuthenticationExceptionException {
AuthenticatorClient authenticationAdminClient = new AuthenticatorClient(context.getContextUrls().getBackEndUrl());
return authenticationAdminClient.login(automationContext.getSuperTenant().
getTenantAdmin().getUserName(), automationContext.getSuperTenant().
getTenantAdmin().getPassword(),
automationContext.getDefaultInstance().getHosts().get("default"));
}
protected String getServiceURL() throws XPathExpressionException {
String serviceURL = automationContext.getContextUrls().getServiceUrl();
return automationContext.getContextUrls().getServiceUrl();
}
protected String getLoginURL() throws XPathExpressionException {
return HomePageGenerator.getProductHomeURL(automationContext);
}
}

@ -33,8 +33,7 @@ public class AssertUtil {
* @param realPayload real json string. * @param realPayload real json string.
* @param mustMatch If the real and expected must match, in order to become the test successful or not. * @param mustMatch If the real and expected must match, in order to become the test successful or not.
*/ */
public static void jsonPayloadCompare(String expectedJsonPayload, String realPayload, public static void jsonPayloadCompare(String expectedJsonPayload, String realPayload, boolean mustMatch) {
boolean mustMatch) {
JsonElement jsonElement = new JsonParser().parse(expectedJsonPayload); JsonElement jsonElement = new JsonParser().parse(expectedJsonPayload);
JsonObject expectedPayloadObject = jsonElement.getAsJsonObject(); JsonObject expectedPayloadObject = jsonElement.getAsJsonObject();
jsonElement = new JsonParser().parse(realPayload); jsonElement = new JsonParser().parse(realPayload);

@ -27,9 +27,51 @@ public class Constants {
public static final String IOT_DEVICES_URL = "/devicemgt/devices"; public static final String IOT_DEVICES_URL = "/devicemgt/devices";
public static final String IOT_CONNECTED_CUP_NAME = "testDevice"; public static final String IOT_CONNECTED_CUP_NAME = "testDevice";
public static final String GROUP_NAME_FIELD_ERROR = "Group Name is a required field. It cannot be empty.";
public static final String GROUP_NAME = "group1";
public static final String GROUP_DESCRIPTION = "This is a test group";
public static final String LOGIN_USER_NAME_ERROR = "Please enter a username";
public static final String LOGIN_PASSWORD_ERROR = "Please provide a password";
public static final String LOGIN_FAILED_ERROR = "Incorrect username or password.!";
public static final String LOGIN_SHORT_PASSWORD_ERROR = "Your password must be at least 3 characters long";
public static final String LOGIN_WRONG_USER_NAME = "admnnn";
public static final String LOGIN_WRONG_USER_PASSWORD = "admmmm";
public static final String LOGIN_SHORT_PASSWORD = "ad";
public static final String ADD_USER_FIRST_NAME = "User";
public static final String ADD_USER_LAST_NAME = "User";
public static final String ADD_USER_EMAIL = "user@wso2.com";
public static final String ADD_USER_EMAIL_ERROR = "user.com";
public static final String ADD_USER_USER_NAME = "user";
public static final String ADD_USER_SHORT_USER_NAME = "us";
public static final String REGISTER_USER_FIRST_NAME = "Firstname";
public static final String REGISTER_USER_LAST_NAME = "Lastname";
public static final String REGISTER_USER_USER_NAME = "testUser";
public static final String REGISTER_USER_PASSWORD = "testPassword";
public static final String REGISTER_USER_CONFIRM_PASSWORD = "testPassword";
public static final String REGISTER_USER_EMAIL = "userName@wso2.com";
public static final String IOT_SERVER_LOGIN_PAGE_TITLE = "Login | IoT Server";
public static final String ADD_USER_SHORT_USER_NAME_ERROR_MSG = "Username must be between 3 and 30 characters long.";
public static final String ADD_USER_FIRST_NAME_ERROR_MSG = "Firstname is a required field. It cannot be empty.";
public static final String ADD_USER_LAST_NAME_ERROR_MSG = "Lastname is a required field. It cannot be empty.";
public static final String ADD_USER_NO_EMAIL_ERROR_MSG = "Email is a required field. It cannot be empty.";
public static final String ADD_USER_WRONG_EMAIL_ERROR_MSG = "Email is a required field. It cannot be empty.";
public static final String ALERT_NOT_PRESENT = "Alert is not present.";
public static final String CARBON_HOME = "carbon.home";
public static final String OS_NAME = "os.name";
public static final String 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 = "34"; public static final String IOT_CONNECTED_CUP_LEVEl = "75";
public static final String IOT_CONNECTED_CUP_TEMPERATURE = "53"; 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";
@ -47,6 +89,11 @@ public class Constants {
public static final String IOT_CONNECTED_CUP_COFFEE_LEVEL_Y_AXIS = "Coffeelevel"; public static final String IOT_CONNECTED_CUP_COFFEE_LEVEL_Y_AXIS = "Coffeelevel";
public static final String IOT_CONNECTED_CUP_COFFEE_LEVEL_X_AXIS = "time"; public static final String IOT_CONNECTED_CUP_COFFEE_LEVEL_X_AXIS = "time";
public static final String IOT_TEST_GROUP_SAMPLE_INSTALL = "iot.sample";
public static final String IOT_TEST_GROUP_SAMPLE_INSTALL_VERIFY = "iot.sample.install";
public static final String IOT_TEST_GROUP_SAMPLE_VERIFY = "iot.sample.install.verify";
public static final String IOT_TEST_GROUP_SAMPLE_ENROLL = "iot.sample.enroll";
public static final String IOT_TEST_GROUP_SAMPLE_ENROLL_VERIFY = "iot.sample.enroll.verify";
public static final String IOT_TEST_GROUP_SAMPLE_TEMPERATURE = "iot.sample.temp";
public static final String IOT_TEST_GROUP_SAMPLE_COFFEELEVEL = "iot.sample.level";
} }

@ -48,7 +48,7 @@ public class DeviceGroupFailTest extends IOTIntegrationUIBaseTestCase {
driver.get(getWebAppURL() + Constants.IOT_GROUP_ADD_URL); driver.get(getWebAppURL() + Constants.IOT_GROUP_ADD_URL);
DeviceAddGroupPage addGroupPage = new DeviceAddGroupPage(driver); DeviceAddGroupPage addGroupPage = new DeviceAddGroupPage(driver);
Assert.assertEquals(addGroupPage.submitEmptyForm(), "Group Name is a required field. It cannot be empty."); Assert.assertEquals(addGroupPage.submitEmptyForm(), Constants.GROUP_NAME_FIELD_ERROR);
} }
@AfterClass(alwaysRun = true) @AfterClass(alwaysRun = true)

@ -51,14 +51,14 @@ public class DeviceGroupTest extends IOTIntegrationUIBaseTestCase {
@Test(description = "Test for adding a new device group.") @Test(description = "Test for adding a new device group.")
public void addNewGroupTest() throws IOException { public void addNewGroupTest() throws IOException {
DeviceAddGroupPage addGroupPage = adminDashboard.addGroup(); DeviceAddGroupPage addGroupPage = adminDashboard.addGroup();
addGroupPage.addNewGroup("group1", "This is test group"); addGroupPage.addNewGroup(Constants.GROUP_NAME, Constants.GROUP_DESCRIPTION);
} }
@Test(description = "Check whether the created group exists", dependsOnMethods = {"addNewGroupTest"}) @Test(description = "Check whether the created group exists", dependsOnMethods = {"addNewGroupTest"})
public void isGroupCreatedTest() throws IOException, XPathExpressionException { public void isGroupCreatedTest() throws IOException, XPathExpressionException {
driver.get(getWebAppURL() + Constants.IOT_HOME_URL); driver.get(getWebAppURL() + Constants.IOT_HOME_URL);
DeviceGroupsPage groupsPage = adminDashboard.viewGroups(); DeviceGroupsPage groupsPage = adminDashboard.viewGroups();
Assert.assertTrue(groupsPage.isGroupCreated("group1")); Assert.assertTrue(groupsPage.isGroupCreated(Constants.GROUP_NAME));
} }
@AfterClass(alwaysRun = true) @AfterClass(alwaysRun = true)

@ -67,23 +67,23 @@ 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(), "Please enter a username"); Assert.assertEquals(alertUserName.getText(), Constants.LOGIN_USER_NAME_ERROR);
Assert.assertEquals(alertPassword.getText(), "Please provide a password"); Assert.assertEquals(alertPassword.getText(), Constants.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("admin1"); userNameField.sendKeys(Constants.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(), "Incorrect username or password.!"); Assert.assertEquals(alert.getText(), Constants.LOGIN_FAILED_ERROR);
} else { } else {
Assert.assertTrue(false, "Alert is not present."); Assert.assertTrue(false, Constants.ALERT_NOT_PRESENT);
} }
} }
@ -92,14 +92,14 @@ 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("admnn"); passwordField.sendKeys(Constants.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(), "Incorrect username or password.!"); Assert.assertEquals(alert.getText(), Constants.LOGIN_FAILED_ERROR);
} else { } else {
Assert.assertTrue(false, "Alert is not present."); Assert.assertTrue(false, Constants.ALERT_NOT_PRESENT);
} }
} }
@ -108,14 +108,14 @@ 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("ad"); passwordField.sendKeys(Constants.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(), "Your password must be at least 3 characters long"); Assert.assertEquals(alert.getText(), Constants.LOGIN_SHORT_PASSWORD_ERROR);
} else { } else {
Assert.assertTrue(false, "Alert is not present."); Assert.assertTrue(false, Constants.ALERT_NOT_PRESENT);
} }
} }

@ -52,14 +52,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 = {"iot.enroll"}, groups = Constants.IOT_TEST_GROUP_SAMPLE_ENROLL,
dependsOnGroups = {"iot.install"}) dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_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 = {"iot.enroll"}, groups = Constants.IOT_TEST_GROUP_SAMPLE_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));

@ -52,15 +52,15 @@ public class SampleEnrolmentVerificationTest extends IOTIntegrationUIBaseTestCas
} }
@Test(description = "Verify enrolment of the sample device", @Test(description = "Verify enrolment of the sample device",
groups = {"iot.enroll.verify"}, groups = Constants.IOT_TEST_GROUP_SAMPLE_ENROLL_VERIFY,
dependsOnGroups = "iot.enroll") dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_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 = {"iot.enroll.verify"}) groups = Constants.IOT_TEST_GROUP_SAMPLE_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);

@ -61,36 +61,37 @@ public class SampleFunctionalityTest extends IOTIntegrationUIBaseTestCase {
} }
@Test(description = "Set the temperature level.", @Test(description = "Set the temperature level.",
groups = {"iot.sample.verify"}, groups = Constants.IOT_TEST_GROUP_SAMPLE_VERIFY,
dependsOnGroups = "iot.enroll.verify") dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_ENROLL_VERIFY)
public void setTemperatureTest() { public void setTemperatureTest() {
Assert.assertTrue(sampleViewPage.changeTemperature(Constants.IOT_CONNECTED_CUP_TEMPERATURE)); Assert.assertTrue(sampleViewPage.changeTemperature(Constants.IOT_CONNECTED_CUP_TEMPERATURE));
} }
@Test(description = "Set the coffee level.", @Test(description = "Set the coffee level.",
groups = {"iot.sample.verify"}, groups = Constants.IOT_TEST_GROUP_SAMPLE_VERIFY,
dependsOnGroups = "iot.enroll.verify") dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_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.IOT_CONNECTED_CUP_LEVEl));
} }
@Test(description = "Verify order coffee function.", @Test(description = "Verify order coffee function.",
groups = {"iot.sample.verify"}, groups = Constants.IOT_TEST_GROUP_SAMPLE_VERIFY,
dependsOnGroups = "iot.enroll.verify") dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_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 = {"iot.sample.verify"}, groups = Constants.IOT_TEST_GROUP_SAMPLE_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(connectedCupDeviceViewPage.isGraphsAvailable(2));
} }
@Test(description = "Test the Y axis name of Temperature graph.", @Test(description = "Test the Y axis name of Temperature graph.",
groups = {"iot.sample.verify", "sample.temp"}, groups = {Constants.IOT_TEST_GROUP_SAMPLE_VERIFY,
dependsOnGroups = {"iot.enroll.verify"}, Constants.IOT_TEST_GROUP_SAMPLE_TEMPERATURE},
dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_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(connectedCupDeviceViewPage.graphAxisName(Constants.IOT_GRAPH_Y_AXIS,
@ -99,8 +100,9 @@ public class SampleFunctionalityTest extends IOTIntegrationUIBaseTestCase {
} }
@Test(description = "Test the X axis name of Temperature graph.", @Test(description = "Test the X axis name of Temperature graph.",
groups = {"iot.sample.verify", "sample.temp"}, groups = {Constants.IOT_TEST_GROUP_SAMPLE_VERIFY,
dependsOnGroups = {"iot.enroll.verify"}, Constants.IOT_TEST_GROUP_SAMPLE_TEMPERATURE},
dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_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(connectedCupDeviceViewPage.graphAxisName(Constants.IOT_GRAPH_X_AXIS,
@ -109,8 +111,9 @@ public class SampleFunctionalityTest extends IOTIntegrationUIBaseTestCase {
} }
@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 = {"iot.sample.verify", "sample.temp"}, groups = {Constants.IOT_TEST_GROUP_SAMPLE_VERIFY,
dependsOnGroups = {"iot.enroll.verify"}, Constants.IOT_TEST_GROUP_SAMPLE_TEMPERATURE},
dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_ENROLL_VERIFY,
dependsOnMethods = {"verifyGraphs"}) dependsOnMethods = {"verifyGraphs"})
public void temperatureGraphLegendTest() { public void temperatureGraphLegendTest() {
Assert.assertTrue(connectedCupDeviceViewPage.graphLegendName(Constants.IOT_CONNECTED_CUP_TEMPERATURE_ID, Assert.assertTrue(connectedCupDeviceViewPage.graphLegendName(Constants.IOT_CONNECTED_CUP_TEMPERATURE_ID,
@ -118,16 +121,18 @@ public class SampleFunctionalityTest extends IOTIntegrationUIBaseTestCase {
} }
@Test(description = "Test the whether the Temperature graph path is visible.", @Test(description = "Test the whether the Temperature graph path is visible.",
groups = {"iot.sample.verify", "sample.temp"}, groups = {Constants.IOT_TEST_GROUP_SAMPLE_VERIFY,
dependsOnGroups = {"iot.enroll.verify"}, Constants.IOT_TEST_GROUP_SAMPLE_TEMPERATURE},
dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_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(connectedCupDeviceViewPage.checkGraphPath(Constants.IOT_CONNECTED_CUP_TEMPERATURE_GRAPH_ID));
} }
@Test(description = "Test the whether the Temperature graph gets values.", @Test(description = "Test the whether the Temperature graph gets values.",
groups = {"iot.sample.verify", "sample.temp"}, groups = {Constants.IOT_TEST_GROUP_SAMPLE_VERIFY,
dependsOnGroups = {"iot.enroll.verify"}, Constants.IOT_TEST_GROUP_SAMPLE_TEMPERATURE},
dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_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(connectedCupDeviceViewPage.checkGraphValues(Constants.IOT_CONNECTED_CUP_TEMPERATURE_GRAPH_ID,
@ -135,8 +140,8 @@ public class SampleFunctionalityTest extends IOTIntegrationUIBaseTestCase {
} }
@Test(description = "Test the Y axis name of Coffee Level graph.", @Test(description = "Test the Y axis name of Coffee Level graph.",
groups = {"iot.sample.coffee"}, groups = Constants.IOT_TEST_GROUP_SAMPLE_COFFEELEVEL,
dependsOnGroups = {"sample.temp"}) dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_TEMPERATURE)
public void coffeeLevelGraphYAxisNameTest() { public void coffeeLevelGraphYAxisNameTest() {
Assert.assertTrue(connectedCupDeviceViewPage.graphAxisName(Constants.IOT_GRAPH_Y_AXIS, Assert.assertTrue(connectedCupDeviceViewPage.graphAxisName(Constants.IOT_GRAPH_Y_AXIS,
Constants.IOT_CONNECTED_CUP_COFFEE_LEVEL_ID, Constants.IOT_CONNECTED_CUP_COFFEE_LEVEL_ID,
@ -144,8 +149,9 @@ public class SampleFunctionalityTest extends IOTIntegrationUIBaseTestCase {
} }
@Test(description = "Test the X axis name of Coffee Level graph.", @Test(description = "Test the X axis name of Coffee Level graph.",
groups = {"iot.sample.coffee"}, groups = Constants.IOT_TEST_GROUP_SAMPLE_COFFEELEVEL,
dependsOnGroups = {"iot.enroll.verify", "sample.temp"}) dependsOnGroups = {Constants.IOT_TEST_GROUP_SAMPLE_ENROLL_VERIFY,
Constants.IOT_TEST_GROUP_SAMPLE_TEMPERATURE})
public void coffeeLevelGraphXAxisNameTest() { public void coffeeLevelGraphXAxisNameTest() {
Assert.assertTrue(connectedCupDeviceViewPage.graphAxisName(Constants.IOT_GRAPH_X_AXIS, Assert.assertTrue(connectedCupDeviceViewPage.graphAxisName(Constants.IOT_GRAPH_X_AXIS,
Constants.IOT_CONNECTED_CUP_COFFEE_LEVEL_ID, Constants.IOT_CONNECTED_CUP_COFFEE_LEVEL_ID,
@ -153,23 +159,23 @@ public class SampleFunctionalityTest extends IOTIntegrationUIBaseTestCase {
} }
@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 = {"iot.sample.coffee"}, groups = Constants.IOT_TEST_GROUP_SAMPLE_COFFEELEVEL,
dependsOnGroups = {"sample.temp"}) dependsOnGroups = {Constants.IOT_TEST_GROUP_SAMPLE_TEMPERATURE})
public void coffeeLevelGraphLegendTest() throws IOException { public void coffeeLevelGraphLegendTest() throws IOException {
Assert.assertTrue(connectedCupDeviceViewPage.graphLegendName(Constants.IOT_CONNECTED_CUP_COFFEE_LEVEL_ID, Assert.assertTrue(connectedCupDeviceViewPage.graphLegendName(Constants.IOT_CONNECTED_CUP_COFFEE_LEVEL_ID,
Constants.IOT_CONNECTED_CUP_COFFEE_LEVEL_LEGEND)); Constants.IOT_CONNECTED_CUP_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 = {"iot.sample.coffee"}, groups = Constants.IOT_TEST_GROUP_SAMPLE_COFFEELEVEL,
dependsOnGroups = {"sample.temp"}) dependsOnGroups = {Constants.IOT_TEST_GROUP_SAMPLE_TEMPERATURE})
public void coffeeLevelGraphPathTest() { public void coffeeLevelGraphPathTest() {
Assert.assertTrue(connectedCupDeviceViewPage.checkGraphPath(Constants.IOT_CONNECTED_CUP_COFFEE_LEVEL_GRAPH_ID)); Assert.assertTrue(connectedCupDeviceViewPage.checkGraphPath(Constants.IOT_CONNECTED_CUP_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 = {"iot.sample.coffee"}, groups = Constants.IOT_TEST_GROUP_SAMPLE_COFFEELEVEL,
dependsOnGroups = {"sample.temp"}) dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_TEMPERATURE)
public void coffeeLevelGraphDataPublisherTest() { public void coffeeLevelGraphDataPublisherTest() {
Assert.assertTrue(connectedCupDeviceViewPage.checkGraphValues(Constants.IOT_CONNECTED_CUP_COFFEE_LEVEL_GRAPH_ID, Assert.assertTrue(connectedCupDeviceViewPage.checkGraphValues(Constants.IOT_CONNECTED_CUP_COFFEE_LEVEL_GRAPH_ID,
Constants.IOT_CONNECTED_CUP_LEVEl)); Constants.IOT_CONNECTED_CUP_LEVEl));

@ -64,7 +64,7 @@ public class SampleInstallationTest extends IOTIntegrationUIBaseTestCase {
private Log log = LogFactory.getLog(SampleInstallationTest.class); private Log log = LogFactory.getLog(SampleInstallationTest.class);
private Process tempProcess = null; private Process tempProcess = null;
private Properties properties = System.getProperties(); private Properties properties = System.getProperties();
private String carbonHome = properties.getProperty("carbon.home"); private String carbonHome = properties.getProperty(Constants.CARBON_HOME);
private String[] cmdArray; private String[] cmdArray;
private LogViewerClient logViewerClient; private LogViewerClient logViewerClient;
@ -75,14 +75,14 @@ public class SampleInstallationTest extends IOTIntegrationUIBaseTestCase {
logViewerClient = new LogViewerClient(getBackendURL(), getSessionCookie(automationContext)); logViewerClient = new LogViewerClient(getBackendURL(), getSessionCookie(automationContext));
} }
@Test(groups = {"iot.sample"}, @Test(description = "Verify the sample build process",
description = "Verify the sample build process") groups = Constants.IOT_TEST_GROUP_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);
File dir = new File(connectedCupDir); File dir = new File(connectedCupDir);
try { try {
if (System.getProperty("os.name").toLowerCase().contains("windows")) { if (System.getProperty(Constants.OS_NAME).toLowerCase().contains("windows")) {
log.info("Executing maven clean install --------------------------------"); log.info("Executing maven clean install --------------------------------");
cmdArray = new String[]{"cmd.exe", "/c", "mvn clean install"}; cmdArray = new String[]{"cmd.exe", "/c", "mvn clean install"};
tempProcess = Runtime.getRuntime().exec(cmdArray, null, dir); tempProcess = Runtime.getRuntime().exec(cmdArray, null, dir);
@ -92,7 +92,7 @@ public class SampleInstallationTest extends IOTIntegrationUIBaseTestCase {
tempProcess = Runtime.getRuntime().exec(cmdArray, null, dir); tempProcess = Runtime.getRuntime().exec(cmdArray, null, dir);
} }
boolean buildStatus = waitForMessage(tempProcess.getInputStream(), "BUILD SUCCESS"); boolean buildStatus = waitForMessage(tempProcess.getInputStream(), Constants.BUILD_SUCCESS_MSG);
Assert.assertTrue(buildStatus, "Building the sample was not successful"); Assert.assertTrue(buildStatus, "Building the sample was not successful");
} finally { } finally {
if (tempProcess != null) { if (tempProcess != null) {
@ -101,23 +101,23 @@ public class SampleInstallationTest extends IOTIntegrationUIBaseTestCase {
} }
} }
@Test(groups = {"iot.sample"}, @Test(description = "Verify the sample installation process",
description = "Verify the sample installation process", groups = Constants.IOT_TEST_GROUP_SAMPLE_INSTALL,
dependsOnMethods = {"sampleBuildTest"}) dependsOnMethods = {"sampleBuildTest"})
public void sampleInstallationTest() throws IOException { public void sampleInstallationTest() throws IOException {
log.info("CARBON_HOME: " + System.getProperty("carbon.home")); log.info("CARBON_HOME: " + System.getProperty(Constants.CARBON_HOME));
File dir = new File(carbonHome); File dir = new File(carbonHome);
log.info("Sample installation started : mvn clean install -f device-deployer.xml"); log.info("Sample installation started : mvn clean install -f device-deployer.xml");
try { try {
if (System.getProperty("os.name").toLowerCase().contains("windows")) { if (System.getProperty(Constants.OS_NAME).toLowerCase().contains("windows")) {
cmdArray = new String[]{"cmd.exe", "/c", "mvn clean install -f device-deployer.xml"}; cmdArray = new String[]{"cmd.exe", "/c", "mvn clean install -f device-deployer.xml"};
tempProcess = Runtime.getRuntime().exec(cmdArray, null, dir); tempProcess = Runtime.getRuntime().exec(cmdArray, null, dir);
} else { } else {
cmdArray = new String[]{"mvn", "clean", "install", "-f", "device-deployer.xml"}; cmdArray = new String[]{"mvn", "clean", "install", "-f", "device-deployer.xml"};
tempProcess = Runtime.getRuntime().exec(cmdArray, null, dir); tempProcess = Runtime.getRuntime().exec(cmdArray, null, dir);
} }
boolean buildStatus = waitForMessage(tempProcess.getInputStream(), "BUILD SUCCESS"); boolean buildStatus = waitForMessage(tempProcess.getInputStream(), Constants.BUILD_SUCCESS_MSG);
Assert.assertTrue(buildStatus, "Sample installation was not successful"); Assert.assertTrue(buildStatus, "Sample installation was not successful");
} finally { } finally {
if (tempProcess != null) { if (tempProcess != null) {
@ -126,8 +126,8 @@ public class SampleInstallationTest extends IOTIntegrationUIBaseTestCase {
} }
} }
@Test(groups = {"iot.sample"}, @Test(description = "Test restarting the server",
description = "Test restarting the server", groups = Constants.IOT_TEST_GROUP_SAMPLE_INSTALL,
dependsOnMethods = {"sampleInstallationTest"}) dependsOnMethods = {"sampleInstallationTest"})
public void serverRestartTest() { public void serverRestartTest() {
ServerConfigurationManager serverManager; ServerConfigurationManager serverManager;

@ -23,6 +23,7 @@ import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.wso2.carbon.automation.extensions.selenium.BrowserManager; import org.wso2.carbon.automation.extensions.selenium.BrowserManager;
import org.wso2.carbon.iot.integration.web.ui.test.common.Constants;
import org.wso2.carbon.iot.integration.web.ui.test.common.LoginUtils; import org.wso2.carbon.iot.integration.web.ui.test.common.LoginUtils;
import org.wso2.carbon.iot.integration.web.ui.test.common.IOTIntegrationUIBaseTestCase; import org.wso2.carbon.iot.integration.web.ui.test.common.IOTIntegrationUIBaseTestCase;
import org.wso2.iot.integration.ui.pages.devices.EnrollDevicePage; import org.wso2.iot.integration.ui.pages.devices.EnrollDevicePage;
@ -48,8 +49,9 @@ public class SampleInstallationVerification extends IOTIntegrationUIBaseTestCase
adminDashboard = new IOTAdminDashboard(driver); adminDashboard = new IOTAdminDashboard(driver);
} }
@Test(description = "Verify the sample is available in Virtual devices section.", groups = {"iot.install"}, @Test(description = "Verify the sample is available in Virtual devices section.",
dependsOnGroups = {"iot.sample"}) groups = Constants.IOT_TEST_GROUP_SAMPLE_INSTALL_VERIFY,
dependsOnGroups = Constants.IOT_TEST_GROUP_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());

@ -94,10 +94,10 @@ public class AddUserFormValidationTest extends IOTIntegrationUIBaseTestCase {
public void shortUserNameTest() { public void shortUserNameTest() {
clearForm(); clearForm();
firstNameField.sendKeys("User"); firstNameField.sendKeys(Constants.ADD_USER_FIRST_NAME);
lastNameField.sendKeys("User"); lastNameField.sendKeys(Constants.ADD_USER_LAST_NAME);
emailField.sendKeys("user@wso2.com"); emailField.sendKeys(Constants.ADD_USER_EMAIL);
userNameField.sendKeys("us"); userNameField.sendKeys(Constants.ADD_USER_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(), "Username must be between 3 and 30 characters long."); Assert.assertEquals(alert.getText(), Constants.ADD_USER_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("User"); lastNameField.sendKeys(Constants.ADD_USER_LAST_NAME);
emailField.sendKeys("user@wso2.com"); emailField.sendKeys(Constants.ADD_USER_EMAIL);
userNameField.sendKeys("user1"); userNameField.sendKeys(Constants.ADD_USER_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(), "Firstname is a required field. It cannot be empty."); Assert.assertEquals(alert.getText(), Constants.ADD_USER_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("User"); firstNameField.sendKeys(Constants.ADD_USER_FIRST_NAME);
lastNameField.sendKeys(""); lastNameField.sendKeys("");
emailField.sendKeys("user@wso2.com"); emailField.sendKeys(Constants.ADD_USER_EMAIL);
userNameField.sendKeys("user1"); userNameField.sendKeys(Constants.ADD_USER_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(), "Lastname is a required field. It cannot be empty."); Assert.assertEquals(alert.getText(), Constants.ADD_USER_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("User"); firstNameField.sendKeys(Constants.ADD_USER_FIRST_NAME);
lastNameField.sendKeys("User"); lastNameField.sendKeys(Constants.ADD_USER_LAST_NAME);
emailField.sendKeys(""); emailField.sendKeys("");
userNameField.sendKeys("user1"); userNameField.sendKeys(Constants.ADD_USER_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(), "Email is a required field. It cannot be empty."); Assert.assertEquals(alert.getText(), Constants.ADD_USER_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("User"); firstNameField.sendKeys(Constants.ADD_USER_FIRST_NAME);
lastNameField.sendKeys("User"); lastNameField.sendKeys(Constants.ADD_USER_LAST_NAME);
emailField.sendKeys("user.com"); emailField.sendKeys(Constants.ADD_USER_EMAIL_ERROR);
userNameField.sendKeys("user1"); userNameField.sendKeys(Constants.ADD_USER_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(), "Provided email is invalid. Please check."); Assert.assertEquals(alert.getText(), Constants.ADD_USER_WRONG_EMAIL_ERROR_MSG);
} }
private void clearForm() { private void clearForm() {

@ -50,18 +50,16 @@ public class NewUserRegistrationTest extends IOTIntegrationUIBaseTestCase {
@Test(description = "Verify new User registration") @Test(description = "Verify new User registration")
public void userRegisterTest() throws IOException { public void userRegisterTest() throws IOException {
LoginPage login = new LoginPage(driver); LoginPage login = new LoginPage(driver);
UIElementMapper uiElementMapper = UIElementMapper.getInstance();
NewUserRegisterPage registerTest = login.registerNewUser(); NewUserRegisterPage registerTest = login.registerNewUser();
LoginPage loginPage = registerTest.registerUser( LoginPage loginPage = registerTest.registerUser(Constants.REGISTER_USER_FIRST_NAME,
uiElementMapper.getElement("iot.user.add.firstname"), Constants.REGISTER_USER_LAST_NAME,
uiElementMapper.getElement("iot.user.add.lastname"), Constants.REGISTER_USER_EMAIL,
uiElementMapper.getElement("iot.user.add.email"), Constants.REGISTER_USER_USER_NAME,
uiElementMapper.getElement("iot.user.add.username"), Constants.REGISTER_USER_PASSWORD,
uiElementMapper.getElement("iot.user.add.password"), Constants.REGISTER_USER_CONFIRM_PASSWORD);
uiElementMapper.getElement("iot.user.add.password"));
IOTHomePage homePage = loginPage.loginAsUser(uiElementMapper.getElement("iot.user.add.username"), IOTHomePage homePage = loginPage.loginAsUser(Constants.REGISTER_USER_USER_NAME,
uiElementMapper.getElement("iot.user.add.password")); Constants.REGISTER_USER_PASSWORD);
Assert.assertTrue(homePage.checkUserName()); Assert.assertTrue(homePage.checkUserName());
} }
@ -70,7 +68,7 @@ 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(), "Login | IoT Server"); Assert.assertEquals(driver.getTitle(), Constants.IOT_SERVER_LOGIN_PAGE_TITLE);
} }
@AfterClass(alwaysRun = true) @AfterClass(alwaysRun = true)

Loading…
Cancel
Save