|
|
|
@ -15,6 +15,7 @@ import org.thingsboard.server.common.data.Device; |
|
|
|
import org.thingsboard.server.common.data.DeviceProfile; |
|
|
|
import org.thingsboard.server.common.data.DeviceProfileType; |
|
|
|
import org.thingsboard.server.common.data.DeviceTransportType; |
|
|
|
import org.thingsboard.server.common.data.exception.EntityVersionMismatchException; |
|
|
|
import org.thingsboard.server.common.data.id.CustomerId; |
|
|
|
import org.thingsboard.server.common.data.id.DeviceId; |
|
|
|
import org.thingsboard.server.common.data.id.TenantId; |
|
|
|
@ -112,6 +113,21 @@ public class JpaDeviceDaoTest extends AbstractJpaDaoTest { |
|
|
|
assertThat(device.getVersion()).isEqualTo(3); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
public void testSaveDevice_presetId_staleVersionRejected() { |
|
|
|
Device device = getDevice(tenantId1, customerId1, "preset-id-stale"); |
|
|
|
device = saveDevice(tenantId1, device); |
|
|
|
deviceIds.add(device.getUuidId()); |
|
|
|
|
|
|
|
Device stale = new Device(device); |
|
|
|
stale.setVersion(device.getVersion()); |
|
|
|
device.setName(device.getName() + "x"); |
|
|
|
saveDevice(tenantId1, device); |
|
|
|
|
|
|
|
stale.setName(stale.getName() + "y"); |
|
|
|
assertThatThrownBy(() -> saveDevice(tenantId1, stale)).isInstanceOf(EntityVersionMismatchException.class); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
public void testSaveDevice_versionIncrement_noChanges() { |
|
|
|
Device device = getDevice(tenantId1, customerId1, "1ewfewf2"); |
|
|
|
|