Search in sources :

Example 1 with IActionControlStatement

use of org.pentaho.actionsequence.dom.IActionControlStatement in project pentaho-platform by pentaho.

the class ActionSequenceExceptionTest method testPrintStackRecursion.

@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());
}
Also used : IActionSequenceExecutableStatement(org.pentaho.actionsequence.dom.IActionSequenceExecutableStatement) IActionControlStatement(org.pentaho.actionsequence.dom.IActionControlStatement) ByteArrayOutputStream(java.io.ByteArrayOutputStream) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Example 2 with IActionControlStatement

use of org.pentaho.actionsequence.dom.IActionControlStatement in project pentaho-platform by pentaho.

the class ActionSequenceException method _printStack.

/*
   * We are not i18n-ing these stack trace messages. This can be thought of as Throwable.printStackTrace()
   */
@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 ");
    }
}
Also used : IActionLoop(org.pentaho.actionsequence.dom.IActionLoop) IActionDefinition(org.pentaho.actionsequence.dom.IActionDefinition) IActionControlStatement(org.pentaho.actionsequence.dom.IActionControlStatement) IActionSequenceExecutableStatement(org.pentaho.actionsequence.dom.IActionSequenceExecutableStatement) IActionIfStatement(org.pentaho.actionsequence.dom.IActionIfStatement)

Aggregations

IActionControlStatement (org.pentaho.actionsequence.dom.IActionControlStatement)2 IActionSequenceExecutableStatement (org.pentaho.actionsequence.dom.IActionSequenceExecutableStatement)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 PrintWriter (java.io.PrintWriter)1 Test (org.junit.Test)1 IActionDefinition (org.pentaho.actionsequence.dom.IActionDefinition)1 IActionIfStatement (org.pentaho.actionsequence.dom.IActionIfStatement)1 IActionLoop (org.pentaho.actionsequence.dom.IActionLoop)1