Search in sources :

Example 1 with SupplierDataContainer

use of com.djrapitops.plan.delivery.domain.container.SupplierDataContainer in project Plan by plan-player-analytics.

the class PerServerContainerQuery method executeQuery.

@Override
public PerServerContainer executeQuery(SQLDB db) {
    PerServerContainer perServerContainer = new PerServerContainer();
    userInformation(db, perServerContainer);
    lastSeen(db, perServerContainer);
    playerKillCount(db, perServerContainer);
    mobKillCount(db, perServerContainer);
    totalDeathCount(db, perServerContainer);
    worldTimes(db, perServerContainer);
    Map<ServerUUID, List<FinishedSession>> sessions = db.query(SessionQueries.fetchSessionsOfPlayer(playerUUID));
    for (Map.Entry<ServerUUID, List<FinishedSession>> entry : sessions.entrySet()) {
        ServerUUID serverUUID = entry.getKey();
        List<FinishedSession> serverSessions = entry.getValue();
        DataContainer serverContainer = perServerContainer.getOrDefault(serverUUID, new SupplierDataContainer());
        serverContainer.putRawData(PerServerKeys.SESSIONS, serverSessions);
        perServerContainer.put(serverUUID, serverContainer);
    }
    return perServerContainer;
}
Also used : PerServerContainer(com.djrapitops.plan.delivery.domain.container.PerServerContainer) ServerUUID(com.djrapitops.plan.identification.ServerUUID) DataContainer(com.djrapitops.plan.delivery.domain.container.DataContainer) SupplierDataContainer(com.djrapitops.plan.delivery.domain.container.SupplierDataContainer) FinishedSession(com.djrapitops.plan.gathering.domain.FinishedSession) List(java.util.List) Map(java.util.Map) SupplierDataContainer(com.djrapitops.plan.delivery.domain.container.SupplierDataContainer)

Example 2 with SupplierDataContainer

use of com.djrapitops.plan.delivery.domain.container.SupplierDataContainer in project Plan by plan-player-analytics.

the class SupplierDataContainerTest method safeUnsafeKeyRawDifferentObject.

@Test
void safeUnsafeKeyRawDifferentObject() {
    DataContainer container = new SupplierDataContainer();
    container.putRawData(TEST_KEY, "Success");
    assertEquals("Success", container.getUnsafe(TEST_KEY_COPY));
}
Also used : SupplierDataContainer(com.djrapitops.plan.delivery.domain.container.SupplierDataContainer) DataContainer(com.djrapitops.plan.delivery.domain.container.DataContainer) SupplierDataContainer(com.djrapitops.plan.delivery.domain.container.SupplierDataContainer) Test(org.junit.jupiter.api.Test)

Example 3 with SupplierDataContainer

use of com.djrapitops.plan.delivery.domain.container.SupplierDataContainer in project Plan by plan-player-analytics.

the class SupplierDataContainerTest method cachingSupplier.

@Test
void cachingSupplier() {
    DataContainer container = new SupplierDataContainer();
    String firstObj = "First";
    String secondObj = "Second";
    assertNotSame(firstObj, secondObj);
    container.putCachingSupplier(TEST_KEY, () -> firstObj);
    String found = container.getUnsafe(TEST_KEY);
    assertEquals(firstObj, found);
    assertSame(firstObj, found);
    assertNotSame(secondObj, found);
    String secondCall = container.getUnsafe(TEST_KEY);
    assertSame(found, secondCall);
}
Also used : SupplierDataContainer(com.djrapitops.plan.delivery.domain.container.SupplierDataContainer) DataContainer(com.djrapitops.plan.delivery.domain.container.DataContainer) SupplierDataContainer(com.djrapitops.plan.delivery.domain.container.SupplierDataContainer) Test(org.junit.jupiter.api.Test)

Example 4 with SupplierDataContainer

use of com.djrapitops.plan.delivery.domain.container.SupplierDataContainer in project Plan by plan-player-analytics.

the class SupplierDataContainerTest method safeUnsafeKeySupplierDifferentObject.

@Test
void safeUnsafeKeySupplierDifferentObject() {
    DataContainer container = new SupplierDataContainer();
    container.putSupplier(TEST_KEY, () -> "Success");
    assertEquals("Success", container.getUnsafe(TEST_KEY_COPY));
}
Also used : SupplierDataContainer(com.djrapitops.plan.delivery.domain.container.SupplierDataContainer) DataContainer(com.djrapitops.plan.delivery.domain.container.DataContainer) SupplierDataContainer(com.djrapitops.plan.delivery.domain.container.SupplierDataContainer) Test(org.junit.jupiter.api.Test)

Example 5 with SupplierDataContainer

use of com.djrapitops.plan.delivery.domain.container.SupplierDataContainer in project Plan by plan-player-analytics.

the class SupplierDataContainerTest method safeUnsafeKeyRawSameObject.

@Test
void safeUnsafeKeyRawSameObject() {
    DataContainer container = new SupplierDataContainer();
    container.putRawData(TEST_KEY, "Success");
    assertEquals("Success", container.getUnsafe(TEST_KEY));
}
Also used : SupplierDataContainer(com.djrapitops.plan.delivery.domain.container.SupplierDataContainer) DataContainer(com.djrapitops.plan.delivery.domain.container.DataContainer) SupplierDataContainer(com.djrapitops.plan.delivery.domain.container.SupplierDataContainer) Test(org.junit.jupiter.api.Test)

Aggregations

DataContainer (com.djrapitops.plan.delivery.domain.container.DataContainer)9 SupplierDataContainer (com.djrapitops.plan.delivery.domain.container.SupplierDataContainer)9 Test (org.junit.jupiter.api.Test)8 PerServerContainer (com.djrapitops.plan.delivery.domain.container.PerServerContainer)1 FinishedSession (com.djrapitops.plan.gathering.domain.FinishedSession)1 ServerUUID (com.djrapitops.plan.identification.ServerUUID)1 List (java.util.List)1 Map (java.util.Map)1