@Test public void testPopulateResult() { SSHShellAbstract sshShellAbstract = new SSHShellAbstract() { }; Map<String, String> returnResult = new HashMap<>(); final String testExceptionMessage = "Test exception"; Exception testException = new Exception(testExceptionMessage); sshShellAbstract.populateResult(returnResult, testException); assertEquals(returnResult.get("returnResult"), testExceptionMessage); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); testException.printStackTrace(pw); pw.close(); assertEquals(returnResult.get("exception"), sw.toString()); assertEquals(returnResult.get("returnCode"), "-1"); }
protected void populateResult(Map<String, String> returnResult, Throwable e) { returnResult.put(OutputNames.RETURN_RESULT, e.getMessage()); returnResult.put(OutputNames.EXCEPTION, StringUtils.getStackTraceAsString(e)); returnResult.put(OutputNames.RETURN_CODE, ReturnCodes.FAILURE); }
SSHShellAbstract { protected void populateResult(Map<String, String> returnResult, Throwable e) { returnResult.put(OutputNames.RETURN_RESULT, e.getMessage()); returnResult.put(OutputNames.EXCEPTION, StringUtils.getStackTraceAsString(e)); returnResult.put(OutputNames.RETURN_CODE, ReturnCodes.FAILURE); } }
SSHShellAbstract { protected void populateResult(Map<String, String> returnResult, Throwable e) { returnResult.put(OutputNames.RETURN_RESULT, e.getMessage()); returnResult.put(OutputNames.EXCEPTION, StringUtils.getStackTraceAsString(e)); returnResult.put(OutputNames.RETURN_CODE, ReturnCodes.FAILURE); }  }
SSHShellAbstract { protected void populateResult(Map<String, String> returnResult, Throwable e) { returnResult.put(OutputNames.RETURN_RESULT, e.getMessage()); returnResult.put(OutputNames.EXCEPTION, StringUtils.getStackTraceAsString(e)); returnResult.put(OutputNames.RETURN_CODE, ReturnCodes.FAILURE); }   }
SSHShellAbstract { protected void populateResult(Map<String, String> returnResult, Throwable e) { returnResult.put(OutputNames.RETURN_RESULT, e.getMessage()); returnResult.put(OutputNames.EXCEPTION, StringUtils.getStackTraceAsString(e)); returnResult.put(OutputNames.RETURN_CODE, ReturnCodes.FAILURE); }   static final String COMMAND_IS_NOT_SPECIFIED_MESSAGE; }