Search in sources :

Example 1 with IActionDefinition

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
}
Also used : PrintMapValsAction(org.pentaho.actionsequence.dom.actions.PrintMapValsAction) IActionDefinition(org.pentaho.actionsequence.dom.IActionDefinition) HashMap(java.util.HashMap) PrintParamAction(org.pentaho.actionsequence.dom.actions.PrintParamAction) FormatMsgAction(org.pentaho.actionsequence.dom.actions.FormatMsgAction) CopyParamAction(org.pentaho.actionsequence.dom.actions.CopyParamAction)

Example 2 with IActionDefinition

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 ");
    }
}
Also used : IActionDefinition(org.pentaho.actionsequence.dom.IActionDefinition) Test(org.junit.Test)

Example 3 with 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());
}
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 4 with IActionDefinition

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 ");
    }
}
Also used : IActionDefinition(org.pentaho.actionsequence.dom.IActionDefinition) Test(org.junit.Test)

Example 5 with 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 ");
    }
}
Also used : IActionDefinition(org.pentaho.actionsequence.dom.IActionDefinition) Test(org.junit.Test)

Aggregations

IActionDefinition (org.pentaho.actionsequence.dom.IActionDefinition)19 Test (org.junit.Test)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 List (java.util.List)3 IActionInput (org.pentaho.actionsequence.dom.IActionInput)3 AbstractRelationalDbAction (org.pentaho.actionsequence.dom.actions.AbstractRelationalDbAction)3 IActionSequence (org.pentaho.platform.api.engine.IActionSequence)3 IMimeTypeListener (org.pentaho.platform.api.engine.IMimeTypeListener)3 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)3 ActionSequenceJCRHelper (org.pentaho.platform.engine.services.ActionSequenceJCRHelper)3 ArrayList (java.util.ArrayList)2 IActionIfStatement (org.pentaho.actionsequence.dom.IActionIfStatement)2 IActionLoop (org.pentaho.actionsequence.dom.IActionLoop)2 CopyParamAction (org.pentaho.actionsequence.dom.actions.CopyParamAction)2 FormatMsgAction (org.pentaho.actionsequence.dom.actions.FormatMsgAction)2 PrintMapValsAction (org.pentaho.actionsequence.dom.actions.PrintMapValsAction)2 PrintParamAction (org.pentaho.actionsequence.dom.actions.PrintParamAction)2 SqlConnectionAction (org.pentaho.actionsequence.dom.actions.SqlConnectionAction)2 XQueryAction (org.pentaho.actionsequence.dom.actions.XQueryAction)2 XQueryConnectionAction (org.pentaho.actionsequence.dom.actions.XQueryConnectionAction)2