test improved

This commit is contained in:
Dima Landiak 2021-11-12 14:45:07 +02:00
parent 916b32264c
commit 4dc2b6ca01

View File

@ -45,6 +45,8 @@ import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
@ -55,6 +57,7 @@ import static org.junit.Assert.assertNotNull;
@Slf4j @Slf4j
public abstract class BaseTimeseriesServiceTest extends AbstractServiceTest { public abstract class BaseTimeseriesServiceTest extends AbstractServiceTest {
static final int MAX_TIMEOUT = 30;
private static final String STRING_KEY = "stringKey"; private static final String STRING_KEY = "stringKey";
private static final String LONG_KEY = "longKey"; private static final String LONG_KEY = "longKey";
@ -495,13 +498,13 @@ public abstract class BaseTimeseriesServiceTest extends AbstractServiceTest {
tsService.save(tenantId, deviceId, toTsEntry(ts, booleanKvEntry)).get(); tsService.save(tenantId, deviceId, toTsEntry(ts, booleanKvEntry)).get();
} }
private void saveEntriesWithoutLatest(DeviceId deviceId, long ts) throws ExecutionException, InterruptedException { private void saveEntriesWithoutLatest(DeviceId deviceId, long ts) throws ExecutionException, InterruptedException, TimeoutException {
TsKvEntry entry1 = toTsEntry(ts, stringKvEntry); List<TsKvEntry> tsKvEntry = List.of(
TsKvEntry entry2 = toTsEntry(ts, longKvEntry); toTsEntry(ts, stringKvEntry),
TsKvEntry entry3 = toTsEntry(ts, doubleKvEntry); toTsEntry(ts, longKvEntry),
TsKvEntry entry4 = toTsEntry(ts, booleanKvEntry); toTsEntry(ts, doubleKvEntry),
List<TsKvEntry> entries = new ArrayList<>(Arrays.asList(entry1, entry2, entry3, entry4)); toTsEntry(ts, booleanKvEntry));
tsService.saveWithoutLatest(tenantId, deviceId, entries, 0).get(); tsService.saveWithoutLatest(tenantId, deviceId, tsKvEntry, 0).get(MAX_TIMEOUT, TimeUnit.SECONDS);
} }
private static TsKvEntry toTsEntry(long ts, KvEntry entry) { private static TsKvEntry toTsEntry(long ts, KvEntry entry) {