Search in sources :

Example 6 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 7 with SupplierDataContainer

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

the class SupplierDataContainerTest method safeUnsafeKeySupplierSameObject.

@Test
void safeUnsafeKeySupplierSameObject() {
    DataContainer container = new SupplierDataContainer();
    container.putSupplier(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)

Example 8 with SupplierDataContainer

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

the class SupplierDataContainerTest method safeUnsafeKeyNullSupplier.

@Test
void safeUnsafeKeyNullSupplier() {
    DataContainer container = new SupplierDataContainer();
    container.putSupplier(TEST_KEY, null);
    assertFalse(container.supports(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)

Example 9 with SupplierDataContainer

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

the class SupplierDataContainerTest method safeUnsafeKeySupplierNull.

@Test
void safeUnsafeKeySupplierNull() {
    DataContainer container = new SupplierDataContainer();
    container.putSupplier(TEST_KEY, () -> null);
    assertTrue(container.supports(TEST_KEY));
    assertNull(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