Search in sources :

Example 1 with IActionSequenceExecutableStatement

use of org.pentaho.actionsequence.dom.IActionSequenceExecutableStatement 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 IActionSequenceExecutableStatement

use of org.pentaho.actionsequence.dom.IActionSequenceExecutableStatement 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)

Example 3 with IActionSequenceExecutableStatement

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

the class ActionSequenceExceptionTest method testPrintStack.

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

Aggregations

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