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());
}
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 ");
}
}
Aggregations