|
|
@ -44,6 +44,7 @@ import org.thingsboard.server.common.data.id.EntityViewId; |
|
|
import org.thingsboard.server.common.data.id.IdBased; |
|
|
import org.thingsboard.server.common.data.id.IdBased; |
|
|
import org.thingsboard.server.common.data.id.TenantId; |
|
|
import org.thingsboard.server.common.data.id.TenantId; |
|
|
import org.thingsboard.server.common.data.kv.AttributeKvEntry; |
|
|
import org.thingsboard.server.common.data.kv.AttributeKvEntry; |
|
|
|
|
|
import org.thingsboard.server.common.data.kv.AttributesSaveResult; |
|
|
import org.thingsboard.server.common.data.kv.BaseAttributeKvEntry; |
|
|
import org.thingsboard.server.common.data.kv.BaseAttributeKvEntry; |
|
|
import org.thingsboard.server.common.data.kv.BasicTsKvEntry; |
|
|
import org.thingsboard.server.common.data.kv.BasicTsKvEntry; |
|
|
import org.thingsboard.server.common.data.kv.DoubleDataEntry; |
|
|
import org.thingsboard.server.common.data.kv.DoubleDataEntry; |
|
|
@ -395,7 +396,7 @@ public class EntityServiceTest extends AbstractControllerTest { |
|
|
List<Long> highTemperatures = new ArrayList<>(); |
|
|
List<Long> highTemperatures = new ArrayList<>(); |
|
|
createTestHierarchy(tenantId, assets, devices, new ArrayList<>(), new ArrayList<>(), temperatures, highTemperatures); |
|
|
createTestHierarchy(tenantId, assets, devices, new ArrayList<>(), new ArrayList<>(), temperatures, highTemperatures); |
|
|
|
|
|
|
|
|
List<ListenableFuture<List<Long>>> attributeFutures = new ArrayList<>(); |
|
|
List<ListenableFuture<AttributesSaveResult>> attributeFutures = new ArrayList<>(); |
|
|
for (int i = 0; i < devices.size(); i++) { |
|
|
for (int i = 0; i < devices.size(); i++) { |
|
|
Device device = devices.get(i); |
|
|
Device device = devices.get(i); |
|
|
attributeFutures.add(saveLongAttribute(device.getId(), "temperature", temperatures.get(i), AttributeScope.CLIENT_SCOPE)); |
|
|
attributeFutures.add(saveLongAttribute(device.getId(), "temperature", temperatures.get(i), AttributeScope.CLIENT_SCOPE)); |
|
|
@ -545,7 +546,7 @@ public class EntityServiceTest extends AbstractControllerTest { |
|
|
List<Long> highTemperatures = new ArrayList<>(); |
|
|
List<Long> highTemperatures = new ArrayList<>(); |
|
|
createTestHierarchy(tenantId, assets, devices, new ArrayList<>(), new ArrayList<>(), temperatures, highTemperatures); |
|
|
createTestHierarchy(tenantId, assets, devices, new ArrayList<>(), new ArrayList<>(), temperatures, highTemperatures); |
|
|
|
|
|
|
|
|
List<ListenableFuture<List<Long>>> attributeFutures = new ArrayList<>(); |
|
|
List<ListenableFuture<AttributesSaveResult>> attributeFutures = new ArrayList<>(); |
|
|
for (int i = 0; i < devices.size(); i++) { |
|
|
for (int i = 0; i < devices.size(); i++) { |
|
|
Device device = devices.get(i); |
|
|
Device device = devices.get(i); |
|
|
attributeFutures.add(saveLongAttribute(device.getId(), "temperature", temperatures.get(i), AttributeScope.CLIENT_SCOPE)); |
|
|
attributeFutures.add(saveLongAttribute(device.getId(), "temperature", temperatures.get(i), AttributeScope.CLIENT_SCOPE)); |
|
|
@ -599,7 +600,7 @@ public class EntityServiceTest extends AbstractControllerTest { |
|
|
List<Long> highConsumptions = new ArrayList<>(); |
|
|
List<Long> highConsumptions = new ArrayList<>(); |
|
|
createTestHierarchy(tenantId, assets, devices, consumptions, highConsumptions, new ArrayList<>(), new ArrayList<>()); |
|
|
createTestHierarchy(tenantId, assets, devices, consumptions, highConsumptions, new ArrayList<>(), new ArrayList<>()); |
|
|
|
|
|
|
|
|
List<ListenableFuture<List<Long>>> attributeFutures = new ArrayList<>(); |
|
|
List<ListenableFuture<AttributesSaveResult>> attributeFutures = new ArrayList<>(); |
|
|
for (int i = 0; i < assets.size(); i++) { |
|
|
for (int i = 0; i < assets.size(); i++) { |
|
|
Asset asset = assets.get(i); |
|
|
Asset asset = assets.get(i); |
|
|
attributeFutures.add(saveLongAttribute(asset.getId(), "consumption", consumptions.get(i), AttributeScope.SERVER_SCOPE)); |
|
|
attributeFutures.add(saveLongAttribute(asset.getId(), "consumption", consumptions.get(i), AttributeScope.SERVER_SCOPE)); |
|
|
@ -1506,7 +1507,7 @@ public class EntityServiceTest extends AbstractControllerTest { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
List<ListenableFuture<List<Long>>> attributeFutures = new ArrayList<>(); |
|
|
List<ListenableFuture<AttributesSaveResult>> attributeFutures = new ArrayList<>(); |
|
|
for (int i = 0; i < devices.size(); i++) { |
|
|
for (int i = 0; i < devices.size(); i++) { |
|
|
Device device = devices.get(i); |
|
|
Device device = devices.get(i); |
|
|
for (AttributeScope currentScope : AttributeScope.values()) { |
|
|
for (AttributeScope currentScope : AttributeScope.values()) { |
|
|
@ -1578,7 +1579,7 @@ public class EntityServiceTest extends AbstractControllerTest { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
List<ListenableFuture<List<Long>>> attributeFutures = new ArrayList<>(); |
|
|
List<ListenableFuture<AttributesSaveResult>> attributeFutures = new ArrayList<>(); |
|
|
for (int i = 0; i < devices.size(); i++) { |
|
|
for (int i = 0; i < devices.size(); i++) { |
|
|
Device device = devices.get(i); |
|
|
Device device = devices.get(i); |
|
|
attributeFutures.add(saveLongAttribute(device.getId(), "temperature", temperatures.get(i), AttributeScope.CLIENT_SCOPE)); |
|
|
attributeFutures.add(saveLongAttribute(device.getId(), "temperature", temperatures.get(i), AttributeScope.CLIENT_SCOPE)); |
|
|
@ -1808,7 +1809,7 @@ public class EntityServiceTest extends AbstractControllerTest { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
List<ListenableFuture<List<Long>>> attributeFutures = new ArrayList<>(); |
|
|
List<ListenableFuture<AttributesSaveResult>> attributeFutures = new ArrayList<>(); |
|
|
for (int i = 0; i < devices.size(); i++) { |
|
|
for (int i = 0; i < devices.size(); i++) { |
|
|
Device device = devices.get(i); |
|
|
Device device = devices.get(i); |
|
|
attributeFutures.add(saveStringAttribute(device.getId(), "attributeString", attributeStrings.get(i), AttributeScope.CLIENT_SCOPE)); |
|
|
attributeFutures.add(saveStringAttribute(device.getId(), "attributeString", attributeStrings.get(i), AttributeScope.CLIENT_SCOPE)); |
|
|
@ -2269,16 +2270,16 @@ public class EntityServiceTest extends AbstractControllerTest { |
|
|
return filter; |
|
|
return filter; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private ListenableFuture<List<Long>> saveLongAttribute(EntityId entityId, String key, long value, AttributeScope scope) { |
|
|
private ListenableFuture<AttributesSaveResult> saveLongAttribute(EntityId entityId, String key, long value, AttributeScope scope) { |
|
|
KvEntry attrValue = new LongDataEntry(key, value); |
|
|
KvEntry attrValue = new LongDataEntry(key, value); |
|
|
AttributeKvEntry attr = new BaseAttributeKvEntry(attrValue, 42L); |
|
|
AttributeKvEntry attr = new BaseAttributeKvEntry(attrValue, 42L); |
|
|
return attributesService.save(tenantId, entityId, scope, Collections.singletonList(attr)); |
|
|
return attributesService.save(tenantId, entityId, scope, List.of(attr)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private ListenableFuture<List<Long>> saveStringAttribute(EntityId entityId, String key, String value, AttributeScope scope) { |
|
|
private ListenableFuture<AttributesSaveResult> saveStringAttribute(EntityId entityId, String key, String value, AttributeScope scope) { |
|
|
KvEntry attrValue = new StringDataEntry(key, value); |
|
|
KvEntry attrValue = new StringDataEntry(key, value); |
|
|
AttributeKvEntry attr = new BaseAttributeKvEntry(attrValue, 42L); |
|
|
AttributeKvEntry attr = new BaseAttributeKvEntry(attrValue, 42L); |
|
|
return attributesService.save(tenantId, entityId, scope, Collections.singletonList(attr)); |
|
|
return attributesService.save(tenantId, entityId, scope, List.of(attr)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private ListenableFuture<TimeseriesSaveResult> saveTimeseries(EntityId entityId, String key, Double value) { |
|
|
private ListenableFuture<TimeseriesSaveResult> saveTimeseries(EntityId entityId, String key, Double value) { |
|
|
@ -2294,8 +2295,8 @@ public class EntityServiceTest extends AbstractControllerTest { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected void createMultiRootHierarchy(List<Asset> buildings, List<Asset> apartments, |
|
|
protected void createMultiRootHierarchy(List<Asset> buildings, List<Asset> apartments, |
|
|
Map<String, Map<UUID, String>> entityNameByTypeMap, |
|
|
Map<String, Map<UUID, String>> entityNameByTypeMap, |
|
|
Map<UUID, UUID> childParentRelationMap) throws InterruptedException { |
|
|
Map<UUID, UUID> childParentRelationMap) throws InterruptedException { |
|
|
for (int k = 0; k < 3; k++) { |
|
|
for (int k = 0; k < 3; k++) { |
|
|
Asset building = new Asset(); |
|
|
Asset building = new Asset(); |
|
|
building.setTenantId(tenantId); |
|
|
building.setTenantId(tenantId); |
|
|
|