use of com.djrapitops.plan.gathering.domain.Ping in project Plan by plan-player-analytics.
the class GeolocationQueriesTest method pingIsGroupedByGeolocationAppropriately.
@Test
default void pingIsGroupedByGeolocationAppropriately() {
UUID[] uuids = storeSpecificGeolocations();
Database db = db();
long time = System.currentTimeMillis();
List<DateObj<Integer>> ping = Collections.singletonList(new DateObj<>(time, 5));
for (UUID uuid : uuids) {
db.executeTransaction(new PingStoreTransaction(uuid, serverUUID(), ping));
}
Map<String, Ping> got = db.query(PingQueries.fetchPingDataOfServerByGeolocation(serverUUID()));
Map<String, Ping> expected = new HashMap<>();
// first user has a more recent connection from Finland so their country should be counted as Finland.
Ping expectedPing = new Ping(time, serverUUID(), 5, 5, 5);
expected.put("Finland", expectedPing);
expected.put("Sweden", expectedPing);
expected.put("Not Known", expectedPing);
expected.put("Local Machine", expectedPing);
expected.put("Denmark", expectedPing);
assertEquals(expected, got);
}
use of com.djrapitops.plan.gathering.domain.Ping in project Plan by plan-player-analytics.
the class PingQueriesTest method singlePingIsStored.
@Test
default void singlePingIsStored() {
DateObj<Integer> saved = RandomData.randomIntDateObject();
int value = saved.getValue();
db().executeTransaction(new PingStoreTransaction(playerUUID, serverUUID(), Collections.singletonList(saved)));
Map<UUID, List<Ping>> expected = Collections.singletonMap(playerUUID, Collections.singletonList(new Ping(saved.getDate(), serverUUID(), value, value, value)));
Map<UUID, List<Ping>> fetched = db().query(PingQueries.fetchAllPingData());
assertEquals(expected, fetched);
}
Aggregations