mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-27 09:00:28 +08:00
Fix flaky singlePingIsStored test due to random 0 going out of ping data bounds
This commit is contained in:
parent
bfe59008d0
commit
c88229fd8f
@ -31,6 +31,7 @@ import utilities.RandomData;
|
||||
import utilities.TestConstants;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
@ -71,14 +72,14 @@ public interface PingQueriesTest extends DatabaseTestPreparer {
|
||||
}
|
||||
|
||||
@Test
|
||||
default void singlePingIsStored() {
|
||||
default void singlePingIsStored() throws ExecutionException, InterruptedException {
|
||||
prepareForPingStorage();
|
||||
|
||||
DateObj<Integer> saved = RandomData.randomIntDateObject();
|
||||
DateObj<Integer> saved = RandomData.randomIntDateObject(1, 4001); // accepted ping range 1-4000 ms
|
||||
int value = saved.getValue();
|
||||
db().executeTransaction(new PingStoreTransaction(playerUUID, serverUUID(),
|
||||
Collections.singletonList(saved)
|
||||
));
|
||||
)).get();
|
||||
Map<UUID, List<Ping>> expected = Collections.singletonMap(playerUUID, Collections.singletonList(
|
||||
new Ping(saved.getDate(), serverUUID(), value, value, value)
|
||||
));
|
||||
|
@ -201,6 +201,10 @@ public class RandomData {
|
||||
return new DateObj<>(randomTime(), randomInt(0, 500));
|
||||
}
|
||||
|
||||
public static DateObj<Integer> randomIntDateObject(int rangeStart, int rangeEnd) {
|
||||
return new DateObj<>(randomTime(), randomInt(rangeStart, rangeEnd));
|
||||
}
|
||||
|
||||
public static double randomDouble() {
|
||||
return ThreadLocalRandom.current().nextDouble();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user