add test on propagated alarm
This commit is contained in:
		
							parent
							
								
									a6bee93d2d
								
							
						
					
					
						commit
						982f6e23fb
					
				@ -29,6 +29,7 @@ import io.restassured.specification.RequestSpecification;
 | 
			
		||||
import org.thingsboard.server.common.data.Customer;
 | 
			
		||||
import org.thingsboard.server.common.data.Device;
 | 
			
		||||
import org.thingsboard.server.common.data.DeviceProfile;
 | 
			
		||||
import org.thingsboard.server.common.data.Tenant;
 | 
			
		||||
import org.thingsboard.server.common.data.User;
 | 
			
		||||
import org.thingsboard.server.common.data.alarm.Alarm;
 | 
			
		||||
import org.thingsboard.server.common.data.asset.AssetProfile;
 | 
			
		||||
@ -432,4 +433,16 @@ public class TestRestClient {
 | 
			
		||||
    public String getRefreshToken() {
 | 
			
		||||
        return refreshToken;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public PageData<Tenant> getTenants(PageLink pageLink) {
 | 
			
		||||
        Map<String, String> params = new HashMap<>();
 | 
			
		||||
        addPageLinkToParam(params, pageLink);
 | 
			
		||||
        return given().spec(requestSpec).queryParams(params)
 | 
			
		||||
                .get("/api/tenants")
 | 
			
		||||
                .then()
 | 
			
		||||
                .statusCode(HTTP_OK)
 | 
			
		||||
                .extract()
 | 
			
		||||
                .as(new TypeRef<PageData<Tenant>>() {
 | 
			
		||||
                });
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -0,0 +1,32 @@
 | 
			
		||||
package org.thingsboard.server.msa.ui.pages;
 | 
			
		||||
 | 
			
		||||
import org.openqa.selenium.WebDriver;
 | 
			
		||||
import org.openqa.selenium.WebElement;
 | 
			
		||||
import org.thingsboard.server.msa.ui.base.AbstractBasePage;
 | 
			
		||||
 | 
			
		||||
public class AlarmDetailsViewElements extends AbstractBasePage {
 | 
			
		||||
    public AlarmDetailsViewElements(WebDriver driver) {
 | 
			
		||||
        super(driver);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static final String ASSIGN_FIELD = "//mat-label[contains(text(),'Assignee')]/parent::label/following-sibling::input";
 | 
			
		||||
    private static final String USER_FROM_DROP_DOWN = "//div[@class='user-display-name']/span[text() = '%s']";
 | 
			
		||||
    private static final String CLOSE_VIEW_BTN = "//mat-dialog-container//mat-icon[contains(text(),'close')]/parent::button";
 | 
			
		||||
    private static final String UNASSIGNED_BTN = "//div[@role='listbox']//mat-icon[text() = 'account_circle']/following-sibling::span";
 | 
			
		||||
 | 
			
		||||
    public WebElement assignField() {
 | 
			
		||||
        return waitUntilElementToBeClickable(ASSIGN_FIELD);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public WebElement userFromAssignDropdown(String emailOrName) {
 | 
			
		||||
        return waitUntilElementToBeClickable(String.format(USER_FROM_DROP_DOWN, emailOrName));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public WebElement closeViewBtn() {
 | 
			
		||||
        return waitUntilElementToBeClickable(CLOSE_VIEW_BTN);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public WebElement unassignedBtn() {
 | 
			
		||||
        return waitUntilElementToBeClickable(UNASSIGNED_BTN);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,19 @@
 | 
			
		||||
package org.thingsboard.server.msa.ui.pages;
 | 
			
		||||
 | 
			
		||||
import org.openqa.selenium.WebDriver;
 | 
			
		||||
 | 
			
		||||
public class AlarmDetailsViewHelper extends AlarmDetailsViewElements{
 | 
			
		||||
    public AlarmDetailsViewHelper(WebDriver driver) {
 | 
			
		||||
        super(driver);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void assignAlarmTo(String emailOrName) {
 | 
			
		||||
        assignField().click();
 | 
			
		||||
        userFromAssignDropdown(emailOrName).click();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void unassignedAlarm() {
 | 
			
		||||
        assignField().click();
 | 
			
		||||
        unassignedBtn().click();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -1,3 +1,18 @@
 | 
			
		||||
/**
 | 
			
		||||
 * Copyright © 2016-2023 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;
 | 
			
		||||
@ -10,14 +25,17 @@ public class AlarmElements extends OtherPageElements{
 | 
			
		||||
        super(driver);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static final String ASSIGN_BTN = "//mat-icon[contains(text(),'keyboard_arrow_down')]/parent::button";
 | 
			
		||||
    private static final String USER_ASSIGN_DROPDOWN = "//div[@class='user-display-name']/span[contains(text(),'%s')]";
 | 
			
		||||
    private static final String ASSIGN_USERS_DISPLAY_NAME = "//div[@class='user-display-name']/span";
 | 
			
		||||
    private static final String ASSIGN_BTN = "//span[text() = '%s']/ancestor::mat-row//mat-icon[contains(text(),'keyboard_arrow_down')]/parent::button";
 | 
			
		||||
    private static final String USER_ASSIGN_DROPDOWN = "//div[@class='user-display-name']/span[text() = '%s']";
 | 
			
		||||
    protected static final String ASSIGN_USERS_DISPLAY_NAME = "//div[@class='user-display-name']/span";
 | 
			
		||||
    private static final String ASSIGN_USER_DISPLAY_NAME = "//span[@class='user-display-name'][contains(text(),'%s')]";
 | 
			
		||||
    private static final String SEARCH_FIELD = "//input[@placeholder='Search users']";
 | 
			
		||||
    private static final String UNASSIGNED_BTN = "//div[@role='listbox']//mat-icon[text() = 'account_circle']/following-sibling::span";
 | 
			
		||||
    private static final String UNASSIGNED = "//span[text() = '%s']/ancestor::mat-row//span[@class='assignee-cell']/mat-icon[text() = 'account_circle']/following-sibling::span";
 | 
			
		||||
    private static final String ALARM_DETAILS_BTN = "//span[text() = '%s']/ancestor::mat-row//mat-icon[contains(text(),'more_horiz')]/parent::button";
 | 
			
		||||
 | 
			
		||||
    public WebElement assignBtn() {
 | 
			
		||||
        return waitUntilElementToBeClickable(ASSIGN_BTN);
 | 
			
		||||
    public WebElement assignBtn(String type) {
 | 
			
		||||
        return waitUntilElementToBeClickable(String.format(ASSIGN_BTN, type));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public WebElement userFromAssignDropDown(String userEmail) {
 | 
			
		||||
@ -35,4 +53,16 @@ public class AlarmElements extends OtherPageElements{
 | 
			
		||||
    public WebElement searchUserField() {
 | 
			
		||||
        return waitUntilElementToBeClickable(SEARCH_FIELD);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public WebElement unassignedBtn() {
 | 
			
		||||
        return waitUntilElementToBeClickable(UNASSIGNED_BTN);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public WebElement unassigned(String alarmType) {
 | 
			
		||||
        return waitUntilVisibilityOfElementLocated(String.format(UNASSIGNED, alarmType));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public WebElement alarmDetailsBtn(String alarmType) {
 | 
			
		||||
        return waitUntilElementToBeClickable(String.format(ALARM_DETAILS_BTN, alarmType));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,9 +1,24 @@
 | 
			
		||||
/**
 | 
			
		||||
 * Copyright © 2016-2023 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.thingsboard.server.msa.ui.utils.Const;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.stream.Collectors;
 | 
			
		||||
 | 
			
		||||
@ -12,11 +27,21 @@ public class AlarmHelper extends AlarmElements {
 | 
			
		||||
        super(driver);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void assignTo(String user) {
 | 
			
		||||
        jsClick(assignBtn());
 | 
			
		||||
    public void assignAlarmTo(String alarmType, String user) {
 | 
			
		||||
        jsClick(assignBtn(alarmType));
 | 
			
		||||
        userFromAssignDropDown(user).click();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void unassignedAlarm(String alarmType) {
 | 
			
		||||
        assignBtn(alarmType).click();
 | 
			
		||||
        unassignedBtn().click();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void searchAlarm(String alarmType, String emailOrName) {
 | 
			
		||||
        assignBtn(alarmType).click();
 | 
			
		||||
        searchUserField().sendKeys(emailOrName);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private List<String> users;
 | 
			
		||||
 | 
			
		||||
    public void setUsers() {
 | 
			
		||||
@ -29,4 +54,9 @@ public class AlarmHelper extends AlarmElements {
 | 
			
		||||
    public List<String> getUsers() {
 | 
			
		||||
        return users;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void assertUsersForAssignIsNotPresent() {
 | 
			
		||||
        sleep(1);
 | 
			
		||||
        elementsIsNotPresent(ASSIGN_USERS_DISPLAY_NAME);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -32,14 +32,16 @@ public class CustomerPageElements extends OtherPageElementsHelper {
 | 
			
		||||
    private static final String TITLES = "//mat-cell[contains(@class,'cdk-column-title')]/span";
 | 
			
		||||
    protected static final String EDIT_MENU_DASHBOARD_FIELD = "//input[@formcontrolname='dashboard']";
 | 
			
		||||
    private static final String EDIT_MENU_DASHBOARD = "//div[@class='cdk-overlay-pane']//span/span[contains(text(),'%s')]";
 | 
			
		||||
    private static final String MANAGE_CUSTOMERS_USERS_BTN = ENTITY + "/ancestor::mat-row//mat-icon[contains(text(),' account_circle')]";
 | 
			
		||||
    private static final String MANAGE_CUSTOMERS_USERS_BTN = ENTITY + "/ancestor::mat-row//mat-icon[contains(text(),' account_circle')]/parent::button";
 | 
			
		||||
    private static final String MANAGE_CUSTOMERS_ASSETS_BTN = ENTITY + "/ancestor::mat-row//mat-icon[contains(text(),' domain')]/parent::button";
 | 
			
		||||
    private static final String MANAGE_CUSTOMERS_DEVICES_BTN = ENTITY + "/ancestor::mat-row//mat-icon[contains(text(),'devices_other')]/parent::button";
 | 
			
		||||
    private static final String MANAGE_CUSTOMERS_DASHBOARDS_BTN = ENTITY + "/ancestor::mat-row//mat-icon[contains(text(),'dashboard')]/parent::button";
 | 
			
		||||
    private static final String MANAGE_CUSTOMERS_EDGE_BTN = ENTITY + "/ancestor::mat-row//mat-icon[contains(text(),'router')]/parent::button";
 | 
			
		||||
    private static final String ADD_USER_EMAIL = "//tb-add-user-dialog//input[@formcontrolname='email']";
 | 
			
		||||
    private static final String ACTIVATE_WINDOW_OK_BTN = "//span[contains(text(),'OK')]";
 | 
			
		||||
    private static final String USER_LOGIN_BTN = "//mat-icon[@data-mat-icon-name='login']";
 | 
			
		||||
    private static final String USER_LOGIN_BTN = "//mat-icon[@data-mat-icon-name='login']/parent::button";
 | 
			
		||||
    private static final String USER_LOGIN_BTN_BY_EMAIL = "//mat-cell[contains(@class,'email')]/span[contains(text(),'%s')]" +
 | 
			
		||||
            "/ancestor::mat-row//mat-icon[@data-mat-icon-name='login']/parent::button";
 | 
			
		||||
    private static final String USERS_WIDGET = "//tb-widget";
 | 
			
		||||
    private static final String SELECT_COUNTRY_MENU = "//mat-form-field//mat-select[@formcontrolname='country']";
 | 
			
		||||
    private static final String COUNTRIES = "//span[@class='mdc-list-item__primary-text']";
 | 
			
		||||
@ -148,6 +150,10 @@ public class CustomerPageElements extends OtherPageElementsHelper {
 | 
			
		||||
        return waitUntilElementToBeClickable(USER_LOGIN_BTN);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public WebElement getUserLoginBtnByEmail(String email) {
 | 
			
		||||
        return waitUntilElementToBeClickable(String.format(USER_LOGIN_BTN_BY_EMAIL, email));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public WebElement usersWidget() {
 | 
			
		||||
        return waitUntilVisibilityOfElementLocated(USERS_WIDGET);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -1,3 +1,18 @@
 | 
			
		||||
/**
 | 
			
		||||
 * Copyright © 2016-2023 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;
 | 
			
		||||
 | 
			
		||||
@ -1,3 +1,18 @@
 | 
			
		||||
/**
 | 
			
		||||
 * Copyright © 2016-2023 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;
 | 
			
		||||
 | 
			
		||||
@ -25,10 +25,18 @@ public class LoginPageHelper extends LoginPageElements {
 | 
			
		||||
        super(driver);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void authorizationTenant() {
 | 
			
		||||
        emailField().sendKeys(Const.TENANT_EMAIL);
 | 
			
		||||
        passwordField().sendKeys(Const.TENANT_PASSWORD);
 | 
			
		||||
    public void login(String username, String password) {
 | 
			
		||||
        emailField().sendKeys(username);
 | 
			
		||||
        passwordField().sendKeys(password);
 | 
			
		||||
        submitBtn().click();
 | 
			
		||||
        waitUntilUrlContainsText("/home");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void authorizationTenant() {
 | 
			
		||||
        login(Const.TENANT_EMAIL, Const.TENANT_PASSWORD);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void authorizationCustomer() {
 | 
			
		||||
        login("customer@thingsboard.org", "customer");
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,110 +0,0 @@
 | 
			
		||||
package org.thingsboard.server.msa.ui.tests;
 | 
			
		||||
 | 
			
		||||
import org.testng.Assert;
 | 
			
		||||
import org.testng.annotations.AfterMethod;
 | 
			
		||||
import org.testng.annotations.BeforeClass;
 | 
			
		||||
import org.testng.annotations.Test;
 | 
			
		||||
import org.thingsboard.server.common.data.id.AlarmId;
 | 
			
		||||
import org.thingsboard.server.common.data.id.DeviceId;
 | 
			
		||||
import org.thingsboard.server.common.data.id.UserId;
 | 
			
		||||
import org.thingsboard.server.msa.prototypes.DevicePrototypes;
 | 
			
		||||
import org.thingsboard.server.msa.ui.base.AbstractDriverBaseTest;
 | 
			
		||||
import org.thingsboard.server.msa.ui.pages.AlarmHelper;
 | 
			
		||||
import org.thingsboard.server.msa.ui.pages.DevicePageHelper;
 | 
			
		||||
import org.thingsboard.server.msa.ui.pages.LoginPageHelper;
 | 
			
		||||
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.assertj.core.api.Assertions.assertThat;
 | 
			
		||||
 | 
			
		||||
public class AssignDetailsTab extends AbstractDriverBaseTest {
 | 
			
		||||
 | 
			
		||||
    AlarmId alarmId;
 | 
			
		||||
    DeviceId deviceId;
 | 
			
		||||
    UserId userId;
 | 
			
		||||
    String deviceName;
 | 
			
		||||
    SideBarMenuViewHelper sideBarMenuView;
 | 
			
		||||
    AlarmHelper alarmPage;
 | 
			
		||||
    DevicePageHelper devicePage;
 | 
			
		||||
 | 
			
		||||
    @BeforeClass
 | 
			
		||||
    public void generateAlarm() {
 | 
			
		||||
        new LoginPageHelper(driver).authorizationTenant();
 | 
			
		||||
        sideBarMenuView = new SideBarMenuViewHelper(driver);
 | 
			
		||||
        alarmPage = new AlarmHelper(driver);
 | 
			
		||||
        devicePage = new DevicePageHelper(driver);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @AfterMethod
 | 
			
		||||
    public void deleteAlarm() {
 | 
			
		||||
        testRestClient.deleteAlarm(alarmId);
 | 
			
		||||
        testRestClient.deleteDevice(deviceId);
 | 
			
		||||
        if (userId != null) {
 | 
			
		||||
            testRestClient.deleteUser(userId);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test(dataProviderClass = DataProviderCredential.class, dataProvider = "assignTo")
 | 
			
		||||
    public void assignAlarmTo(String user) {
 | 
			
		||||
        deviceName = testRestClient.postDevice("", DevicePrototypes.defaultDevicePrototype("")).getName();
 | 
			
		||||
        deviceId = testRestClient.getDeviceByName(deviceName).getId();
 | 
			
		||||
        alarmId = testRestClient.postAlarm(EntityPrototypes.defaultAlarm(deviceId)).getId();
 | 
			
		||||
 | 
			
		||||
        sideBarMenuView.goToDevicesPage();
 | 
			
		||||
        devicePage.openDeviceAlarms(deviceName);
 | 
			
		||||
        alarmPage.assignTo(user);
 | 
			
		||||
 | 
			
		||||
        Assert.assertTrue(alarmPage.assignedUser(user).isDisplayed());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    public void reassignAlarm() {
 | 
			
		||||
        testRestClient.postCustomer(EntityPrototypes.defaultCustomerPrototype("TestCustomer"));
 | 
			
		||||
        userId = testRestClient.postUser(EntityPrototypes.defaultUser(getCustomerByName("TestCustomer").getId())).getId();
 | 
			
		||||
        deviceName = testRestClient.postDevice("", DevicePrototypes.defaultDevicePrototype("")).getName();
 | 
			
		||||
        deviceId = testRestClient.getDeviceByName(deviceName).getId();
 | 
			
		||||
        alarmId = testRestClient.postAlarm(EntityPrototypes.defaultAlarm(deviceId, userId)).getId();
 | 
			
		||||
 | 
			
		||||
        sideBarMenuView.goToDevicesPage();
 | 
			
		||||
        devicePage.openDeviceAlarms(deviceName);
 | 
			
		||||
        alarmPage.assignTo("customer@thingsboard.org");
 | 
			
		||||
 | 
			
		||||
        Assert.assertTrue(alarmPage.assignedUser("customer@thingsboard.org").isDisplayed());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    public void searchByEmail() {
 | 
			
		||||
        deviceName = testRestClient.postDevice("", DevicePrototypes.defaultDevicePrototype("")).getName();
 | 
			
		||||
        deviceId = testRestClient.getDeviceByName(deviceName).getId();
 | 
			
		||||
        alarmId = testRestClient.postAlarm(EntityPrototypes.defaultAlarm(deviceId)).getId();
 | 
			
		||||
 | 
			
		||||
        sideBarMenuView.goToDevicesPage();
 | 
			
		||||
        devicePage.openDeviceAlarms(deviceName);
 | 
			
		||||
        alarmPage.assignBtn().click();
 | 
			
		||||
        alarmPage.searchUserField().sendKeys("customer@thingsboard.org");
 | 
			
		||||
        alarmPage.setUsers();
 | 
			
		||||
 | 
			
		||||
        assertThat(alarmPage.getUsers()).contains("customer@thingsboard.org");
 | 
			
		||||
        alarmPage.assignUsers().forEach(u -> assertThat(u.isDisplayed()).isTrue());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    public void searchByName() {
 | 
			
		||||
        String name = "usik";
 | 
			
		||||
 | 
			
		||||
        userId = testRestClient.postUser(EntityPrototypes.defaultUser(getCustomerByName("Customer A").getId(), name)).getId();
 | 
			
		||||
        deviceName = testRestClient.postDevice("", DevicePrototypes.defaultDevicePrototype("")).getName();
 | 
			
		||||
        deviceId = testRestClient.getDeviceByName(deviceName).getId();
 | 
			
		||||
        alarmId = testRestClient.postAlarm(EntityPrototypes.defaultAlarm(deviceId)).getId();
 | 
			
		||||
 | 
			
		||||
        sideBarMenuView.goToDevicesPage();
 | 
			
		||||
        devicePage.openDeviceAlarms(deviceName);
 | 
			
		||||
        alarmPage.assignBtn().click();
 | 
			
		||||
        alarmPage.searchUserField().sendKeys(name);
 | 
			
		||||
        alarmPage.setUsers();
 | 
			
		||||
 | 
			
		||||
        assertThat(alarmPage.getUsers()).contains(name);
 | 
			
		||||
        alarmPage.assignUsers().forEach(u -> assertThat(u.isDisplayed()).isTrue());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,6 @@
 | 
			
		||||
package org.thingsboard.server.msa.ui.tests.assignee;
 | 
			
		||||
 | 
			
		||||
import org.thingsboard.server.msa.ui.base.AbstractDriverBaseTest;
 | 
			
		||||
 | 
			
		||||
abstract public class AbstractAssignByCustomerTest extends AbstractDriverBaseTest {
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,117 @@
 | 
			
		||||
package org.thingsboard.server.msa.ui.tests.assignee;
 | 
			
		||||
 | 
			
		||||
import org.openqa.selenium.WebElement;
 | 
			
		||||
import org.testng.annotations.AfterClass;
 | 
			
		||||
import org.testng.annotations.AfterMethod;
 | 
			
		||||
import org.testng.annotations.BeforeClass;
 | 
			
		||||
import org.testng.annotations.BeforeMethod;
 | 
			
		||||
import org.testng.annotations.DataProvider;
 | 
			
		||||
import org.thingsboard.server.common.data.id.AlarmId;
 | 
			
		||||
import org.thingsboard.server.common.data.id.CustomerId;
 | 
			
		||||
import org.thingsboard.server.common.data.id.DeviceId;
 | 
			
		||||
import org.thingsboard.server.common.data.id.TenantId;
 | 
			
		||||
import org.thingsboard.server.common.data.id.UserId;
 | 
			
		||||
import org.thingsboard.server.msa.ui.base.AbstractDriverBaseTest;
 | 
			
		||||
import org.thingsboard.server.msa.ui.pages.AlarmDetailsViewHelper;
 | 
			
		||||
import org.thingsboard.server.msa.ui.pages.AlarmHelper;
 | 
			
		||||
import org.thingsboard.server.msa.ui.pages.CustomerPageHelper;
 | 
			
		||||
import org.thingsboard.server.msa.ui.pages.DevicePageHelper;
 | 
			
		||||
import org.thingsboard.server.msa.ui.pages.LoginPageHelper;
 | 
			
		||||
import org.thingsboard.server.msa.ui.pages.SideBarMenuViewHelper;
 | 
			
		||||
import org.thingsboard.server.msa.ui.utils.EntityPrototypes;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import static org.thingsboard.server.msa.ui.base.AbstractBasePage.random;
 | 
			
		||||
 | 
			
		||||
abstract public class AbstractAssignTest extends AbstractDriverBaseTest {
 | 
			
		||||
 | 
			
		||||
    protected AlarmId alarmId;
 | 
			
		||||
    protected AlarmId assignedAlarmId;
 | 
			
		||||
    protected AlarmId propageteAlarmId;
 | 
			
		||||
    protected AlarmId propageteAssigneAlarmId;
 | 
			
		||||
    protected AlarmId tenantAssigneAlarmId;
 | 
			
		||||
    protected DeviceId deviceId;
 | 
			
		||||
    protected UserId userId;
 | 
			
		||||
    protected UserId userWithNameId;
 | 
			
		||||
//    protected TenantId tenantId = testRestClient.getTenants(pageLink).getData().get(0).getId();
 | 
			
		||||
    protected CustomerId customerId;
 | 
			
		||||
    protected String deviceName;
 | 
			
		||||
    protected SideBarMenuViewHelper sideBarMenuView;
 | 
			
		||||
    protected AlarmHelper alarmPage;
 | 
			
		||||
    protected DevicePageHelper devicePage;
 | 
			
		||||
    protected AlarmDetailsViewHelper alarmDetailsView;
 | 
			
		||||
    CustomerPageHelper customerPage;
 | 
			
		||||
 | 
			
		||||
    protected String name = "User";
 | 
			
		||||
    protected String customerTitle = "Customer" + random();
 | 
			
		||||
    protected String userEmail = random() + "@thingsboard.org";
 | 
			
		||||
    protected String userWithNameEmail = random() + "@thingsboard.org";
 | 
			
		||||
    protected String alarm = "Test alarm 1";
 | 
			
		||||
    protected String assignedAlarm = "Test alarm 2";
 | 
			
		||||
    protected String propagateAlarm = "Test propagated alarm 1";
 | 
			
		||||
    protected String propagateAssignedAlarm = "Test propagated alarm 2";
 | 
			
		||||
 | 
			
		||||
    @BeforeClass
 | 
			
		||||
    public void generateTestEntities() {
 | 
			
		||||
        new LoginPageHelper(driver).authorizationTenant();
 | 
			
		||||
        sideBarMenuView = new SideBarMenuViewHelper(driver);
 | 
			
		||||
        alarmPage = new AlarmHelper(driver);
 | 
			
		||||
        devicePage = new DevicePageHelper(driver);
 | 
			
		||||
        alarmDetailsView = new AlarmDetailsViewHelper(driver);
 | 
			
		||||
        customerPage = new CustomerPageHelper(driver);
 | 
			
		||||
 | 
			
		||||
        customerId = testRestClient.postCustomer(EntityPrototypes.defaultCustomerPrototype(customerTitle)).getId();
 | 
			
		||||
        userId = testRestClient.postUser(EntityPrototypes.defaultUser(userEmail, getCustomerByName(customerTitle).getId())).getId();
 | 
			
		||||
        userWithNameId = testRestClient.postUser(EntityPrototypes.defaultUser(userWithNameEmail, getCustomerByName(customerTitle).getId(), name)).getId();
 | 
			
		||||
        deviceName = testRestClient.postDevice("", EntityPrototypes.defaultDevicePrototype("", customerId)).getName();
 | 
			
		||||
        deviceId = testRestClient.getDeviceByName(deviceName).getId();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @BeforeMethod
 | 
			
		||||
    public void generateTestAlarms() {
 | 
			
		||||
        if (getJwtTokenFromLocalStorage() == null) {
 | 
			
		||||
            new LoginPageHelper(driver).authorizationTenant();
 | 
			
		||||
        }
 | 
			
		||||
        alarmId = testRestClient.postAlarm(EntityPrototypes.defaultAlarm(deviceId, alarm)).getId();
 | 
			
		||||
        assignedAlarmId = testRestClient.postAlarm(EntityPrototypes.defaultAlarm(deviceId, assignedAlarm, userId)).getId();
 | 
			
		||||
        propageteAlarmId = testRestClient.postAlarm(EntityPrototypes.defaultAlarm(deviceId, propagateAlarm, true)).getId();
 | 
			
		||||
        propageteAssigneAlarmId = testRestClient.postAlarm(EntityPrototypes.defaultAlarm(deviceId, propagateAssignedAlarm, userId, true)).getId();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @AfterClass
 | 
			
		||||
    public void deleteTestEntities() {
 | 
			
		||||
        testRestClient.deleteDevice(deviceId);
 | 
			
		||||
        testRestClient.deleteCustomer(customerId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @AfterMethod
 | 
			
		||||
    public void deleteTestAlarms() {
 | 
			
		||||
        testRestClient.deleteAlarm(alarmId);
 | 
			
		||||
        testRestClient.deleteAlarm(assignedAlarmId);
 | 
			
		||||
        testRestClient.deleteAlarm(propageteAlarmId);
 | 
			
		||||
        testRestClient.deleteAlarm(propageteAssigneAlarmId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void loginByUser(String userEmail) {
 | 
			
		||||
        sideBarMenuView.customerBtn().click();
 | 
			
		||||
        customerPage.manageCustomersUserBtn(customerTitle).click();
 | 
			
		||||
        customerPage.getUserLoginBtnByEmail(userEmail).click();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @DataProvider
 | 
			
		||||
    public Object[][] alarms() {
 | 
			
		||||
        return new Object[][]{
 | 
			
		||||
                {alarm},
 | 
			
		||||
                {propagateAlarm}};
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @DataProvider
 | 
			
		||||
    public Object[][] assignedAlarms() {
 | 
			
		||||
        return new Object[][]{
 | 
			
		||||
                {assignedAlarm},
 | 
			
		||||
                {propagateAssignedAlarm}};
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,4 @@
 | 
			
		||||
package org.thingsboard.server.msa.ui.tests.assignee;
 | 
			
		||||
 | 
			
		||||
public class AssignByCustomerTest extends AbstractAssignByCustomerTest{
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,209 @@
 | 
			
		||||
/**
 | 
			
		||||
 * Copyright © 2016-2023 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.assignee;
 | 
			
		||||
 | 
			
		||||
import org.junit.platform.commons.function.Try;
 | 
			
		||||
import org.openqa.selenium.html5.WebStorage;
 | 
			
		||||
import org.testng.Assert;
 | 
			
		||||
import org.testng.annotations.Test;
 | 
			
		||||
import org.thingsboard.server.msa.ui.utils.Const;
 | 
			
		||||
 | 
			
		||||
import static org.assertj.core.api.Assertions.assertThat;
 | 
			
		||||
 | 
			
		||||
public class AssignDetailsTab extends AbstractAssignTest {
 | 
			
		||||
 | 
			
		||||
    /*@BeforeMethod
 | 
			
		||||
    public void openAlarmView() {
 | 
			
		||||
        sideBarMenuView.goToDevicesPage();
 | 
			
		||||
        devicePage.openDeviceAlarms(deviceName);
 | 
			
		||||
    }*/
 | 
			
		||||
 | 
			
		||||
    @Test(dataProvider = "alarms")
 | 
			
		||||
    public void assignAlarmToYourself(String alarm) {
 | 
			
		||||
        sideBarMenuView.goToDevicesPage();
 | 
			
		||||
        devicePage.openDeviceAlarms(deviceName);
 | 
			
		||||
        alarmPage.assignAlarmTo(alarm, Const.TENANT_EMAIL);
 | 
			
		||||
 | 
			
		||||
        Assert.assertTrue(alarmPage.assignedUser(Const.TENANT_EMAIL).isDisplayed());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test(dataProvider = "alarms")
 | 
			
		||||
    public void assignAlarmToAnotherUser(String alarm) {
 | 
			
		||||
        sideBarMenuView.goToDevicesPage();
 | 
			
		||||
        devicePage.openDeviceAlarms(deviceName);
 | 
			
		||||
        alarmPage.assignAlarmTo(alarm, userEmail);
 | 
			
		||||
 | 
			
		||||
        Assert.assertTrue(alarmPage.assignedUser(userEmail).isDisplayed());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test(dataProvider = "assignedAlarms")
 | 
			
		||||
    public void unassignedAlarm(String assignedAlarm) {
 | 
			
		||||
        sideBarMenuView.goToDevicesPage();
 | 
			
		||||
        devicePage.openDeviceAlarms(deviceName);
 | 
			
		||||
        alarmPage.unassignedAlarm(assignedAlarm);
 | 
			
		||||
 | 
			
		||||
        Assert.assertTrue(alarmPage.unassigned(assignedAlarm).isDisplayed());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test(dataProvider = "assignedAlarms")
 | 
			
		||||
    public void reassignAlarm(String assignedAlarm) {
 | 
			
		||||
        sideBarMenuView.goToDevicesPage();
 | 
			
		||||
        devicePage.openDeviceAlarms(deviceName);
 | 
			
		||||
        alarmPage.assignAlarmTo(assignedAlarm, Const.TENANT_EMAIL);
 | 
			
		||||
 | 
			
		||||
        Assert.assertTrue(alarmPage.assignedUser(Const.TENANT_EMAIL).isDisplayed());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    public void searchByEmail() {
 | 
			
		||||
        sideBarMenuView.goToDevicesPage();
 | 
			
		||||
        devicePage.openDeviceAlarms(deviceName);
 | 
			
		||||
        alarmPage.searchAlarm(alarm, Const.TENANT_EMAIL);
 | 
			
		||||
        alarmPage.setUsers();
 | 
			
		||||
 | 
			
		||||
        assertThat(alarmPage.getUsers()).hasSize(1).contains(Const.TENANT_EMAIL);
 | 
			
		||||
        alarmPage.assignUsers().forEach(u -> assertThat(u.isDisplayed()).isTrue());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    public void searchByName() {
 | 
			
		||||
        sideBarMenuView.goToDevicesPage();
 | 
			
		||||
        devicePage.openDeviceAlarms(deviceName);
 | 
			
		||||
        alarmPage.searchAlarm(alarm, name);
 | 
			
		||||
        alarmPage.setUsers();
 | 
			
		||||
 | 
			
		||||
        assertThat(alarmPage.getUsers()).hasSize(1).contains(name);
 | 
			
		||||
        alarmPage.assignUsers().forEach(u -> assertThat(u.isDisplayed()).isTrue());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    public void assignAlarmToYourselfFromDetails() {
 | 
			
		||||
        sideBarMenuView.goToDevicesPage();
 | 
			
		||||
        devicePage.openDeviceAlarms(deviceName);
 | 
			
		||||
        alarmPage.alarmDetailsBtn(alarm).click();
 | 
			
		||||
        alarmDetailsView.assignAlarmTo(Const.TENANT_EMAIL);
 | 
			
		||||
        alarmDetailsView.closeViewBtn().click();
 | 
			
		||||
 | 
			
		||||
        Assert.assertTrue(alarmPage.assignedUser(Const.TENANT_EMAIL).isDisplayed());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    public void assignAlarmToAnotherUserFromDetails() {
 | 
			
		||||
        sideBarMenuView.goToDevicesPage();
 | 
			
		||||
        devicePage.openDeviceAlarms(deviceName);
 | 
			
		||||
        alarmPage.alarmDetailsBtn(alarm).click();
 | 
			
		||||
        alarmDetailsView.assignAlarmTo(userEmail);
 | 
			
		||||
        alarmDetailsView.closeViewBtn().click();
 | 
			
		||||
 | 
			
		||||
        Assert.assertTrue(alarmPage.assignedUser(userEmail).isDisplayed());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    public void unassignedAlarmFromDetails() {
 | 
			
		||||
        sideBarMenuView.goToDevicesPage();
 | 
			
		||||
        devicePage.openDeviceAlarms(deviceName);
 | 
			
		||||
        alarmPage.alarmDetailsBtn(assignedAlarm).click();
 | 
			
		||||
        alarmDetailsView.unassignedAlarm();
 | 
			
		||||
        alarmDetailsView.closeViewBtn().click();
 | 
			
		||||
 | 
			
		||||
        Assert.assertTrue(alarmPage.unassigned(assignedAlarm).isDisplayed());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    public void reassignAlarmFromDetails() {
 | 
			
		||||
        sideBarMenuView.goToDevicesPage();
 | 
			
		||||
        devicePage.openDeviceAlarms(deviceName);
 | 
			
		||||
        alarmPage.alarmDetailsBtn(assignedAlarm).click();
 | 
			
		||||
        alarmDetailsView.assignAlarmTo(Const.TENANT_EMAIL);
 | 
			
		||||
        alarmDetailsView.closeViewBtn().click();
 | 
			
		||||
 | 
			
		||||
        Assert.assertTrue(alarmPage.assignedUser(Const.TENANT_EMAIL).isDisplayed());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    public void assignAlarmToYourselfCustomer() {
 | 
			
		||||
        loginByUser(userEmail);
 | 
			
		||||
        sideBarMenuView.goToDevicesPage();
 | 
			
		||||
        devicePage.openDeviceAlarms(deviceName);
 | 
			
		||||
        alarmPage.assignAlarmTo(alarm, userEmail);
 | 
			
		||||
        clearStorage();
 | 
			
		||||
 | 
			
		||||
        Assert.assertTrue(alarmPage.assignedUser(userEmail).isDisplayed());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    public void reassignAlarmByCustomerFromAnotherCustomerUser() {
 | 
			
		||||
        loginByUser(userWithNameEmail);
 | 
			
		||||
        sideBarMenuView.goToDevicesPage();
 | 
			
		||||
        devicePage.openDeviceAlarms(deviceName);
 | 
			
		||||
        alarmPage.assignAlarmTo(assignedAlarm, name);
 | 
			
		||||
        clearStorage();
 | 
			
		||||
 | 
			
		||||
        Assert.assertTrue(alarmPage.assignedUser(name).isDisplayed());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    public void unassignedAlarmFromCustomer() {
 | 
			
		||||
        loginByUser(userWithNameEmail);
 | 
			
		||||
        sideBarMenuView.goToDevicesPage();
 | 
			
		||||
        devicePage.openDeviceAlarms(deviceName);
 | 
			
		||||
        alarmPage.unassignedAlarm(assignedAlarm);
 | 
			
		||||
        clearStorage();
 | 
			
		||||
 | 
			
		||||
        Assert.assertTrue(alarmPage.unassigned(assignedAlarm).isDisplayed());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    public void unassignedAlarmFromAnotherUserFromCustomer() {
 | 
			
		||||
        loginByUser(userEmail);
 | 
			
		||||
        sideBarMenuView.goToDevicesPage();
 | 
			
		||||
        devicePage.openDeviceAlarms(deviceName);
 | 
			
		||||
        alarmPage.unassignedAlarm(assignedAlarm);
 | 
			
		||||
        clearStorage();
 | 
			
		||||
 | 
			
		||||
        Assert.assertTrue(alarmPage.unassigned(assignedAlarm).isDisplayed());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    public void checkTheDisplayOfNamesEmailsFromCustomer() {
 | 
			
		||||
        sideBarMenuView.goToDevicesPage();
 | 
			
		||||
        devicePage.openDeviceAlarms(deviceName);
 | 
			
		||||
        alarmPage.assignAlarmTo(alarm, Const.TENANT_EMAIL);
 | 
			
		||||
        loginByUser(userEmail);
 | 
			
		||||
        sideBarMenuView.goToDevicesPage();
 | 
			
		||||
        devicePage.openDeviceAlarms(deviceName);
 | 
			
		||||
        alarmPage.assignBtn(alarm).click();
 | 
			
		||||
        try {
 | 
			
		||||
            alarmPage.assertUsersForAssignIsNotPresent();
 | 
			
		||||
        } finally {
 | 
			
		||||
            clearStorage();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public WebStorage getWebStorage() {
 | 
			
		||||
        if (driver instanceof WebStorage) {
 | 
			
		||||
            return (WebStorage) driver;
 | 
			
		||||
        } else {
 | 
			
		||||
            throw new IllegalArgumentException("This test expects the driver to implement WebStorage");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void clearStorage() {
 | 
			
		||||
        getWebStorage().getLocalStorage().clear();
 | 
			
		||||
        getWebStorage().getSessionStorage().clear();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -150,10 +150,4 @@ public class DataProviderCredential {
 | 
			
		||||
                {description, Keys.CONTROL + "A" + Keys.BACK_SPACE, ""}};
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @DataProvider
 | 
			
		||||
    public static Object[][] assignTo() {
 | 
			
		||||
        return new Object[][]{
 | 
			
		||||
                {Const.TENANT_EMAIL},
 | 
			
		||||
                {"customer@thingsboard.org"}};
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -15,8 +15,10 @@
 | 
			
		||||
 */
 | 
			
		||||
package org.thingsboard.server.msa.ui.utils;
 | 
			
		||||
 | 
			
		||||
import org.testcontainers.shaded.org.apache.commons.lang3.RandomStringUtils;
 | 
			
		||||
import org.thingsboard.common.util.JacksonUtil;
 | 
			
		||||
import org.thingsboard.server.common.data.Customer;
 | 
			
		||||
import org.thingsboard.server.common.data.Device;
 | 
			
		||||
import org.thingsboard.server.common.data.DeviceProfile;
 | 
			
		||||
import org.thingsboard.server.common.data.DeviceProfileProvisionType;
 | 
			
		||||
import org.thingsboard.server.common.data.DeviceProfileType;
 | 
			
		||||
@ -32,8 +34,11 @@ import org.thingsboard.server.common.data.device.profile.DisabledDeviceProfilePr
 | 
			
		||||
import org.thingsboard.server.common.data.id.CustomerId;
 | 
			
		||||
import org.thingsboard.server.common.data.id.EntityId;
 | 
			
		||||
import org.thingsboard.server.common.data.id.UserId;
 | 
			
		||||
import org.thingsboard.server.common.data.notification.targets.platform.CustomerUsersFilter;
 | 
			
		||||
import org.thingsboard.server.common.data.rule.RuleChain;
 | 
			
		||||
import org.thingsboard.server.common.data.security.Authority;
 | 
			
		||||
import org.thingsboard.server.common.data.security.UserCredentials;
 | 
			
		||||
import org.thingsboard.server.common.data.settings.UserSettings;
 | 
			
		||||
 | 
			
		||||
public class EntityPrototypes {
 | 
			
		||||
 | 
			
		||||
@ -105,37 +110,71 @@ public class EntityPrototypes {
 | 
			
		||||
        return assetProfile;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static Alarm defaultAlarm(EntityId id) {
 | 
			
		||||
    public static Alarm defaultAlarm(EntityId id, String type) {
 | 
			
		||||
        Alarm alarm = new Alarm();
 | 
			
		||||
        alarm.setType("default");
 | 
			
		||||
        alarm.setType(type);
 | 
			
		||||
        alarm.setOriginator(id);
 | 
			
		||||
        alarm.setSeverity(AlarmSeverity.CRITICAL);
 | 
			
		||||
        return alarm;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static Alarm defaultAlarm(EntityId id, UserId userId) {
 | 
			
		||||
    public static Alarm defaultAlarm(EntityId id, String type, boolean propagate) {
 | 
			
		||||
        Alarm alarm = new Alarm();
 | 
			
		||||
        alarm.setType("default");
 | 
			
		||||
        alarm.setType(type);
 | 
			
		||||
        alarm.setOriginator(id);
 | 
			
		||||
        alarm.setSeverity(AlarmSeverity.CRITICAL);
 | 
			
		||||
        alarm.setPropagate(propagate);
 | 
			
		||||
        return alarm;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static Alarm defaultAlarm(EntityId id, String type, UserId userId) {
 | 
			
		||||
        Alarm alarm = new Alarm();
 | 
			
		||||
        alarm.setType(type);
 | 
			
		||||
        alarm.setOriginator(id);
 | 
			
		||||
        alarm.setSeverity(AlarmSeverity.CRITICAL);
 | 
			
		||||
        alarm.setAssigneeId(userId);
 | 
			
		||||
        return alarm;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static User defaultUser(CustomerId customerId) {
 | 
			
		||||
    public static Alarm defaultAlarm(EntityId id, String type, UserId userId, boolean propagate) {
 | 
			
		||||
        Alarm alarm = new Alarm();
 | 
			
		||||
        alarm.setType(type);
 | 
			
		||||
        alarm.setOriginator(id);
 | 
			
		||||
        alarm.setSeverity(AlarmSeverity.CRITICAL);
 | 
			
		||||
        alarm.setAssigneeId(userId);
 | 
			
		||||
        alarm.setPropagate(propagate);
 | 
			
		||||
        return alarm;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static User defaultUser(String email, CustomerId customerId) {
 | 
			
		||||
        User user = new User();
 | 
			
		||||
        user.setEmail("test@thingsboard.org");
 | 
			
		||||
        user.setEmail(email);
 | 
			
		||||
        user.setCustomerId(customerId);
 | 
			
		||||
        user.setAuthority(Authority.CUSTOMER_USER);
 | 
			
		||||
        return user;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static User defaultUser(CustomerId customerId, String name) {
 | 
			
		||||
    public static User defaultUser(String email, CustomerId customerId, String name) {
 | 
			
		||||
        User user = new User();
 | 
			
		||||
        user.setEmail("test@thingsboard.org");
 | 
			
		||||
        user.setEmail(email);
 | 
			
		||||
        user.setFirstName(name);
 | 
			
		||||
        user.setCustomerId(customerId);
 | 
			
		||||
        user.setAuthority(Authority.CUSTOMER_USER);
 | 
			
		||||
        return user;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static Device defaultDevicePrototype(String name){
 | 
			
		||||
        Device device = new Device();
 | 
			
		||||
        device.setName(name + RandomStringUtils.randomAlphanumeric(7));
 | 
			
		||||
        device.setType("DEFAULT");
 | 
			
		||||
        return device;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static Device defaultDevicePrototype(String name, CustomerId id){
 | 
			
		||||
        Device device = new Device();
 | 
			
		||||
        device.setName(name + RandomStringUtils.randomAlphanumeric(7));
 | 
			
		||||
        device.setCustomerId(id);
 | 
			
		||||
        device.setType("DEFAULT");
 | 
			
		||||
        return device;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user