ActionSequenceException extends Exception { @SuppressWarnings( "nls" ) protected void _printStack( IActionSequenceExecutableStatement statement, PrintWriter s, String prefix ) { if ( statement instanceof IActionIfStatement ) { s.println( prefix + "IF STATEMENT: " + ( (IActionIfStatement) statement ).getCondition() ); } else if ( statement instanceof IActionLoop ) { s.println( prefix + "LOOP ON: " + ( (IActionLoop) statement ).getLoopOn() ); } else if ( statement instanceof IActionDefinition ) { String actionDesc = StringUtils.defaultString( ( (IActionDefinition) statement ).getDescription(), "" ); s.println( prefix + "EXECUTING ACTION: " + actionDesc + " (" + ( (IActionDefinition) statement ).getComponentName() + ")" ); } else if ( statement instanceof IActionControlStatement ) { s.println( prefix + "UNKNOWN CONTROL STATEMENT" ); } else { s.println( prefix + "UNKNOWN EXECUTABLE STATEMENT" ); } IActionSequenceExecutableStatement parent = statement.getParent(); if ( parent != null ) { _printStack( statement.getParent(), s, "\tin " ); } } ActionSequenceException();  ActionSequenceException( String msg );  ActionSequenceException( String msg, Throwable cause );  ActionSequenceException( Throwable cause );  ActionSequenceException( String msg, Throwable cause, String sessionName, String instanceId,
      String actionSequenceName, String actionDescription, String componentName );  ActionSequenceException( String msg, Throwable cause, String sessionName, String instanceId,
      String actionSequenceName, IActionDefinition actionDefinition );  ActionSequenceException( String msg, String sessionName, String instanceId, String actionSequenceName,
      IActionDefinition actionDefinition ); String getStepDescription(); void setStepDescription( String description ); String getActionSequenceName(); void setActionSequenceName( String actionSequenceName ); Integer getStepNumber(); void setStepNumber( Integer stepNumber ); String getInstanceId(); void setInstanceId( String instanceId ); String getSessionId(); void setSessionId( String sessionId ); String getActionClass(); void setActionClass( String actionClass ); Date getDate(); IActionDefinition getActionDefinition(); void setActionDefinition( IActionDefinition actionDefinition ); Integer getLoopIndex(); void setLoopIndex( Integer loopIndex ); @SuppressWarnings( "nls" ) void printActionExecutionStack( PrintWriter s );  }
@Test public void testPrintStack() { ByteArrayOutputStream stream = new ByteArrayOutputStream(); PrintWriter writer = new PrintWriter( stream, true ); ActionSequenceException exception = new ActionSequenceException( MSG ); IActionSequenceExecutableStatement statement = mock( IActionControlStatement.class ); exception._printStack( statement, writer, "" ); assertNotEquals( "", stream.toString() ); statement = mock( IActionSequenceExecutableStatement.class ); exception._printStack( statement, writer, "" ); assertNotEquals( "", stream.toString() ); }
@Test public void testPrintStackRecursion() { ByteArrayOutputStream stream = new ByteArrayOutputStream(); PrintWriter writer = new PrintWriter( stream, true ); ActionSequenceException exception = new ActionSequenceException( MSG ); IActionSequenceExecutableStatement statement = mock( IActionSequenceExecutableStatement.class ); IActionControlStatement parent = mock( IActionControlStatement.class ); Mockito.when( statement.getParent() ).thenReturn( parent ); exception._printStack( statement, writer, "" ); assertNotEquals( "", stream.toString() ); }