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);
}
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));
}
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));
}
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));
}
Aggregations