SessionCache { public static Optional<Session> getCachedSession(UUID playerUUID) { Optional<Session> found = Optional.ofNullable(ACTIVE_SESSIONS.get(playerUUID)); found.ifPresent(Session::updateState); return found; } @Inject  SessionCache(); static Map<UUID, Session> getActiveSessions(); static void clear(); static void refreshActiveSessionsState(); static Optional<Session> getCachedSession(UUID playerUUID); Optional<Session> cacheSession(UUID playerUUID, Session session); Optional<Session> endSession(UUID playerUUID, long time);  }
@Test void testAtomity() { Optional<Session> cachedSession = SessionCache.getCachedSession(uuid); assertTrue(cachedSession.isPresent()); assertEquals(session, cachedSession.get()); }