mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-08-21 20:22:45 +02:00
[Test] CachingSupplier test to DataContainerTest
This commit is contained in:
parent
3af725f3ff
commit
7e89a24706
|
@ -20,8 +20,6 @@ public class DataContainerTest {
|
|||
DataContainer container = new DataContainer();
|
||||
container.putSupplier(TEST_KEY, () -> "Success");
|
||||
|
||||
// Test twice for CachingSupplier
|
||||
assertEquals("Success", container.getUnsafe(TEST_KEY));
|
||||
assertEquals("Success", container.getUnsafe(TEST_KEY));
|
||||
}
|
||||
|
||||
|
@ -30,8 +28,6 @@ public class DataContainerTest {
|
|||
DataContainer container = new DataContainer();
|
||||
container.putSupplier(TEST_KEY, () -> "Success");
|
||||
|
||||
// Test twice for CachingSupplier
|
||||
assertEquals("Success", container.getUnsafe(TEST_KEY_COPY));
|
||||
assertEquals("Success", container.getUnsafe(TEST_KEY_COPY));
|
||||
}
|
||||
|
||||
|
@ -40,8 +36,6 @@ public class DataContainerTest {
|
|||
DataContainer container = new DataContainer();
|
||||
container.putRawData(TEST_KEY, "Success");
|
||||
|
||||
// Test twice for CachingSupplier
|
||||
assertEquals("Success", container.getUnsafe(TEST_KEY));
|
||||
assertEquals("Success", container.getUnsafe(TEST_KEY));
|
||||
}
|
||||
|
||||
|
@ -50,8 +44,6 @@ public class DataContainerTest {
|
|||
DataContainer container = new DataContainer();
|
||||
container.putRawData(TEST_KEY, "Success");
|
||||
|
||||
// Test twice for CachingSupplier
|
||||
assertEquals("Success", container.getUnsafe(TEST_KEY_COPY));
|
||||
assertEquals("Success", container.getUnsafe(TEST_KEY_COPY));
|
||||
}
|
||||
|
||||
|
@ -60,10 +52,8 @@ public class DataContainerTest {
|
|||
DataContainer container = new DataContainer();
|
||||
container.putRawData(TEST_KEY, null);
|
||||
|
||||
// Test twice for CachingSupplier
|
||||
assertTrue(container.supports(TEST_KEY));
|
||||
assertNull(container.getUnsafe(TEST_KEY));
|
||||
assertNull(container.getUnsafe(TEST_KEY));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -79,10 +69,27 @@ public class DataContainerTest {
|
|||
DataContainer container = new DataContainer();
|
||||
container.putSupplier(TEST_KEY, () -> null);
|
||||
|
||||
// Test twice for CachingSupplier
|
||||
assertTrue(container.supports(TEST_KEY));
|
||||
assertNull(container.getUnsafe(TEST_KEY));
|
||||
assertNull(container.getUnsafe(TEST_KEY));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cachingSupplier() {
|
||||
DataContainer container = new DataContainer();
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user