### Question:
SessionManager { public String findUserMachineId(UserId userId) { if ( userId == null ) return null; Jedis jedis = JedisFactory.getJedis(); String machineBytes = jedis.hget(userId.toString(), H_MACHINE_KEY); return machineBytes; } SessionManager(); String getLocalSessionPrefix(); SessionKey registerSession(IoSession session, User user); SessionKey registerSession(IoSession session, User user, SessionKey existSessionKey); boolean deregisterSession(IoSession session, User user); Locale findUserLocale(SessionKey sessionKey); String findUserMachineId(UserId userId); String findUserRpcId(UserId userId); String findUserRpcId(SessionKey userSessionKey); String findUserGameServerId(UserId userId); String findUserGameServerId(SessionKey userSessionKey); List<SessionKey> findAllOnlineUsers(); List<SessionKey> findAllOnlineUsers(int limit); String findSessionMachineId(SessionKey sessionKey); UserId findUserIdBySessionKey(SessionKey sessionKey); SessionKey findSessionKeyByUserId(UserId userId); SessionKey findSessionKeyByProxyUserId(UserId userId); boolean isSessionKeyFromAI(SessionKey sessionKey); boolean isSessionKeyFromProxy(SessionKey sesseionKey); static final String PROXY_SESSION_KEYS; static final String LOCALE_SESSION_KEY; static final String H_MACHINE_KEY; static final String H_RPCSERVER_KEY; static final String H_GAMESERVER_KEY; static final String H_USERID_KEY; static final String H_SESSION_KEY; static final String H_LOCALE_KEY; static final String H_ISAI; static final String H_ISPROXY; static final String V_TRUE; static final String V_FALSE; static final String Q_SESSION_PATTERN; static final String L_SESSION_PATTERN; }### Answer:
@Test public void testFindUserMachineId() { GlobalConfig.getInstance().overrideProperty("runtime.local_messageserver", "localhost:12345"); GlobalConfig.getInstance().overrideProperty(GlobalConfig.RUNTIME_RPC_SERVERID, "localhost:12346"); GlobalConfig.getInstance().overrideProperty(GlobalConfig.RUNTIME_GAME_SERVERID, "localhost:3443"); GlobalConfig.getInstance().overrideProperty(GlobalConfigKey.session_timeout_seconds, "0"); SessionManager manager = new SessionManager(); SessionRawMessage message = createSessionRawMessage(40, "10.0.0.1", 10000); User user = UserManager.getInstance().createDefaultUser(); user.set_id(new UserId("test-001")); IoSession session = createNiceMock(IoSession.class); replay(session); SessionKey sessionKey = manager.registerSession(session, user); verify(session); String actualMachineId = manager.findUserMachineId(user.get_id()); assertEquals("localhost:12345", actualMachineId); String actualRpcServerId = manager.findUserRpcId(user.get_id()); assertEquals("localhost:12346", actualRpcServerId); String actualGameServerId = manager.findUserGameServerId(user.get_id()); assertEquals("localhost:3443", actualGameServerId); manager.deregisterSession(session, user); actualMachineId = manager.findUserMachineId(user.get_id()); assertEquals(null, actualMachineId); actualRpcServerId = manager.findUserRpcId(user.get_id()); assertEquals(null, actualRpcServerId); actualGameServerId = manager.findUserGameServerId(user.get_id()); assertEquals(null, actualGameServerId); }