use of org.pentaho.actionsequence.dom.IActionDefinition in project pentaho-platform by pentaho.
the class UtilityComponent method executeAction.
/*
* (non-Javadoc)
*
* @see org.pentaho.component.ComponentBase#execute()
*/
@Override
protected boolean executeAction() {
IActionDefinition actionDefinition = getActionDefinition();
// Make sure we start with an empty list in
tmpOutputs = new HashMap();
boolean result = true;
if (actionDefinition instanceof CopyParamAction) {
executeCopyAction((CopyParamAction) actionDefinition);
} else if (actionDefinition instanceof FormatMsgAction) {
executeFormatAction((FormatMsgAction) actionDefinition);
} else if (actionDefinition instanceof PrintMapValsAction) {
executeGetMapValuesAction((PrintMapValsAction) actionDefinition);
} else if (actionDefinition instanceof PrintParamAction) {
executePrintParamAction((PrintParamAction) actionDefinition);
} else {
// This component allows multiple actions to be defined in a single action definition.
// While this is no longer supported by the design studio, it needs to be supported here
// for backwards compatibility with older action sequence documents.
result = executeAction(actionDefinition);
}
return result;
// this iteration
}
use of org.pentaho.actionsequence.dom.IActionDefinition in project pentaho-platform by pentaho.
the class ActionInitializationExceptionTest method testCustomizedConstructors.
@Test
public void testCustomizedConstructors() {
IActionDefinition actionDef = Mockito.mock(IActionDefinition.class);
try {
Constructor<ActionInitializationException> constructor = ActionInitializationException.class.getDeclaredConstructor(String.class, Throwable.class, String.class, String.class, String.class, IActionDefinition.class);
constructor.setAccessible(true);
constructor.newInstance("msg", new Exception("cause"), "sessionName", "instanceId", "actionSequenceName", actionDef);
} catch (Exception e) {
fail(ActionInitializationException.class.getSimpleName() + " Does not have a constructor with String, Throwable, String, String, String, IActionDefinition ");
}
try {
Constructor<ActionInitializationException> constructor = ActionInitializationException.class.getDeclaredConstructor(String.class, String.class, String.class, String.class, IActionDefinition.class);
constructor.setAccessible(true);
constructor.newInstance("msg", "sessionName", "instanceId", "actionSequenceName", actionDef);
} catch (Exception e) {
fail(ActionInitializationException.class.getSimpleName() + " Does not have a constructor with String, String, String, String, IActionDefinition ");
}
}
use of org.pentaho.actionsequence.dom.IActionDefinition 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.IActionDefinition in project pentaho-platform by pentaho.
the class ActionSequencePromptExceptionTest method testCustomizedConstructors.
@Test
public void testCustomizedConstructors() {
IActionDefinition actionDef = Mockito.mock(IActionDefinition.class);
try {
Constructor<ActionSequencePromptException> constructor = ActionSequencePromptException.class.getDeclaredConstructor(String.class, Throwable.class, String.class, String.class, String.class, IActionDefinition.class);
constructor.setAccessible(true);
constructor.newInstance("msg", new Exception("cause"), "sessionName", "instanceId", "actionSequenceName", actionDef);
} catch (Exception e) {
fail(ActionExecutionException.class.getSimpleName() + " Does not have a constructor with String, Throwable, String, String, String, IActionDefinition ");
}
try {
Constructor<ActionSequencePromptException> constructor = ActionSequencePromptException.class.getDeclaredConstructor(String.class, String.class, String.class, String.class, IActionDefinition.class);
constructor.setAccessible(true);
constructor.newInstance("msg", "sessionName", "instanceId", "actionSequenceName", actionDef);
} catch (Exception e) {
fail(ActionSequencePromptException.class.getSimpleName() + " Does not have a constructor with String, String, String, String, IActionDefinition ");
}
}
use of org.pentaho.actionsequence.dom.IActionDefinition in project pentaho-platform by pentaho.
the class ActionValidationExceptionTest method testExceptionConstructors.
@Test
public void testExceptionConstructors() {
try {
Constructor<ActionValidationException> constructor = ActionValidationException.class.getDeclaredConstructor(String.class, String.class);
constructor.setAccessible(true);
constructor.newInstance("testMsg", "componentName");
} catch (Exception e) {
fail(ActionValidationException.class.getSimpleName() + " Does not have a constructor with String, String parameters");
}
try {
Constructor<ActionValidationException> constructor = ActionValidationException.class.getDeclaredConstructor(String.class, Throwable.class, String.class);
constructor.setAccessible(true);
constructor.newInstance("testMsg", new Exception("cause"), "componentName");
} catch (Exception e) {
fail(ActionValidationException.class.getSimpleName() + " Does not have a constructor with String, Throwable, String parameters");
}
try {
Constructor<ActionValidationException> constructor = ActionValidationException.class.getDeclaredConstructor(String.class, Throwable.class, String.class, String.class, String.class, String.class, String.class);
constructor.setAccessible(true);
constructor.newInstance("testMsg", new Exception("cause"), "sessionName", "instanceId", "actionSequenceName", "actionDescription", "componentName");
} catch (Exception e) {
fail(ActionValidationException.class.getSimpleName() + " Does not have a constructor with String, Throwable, String, String, String, String, String parameters");
}
try {
Constructor<ActionValidationException> constructor = ActionValidationException.class.getDeclaredConstructor(String.class);
constructor.setAccessible(true);
constructor.newInstance("testMsg");
} catch (Exception e) {
fail(ActionValidationException.class.getSimpleName() + " Does not have a constructor with String parameter");
}
try {
Constructor<ActionValidationException> constructor = ActionValidationException.class.getDeclaredConstructor(Throwable.class);
constructor.setAccessible(true);
constructor.newInstance(new Exception("cause"));
} catch (Exception e) {
fail(ActionValidationException.class.getSimpleName() + " Does not have a constructor with Throwable parameter");
}
try {
Constructor<ActionValidationException> constructor = ActionValidationException.class.getDeclaredConstructor(String.class, Throwable.class);
constructor.setAccessible(true);
constructor.newInstance("testMsg", new Exception("cause"));
} catch (Exception e) {
fail(ActionValidationException.class.getSimpleName() + " Does not have a constructor with String and Throwable parameter");
}
IActionDefinition actionDef = Mockito.mock(IActionDefinition.class);
try {
Constructor<ActionValidationException> constructor = ActionValidationException.class.getDeclaredConstructor(String.class, Throwable.class, String.class, String.class, String.class, IActionDefinition.class);
constructor.setAccessible(true);
constructor.newInstance("testMsg", new Exception("cause"), "sessionName", "instanceId", "actionSequenceName", actionDef);
} catch (Exception e) {
fail(ActionValidationException.class.getSimpleName() + " Does not have a constructor with String, Throwable, String, String, String, IActionDefinition ");
}
try {
Constructor<ActionValidationException> constructor = ActionValidationException.class.getDeclaredConstructor(String.class, String.class, String.class, String.class, IActionDefinition.class);
constructor.setAccessible(true);
constructor.newInstance("testMsg", "sessionName", "instanceId", "actionSequenceName", actionDef);
} catch (Exception e) {
fail(ActionValidationException.class.getSimpleName() + " Does not have a constructor with String, String, String, String, IActionDefinition ");
}
}
Aggregations