use of org.thingsboard.server.common.data.kv.AttributeKvEntry in project thingsboard by thingsboard.
the class BaseAttributesServiceTest method saveMultipleTypeAndFetch.
@Test
public void saveMultipleTypeAndFetch() throws Exception {
DeviceId deviceId = new DeviceId(UUIDs.timeBased());
KvEntry attrOldValue = new StringDataEntry("attribute1", "value1");
AttributeKvEntry attrOld = new BaseAttributeKvEntry(attrOldValue, 42L);
attributesService.save(deviceId, DataConstants.CLIENT_SCOPE, Collections.singletonList(attrOld)).get();
Optional<AttributeKvEntry> saved = attributesService.find(deviceId, DataConstants.CLIENT_SCOPE, attrOld.getKey()).get();
Assert.assertTrue(saved.isPresent());
Assert.assertEquals(attrOld, saved.get());
KvEntry attrNewValue = new StringDataEntry("attribute1", "value2");
AttributeKvEntry attrNew = new BaseAttributeKvEntry(attrNewValue, 73L);
attributesService.save(deviceId, DataConstants.CLIENT_SCOPE, Collections.singletonList(attrNew)).get();
saved = attributesService.find(deviceId, DataConstants.CLIENT_SCOPE, attrOld.getKey()).get();
Assert.assertEquals(attrNew, saved.get());
}
Aggregations