Search in sources :

Example 11 with Ping

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);
}
Also used : DateObj(com.djrapitops.plan.delivery.domain.DateObj) Ping(com.djrapitops.plan.gathering.domain.Ping) Database(com.djrapitops.plan.storage.database.Database) PingStoreTransaction(com.djrapitops.plan.storage.database.transactions.events.PingStoreTransaction) Test(org.junit.jupiter.api.Test)

Example 12 with Ping

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);
}
Also used : Ping(com.djrapitops.plan.gathering.domain.Ping) PingStoreTransaction(com.djrapitops.plan.storage.database.transactions.events.PingStoreTransaction) List(java.util.List) UUID(java.util.UUID) Test(org.junit.jupiter.api.Test)

Aggregations

Ping (com.djrapitops.plan.gathering.domain.Ping)12 ServerUUID (com.djrapitops.plan.identification.ServerUUID)5 AveragePing (com.djrapitops.plan.delivery.domain.AveragePing)3 Lists (com.djrapitops.plan.utilities.java.Lists)3 ResultSet (java.sql.ResultSet)3 DateHolder (com.djrapitops.plan.delivery.domain.DateHolder)2 FinishedSession (com.djrapitops.plan.gathering.domain.FinishedSession)2 Database (com.djrapitops.plan.storage.database.Database)2 QueryStatement (com.djrapitops.plan.storage.database.queries.QueryStatement)2 PingStoreTransaction (com.djrapitops.plan.storage.database.transactions.events.PingStoreTransaction)2 DateHolderOldestComparator (com.djrapitops.plan.utilities.comparators.DateHolderOldestComparator)2 PreparedStatement (java.sql.PreparedStatement)2 Test (org.junit.jupiter.api.Test)2 DateObj (com.djrapitops.plan.delivery.domain.DateObj)1 DataContainer (com.djrapitops.plan.delivery.domain.container.DataContainer)1 PlayerContainer (com.djrapitops.plan.delivery.domain.container.PlayerContainer)1 CommonKeys (com.djrapitops.plan.delivery.domain.keys.CommonKeys)1 PingMutator (com.djrapitops.plan.delivery.domain.mutators.PingMutator)1 PingGraph (com.djrapitops.plan.delivery.rendering.json.graphs.line.PingGraph)1 GeoInfo (com.djrapitops.plan.gathering.domain.GeoInfo)1