@Test public void testGetFromCache() { SSHShellAbstract sshShellAbstract = new SSHShellAbstract() { }; mockStatic(CacheUtils.class); String sessionId = "sessionId"; when(sshShellInputsMock.getSshGlobalSessionObject()).thenReturn(sshGlobalSessionObjectMock); when(sshGlobalSessionObjectMock.getResource()).thenReturn(sessionResourceMock); when(CacheUtils.getFromCache(sessionResourceMock, sessionId)).thenReturn(sshServiceMock); SSHService serviceFromCache = sshShellAbstract.getFromCache(sshShellInputsMock, sessionId); assertNotNull(serviceFromCache); assertEquals(sshServiceMock, serviceFromCache); serviceFromCache = sshShellAbstract.getFromCache(sshShellInputsMock, ""); assertNull(serviceFromCache); serviceFromCache = sshShellAbstract.getFromCache(sshShellInputsMock, null); assertNull(serviceFromCache); }
protected SSHService getFromCache(SSHShellInputs sshShellInputs, String sessionId) { if (sessionId != null) { synchronized (sessionId) { return CacheUtils.getFromCache(sshShellInputs.getSshGlobalSessionObject().getResource(), sessionId); } } else { return null; } }
SSHShellAbstract { protected SSHService getFromCache(SSHShellInputs sshShellInputs, String sessionId) { if (sessionId != null) { synchronized (sessionId) { return CacheUtils.getFromCache(sshShellInputs.getSshGlobalSessionObject().getResource(), sessionId); } } else { return null; } } }
SSHShellAbstract { protected SSHService getFromCache(SSHShellInputs sshShellInputs, String sessionId) { if (sessionId != null) { synchronized (sessionId) { return CacheUtils.getFromCache(sshShellInputs.getSshGlobalSessionObject().getResource(), sessionId); } } else { return null; } }  }
SSHShellAbstract { protected SSHService getFromCache(SSHShellInputs sshShellInputs, String sessionId) { if (sessionId != null) { synchronized (sessionId) { return CacheUtils.getFromCache(sshShellInputs.getSshGlobalSessionObject().getResource(), sessionId); } } else { return null; } }   }
SSHShellAbstract { protected SSHService getFromCache(SSHShellInputs sshShellInputs, String sessionId) { if (sessionId != null) { synchronized (sessionId) { return CacheUtils.getFromCache(sshShellInputs.getSshGlobalSessionObject().getResource(), sessionId); } } else { return null; } }   static final String COMMAND_IS_NOT_SPECIFIED_MESSAGE; }