|
|
@ -22,6 +22,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.EntityType; |
|
|
import org.thingsboard.server.common.data.EntityType; |
|
|
import org.thingsboard.server.common.data.id.AssetId; |
|
|
import org.thingsboard.server.common.data.id.AssetId; |
|
|
import org.thingsboard.server.common.data.id.DeviceId; |
|
|
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 { |
|
|
public void testSaveRelationWithEmptyFrom() throws ExecutionException, InterruptedException { |
|
|
EntityRelation relation = new EntityRelation(); |
|
|
EntityRelation relation = new EntityRelation(); |
|
|
relation.setTo(new AssetId(Uuids.timeBased())); |
|
|
relation.setTo(new AssetId(Uuids.timeBased())); |
|
|
relation.setType(EntityRelation.CONTAINS_TYPE); |
|
|
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 { |
|
|
public void testSaveRelationWithEmptyTo() throws ExecutionException, InterruptedException { |
|
|
EntityRelation relation = new EntityRelation(); |
|
|
EntityRelation relation = new EntityRelation(); |
|
|
relation.setFrom(new AssetId(Uuids.timeBased())); |
|
|
relation.setFrom(new AssetId(Uuids.timeBased())); |
|
|
relation.setType(EntityRelation.CONTAINS_TYPE); |
|
|
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 { |
|
|
public void testSaveRelationWithEmptyType() throws ExecutionException, InterruptedException { |
|
|
EntityRelation relation = new EntityRelation(); |
|
|
EntityRelation relation = new EntityRelation(); |
|
|
relation.setFrom(new AssetId(Uuids.timeBased())); |
|
|
relation.setFrom(new AssetId(Uuids.timeBased())); |
|
|
relation.setTo(new AssetId(Uuids.timeBased())); |
|
|
relation.setTo(new AssetId(Uuids.timeBased())); |
|
|
Assert.assertTrue(saveRelation(relation)); |
|
|
Assertions.assertThrows(DataValidationException.class, () -> { |
|
|
|
|
|
Assert.assertTrue(saveRelation(relation)); |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Test |
|
|
@Test |
|
|
|