diff --git a/dao/src/test/java/org/thingsboard/server/dao/service/BaseRelationServiceTest.java b/dao/src/test/java/org/thingsboard/server/dao/service/BaseRelationServiceTest.java index 82c50f2438..c920b86bd5 100644 --- a/dao/src/test/java/org/thingsboard/server/dao/service/BaseRelationServiceTest.java +++ b/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