Browse Source

junit5: BaseRelationServiceTest annotation exceptions refactoring

pull/8174/head
Oleksandra Matviienko 4 years ago
parent
commit
3ecb2627d5
  1. 19
      dao/src/test/java/org/thingsboard/server/dao/service/BaseRelationServiceTest.java

19
dao/src/test/java/org/thingsboard/server/dao/service/BaseRelationServiceTest.java

@ -22,6 +22,7 @@ import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.thingsboard.server.common.data.EntityType;
import org.thingsboard.server.common.data.id.AssetId;
import org.thingsboard.server.common.data.id.DeviceId;
@ -334,28 +335,34 @@ public abstract class BaseRelationServiceTest extends AbstractServiceTest {
}
}
@Test(expected = DataValidationException.class)
@Test
public void testSaveRelationWithEmptyFrom() throws ExecutionException, InterruptedException {
EntityRelation relation = new EntityRelation();
relation.setTo(new AssetId(Uuids.timeBased()));
relation.setType(EntityRelation.CONTAINS_TYPE);
Assert.assertTrue(saveRelation(relation));
Assertions.assertThrows(DataValidationException.class, () -> {
Assert.assertTrue(saveRelation(relation));
});
}
@Test(expected = DataValidationException.class)
@Test
public void testSaveRelationWithEmptyTo() throws ExecutionException, InterruptedException {
EntityRelation relation = new EntityRelation();
relation.setFrom(new AssetId(Uuids.timeBased()));
relation.setType(EntityRelation.CONTAINS_TYPE);
Assert.assertTrue(saveRelation(relation));
Assertions.assertThrows(DataValidationException.class, () -> {
Assert.assertTrue(saveRelation(relation));
});
}
@Test(expected = DataValidationException.class)
@Test
public void testSaveRelationWithEmptyType() throws ExecutionException, InterruptedException {
EntityRelation relation = new EntityRelation();
relation.setFrom(new AssetId(Uuids.timeBased()));
relation.setTo(new AssetId(Uuids.timeBased()));
Assert.assertTrue(saveRelation(relation));
Assertions.assertThrows(DataValidationException.class, () -> {
Assert.assertTrue(saveRelation(relation));
});
}
@Test

Loading…
Cancel
Save