Search in sources :

Example 1 with IActionIfStatement

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

the class ActionSequenceExceptionTest method testPrint.

@Test
public void testPrint() {
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    PrintWriter writer = new PrintWriter(stream, true);
    ActionSequenceException exception = new ActionSequenceException(MSG);
    exception.setActionDefinition(null);
    exception.printActionExecutionStack(writer);
    assertEquals("", stream.toString());
    IActionDefinition actionDef = mock(IActionDefinition.class, withSettings().extraInterfaces(IActionIfStatement.class));
    exception.setActionDefinition(actionDef);
    verify(actionDef).getDescription();
    verify(actionDef).getComponentName();
    exception.printActionExecutionStack(writer);
    verify((IActionIfStatement) actionDef).getCondition();
    assertNotEquals("", stream.toString());
    actionDef = mock(IActionDefinition.class, withSettings().extraInterfaces(IActionLoop.class));
    exception.setActionDefinition(actionDef);
    writer = new PrintWriter(stream, true);
    exception.printActionExecutionStack(writer);
    verify((IActionLoop) actionDef).getLoopOn();
    assertNotEquals("", stream.toString());
    actionDef = mock(IActionDefinition.class);
    exception.setActionDefinition(actionDef);
    writer = new PrintWriter(stream, true);
    exception.printActionExecutionStack(writer);
    verify(actionDef, times(2)).getDescription();
    verify(actionDef, times(2)).getComponentName();
    assertNotEquals("", stream.toString());
}
Also used : IActionDefinition(org.pentaho.actionsequence.dom.IActionDefinition) IActionLoop(org.pentaho.actionsequence.dom.IActionLoop) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IActionIfStatement(org.pentaho.actionsequence.dom.IActionIfStatement) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Example 2 with IActionIfStatement

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

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