add tests on create and import device profiles

This commit is contained in:
Serafym Tuhai 2022-12-26 16:31:06 +02:00
parent 832b406420
commit d629151266
15 changed files with 627 additions and 25 deletions

View File

@ -278,6 +278,18 @@ public class TestRestClient {
.as(JsonNode.class);
}
public PageData<DeviceProfile> getDeviceProfiles(PageLink pageLink) {
Map<String, String> params = new HashMap<>();
addPageLinkToParam(params, pageLink);
return given().spec(requestSpec).queryParams(params)
.get("/api/deviceProfiles")
.then()
.statusCode(HTTP_OK)
.extract()
.as(new TypeRef<PageData<DeviceProfile>>() {
});
}
public DeviceProfile getDeviceProfileById(DeviceProfileId deviceProfileId) {
return given().spec(requestSpec).get("/api/deviceProfile/{deviceProfileId}", deviceProfileId.getId())
.then()
@ -296,6 +308,13 @@ public class TestRestClient {
.as(DeviceProfile.class);
}
public void deleteDeviseProfile(DeviceProfileId deviceProfileId) {
given().spec(requestSpec)
.delete("/api/deviceProfile/{deviceProfileId}", deviceProfileId.getId())
.then()
.statusCode(HTTP_OK);
}
public Customer postCustomer(Customer customer) {
return given().spec(requestSpec)
.body(customer)

View File

@ -35,6 +35,7 @@ import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.thingsboard.server.common.data.Customer;
import org.thingsboard.server.common.data.DeviceProfile;
import org.thingsboard.server.common.data.page.PageLink;
import org.thingsboard.server.common.data.rule.RuleChain;
import org.thingsboard.server.msa.AbstractContainerTest;
@ -113,6 +114,11 @@ abstract public class AbstractDriverBaseTest extends AbstractContainerTest {
.filter(x -> x.getName().equals(name)).collect(Collectors.toList()).get(0);
}
public static DeviceProfile getDeviceProfileByName(String name) {
return testRestClient.getDeviceProfiles(pageLink).getData().stream()
.filter(x -> x.getName().equals(name)).collect(Collectors.toList()).get(0);
}
@SneakyThrows
@Attachment(value = "Page screenshot", type = "image/png")
public static byte[] captureScreen(WebDriver driver, String dirPath) {

View File

@ -15,6 +15,7 @@
*/
package org.thingsboard.server.msa.ui.pages;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.thingsboard.server.msa.ui.base.AbstractBasePage;
@ -62,9 +63,14 @@ public class OtherPageElements extends AbstractBasePage {
private static final String ERROR_MESSAGE = "//mat-error";
private static final String ENTITY_VIEW_TITLE = "//div[@class='tb-details-title']//span";
private static final String LIST_OF_ENTITY = "//div[@role='listbox']/mat-option";
private static final String ENTITY_FROM_LIST = "//div[@role='listbox']/mat-option//span[contains(text(),'%s')]";
protected static final String ADD_ENTITY_VIEW = "//tb-add-entity-dialog";
protected static final String STATE_CONTROLLER = "//tb-entity-state-controller";
private static final String SEARCH_FIELD = "//input[contains (@data-placeholder,'Search')]";
private static final String BROWSE_FILE = "//input[@class='file-input']";
private static final String IMPORT_BROWSE_FILE = "//mat-dialog-container//span[contains(text(),'Import')]/..";
private static final String IMPORTING_FILE = "//div[contains(text(),'%s')]";
private static final String CLEAR_IMPORT_FILE_BTN = "//div[@class='tb-file-clear-container']//button";
public String getEntity(String entityName) {
return String.format(ENTITY, entityName);
@ -235,6 +241,10 @@ public class OtherPageElements extends AbstractBasePage {
return waitUntilElementsToBeClickable(LIST_OF_ENTITY);
}
public WebElement entityFromList(String entityName) {
return waitUntilVisibilityOfElementLocated(String.format(ENTITY_FROM_LIST, entityName));
}
public WebElement addEntityView() {
return waitUntilVisibilityOfElementLocated(ADD_ENTITY_VIEW);
}
@ -246,4 +256,21 @@ public class OtherPageElements extends AbstractBasePage {
public WebElement searchField() {
return waitUntilElementToBeClickable(SEARCH_FIELD);
}
public WebElement browseFile() {
waitUntilElementToBeClickable(BROWSE_FILE + "/preceding-sibling::button");
return driver.findElement(By.xpath(BROWSE_FILE));
}
public WebElement importBrowseFileBtn() {
return waitUntilElementToBeClickable(IMPORT_BROWSE_FILE);
}
public WebElement importingFile(String fileName) {
return waitUntilVisibilityOfElementLocated(String.format(IMPORTING_FILE, fileName));
}
public WebElement clearImportFileBtn() {
return waitUntilElementToBeClickable(CLEAR_IMPORT_FILE_BTN);
}
}

View File

@ -0,0 +1,93 @@
/**
* Copyright © 2016-2022 The Thingsboard Authors
*
* Licensed 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.thingsboard.server.msa.ui.pages;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.w3c.dom.html.HTMLInputElement;
public class ProfilesPageElements extends OtherPageElementsHelper {
public ProfilesPageElements(WebDriver driver) {
super(driver);
}
private static final String CREATE_DEVICE_PROFILE_BTN = "//span[text()='Create new device profile']";
private static final String IMPORT_PROFILE_BTN = "//span[text()='Import device profile']";
private static final String ADD_DEVICE_PROFILE_VIEW = "//tb-add-device-profile-dialog";
private static final String DEVICE_PROFILE_VIEW = "//tb-entity-details-panel";
private static final String NAME_FIELD = "//input[@formcontrolname='name']";
private static final String RULE_CHAIN_FIELD = "//input[@formcontrolname='ruleChainId']";
private static final String DASHBOARD_FIELD = "//input[@formcontrolname='dashboard']";
private static final String QUEUE_FIELD = "//input[@formcontrolname='queueName']";
private static final String DESCRIPTION_FIELD = "//textarea[@formcontrolname='description']";
private static final String ADD_DEVICE_PROFILE_ADD_BTN = ADD_DEVICE_PROFILE_VIEW + "//span[text() = 'Add']/..";
public WebElement createNewDeviceProfileBtn() {
return waitUntilElementToBeClickable(CREATE_DEVICE_PROFILE_BTN);
}
public WebElement importDeviceProfileBtn() {
return waitUntilElementToBeClickable(IMPORT_PROFILE_BTN);
}
public WebElement addDeviceProfileView() {
return waitUntilElementToBeClickable(ADD_DEVICE_PROFILE_VIEW);
}
public WebElement addDeviceProfileNameField() {
return waitUntilElementToBeClickable(ADD_DEVICE_PROFILE_VIEW + NAME_FIELD);
}
public WebElement profileViewNameField() {
return waitUntilVisibilityOfElementLocated(DEVICE_PROFILE_VIEW + NAME_FIELD);
}
public WebElement addDeviceProfileRuleChainField() {
return waitUntilElementToBeClickable(ADD_DEVICE_PROFILE_VIEW + RULE_CHAIN_FIELD);
}
public WebElement profileViewRuleChainField() {
return waitUntilVisibilityOfElementLocated(DEVICE_PROFILE_VIEW + RULE_CHAIN_FIELD);
}
public WebElement addDeviceProfileMobileDashboardField() {
return waitUntilElementToBeClickable(ADD_DEVICE_PROFILE_VIEW + DASHBOARD_FIELD);
}
public WebElement profileViewMobileDashboardField() {
return waitUntilVisibilityOfElementLocated(DEVICE_PROFILE_VIEW + DASHBOARD_FIELD);
}
public WebElement addDeviceProfileQueueField() {
return waitUntilElementToBeClickable(ADD_DEVICE_PROFILE_VIEW + QUEUE_FIELD);
}
public WebElement profileViewQueueField() {
return waitUntilVisibilityOfElementLocated(DEVICE_PROFILE_VIEW + QUEUE_FIELD);
}
public WebElement addDeviceDescriptionField() {
return waitUntilElementToBeClickable(ADD_DEVICE_PROFILE_VIEW + DESCRIPTION_FIELD);
}
public WebElement profileViewDescriptionField() {
return waitUntilVisibilityOfElementLocated(DEVICE_PROFILE_VIEW + DESCRIPTION_FIELD);
}
public WebElement addDeviceProfileAddBtn() {
return waitUntilElementToBeClickable(ADD_DEVICE_PROFILE_ADD_BTN);
}
}

View File

@ -0,0 +1,105 @@
/**
* Copyright © 2016-2022 The Thingsboard Authors
*
* Licensed 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.thingsboard.server.msa.ui.pages;
import org.openqa.selenium.WebDriver;
public class ProfilesPageHelper extends ProfilesPageElements {
public ProfilesPageHelper(WebDriver driver) {
super(driver);
}
private String name;
private String ruleChain;
private String mobileDashboard;
private String queue;
private String description;
public void setName() {
this.name = profileViewNameField().getAttribute("value");
}
public void setRuleChain() {
this.ruleChain = profileViewRuleChainField().getAttribute("value");
}
public void setMobileDashboard() {
this.mobileDashboard = profileViewMobileDashboardField().getAttribute("value");
}
public void setQueue() {
this.queue = profileViewQueueField().getAttribute("value");
}
public void setDescription() {
this.description = profileViewDescriptionField().getAttribute("value");
}
public String getName() {
return this.name;
}
public String getRuleChain() {
return this.ruleChain;
}
public String getMobileDashboard() {
return this.mobileDashboard;
}
public String getQueue() {
return this.queue;
}
public String getDescription() {
return this.description;
}
public void enterName(String name) {
addDeviceProfileNameField().click();
addDeviceProfileNameField().sendKeys(name);
}
public void chooseRuleChain(String ruleChain) {
addDeviceProfileRuleChainField().click();
entityFromList(ruleChain).click();
}
public void chooseMobileDashboard(String mobileDashboard) {
addDeviceProfileMobileDashboardField().click();
entityFromList(mobileDashboard).click();
}
public void chooseQueue(String queue) {
addDeviceProfileQueueField().click();
entityFromList(queue).click();
}
public void enterDescription(String description) {
addDeviceDescriptionField().sendKeys(description);
}
public void openCreateDeviceProfileView() {
plusBtn().click();
createNewDeviceProfileBtn().click();
}
public void openImportDeviceProfileView() {
plusBtn().click();
importDeviceProfileBtn().click();
}
}

View File

@ -35,10 +35,6 @@ public class RuleChainsPageElements extends OtherPageElementsHelper {
private static final String RULE_CHAINS_NAMES_WITHOUT_ROOT = "//mat-icon[contains(text(),'check_box_outline_blank')]/../../../mat-cell[contains(@class,'name')]/span";
private static final String DELETE_RULE_CHAIN_FROM_VIEW_BTN = "//span[contains(text(),' Delete')]";
private static final String IMPORT_RULE_CHAIN_BTN = "//span[contains(text(),'Import rule chain')]";
private static final String BROWSE_FILE = "//input[@class='file-input']";
private static final String IMPORT_BROWSE_FILE = "//mat-dialog-container//span[contains(text(),'Import')]/..";
private static final String IMPORTING_FILE = "//div[contains(text(),'%s')]";
private static final String CLEAR_IMPORT_FILE_BTN = "//div[@class='tb-file-clear-container']//button";
private static final String OPEN_RULE_CHAIN = ENTITY + "/../..//mat-icon[contains(text(),' settings_ethernet')]";
private static final String OPEN_RULE_CHAIN_FROM_VIEW = "//span[contains(text(),'Open rule chain')]";
private static final String MAKE_ROOT_FROM_VIEW = "(//span[contains(text(),' Make rule chain root ')]/..)[1]";
@ -85,23 +81,6 @@ public class RuleChainsPageElements extends OtherPageElementsHelper {
return waitUntilElementToBeClickable(DELETE_RULE_CHAIN_FROM_VIEW_BTN);
}
public WebElement browseFile() {
waitUntilElementToBeClickable(BROWSE_FILE + "/preceding-sibling::button");
return driver.findElement(By.xpath(BROWSE_FILE));
}
public WebElement importBrowseFileBtn() {
return waitUntilElementToBeClickable(IMPORT_BROWSE_FILE);
}
public WebElement importingFile(String fileName) {
return waitUntilVisibilityOfElementLocated(String.format(IMPORTING_FILE, fileName));
}
public WebElement clearImportFileBtn() {
return waitUntilElementToBeClickable(CLEAR_IMPORT_FILE_BTN);
}
public WebElement openRuleChainFromViewBtn() {
return waitUntilElementToBeClickable(OPEN_RULE_CHAIN_FROM_VIEW);
}

View File

@ -27,6 +27,8 @@ public class SideBarMenuViewElements extends AbstractBasePage {
private static final String RULE_CHAINS_BTN = "//mat-toolbar//a[@href='/ruleChains']";
private static final String CUSTOMER_BTN = "//mat-toolbar//a[@href='/customers']";
private static final String DASHBOARD_BTN = "//mat-toolbar//a[@href='/dashboards']";
private static final String PROFILES_BTN = "//mat-toolbar//a[@href='/profiles']";
private static final String DEVICE_PROFILE_BTN = "//mat-toolbar//a[@href='/profiles/deviceProfiles']";
public WebElement ruleChainsBtn() {
return waitUntilElementToBeClickable(RULE_CHAINS_BTN);
@ -39,4 +41,12 @@ public class SideBarMenuViewElements extends AbstractBasePage {
public WebElement dashboardBtn() {
return waitUntilElementToBeClickable(DASHBOARD_BTN);
}
public WebElement profilesBtn() {
return waitUntilElementToBeClickable(PROFILES_BTN);
}
public WebElement deviceProfileBtn() {
return waitUntilElementToBeClickable(DEVICE_PROFILE_BTN);
}
}

View File

@ -0,0 +1,29 @@
/**
* Copyright © 2016-2022 The Thingsboard Authors
*
* Licensed 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.thingsboard.server.msa.ui.pages;
import org.openqa.selenium.WebDriver;
public class SideBarMenuViewHelper extends SideBarMenuViewElements{
public SideBarMenuViewHelper(WebDriver driver) {
super(driver);
}
public void openDeviceProfiles() {
profilesBtn().click();
deviceProfileBtn().click();
}
}

View File

@ -0,0 +1,98 @@
package org.thingsboard.server.msa.ui.tests.deviceProfileSmoke;
import io.qameta.allure.Description;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.thingsboard.server.msa.ui.base.AbstractDriverBaseTest;
import org.thingsboard.server.msa.ui.pages.LoginPageHelper;
import org.thingsboard.server.msa.ui.pages.ProfilesPageHelper;
import org.thingsboard.server.msa.ui.pages.SideBarMenuViewHelper;
import static org.thingsboard.server.msa.ui.utils.Const.EMPTY_IMPORT_MESSAGE;
import static org.thingsboard.server.msa.ui.utils.Const.ENTITY_NAME;
import static org.thingsboard.server.msa.ui.utils.Const.IMPORT_DEVICE_PROFILE_FILE_NAME;
import static org.thingsboard.server.msa.ui.utils.Const.IMPORT_DEVICE_PROFILE_NAME;
import static org.thingsboard.server.msa.ui.utils.Const.IMPORT_TXT_FILE_NAME;
import static org.thingsboard.server.msa.ui.utils.Const.TENANT_EMAIL;
import static org.thingsboard.server.msa.ui.utils.Const.TENANT_PASSWORD;
public class CreateDeviceProfileImportTest extends AbstractDriverBaseTest {
private SideBarMenuViewHelper sideBarMenuView;
private ProfilesPageHelper profilesPage;
private final String absolutePathToFileImportDeviceProfile = getClass().getClassLoader().getResource(IMPORT_DEVICE_PROFILE_FILE_NAME).getPath();
private final String absolutePathToFileImportTxt = getClass().getClassLoader().getResource(IMPORT_TXT_FILE_NAME).getPath();
private String name;
@BeforeMethod
public void login() {
openLocalhost();
new LoginPageHelper(driver).authorizationTenant();
testRestClient.login(TENANT_EMAIL, TENANT_PASSWORD);
sideBarMenuView = new SideBarMenuViewHelper(driver);
profilesPage = new ProfilesPageHelper(driver);
}
@AfterMethod
public void delete() {
if (name != null) {
testRestClient.deleteDeviseProfile(getDeviceProfileByName(name).getId());
name = null;
}
}
@Test
public void importDeviceProfile() {
sideBarMenuView.openDeviceProfiles();
profilesPage.openImportDeviceProfileView();
profilesPage.browseFile().sendKeys(absolutePathToFileImportDeviceProfile);
profilesPage.importBrowseFileBtn().click();
name = IMPORT_DEVICE_PROFILE_NAME;
profilesPage.refreshBtn().click();
Assert.assertNotNull(profilesPage.entity(IMPORT_DEVICE_PROFILE_NAME));
Assert.assertTrue(profilesPage.entity(IMPORT_DEVICE_PROFILE_NAME).isDisplayed());
}
@Test
public void importTxtFile() {
sideBarMenuView.openDeviceProfiles();
profilesPage.openImportDeviceProfileView();
profilesPage.browseFile().sendKeys(absolutePathToFileImportTxt);
Assert.assertNotNull(profilesPage.importingFile(EMPTY_IMPORT_MESSAGE));
Assert.assertTrue(profilesPage.importingFile(EMPTY_IMPORT_MESSAGE).isDisplayed());
}
@Test(groups = "smoke")
@Description
public void addFileTiImportAndRemove() {
sideBarMenuView.openDeviceProfiles();
profilesPage.openImportDeviceProfileView();
profilesPage.browseFile().sendKeys(absolutePathToFileImportDeviceProfile);
profilesPage.clearImportFileBtn().click();
Assert.assertNotNull(profilesPage.importingFile(EMPTY_IMPORT_MESSAGE));
Assert.assertTrue(profilesPage.importingFile(EMPTY_IMPORT_MESSAGE).isDisplayed());
Assert.assertTrue(profilesPage.entityIsNotPresent(IMPORT_DEVICE_PROFILE_NAME));
}
@Test
public void importDeviceProfileWithSameName() {
String name = ENTITY_NAME;
testRestClient.postDeviceProfile()
sideBarMenuView.openDeviceProfiles();
profilesPage.openImportDeviceProfileView();
profilesPage.browseFile().sendKeys(absolutePathToFileImportDeviceProfile);
profilesPage.importBrowseFileBtn().click();
this.name = IMPORT_DEVICE_PROFILE_NAME;
profilesPage.refreshBtn().click();
Assert.assertNotNull(profilesPage.entity(IMPORT_DEVICE_PROFILE_NAME));
Assert.assertTrue(profilesPage.entity(IMPORT_DEVICE_PROFILE_NAME).isDisplayed());
}
}

View File

@ -0,0 +1,184 @@
/**
* Copyright © 2016-2022 The Thingsboard Authors
*
* Licensed 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.thingsboard.server.msa.ui.tests.deviceProfileSmoke;
import io.qameta.allure.Description;
import org.openqa.selenium.Keys;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.thingsboard.server.msa.ui.base.AbstractDriverBaseTest;
import org.thingsboard.server.msa.ui.pages.LoginPageHelper;
import org.thingsboard.server.msa.ui.pages.ProfilesPageHelper;
import org.thingsboard.server.msa.ui.pages.SideBarMenuViewHelper;
import org.thingsboard.server.msa.ui.utils.EntityPrototypes;
import static org.thingsboard.server.msa.ui.utils.Const.EMPTY_DEVICE_PROFILE_MESSAGE;
import static org.thingsboard.server.msa.ui.utils.Const.ENTITY_NAME;
import static org.thingsboard.server.msa.ui.utils.Const.NAME_IS_REQUIRED_MESSAGE;
import static org.thingsboard.server.msa.ui.utils.Const.SAME_NAME_WARNING_DEVICE_PROFILE_MESSAGE;
import static org.thingsboard.server.msa.ui.utils.Const.TENANT_EMAIL;
import static org.thingsboard.server.msa.ui.utils.Const.TENANT_PASSWORD;
public class CreateDeviceProfileTest extends AbstractDriverBaseTest {
private SideBarMenuViewHelper sideBarMenuView;
private ProfilesPageHelper profilesPage;
private String name;
@BeforeMethod
public void login() {
openLocalhost();
new LoginPageHelper(driver).authorizationTenant();
testRestClient.login(TENANT_EMAIL, TENANT_PASSWORD);
sideBarMenuView = new SideBarMenuViewHelper(driver);
profilesPage = new ProfilesPageHelper(driver);
}
@AfterMethod
public void delete() {
if (name != null) {
testRestClient.deleteDeviseProfile(getDeviceProfileByName(name).getId());
name = null;
}
}
@Test
public void createDeviceProfile() {
String name = ENTITY_NAME;
sideBarMenuView.openDeviceProfiles();
profilesPage.openCreateDeviceProfileView();
profilesPage.addDeviceProfileNameField().click();
profilesPage.addDeviceProfileNameField().sendKeys(name);
profilesPage.addDeviceProfileAddBtn().click();
this.name = name;
profilesPage.refreshBtn().click();
Assert.assertNotNull(profilesPage.entity(name));
Assert.assertTrue(profilesPage.entity(name).isDisplayed());
}
@Test
public void createDeviceProfileWithDetails() {
String name = ENTITY_NAME;
String ruleChain = "Root Rule Chain";
String mobileDashboard = "Firmware";
String queue = "Main";
String description = "Description";
sideBarMenuView.openDeviceProfiles();
profilesPage.openCreateDeviceProfileView();
profilesPage.enterName(name);
profilesPage.chooseRuleChain(ruleChain);
profilesPage.chooseMobileDashboard(mobileDashboard);
profilesPage.chooseQueue(queue);
profilesPage.enterDescription(description);
profilesPage.addDeviceProfileAddBtn().click();
this.name = name;
profilesPage.refreshBtn().click();
profilesPage.entity(name).click();
profilesPage.setName();
profilesPage.setRuleChain();
profilesPage.setMobileDashboard();
profilesPage.setQueue();
profilesPage.setDescription();
Assert.assertNotNull(profilesPage.entity(name));
Assert.assertTrue(profilesPage.entity(name).isDisplayed());
Assert.assertEquals(name, profilesPage.getName());
Assert.assertEquals(ruleChain, profilesPage.getRuleChain());
Assert.assertEquals(mobileDashboard, profilesPage.getMobileDashboard());
Assert.assertEquals(queue, profilesPage.getQueue());
Assert.assertEquals(description, profilesPage.getDescription());
}
@Test
public void createDeviseProfileWithSameName() {
String name = ENTITY_NAME;
testRestClient.postDeviceProfile(EntityPrototypes.defaultDeviceProfile(name));
this.name = name;
sideBarMenuView.openDeviceProfiles();
profilesPage.openCreateDeviceProfileView();
profilesPage.addDeviceProfileNameField().click();
profilesPage.addDeviceProfileNameField().sendKeys(name);
profilesPage.addDeviceProfileAddBtn().click();
Assert.assertNotNull(profilesPage.warningMessage());
Assert.assertTrue(profilesPage.warningMessage().isDisplayed());
Assert.assertEquals(profilesPage.warningMessage().getText(), SAME_NAME_WARNING_DEVICE_PROFILE_MESSAGE);
Assert.assertNotNull(profilesPage.addDeviceProfileView());
Assert.assertTrue(profilesPage.addDeviceProfileView().isDisplayed());
}
@Test
public void createDeviceProfileWithoutName() {
sideBarMenuView.openDeviceProfiles();
profilesPage.openCreateDeviceProfileView();
profilesPage.addDeviceProfileAddBtn().click();
Assert.assertNotNull(profilesPage.addDeviceProfileView());
Assert.assertTrue(profilesPage.addDeviceProfileView().isDisplayed());
Assert.assertNotNull(profilesPage.errorMessage());
Assert.assertEquals(profilesPage.errorMessage().getText(), NAME_IS_REQUIRED_MESSAGE);
}
@Test
public void createDeviseProfileWithOnlySpaceInName() {
sideBarMenuView.openDeviceProfiles();
profilesPage.openCreateDeviceProfileView();
profilesPage.addDeviceProfileNameField().click();
profilesPage.addDeviceProfileNameField().sendKeys(Keys.SPACE);
profilesPage.addDeviceProfileAddBtn().click();
Assert.assertNotNull(profilesPage.warningMessage());
Assert.assertTrue(profilesPage.warningMessage().isDisplayed());
Assert.assertEquals(profilesPage.warningMessage().getText(), EMPTY_DEVICE_PROFILE_MESSAGE);
Assert.assertNotNull(profilesPage.addDeviceProfileView());
Assert.assertTrue(profilesPage.addDeviceProfileView().isDisplayed());
}
@Test
public void createDeviceProfileWithoutRefresh() {
String name = ENTITY_NAME;
sideBarMenuView.openDeviceProfiles();
profilesPage.openCreateDeviceProfileView();
profilesPage.addDeviceProfileNameField().click();
profilesPage.addDeviceProfileNameField().sendKeys(name);
profilesPage.addDeviceProfileAddBtn().click();
this.name = name;
Assert.assertNotNull(profilesPage.entity(name));
Assert.assertTrue(profilesPage.entity(name).isDisplayed());
}
@Test(groups = "smoke")
@Description
public void documentation() {
String urlPath = "docs/user-guide/device-profiles/";
sideBarMenuView.openDeviceProfiles();
profilesPage.allEntity().get(0).click();
profilesPage.goToHelpPage();
Assert.assertTrue(urlContains(urlPath));
}
}

View File

@ -83,7 +83,7 @@ public class CreateRuleChainImportTest extends AbstractDriverBaseTest {
Assert.assertNotNull(ruleChainsPage.importingFile(EMPTY_IMPORT_MESSAGE));
Assert.assertTrue(ruleChainsPage.importingFile(EMPTY_IMPORT_MESSAGE).isDisplayed());
Assert.assertTrue(ruleChainsPage.entityIsNotPresent(IMPORT_TXT_FILE_NAME));
Assert.assertTrue(ruleChainsPage.entityIsNotPresent(IMPORT_RULE_CHAIN_FILE_NAME));
}
@Test(priority = 20, groups = "smoke")

View File

@ -25,13 +25,18 @@ public class Const {
public static final String TENANT_PASSWORD = "tenant";
public static final String ENTITY_NAME = "Az!@#$%^&*()_-+=~`" + getRandomNumber();
public static final String ROOT_RULE_CHAIN_NAME = "Root Rule Chain";
public static final String IMPORT_RULE_CHAIN_NAME = "Rule Chain from Import";
public static final String IMPORT_RULE_CHAIN_FILE_NAME = "forImport.json";
public static final String IMPORT_RULE_CHAIN_NAME = "Rule Chain For Import";
public static final String IMPORT_DEVICE_PROFILE_NAME = "Device Profile For Import";
public static final String IMPORT_RULE_CHAIN_FILE_NAME = "ruleChainForImport.json";
public static final String IMPORT_DEVICE_PROFILE_FILE_NAME = "deviceProfileForImport.json";
public static final String IMPORT_TXT_FILE_NAME = "forImport.txt";
public static final String EMPTY_IMPORT_MESSAGE = "No file selected";
public static final String EMPTY_RULE_CHAIN_MESSAGE = "Rule chain name should be specified!";
public static final String EMPTY_CUSTOMER_MESSAGE = "Customer title should be specified!";
public static final String EMPTY_DEVICE_PROFILE_MESSAGE = "Device profile name should be specified!";
public static final String DELETE_RULE_CHAIN_WITH_PROFILE_MESSAGE = "The rule chain referenced by the device profiles cannot be deleted!";
public static final String SAME_NAME_WARNING_CUSTOMER_MESSAGE = "Customer with such title already exists!";
public static final String SAME_NAME_WARNING_DEVICE_PROFILE_MESSAGE = "Device profile with such name already exists!";
public static final String PHONE_NUMBER_ERROR_MESSAGE = "Phone number is invalid or not possible";
public static final String NAME_IS_REQUIRED_MESSAGE = "Name is required.";
}

View File

@ -16,6 +16,12 @@
package org.thingsboard.server.msa.ui.utils;
import org.thingsboard.server.common.data.Customer;
import org.thingsboard.server.common.data.DeviceProfile;
import org.thingsboard.server.common.data.DeviceProfileType;
import org.thingsboard.server.common.data.DeviceTransportType;
import org.thingsboard.server.common.data.device.profile.AllowCreateNewDevicesDeviceProfileProvisionConfiguration;
import org.thingsboard.server.common.data.device.profile.DefaultDeviceProfileTransportConfiguration;
import org.thingsboard.server.common.data.device.profile.DeviceProfileData;
import org.thingsboard.server.common.data.rule.RuleChain;
public class EntityPrototypes {
@ -31,4 +37,16 @@ public class EntityPrototypes {
ruleChain.setName(entityName);
return ruleChain;
}
public static DeviceProfile defaultDeviceProfile(String entityName){
DeviceProfile deviceProfile = new DeviceProfile();
deviceProfile.setName(entityName);
deviceProfile.setType(DeviceProfileType.DEFAULT);
deviceProfile.setTransportType(DeviceTransportType.DEFAULT);
DeviceProfileData deviceProfileData = new DeviceProfileData();
deviceProfileData.setProvisionConfiguration( new AllowCreateNewDevicesDeviceProfileProvisionConfiguration(""));
deviceProfileData.setTransportConfiguration(new DefaultDeviceProfileTransportConfiguration());
deviceProfile.setProfileData(deviceProfileData);
return deviceProfile;
}
}

View File

@ -0,0 +1,29 @@
{
"name": "Device Profile For Import",
"description": "",
"image": null,
"type": "DEFAULT",
"transportType": "DEFAULT",
"provisionType": "DISABLED",
"defaultRuleChainId": null,
"defaultDashboardId": null,
"defaultQueueName": null,
"profileData": {
"configuration": {
"type": "DEFAULT"
},
"transportConfiguration": {
"type": "DEFAULT"
},
"provisionConfiguration": {
"type": "DISABLED",
"provisionDeviceSecret": null
},
"alarms": null
},
"provisionDeviceKey": null,
"firmwareId": null,
"softwareId": null,
"externalId": null,
"default": false
}

View File

@ -3,7 +3,7 @@
"additionalInfo": {
"description": ""
},
"name": "Rule Chain from Import",
"name": "Rule Chain For Import",
"type": "CORE",
"firstRuleNodeId": null,
"root": false,