use of org.thingsboard.server.common.data.Device in project thingsboard by thingsboard.
the class BaseDeviceCredentialsServiceTest method testSaveDeviceCredentialsWithEmptyCredentialsType.
@Test(expected = DataValidationException.class)
public void testSaveDeviceCredentialsWithEmptyCredentialsType() {
Device device = new Device();
device.setName("My device");
device.setType("default");
device.setTenantId(tenantId);
device = deviceService.saveDevice(device);
DeviceCredentials deviceCredentials = deviceCredentialsService.findDeviceCredentialsByDeviceId(device.getId());
deviceCredentials.setCredentialsType(null);
try {
deviceCredentialsService.updateDeviceCredentials(deviceCredentials);
} finally {
deviceService.deleteDevice(device.getId());
}
}
use of org.thingsboard.server.common.data.Device in project thingsboard by thingsboard.
the class BaseDeviceCredentialsServiceTest method testFindDeviceCredentialsByCredentialsId.
@Test
public void testFindDeviceCredentialsByCredentialsId() {
Device device = new Device();
device.setTenantId(tenantId);
device.setName("My device");
device.setType("default");
Device savedDevice = deviceService.saveDevice(device);
DeviceCredentials deviceCredentials = deviceCredentialsService.findDeviceCredentialsByDeviceId(savedDevice.getId());
Assert.assertEquals(savedDevice.getId(), deviceCredentials.getDeviceId());
DeviceCredentials foundDeviceCredentials = deviceCredentialsService.findDeviceCredentialsByCredentialsId(deviceCredentials.getCredentialsId());
Assert.assertEquals(deviceCredentials, foundDeviceCredentials);
deviceService.deleteDevice(savedDevice.getId());
foundDeviceCredentials = deviceCredentialsService.findDeviceCredentialsByCredentialsId(deviceCredentials.getCredentialsId());
Assert.assertNull(foundDeviceCredentials);
}
use of org.thingsboard.server.common.data.Device in project thingsboard by thingsboard.
the class BaseDeviceCredentialsServiceTest method testSaveDeviceCredentialsWithNonExistentDevice.
@Test(expected = DataValidationException.class)
public void testSaveDeviceCredentialsWithNonExistentDevice() {
Device device = new Device();
device.setName("My device");
device.setType("default");
device.setTenantId(tenantId);
device = deviceService.saveDevice(device);
DeviceCredentials deviceCredentials = deviceCredentialsService.findDeviceCredentialsByDeviceId(device.getId());
deviceCredentials.setDeviceId(new DeviceId(UUIDs.timeBased()));
try {
deviceCredentialsService.updateDeviceCredentials(deviceCredentials);
} finally {
deviceService.deleteDevice(device.getId());
}
}
use of org.thingsboard.server.common.data.Device in project thingsboard by thingsboard.
the class BaseDeviceCredentialsServiceTest method testSaveNonExistentDeviceCredentials.
@Test(expected = DataValidationException.class)
public void testSaveNonExistentDeviceCredentials() {
Device device = new Device();
device.setName("My device");
device.setType("default");
device.setTenantId(tenantId);
device = deviceService.saveDevice(device);
DeviceCredentials deviceCredentials = deviceCredentialsService.findDeviceCredentialsByDeviceId(device.getId());
DeviceCredentials newDeviceCredentials = new DeviceCredentials(new DeviceCredentialsId(UUIDs.timeBased()));
newDeviceCredentials.setCreatedTime(deviceCredentials.getCreatedTime());
newDeviceCredentials.setDeviceId(deviceCredentials.getDeviceId());
newDeviceCredentials.setCredentialsType(deviceCredentials.getCredentialsType());
newDeviceCredentials.setCredentialsId(deviceCredentials.getCredentialsId());
try {
deviceCredentialsService.updateDeviceCredentials(newDeviceCredentials);
} finally {
deviceService.deleteDevice(device.getId());
}
}
use of org.thingsboard.server.common.data.Device in project thingsboard by thingsboard.
the class BaseDeviceServiceTest method testSaveDeviceWithInvalidTenant.
@Test(expected = DataValidationException.class)
public void testSaveDeviceWithInvalidTenant() {
Device device = new Device();
device.setName("My device");
device.setType("default");
device.setTenantId(new TenantId(UUIDs.timeBased()));
deviceService.saveDevice(device);
}
Aggregations