use of org.thingsboard.server.common.data.id.DeviceCredentialsId 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());
}
}
Aggregations