|
|
|
@ -35,6 +35,7 @@ import org.thingsboard.server.common.data.kv.DoubleDataEntry; |
|
|
|
import org.thingsboard.server.common.data.kv.KvEntry; |
|
|
|
import org.thingsboard.server.common.data.kv.LongDataEntry; |
|
|
|
import org.thingsboard.server.common.data.kv.ReadTsKvQuery; |
|
|
|
import org.thingsboard.server.common.data.kv.ReadTsKvQueryResult; |
|
|
|
import org.thingsboard.server.common.data.kv.StringDataEntry; |
|
|
|
import org.thingsboard.server.common.data.kv.TsKvEntry; |
|
|
|
import org.thingsboard.server.common.data.objects.TelemetryEntityView; |
|
|
|
@ -48,6 +49,7 @@ import java.util.concurrent.ExecutionException; |
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
import java.util.concurrent.TimeoutException; |
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat; |
|
|
|
import static org.junit.Assert.assertEquals; |
|
|
|
import static org.junit.Assert.assertNotNull; |
|
|
|
|
|
|
|
@ -344,6 +346,36 @@ public abstract class BaseTimeseriesServiceTest extends AbstractServiceTest { |
|
|
|
Assert.assertEquals(toTsEntry(TS - 3, stringKvEntry), entries.get(2)); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
public void testFindAllByQueries_verifyQueryId() throws Exception { |
|
|
|
DeviceId deviceId = new DeviceId(Uuids.timeBased()); |
|
|
|
saveEntries(deviceId, TS); |
|
|
|
saveEntries(deviceId, TS - 2); |
|
|
|
saveEntries(deviceId, TS - 10); |
|
|
|
|
|
|
|
BaseReadTsKvQuery query = new BaseReadTsKvQuery(STRING_KEY, TS - 10, TS + 1, 0, 1000, Aggregation.NONE, "DESC"); |
|
|
|
findAndVerifyQueryId(deviceId, query); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
public void testFindAllByQueries_verifyQueryId_forEntityView() throws Exception { |
|
|
|
DeviceId deviceId = new DeviceId(Uuids.timeBased()); |
|
|
|
saveEntries(deviceId, TS); |
|
|
|
saveEntries(deviceId, TS - 2); |
|
|
|
saveEntries(deviceId, TS - 12); |
|
|
|
|
|
|
|
EntityView entityView = saveAndCreateEntityView(deviceId, List.of(LONG_KEY)); |
|
|
|
|
|
|
|
BaseReadTsKvQuery query = new BaseReadTsKvQuery(LONG_KEY, TS - 10, TS + 1, 0, 1000, Aggregation.NONE, "DESC"); |
|
|
|
findAndVerifyQueryId(entityView.getId(), query); |
|
|
|
} |
|
|
|
|
|
|
|
private void findAndVerifyQueryId(EntityId entityId, ReadTsKvQuery query) throws InterruptedException, ExecutionException, TimeoutException { |
|
|
|
List<ReadTsKvQueryResult> results = tsService.findAllByQueries(tenantId, entityId, List.of(query)).get(MAX_TIMEOUT, TimeUnit.SECONDS); |
|
|
|
assertThat(results).isNotEmpty(); |
|
|
|
assertThat(results).extracting(ReadTsKvQueryResult::getQueryId).containsOnly(query.getId()); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
public void testDeleteDeviceTsDataWithOverwritingLatest() throws Exception { |
|
|
|
DeviceId deviceId = new DeviceId(Uuids.timeBased()); |
|
|
|
|