@Test public void testSaveSshSessionAndChannel() { boolean saved = CacheUtils.saveSshSessionAndChannel(sessionMock, channelShellMock, sshGlobalSessionObjectMock, sessionId); assertEquals(true, saved); saved = CacheUtils.saveSshSessionAndChannel(null, null, null, null); assertEquals(false, saved); saved = CacheUtils.saveSshSessionAndChannel(null, null, null, ""); assertEquals(false, saved); when(sshGlobalSessionObjectMock.get()).thenReturn(null); saved = CacheUtils.saveSshSessionAndChannel(sessionMock, channelShellMock, sshGlobalSessionObjectMock, sessionId); assertEquals(true, saved); when(sshGlobalSessionObjectMock.get()).thenReturn(mapMock); saved = CacheUtils.saveSshSessionAndChannel(sessionMock, channelShellMock, sshGlobalSessionObjectMock, sessionId); assertEquals(true, saved); }
public static boolean saveSshSessionAndChannel(Session session, Channel channel, GlobalSessionObject<Map<String, SSHConnection>> sessionParam, String sessionId) { final SSHConnection sshConnection; if (channel != null) { sshConnection = new SSHConnection(session, channel); } else { sshConnection = new SSHConnection(session); } if (sessionParam != null) { Map<String, SSHConnection> tempMap = sessionParam.get(); if (tempMap == null) { tempMap = new HashMap<>(); } tempMap.put(sessionId, sshConnection); sessionParam.setResource(new SSHSessionResource(tempMap)); return true; } return false; }
CacheUtils { public static boolean saveSshSessionAndChannel(Session session, Channel channel, GlobalSessionObject<Map<String, SSHConnection>> sessionParam, String sessionId) { final SSHConnection sshConnection; if (channel != null) { sshConnection = new SSHConnection(session, channel); } else { sshConnection = new SSHConnection(session); } if (sessionParam != null) { Map<String, SSHConnection> tempMap = sessionParam.get(); if (tempMap == null) { tempMap = new HashMap<>(); } tempMap.put(sessionId, sshConnection); sessionParam.setResource(new SSHSessionResource(tempMap)); return true; } return false; } }
CacheUtils { public static boolean saveSshSessionAndChannel(Session session, Channel channel, GlobalSessionObject<Map<String, SSHConnection>> sessionParam, String sessionId) { final SSHConnection sshConnection; if (channel != null) { sshConnection = new SSHConnection(session, channel); } else { sshConnection = new SSHConnection(session); } if (sessionParam != null) { Map<String, SSHConnection> tempMap = sessionParam.get(); if (tempMap == null) { tempMap = new HashMap<>(); } tempMap.put(sessionId, sshConnection); sessionParam.setResource(new SSHSessionResource(tempMap)); return true; } return false; }  }
CacheUtils { public static boolean saveSshSessionAndChannel(Session session, Channel channel, GlobalSessionObject<Map<String, SSHConnection>> sessionParam, String sessionId) { final SSHConnection sshConnection; if (channel != null) { sshConnection = new SSHConnection(session, channel); } else { sshConnection = new SSHConnection(session); } if (sessionParam != null) { Map<String, SSHConnection> tempMap = sessionParam.get(); if (tempMap == null) { tempMap = new HashMap<>(); } tempMap.put(sessionId, sshConnection); sessionParam.setResource(new SSHSessionResource(tempMap)); return true; } return false; }  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 boolean saveSshSessionAndChannel(Session session, Channel channel, GlobalSessionObject<Map<String, SSHConnection>> sessionParam, String sessionId) { final SSHConnection sshConnection; if (channel != null) { sshConnection = new SSHConnection(session, channel); } else { sshConnection = new SSHConnection(session); } if (sessionParam != null) { Map<String, SSHConnection> tempMap = sessionParam.get(); if (tempMap == null) { tempMap = new HashMap<>(); } tempMap.put(sessionId, sshConnection); sessionParam.setResource(new SSHSessionResource(tempMap)); return true; } return false; }  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);  }