add tests on search and sort device profiles

This commit is contained in:
Serafym Tuhai 2023-01-04 18:01:50 +02:00
parent fc304404a5
commit 4c58de7949
15 changed files with 407 additions and 13 deletions

View File

@ -43,7 +43,7 @@ public class TestProperties {
if (instance.isActive()) {
return "https://host.docker.internal";
}
return getProperties().getProperty("tb.baseUrl");
return getProperties().getProperty("tb.baseUiUrl");
}
public static String getWebSocketUrl() {

View File

@ -18,6 +18,7 @@ package org.thingsboard.server.msa.ui.base;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement;
@ -35,11 +36,14 @@ abstract public class AbstractBasePage {
protected WebDriver driver;
protected WebDriverWait wait;
protected Actions actions;
protected JavascriptExecutor js;
public AbstractBasePage(WebDriver driver) {
this.driver = driver;
this.wait = new WebDriverWait(driver, Duration.ofMillis(5000));
this.actions = new Actions(driver);
this.js = (JavascriptExecutor) driver;
}
@SneakyThrows
@ -134,6 +138,18 @@ abstract public class AbstractBasePage {
}
}
public void jsClick(WebElement element) {
js.executeScript("arguments[0].click();", element);
}
public void scrollToElement(WebElement element) {
js.executeScript("arguments[0].scrollIntoView(true);", element);
}
public void waitUntilAttributeContains(WebElement element, String attribute, String value) {
wait.until(ExpectedConditions.attributeContains(element, attribute, value));
}
public void goToNextTab(int tabNumber) {
waitUntilNumberOfTabToBe(tabNumber);
ArrayList<String> tabs = new ArrayList<>(driver.getWindowHandles());

View File

@ -22,10 +22,12 @@ import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.LocalFileDetector;
@ -58,6 +60,7 @@ abstract public class AbstractDriverBaseTest extends AbstractContainerTest {
private static final String REMOTE_WEBDRIVER_HOST = "http://localhost:4444";
protected static final PageLink pageLink = new PageLink(10);
private static final ContainerTestSuite instance = ContainerTestSuite.getInstance();
private JavascriptExecutor js;
@SneakyThrows
@BeforeMethod
@ -104,6 +107,11 @@ abstract public class AbstractDriverBaseTest extends AbstractContainerTest {
return driver.getCurrentUrl().contains(urlPath);
}
public void jsClick(WebElement element) {
js = (JavascriptExecutor) driver;
js.executeScript("arguments[0].click();", element);
}
public static RuleChain getRuleChainByName(String name) {
return testRestClient.getRuleChains(pageLink).getData().stream()
.filter(s -> s.getName().equals(name)).collect(Collectors.toList()).get(0);

View File

@ -17,7 +17,8 @@ package org.thingsboard.server.msa.ui.pages;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.w3c.dom.html.HTMLInputElement;
import java.util.List;
public class ProfilesPageElements extends OtherPageElementsHelper {
public ProfilesPageElements(WebDriver driver) {
@ -35,6 +36,7 @@ public class ProfilesPageElements extends OtherPageElementsHelper {
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']/..";
private static final String DEVISE_PROFILE_VIEW_DELETE_BTN = "//tb-device-profile//span[contains(text(),'Delete')]";
private static final String PROFILE_NAMES = "//tbody/mat-row/mat-cell[contains(@class,'name')]";
protected String getDeviseProfileViewDeleteBtn() {
return DEVISE_PROFILE_VIEW_DELETE_BTN;
@ -99,4 +101,8 @@ public class ProfilesPageElements extends OtherPageElementsHelper {
public WebElement deviceProfileViewDeleteBtn() {
return waitUntilElementToBeClickable(DEVISE_PROFILE_VIEW_DELETE_BTN);
}
public List<WebElement> profileNames() {
return waitUntilElementsToBeClickable(PROFILE_NAMES);
}
}

View File

@ -16,8 +16,8 @@
package org.thingsboard.server.msa.ui.pages;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
public class ProfilesPageHelper extends ProfilesPageElements {
@ -30,6 +30,7 @@ public class ProfilesPageHelper extends ProfilesPageElements {
private String mobileDashboard;
private String queue;
private String description;
private String profile;
public void setName() {
this.name = profileViewNameField().getAttribute("value");
@ -48,9 +49,18 @@ public class ProfilesPageHelper extends ProfilesPageElements {
}
public void setDescription() {
scrollToElement(profileViewDescriptionField());
this.description = profileViewDescriptionField().getAttribute("value");
}
public void setProfileName() {
this.profile = profileNames().get(0).getText();
}
public void setProfileName(int number) {
this.profile = profileNames().get(number).getText();
}
public String getName() {
return this.name;
}
@ -71,6 +81,10 @@ public class ProfilesPageHelper extends ProfilesPageElements {
return this.description;
}
public String getProfileName() {
return this.profile;
}
public void enterName(String name) {
addDeviceProfileNameField().click();
addDeviceProfileNameField().sendKeys(name);
@ -89,6 +103,7 @@ public class ProfilesPageHelper extends ProfilesPageElements {
public void chooseQueue(String queue) {
addDeviceProfileQueueField().click();
entityFromList(queue).click();
waitUntilAttributeContains(addDeviceProfileQueueField(), "aria-expanded", "false");
}
public void enterDescription(String description) {
@ -108,5 +123,14 @@ public class ProfilesPageHelper extends ProfilesPageElements {
public boolean deleteDeviceProfileFromViewBtnIsNotDisplayed() {
return wait.until(ExpectedConditions.invisibilityOfElementLocated(By.xpath(getDeviseProfileViewDeleteBtn())));
}
}
public void goToProfileHelpPage() {
jsClick(helpBtn());
goToNextTab(2);
}
public void sortByNameDown() {
doubleClick(sortByNameBtn());
}
}

View File

@ -1,3 +1,18 @@
/**
* 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;

View File

@ -16,6 +16,7 @@
package org.thingsboard.server.msa.ui.tests.deviceProfileSmoke;
import io.qameta.allure.Description;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.Keys;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
@ -176,7 +177,7 @@ public class CreateDeviceProfileTest extends AbstractDriverBaseTest {
sideBarMenuView.openDeviceProfiles();
profilesPage.allEntity().get(0).click();
profilesPage.goToHelpPage();
profilesPage.goToProfileHelpPage();
Assert.assertTrue(urlContains(urlPath));
}

View File

@ -1,3 +1,18 @@
/**
* 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 org.testng.Assert;

View File

@ -1,3 +1,18 @@
/**
* 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;
@ -9,13 +24,14 @@ 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.DataProviderCredential;
import org.thingsboard.server.msa.ui.utils.EntityPrototypes;
import static org.thingsboard.server.msa.ui.base.AbstractBasePage.getRandomNumber;
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.TENANT_EMAIL;
import static org.thingsboard.server.msa.ui.utils.Const.TENANT_PASSWORD;
import static org.thingsboard.server.msa.ui.utils.EntityPrototypes.defaultCustomerPrototype;
public class DeviceProfileEditMenuTest extends AbstractDriverBaseTest {
@ -42,24 +58,74 @@ public class DeviceProfileEditMenuTest extends AbstractDriverBaseTest {
@Test(priority = 10, groups = "smoke")
@Description
public void changeTitle() {
public void changeName() {
String name = ENTITY_NAME;
String newName = "Changed" + getRandomNumber();
testRestClient.postDeviceProfile(EntityPrototypes.defaultDeviceProfile(name));
this.name = name;
sideBarMenuView.customerBtn().click();
sideBarMenuView.openDeviceProfiles();
profilesPage.entity(name).click();
profilesPage.setHeaderName();
String titleBefore = profilesPage.getHeaderName();
profilesPage.editPencilBtn().click();
jsClick(profilesPage.editPencilBtn());
profilesPage.changeNameEditMenu(newName);
profilesPage.doneBtnEditView().click();
this.name = newName;
profilesPage.setHeaderName();
String titleAfter = profilesPage.getHeaderName();
Assert.assertNotEquals(titleBefore, titleAfter);
Assert.assertEquals(titleAfter, newName);
}
@Test(priority = 10, groups = "smoke")
@Description
public void deleteName() {
String name = ENTITY_NAME;
testRestClient.postDeviceProfile(EntityPrototypes.defaultDeviceProfile(name));
this.name = name;
sideBarMenuView.openDeviceProfiles();
profilesPage.entity(name).click();
jsClick(profilesPage.editPencilBtn());
profilesPage.changeNameEditMenu("");
Assert.assertFalse(profilesPage.doneBtnEditViewVisible().isEnabled());
}
@Test(priority = 10, groups = "smoke")
@Description
public void saveWithOnlySpaceInName() {
String name = ENTITY_NAME;
testRestClient.postDeviceProfile(EntityPrototypes.defaultDeviceProfile(name));
this.name = name;
sideBarMenuView.openDeviceProfiles();
profilesPage.entity(name).click();
jsClick(profilesPage.editPencilBtn());
profilesPage.changeNameEditMenu(" ");
profilesPage.doneBtnEditView().click();
Assert.assertNotNull(profilesPage.warningMessage());
Assert.assertTrue(profilesPage.warningMessage().isDisplayed());
Assert.assertEquals(profilesPage.warningMessage().getText(), EMPTY_DEVICE_PROFILE_MESSAGE);
}
@Test(priority = 10, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "editMenuDescription")
@Description
public void editDescription(String description, String newDescription, String finalDescription) {
String name = ENTITY_NAME;
testRestClient.postDeviceProfile(EntityPrototypes.defaultDeviceProfile(name, description));
this.name = name;
sideBarMenuView.openDeviceProfiles();
profilesPage.entity(name).click();
jsClick(profilesPage.editPencilBtn());
profilesPage.profileViewDescriptionField().sendKeys(newDescription);
profilesPage.doneBtnEditView().click();
profilesPage.setDescription();
Assert.assertEquals(profilesPage.getDescription(), finalDescription);
}
}

View File

@ -0,0 +1,67 @@
/**
* 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.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.DataProviderCredential;
import static org.thingsboard.server.msa.ui.utils.Const.TENANT_EMAIL;
import static org.thingsboard.server.msa.ui.utils.Const.TENANT_PASSWORD;
import static org.thingsboard.server.msa.ui.utils.EntityPrototypes.defaultDeviceProfile;
public class SearchDeviceProfileTest 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(priority = 10, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "deviceProfileSearch")
@Description
public void searchFirstWord(String name, String namePath) {
testRestClient.postDeviceProfile(defaultDeviceProfile(name));
this.name = name;
sideBarMenuView.openDeviceProfiles();
profilesPage.searchEntity(namePath);
profilesPage.allEntity().forEach(x -> Assert.assertTrue(x.getText().contains(namePath)));
}
}

View File

@ -0,0 +1,132 @@
/**
* 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.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.DataProviderCredential;
import static org.thingsboard.server.msa.ui.utils.Const.TENANT_EMAIL;
import static org.thingsboard.server.msa.ui.utils.Const.TENANT_PASSWORD;
import static org.thingsboard.server.msa.ui.utils.EntityPrototypes.defaultCustomerPrototype;
import static org.thingsboard.server.msa.ui.utils.EntityPrototypes.defaultDeviceProfile;
public class SortByNameTest 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(priority = 10, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "nameForSort")
@Description
public void specialCharacterUp(String name) {
testRestClient.postDeviceProfile(defaultDeviceProfile(name));
this.name = name;
sideBarMenuView.openDeviceProfiles();
profilesPage.sortByNameBtn().click();
profilesPage.setProfileName();
Assert.assertEquals(profilesPage.getProfileName(), name);
}
@Test(priority = 20, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "nameForAllSort")
@Description
public void allSortUp(String deviceProfile, String deviceProfileSymbol, String deviceProfileNumber) {
testRestClient.postDeviceProfile(defaultDeviceProfile(deviceProfileSymbol));
testRestClient.postDeviceProfile(defaultDeviceProfile(deviceProfile));
testRestClient.postDeviceProfile(defaultDeviceProfile(deviceProfileNumber));
sideBarMenuView.openDeviceProfiles();
profilesPage.sortByNameBtn().click();
profilesPage.setProfileName(0);
String firstDeviceProfile = profilesPage.getProfileName();
profilesPage.setProfileName(1);
String secondDeviceProfile = profilesPage.getProfileName();
profilesPage.setProfileName(2);
String thirdDeviceProfile = profilesPage.getProfileName();
testRestClient.deleteDeviseProfile(getDeviceProfileByName(deviceProfile).getId());
testRestClient.deleteDeviseProfile(getDeviceProfileByName(deviceProfileNumber).getId());
testRestClient.deleteDeviseProfile(getDeviceProfileByName(deviceProfileSymbol).getId());
Assert.assertEquals(firstDeviceProfile, deviceProfileSymbol);
Assert.assertEquals(secondDeviceProfile, deviceProfileNumber);
Assert.assertEquals(thirdDeviceProfile, deviceProfile);
}
@Test(priority = 10, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "nameForSort")
@Description
public void specialCharacterDown(String name) {
testRestClient.postDeviceProfile(defaultDeviceProfile(name));
this.name = name;
sideBarMenuView.openDeviceProfiles();
profilesPage.sortByNameDown();
profilesPage.setProfileName(profilesPage.allEntity().size() - 1);
Assert.assertEquals(profilesPage.getProfileName(), name);
}
@Test(priority = 20, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "nameForAllSort")
@Description
public void allSortDown(String deviceProfile, String deviceProfileSymbol, String deviceProfileNumber) {
testRestClient.postDeviceProfile(defaultDeviceProfile(deviceProfileSymbol));
testRestClient.postDeviceProfile(defaultDeviceProfile(deviceProfile));
testRestClient.postDeviceProfile(defaultDeviceProfile(deviceProfileNumber));
sideBarMenuView.openDeviceProfiles();
int lastIndex = profilesPage.allEntity().size() - 1;
profilesPage.sortByNameDown();
profilesPage.setProfileName(lastIndex);
String firstDeviceProfile = profilesPage.getProfileName();
profilesPage.setProfileName(lastIndex - 1);
String secondDeviceProfile = profilesPage.getProfileName();
profilesPage.setProfileName(lastIndex - 2);
String thirdDeviceProfile = profilesPage.getProfileName();
testRestClient.deleteDeviseProfile(getDeviceProfileByName(deviceProfile).getId());
testRestClient.deleteDeviseProfile(getDeviceProfileByName(deviceProfileNumber).getId());
testRestClient.deleteDeviseProfile(getDeviceProfileByName(deviceProfileSymbol).getId());
Assert.assertEquals(firstDeviceProfile, deviceProfileSymbol);
Assert.assertEquals(secondDeviceProfile, deviceProfileNumber);
Assert.assertEquals(thirdDeviceProfile, deviceProfile);
}
}

View File

@ -15,8 +15,10 @@
*/
package org.thingsboard.server.msa.ui.utils;
import org.openqa.selenium.Keys;
import org.testng.annotations.DataProvider;
import static org.thingsboard.server.msa.ui.base.AbstractBasePage.getRandomNumber;
import static org.thingsboard.server.msa.ui.base.AbstractBasePage.getRandomSymbol;
import static org.thingsboard.server.msa.ui.utils.Const.ENTITY_NAME;
@ -31,6 +33,7 @@ public class DataProviderCredential {
private static final String CUSTOMER_SECOND_WORD_NAME_PATH = "Customer";
private static final String RULE_CHAIN_FIRST_WORD_NAME_PATH = "Root";
private static final String CUSTOMER_FIRST_WORD_NAME_PATH = "A";
private static final String DEFAULT_DEVICE_PROFILE_NAME = "Device Profile";
@DataProvider
public static Object[][] ruleChainNameForSearchByFirstAndSecondWord() {
@ -74,4 +77,23 @@ public class DataProviderCredential {
{CUSTOMER_FIRST_WORD_NAME_PATH},
{CUSTOMER_SECOND_WORD_NAME_PATH}};
}
@DataProvider
public static Object[][] deviceProfileSearch() {
return new Object[][]{
{DEFAULT_DEVICE_PROFILE_NAME, DEFAULT_DEVICE_PROFILE_NAME.split(" ")[0]},
{DEFAULT_DEVICE_PROFILE_NAME, DEFAULT_DEVICE_PROFILE_NAME.split(" ")[1]},
{NAME, ENTITY_NAME.split("`")[1]},
{NAME, String.valueOf(getRandomSymbol())}};
}
@DataProvider
public static Object[][] editMenuDescription() {
String newDescription = "Description" + getRandomNumber();
String description = "Description";
return new Object[][]{
{"", newDescription, newDescription},
{description, newDescription, description + newDescription},
{description, Keys.CONTROL + "A" + Keys.BACK_SPACE, ""}};
}
}

View File

@ -17,11 +17,15 @@ 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.DeviceProfileProvisionType;
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.DefaultDeviceProfileConfiguration;
import org.thingsboard.server.common.data.device.profile.DefaultDeviceProfileTransportConfiguration;
import org.thingsboard.server.common.data.device.profile.DeviceProfileConfiguration;
import org.thingsboard.server.common.data.device.profile.DeviceProfileData;
import org.thingsboard.server.common.data.device.profile.DisabledDeviceProfileProvisionConfiguration;
import org.thingsboard.server.common.data.rule.RuleChain;
public class EntityPrototypes {
@ -43,8 +47,25 @@ public class EntityPrototypes {
deviceProfile.setName(entityName);
deviceProfile.setType(DeviceProfileType.DEFAULT);
deviceProfile.setTransportType(DeviceTransportType.DEFAULT);
deviceProfile.setProvisionType(DeviceProfileProvisionType.DISABLED);
DeviceProfileData deviceProfileData = new DeviceProfileData();
deviceProfileData.setProvisionConfiguration( new AllowCreateNewDevicesDeviceProfileProvisionConfiguration(""));
deviceProfileData.setConfiguration(new DefaultDeviceProfileConfiguration());
deviceProfileData.setProvisionConfiguration(new DisabledDeviceProfileProvisionConfiguration(null));
deviceProfileData.setTransportConfiguration(new DefaultDeviceProfileTransportConfiguration());
deviceProfile.setProfileData(deviceProfileData);
return deviceProfile;
}
public static DeviceProfile defaultDeviceProfile(String entityName, String description){
DeviceProfile deviceProfile = new DeviceProfile();
deviceProfile.setName(entityName);
deviceProfile.setDescription(description);
deviceProfile.setType(DeviceProfileType.DEFAULT);
deviceProfile.setTransportType(DeviceTransportType.DEFAULT);
deviceProfile.setProvisionType(DeviceProfileProvisionType.DISABLED);
DeviceProfileData deviceProfileData = new DeviceProfileData();
deviceProfileData.setConfiguration(new DefaultDeviceProfileConfiguration());
deviceProfileData.setProvisionConfiguration(new DisabledDeviceProfileProvisionConfiguration(null));
deviceProfileData.setTransportConfiguration(new DefaultDeviceProfileTransportConfiguration());
deviceProfile.setProfileData(deviceProfileData);
return deviceProfile;

View File

@ -1,2 +1,3 @@
tb.baseUrl=http://localhost:8080
tb.baseUiUrl=http://localhost:8080
tb.wsUrl=ws://localhost:8080

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
Copyright © 2016-2022 The Thingsboard Authors
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.