small refactoring

This commit is contained in:
Seraphym-Tuhai 2023-01-09 19:09:52 +02:00
parent 3d8059be9e
commit c7ac12115c
10 changed files with 30 additions and 26 deletions

View File

@ -113,18 +113,33 @@ abstract public class AbstractDriverBaseTest extends AbstractContainerTest {
}
public static RuleChain getRuleChainByName(String name) {
return testRestClient.getRuleChains(pageLink).getData().stream()
.filter(s -> s.getName().equals(name)).collect(Collectors.toList()).get(0);
try {
return testRestClient.getRuleChains(pageLink).getData().stream()
.filter(s -> s.getName().equals(name)).collect(Collectors.toList()).get(0);
} catch (Exception e) {
log.error("No such rule chain with name: " + name);
return null;
}
}
public static Customer getCustomerByName(String name) {
return testRestClient.getCustomers(pageLink).getData().stream()
.filter(x -> x.getName().equals(name)).collect(Collectors.toList()).get(0);
try {
return testRestClient.getCustomers(pageLink).getData().stream()
.filter(x -> x.getName().equals(name)).collect(Collectors.toList()).get(0);
} catch (Exception e) {
log.error("No such customer with name: " + name);
return null;
}
}
public static DeviceProfile getDeviceProfileByName(String name) {
return testRestClient.getDeviceProfiles(pageLink).getData().stream()
.filter(x -> x.getName().equals(name)).collect(Collectors.toList()).get(0);
try {
return testRestClient.getDeviceProfiles(pageLink).getData().stream()
.filter(x -> x.getName().equals(name)).collect(Collectors.toList()).get(0);
} catch (Exception e) {
log.error("No such device profile with name: " + name);
return null;
}
}
@SneakyThrows

View File

@ -15,7 +15,6 @@
*/
package org.thingsboard.server.msa.ui.pages;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
@ -35,7 +34,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 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]";
private static final String ROOT_ACTIVE_CHECKBOXES = "//mat-icon[text() = 'check_box']";
@ -85,10 +83,6 @@ public class RuleChainsPageElements extends OtherPageElementsHelper {
return waitUntilElementToBeClickable(OPEN_RULE_CHAIN_FROM_VIEW);
}
public WebElement openRuleChainBtn(String name) {
return waitUntilElementToBeClickable(String.format(OPEN_RULE_CHAIN, name));
}
public List<WebElement> entities(String name) {
return waitUntilVisibilityOfElementsLocated(String.format(ENTITY, name));
}

View File

@ -101,10 +101,6 @@ public class RuleChainsPageHelper extends RuleChainsPageElements {
return elementsIsNotPresent(getEntity(ruleChainName));
}
public void doubleClickOnRuleChain(String ruleChainName) {
doubleClick(entity(ruleChainName));
}
public void sortByNameDown() {
doubleClick(sortByNameBtn());
}

View File

@ -17,7 +17,7 @@ package org.thingsboard.server.msa.ui.pages;
import org.openqa.selenium.WebDriver;
public class SideBarMenuViewHelper extends SideBarMenuViewElements{
public class SideBarMenuViewHelper extends SideBarMenuViewElements {
public SideBarMenuViewHelper(WebDriver driver) {
super(driver);
}

View File

@ -42,7 +42,6 @@ public class CustomerEditMenuTest extends AbstractDriverBaseTest {
private DashboardPageHelper dashboardPage;
private String customerName;
@BeforeMethod
public void login() {
openLocalhost();

View File

@ -16,7 +16,6 @@
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;

View File

@ -24,7 +24,9 @@ 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.*;
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.defaultDeviceProfile;
public class DeleteSeveralDeviceProfilesTest extends AbstractDriverBaseTest {

View File

@ -28,7 +28,6 @@ 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 {

View File

@ -49,7 +49,7 @@ public class OpenRuleChainTest extends AbstractDriverBaseTest {
}
@AfterMethod
public void delete(){
public void delete() {
if (ruleChainName != null) {
testRestClient.deleteRuleChain(getRuleChainByName(ruleChainName).getId());
ruleChainName = null;

View File

@ -30,19 +30,19 @@ import org.thingsboard.server.common.data.rule.RuleChain;
public class EntityPrototypes {
public static Customer defaultCustomerPrototype(String entityName){
public static Customer defaultCustomerPrototype(String entityName) {
Customer customer = new Customer();
customer.setTitle(entityName);
return customer;
}
public static RuleChain defaultRuleChainPrototype(String entityName){
public static RuleChain defaultRuleChainPrototype(String entityName) {
RuleChain ruleChain = new RuleChain();
ruleChain.setName(entityName);
return ruleChain;
}
public static DeviceProfile defaultDeviceProfile(String entityName){
public static DeviceProfile defaultDeviceProfile(String entityName) {
DeviceProfile deviceProfile = new DeviceProfile();
deviceProfile.setName(entityName);
deviceProfile.setType(DeviceProfileType.DEFAULT);
@ -56,7 +56,7 @@ public class EntityPrototypes {
return deviceProfile;
}
public static DeviceProfile defaultDeviceProfile(String entityName, String description){
public static DeviceProfile defaultDeviceProfile(String entityName, String description) {
DeviceProfile deviceProfile = new DeviceProfile();
deviceProfile.setName(entityName);
deviceProfile.setDescription(description);