@Test public void testGetFromCache() { when(sessionResourceMock.get()).thenReturn(mapMock); when(mapMock.get(sessionId)).thenReturn(sshConnectionMock); when(sshConnectionMock.getSession()).thenReturn(sessionMock); when(sessionMock.isConnected()).thenReturn(true); SSHService fromCache = CacheUtils.getFromCache(sessionResourceMock, sessionId); assertNotNull(fromCache); assertEquals(fromCache.getSSHSession(), sessionMock); assertEquals(fromCache.getExecChannel(), null); fromCache = CacheUtils.getFromCache(null, null); assertNull(fromCache); }
public static SSHService getFromCache(SessionResource<Map<String, SSHConnection>> sessionResource, String sessionId) { Session savedSession = CacheUtils.getSshSession(sessionResource, sessionId); if (savedSession != null && savedSession.isConnected()) { Channel savedChannel = CacheUtils.getSshChannel(sessionResource, sessionId); return new SSHServiceImpl(savedSession, savedChannel); } return null; }
CacheUtils { public static SSHService getFromCache(SessionResource<Map<String, SSHConnection>> sessionResource, String sessionId) { Session savedSession = CacheUtils.getSshSession(sessionResource, sessionId); if (savedSession != null && savedSession.isConnected()) { Channel savedChannel = CacheUtils.getSshChannel(sessionResource, sessionId); return new SSHServiceImpl(savedSession, savedChannel); } return null; } }
CacheUtils { public static SSHService getFromCache(SessionResource<Map<String, SSHConnection>> sessionResource, String sessionId) { Session savedSession = CacheUtils.getSshSession(sessionResource, sessionId); if (savedSession != null && savedSession.isConnected()) { Channel savedChannel = CacheUtils.getSshChannel(sessionResource, sessionId); return new SSHServiceImpl(savedSession, savedChannel); } return null; }  }
CacheUtils { public static SSHService getFromCache(SessionResource<Map<String, SSHConnection>> sessionResource, String sessionId) { Session savedSession = CacheUtils.getSshSession(sessionResource, sessionId); if (savedSession != null && savedSession.isConnected()) { Channel savedChannel = CacheUtils.getSshChannel(sessionResource, sessionId); return new SSHServiceImpl(savedSession, savedChannel); } return null; }  static boolean saveSshSessionAndChannel(Session session, Channel channel, GlobalSessionObject<Map<String, SSHConnection>> sessionParam, String sessionId); static void removeSshSession(GlobalSessionObject<Map<String, SSHConnection>> sessionParam, String sessionId); static SSHService getFromCache(SessionResource<Map<String, SSHConnection>> sessionResource, String sessionId); }
CacheUtils { public static SSHService getFromCache(SessionResource<Map<String, SSHConnection>> sessionResource, String sessionId) { Session savedSession = CacheUtils.getSshSession(sessionResource, sessionId); if (savedSession != null && savedSession.isConnected()) { Channel savedChannel = CacheUtils.getSshChannel(sessionResource, sessionId); return new SSHServiceImpl(savedSession, savedChannel); } return null; }  static boolean saveSshSessionAndChannel(Session session, Channel channel, GlobalSessionObject<Map<String, SSHConnection>> sessionParam, String sessionId); static void removeSshSession(GlobalSessionObject<Map<String, SSHConnection>> sessionParam, String sessionId); static SSHService getFromCache(SessionResource<Map<String, SSHConnection>> sessionResource, String sessionId);  }