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