Browse Source

junit5: BaseRuleChainServiceTest annotation exceptions refactoring

pull/8174/head
Oleksandra Matviienko 4 years ago
parent
commit
84e4c8f231
  1. 29
      dao/src/test/java/org/thingsboard/server/dao/service/BaseRuleChainServiceTest.java

29
dao/src/test/java/org/thingsboard/server/dao/service/BaseRuleChainServiceTest.java

@ -21,6 +21,7 @@ import org.junit.After;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.thingsboard.server.common.data.StringUtils; import org.thingsboard.server.common.data.StringUtils;
import org.thingsboard.server.common.data.Tenant; import org.thingsboard.server.common.data.Tenant;
import org.thingsboard.server.common.data.edge.Edge; import org.thingsboard.server.common.data.edge.Edge;
@ -86,19 +87,23 @@ public abstract class BaseRuleChainServiceTest extends AbstractServiceTest {
ruleChainService.deleteRuleChainById(tenantId, savedRuleChain.getId()); ruleChainService.deleteRuleChainById(tenantId, savedRuleChain.getId());
} }
@Test(expected = DataValidationException.class) @Test
public void testSaveRuleChainWithEmptyName() { public void testSaveRuleChainWithEmptyName() {
RuleChain ruleChain = new RuleChain(); RuleChain ruleChain = new RuleChain();
ruleChain.setTenantId(tenantId); ruleChain.setTenantId(tenantId);
ruleChainService.saveRuleChain(ruleChain); Assertions.assertThrows(DataValidationException.class, () -> {
ruleChainService.saveRuleChain(ruleChain);
});
} }
@Test(expected = DataValidationException.class) @Test
public void testSaveRuleChainWithInvalidTenant() { public void testSaveRuleChainWithInvalidTenant() {
RuleChain ruleChain = new RuleChain(); RuleChain ruleChain = new RuleChain();
ruleChain.setName("My RuleChain"); ruleChain.setName("My RuleChain");
ruleChain.setTenantId(TenantId.fromUUID(Uuids.timeBased())); ruleChain.setTenantId(TenantId.fromUUID(Uuids.timeBased()));
ruleChainService.saveRuleChain(ruleChain); Assertions.assertThrows(DataValidationException.class, () -> {
ruleChainService.saveRuleChain(ruleChain);
});
} }
@Test @Test
@ -321,14 +326,18 @@ public abstract class BaseRuleChainServiceTest extends AbstractServiceTest {
ruleChainService.deleteRuleChainById(tenantId, savedRuleChainMetaData.getRuleChainId()); ruleChainService.deleteRuleChainById(tenantId, savedRuleChainMetaData.getRuleChainId());
} }
@Test(expected = DataValidationException.class) @Test
public void testUpdateRuleChainMetaDataWithCirclingRelation() throws Exception { public void testUpdateRuleChainMetaDataWithCirclingRelation() {
ruleChainService.saveRuleChainMetaData(tenantId, createRuleChainMetadataWithCirclingRelation()); Assertions.assertThrows(DataValidationException.class, () -> {
ruleChainService.saveRuleChainMetaData(tenantId, createRuleChainMetadataWithCirclingRelation());
});
} }
@Test(expected = DataValidationException.class) @Test
public void testUpdateRuleChainMetaDataWithCirclingRelation2() throws Exception { public void testUpdateRuleChainMetaDataWithCirclingRelation2() {
ruleChainService.saveRuleChainMetaData(tenantId, createRuleChainMetadataWithCirclingRelation2()); Assertions.assertThrows(DataValidationException.class, () -> {
ruleChainService.saveRuleChainMetaData(tenantId, createRuleChainMetadataWithCirclingRelation2());
});
} }
@Test @Test

Loading…
Cancel
Save