|
|
|
@ -24,6 +24,7 @@ import org.junit.Assert; |
|
|
|
import org.junit.Before; |
|
|
|
import org.junit.Ignore; |
|
|
|
import org.junit.Test; |
|
|
|
import org.junit.jupiter.api.Assertions; |
|
|
|
import org.thingsboard.common.util.ThingsBoardThreadFactory; |
|
|
|
import org.thingsboard.server.common.data.Device; |
|
|
|
import org.thingsboard.server.common.data.DeviceProfile; |
|
|
|
@ -196,23 +197,27 @@ public abstract class BaseDeviceProfileServiceTest extends AbstractServiceTest { |
|
|
|
Assert.assertEquals(savedDeviceProfile2.getId(), defaultDeviceProfile.getId()); |
|
|
|
} |
|
|
|
|
|
|
|
@Test(expected = DataValidationException.class) |
|
|
|
@Test |
|
|
|
public void testSaveDeviceProfileWithEmptyName() { |
|
|
|
DeviceProfile deviceProfile = new DeviceProfile(); |
|
|
|
deviceProfile.setTenantId(tenantId); |
|
|
|
deviceProfileService.saveDeviceProfile(deviceProfile); |
|
|
|
Assertions.assertThrows(DataValidationException.class, () -> { |
|
|
|
deviceProfileService.saveDeviceProfile(deviceProfile); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
@Test(expected = DataValidationException.class) |
|
|
|
@Test |
|
|
|
public void testSaveDeviceProfileWithSameName() { |
|
|
|
DeviceProfile deviceProfile = this.createDeviceProfile(tenantId, "Device Profile"); |
|
|
|
deviceProfileService.saveDeviceProfile(deviceProfile); |
|
|
|
DeviceProfile deviceProfile2 = this.createDeviceProfile(tenantId, "Device Profile"); |
|
|
|
deviceProfileService.saveDeviceProfile(deviceProfile2); |
|
|
|
Assertions.assertThrows(DataValidationException.class, () -> { |
|
|
|
deviceProfileService.saveDeviceProfile(deviceProfile2); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
@Ignore |
|
|
|
@Test(expected = DataValidationException.class) |
|
|
|
@Test |
|
|
|
public void testChangeDeviceProfileTypeWithExistingDevices() { |
|
|
|
DeviceProfile deviceProfile = this.createDeviceProfile(tenantId, "Device Profile"); |
|
|
|
DeviceProfile savedDeviceProfile = deviceProfileService.saveDeviceProfile(deviceProfile); |
|
|
|
@ -224,10 +229,12 @@ public abstract class BaseDeviceProfileServiceTest extends AbstractServiceTest { |
|
|
|
deviceService.saveDevice(device); |
|
|
|
//TODO: once we have more profile types, we should test that we can not change profile type in runtime and uncomment the @Ignore.
|
|
|
|
// savedDeviceProfile.setType(DeviceProfileType.LWM2M);
|
|
|
|
deviceProfileService.saveDeviceProfile(savedDeviceProfile); |
|
|
|
Assertions.assertThrows(DataValidationException.class, () -> { |
|
|
|
deviceProfileService.saveDeviceProfile(savedDeviceProfile); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
@Test(expected = DataValidationException.class) |
|
|
|
@Test |
|
|
|
public void testChangeDeviceProfileTransportTypeWithExistingDevices() { |
|
|
|
DeviceProfile deviceProfile = this.createDeviceProfile(tenantId, "Device Profile"); |
|
|
|
DeviceProfile savedDeviceProfile = deviceProfileService.saveDeviceProfile(deviceProfile); |
|
|
|
@ -238,10 +245,12 @@ public abstract class BaseDeviceProfileServiceTest extends AbstractServiceTest { |
|
|
|
device.setDeviceProfileId(savedDeviceProfile.getId()); |
|
|
|
deviceService.saveDevice(device); |
|
|
|
savedDeviceProfile.setTransportType(DeviceTransportType.MQTT); |
|
|
|
deviceProfileService.saveDeviceProfile(savedDeviceProfile); |
|
|
|
Assertions.assertThrows(DataValidationException.class, () -> { |
|
|
|
deviceProfileService.saveDeviceProfile(savedDeviceProfile); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
@Test(expected = DataValidationException.class) |
|
|
|
@Test |
|
|
|
public void testDeleteDeviceProfileWithExistingDevice() { |
|
|
|
DeviceProfile deviceProfile = this.createDeviceProfile(tenantId, "Device Profile"); |
|
|
|
DeviceProfile savedDeviceProfile = deviceProfileService.saveDeviceProfile(deviceProfile); |
|
|
|
@ -251,7 +260,9 @@ public abstract class BaseDeviceProfileServiceTest extends AbstractServiceTest { |
|
|
|
device.setType("default"); |
|
|
|
device.setDeviceProfileId(savedDeviceProfile.getId()); |
|
|
|
deviceService.saveDevice(device); |
|
|
|
deviceProfileService.deleteDeviceProfile(tenantId, savedDeviceProfile.getId()); |
|
|
|
Assertions.assertThrows(DataValidationException.class, () -> { |
|
|
|
deviceProfileService.deleteDeviceProfile(tenantId, savedDeviceProfile.getId()); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
|