rm try catch from getRuleChainByName(), getRuleChainsByName()
This commit is contained in:
parent
508ba5e75f
commit
c3aa9b1b32
@ -47,8 +47,8 @@ import java.io.ByteArrayInputStream;
|
|||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@ -138,23 +138,23 @@ abstract public class AbstractDriverBaseTest extends AbstractContainerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static RuleChain getRuleChainByName(String name) {
|
public static RuleChain getRuleChainByName(String name) {
|
||||||
try {
|
Optional<RuleChain> ruleChain = testRestClient.getRuleChains(pageLink).getData().stream()
|
||||||
return testRestClient.getRuleChains(pageLink).getData().stream()
|
.filter(s -> s.getName().equals(name))
|
||||||
.filter(s -> s.getName().equals(name)).collect(Collectors.toList()).get(0);
|
.findFirst();
|
||||||
} catch (IndexOutOfBoundsException e) {
|
return ruleChain.orElseGet(() -> {
|
||||||
log.error("No such rule chain with name: " + name);
|
log.error("No rule chains found with name: " + name);
|
||||||
return null;
|
return null;
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<RuleChain> getRuleChainsByName(String name) {
|
public List<RuleChain> getRuleChainsByName(String name) {
|
||||||
try {
|
List<RuleChain> ruleChains = testRestClient.getRuleChains(pageLink).getData().stream()
|
||||||
return testRestClient.getRuleChains(pageLink).getData().stream()
|
.filter(s -> s.getName().equals(name))
|
||||||
.filter(s -> s.getName().equals(name)).collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
} catch (IndexOutOfBoundsException e) {
|
if (ruleChains.isEmpty()) {
|
||||||
log.error("No such rule chain with name: " + name);
|
log.error("No rule chains found with name: " + name);
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
}
|
||||||
|
return ruleChains;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Customer getCustomerByName(String name) {
|
public static Customer getCustomerByName(String name) {
|
||||||
|
|||||||
@ -19,7 +19,6 @@ import io.qameta.allure.Description;
|
|||||||
import io.qameta.allure.Epic;
|
import io.qameta.allure.Epic;
|
||||||
import io.qameta.allure.Feature;
|
import io.qameta.allure.Feature;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
import org.thingsboard.server.common.data.id.RuleChainId;
|
|
||||||
import org.thingsboard.server.msa.ui.utils.DataProviderCredential;
|
import org.thingsboard.server.msa.ui.utils.DataProviderCredential;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
@ -46,9 +45,9 @@ public class SortByNameTest extends AbstractRuleChainTest {
|
|||||||
@Test(priority = 20, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "nameForAllSort")
|
@Test(priority = 20, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "nameForAllSort")
|
||||||
@Description("Sort rule chain 'UP'")
|
@Description("Sort rule chain 'UP'")
|
||||||
public void allSortUp(String ruleChain, String ruleChainSymbol, String ruleChainNumber) {
|
public void allSortUp(String ruleChain, String ruleChainSymbol, String ruleChainNumber) {
|
||||||
RuleChainId ruleChainSymbolId = testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainSymbol)).getId();
|
testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainSymbol));
|
||||||
RuleChainId ruleChainId = testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChain)).getId();
|
testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChain));
|
||||||
RuleChainId ruleChainNumberId = testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainNumber)).getId();
|
testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainNumber));
|
||||||
|
|
||||||
sideBarMenuView.ruleChainsBtn().click();
|
sideBarMenuView.ruleChainsBtn().click();
|
||||||
ruleChainsPage.sortByNameBtn().click();
|
ruleChainsPage.sortByNameBtn().click();
|
||||||
@ -59,9 +58,9 @@ public class SortByNameTest extends AbstractRuleChainTest {
|
|||||||
ruleChainsPage.setRuleChainName(2);
|
ruleChainsPage.setRuleChainName(2);
|
||||||
String thirdRuleChain = ruleChainsPage.getRuleChainName();
|
String thirdRuleChain = ruleChainsPage.getRuleChainName();
|
||||||
|
|
||||||
testRestClient.deleteRuleChain(ruleChainId);
|
deleteRuleChainByName(ruleChain);
|
||||||
testRestClient.deleteRuleChain(ruleChainNumberId);
|
deleteRuleChainByName(ruleChainNumber);
|
||||||
testRestClient.deleteRuleChain(ruleChainSymbolId);
|
deleteRuleChainByName(ruleChainSymbol);
|
||||||
|
|
||||||
assertThat(firstRuleChain).as("First rule chain with symbol in name").isEqualTo(ruleChainSymbol);
|
assertThat(firstRuleChain).as("First rule chain with symbol in name").isEqualTo(ruleChainSymbol);
|
||||||
assertThat(secondRuleChain).as("Second rule chain with number in name").isEqualTo(ruleChainNumber);
|
assertThat(secondRuleChain).as("Second rule chain with number in name").isEqualTo(ruleChainNumber);
|
||||||
@ -88,9 +87,9 @@ public class SortByNameTest extends AbstractRuleChainTest {
|
|||||||
@Test(priority = 20, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "nameForAllSort")
|
@Test(priority = 20, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "nameForAllSort")
|
||||||
@Description("Sort rule chain 'DOWN'")
|
@Description("Sort rule chain 'DOWN'")
|
||||||
public void allSortDown(String ruleChain, String ruleChainSymbol, String ruleChainNumber) {
|
public void allSortDown(String ruleChain, String ruleChainSymbol, String ruleChainNumber) {
|
||||||
RuleChainId ruleChainSymbolId = testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainSymbol)).getId();
|
testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainSymbol));
|
||||||
RuleChainId ruleChainId = testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChain)).getId();
|
testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChain));
|
||||||
RuleChainId ruleChainNumberId = testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainNumber)).getId();
|
testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainNumber));
|
||||||
|
|
||||||
sideBarMenuView.ruleChainsBtn().click();
|
sideBarMenuView.ruleChainsBtn().click();
|
||||||
int lastIndex = ruleChainsPage.allNames().size() - 1;
|
int lastIndex = ruleChainsPage.allNames().size() - 1;
|
||||||
@ -102,9 +101,9 @@ public class SortByNameTest extends AbstractRuleChainTest {
|
|||||||
ruleChainsPage.setRuleChainName(lastIndex - 2);
|
ruleChainsPage.setRuleChainName(lastIndex - 2);
|
||||||
String thirdRuleChain = ruleChainsPage.getRuleChainName();
|
String thirdRuleChain = ruleChainsPage.getRuleChainName();
|
||||||
|
|
||||||
testRestClient.deleteRuleChain(ruleChainId);
|
deleteRuleChainByName(ruleChain);
|
||||||
testRestClient.deleteRuleChain(ruleChainNumberId);
|
deleteRuleChainByName(ruleChainNumber);
|
||||||
testRestClient.deleteRuleChain(ruleChainSymbolId);
|
deleteRuleChainByName(ruleChainSymbol);
|
||||||
|
|
||||||
assertThat(firstRuleChain).as("First from the end rule chain with symbol in name").isEqualTo(ruleChainSymbol);
|
assertThat(firstRuleChain).as("First from the end rule chain with symbol in name").isEqualTo(ruleChainSymbol);
|
||||||
assertThat(secondRuleChain).as("Second from the end rule chain with number in name").isEqualTo(ruleChainNumber);
|
assertThat(secondRuleChain).as("Second from the end rule chain with number in name").isEqualTo(ruleChainNumber);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user