Search in sources :

Example 51 with IActionParameter

use of org.pentaho.platform.api.engine.IActionParameter in project pentaho-platform by pentaho.

the class ScriptableConditionTest method shouldExecute_returns_default_value_for_result_of_unsupported_type.

@Test
public void shouldExecute_returns_default_value_for_result_of_unsupported_type() throws Exception {
    ScriptableCondition conditionalExecution = new ScriptableCondition();
    conditionalExecution.setScript(RESULT_ELEMENT_SCRIPT);
    IActionParameter parameter = createParameterWithUnsupportedResultType();
    conditionalExecution.setDefaultResult(true);
    boolean actualResult = conditionalExecution.shouldExecute(Collections.singletonMap(RESULT_ELEMENT, parameter), logger);
    assertTrue(actualResult);
    conditionalExecution.setDefaultResult(false);
    boolean actualResult2 = conditionalExecution.shouldExecute(Collections.singletonMap(RESULT_ELEMENT, parameter), logger);
    assertFalse(actualResult2);
}
Also used : IActionParameter(org.pentaho.platform.api.engine.IActionParameter) Test(org.junit.Test)

Example 52 with IActionParameter

use of org.pentaho.platform.api.engine.IActionParameter in project pentaho-platform by pentaho.

the class ScriptableConditionTest method createParameterWithUnsupportedResultType.

private static IActionParameter createParameterWithUnsupportedResultType() {
    IActionParameter parameter = mock(IActionParameter.class);
    when(parameter.getValue()).thenReturn(new UnsupportedResultType());
    return parameter;
}
Also used : IActionParameter(org.pentaho.platform.api.engine.IActionParameter)

Example 53 with IActionParameter

use of org.pentaho.platform.api.engine.IActionParameter in project pentaho-platform by pentaho.

the class ResultsetCompareIT method testRSCompareOK.

public void testRSCompareOK() {
    startTest();
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    IRuntimeContext context = run("/test/rules/ResultSetCompareTest.xaction");
    assertEquals(Messages.getInstance().getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_SUCCESS, // $NON-NLS-1$
    context.getStatus());
    // $NON-NLS-1$
    IActionParameter rtn = context.getOutputParameter("COMPARERESULT");
    assertNotNull(rtn);
    String compareResult = rtn.getStringValue();
    // $NON-NLS-1$
    assertEquals(compareResult, "No Mismatches");
    finishTest();
}
Also used : IRuntimeContext(org.pentaho.platform.api.engine.IRuntimeContext) IActionParameter(org.pentaho.platform.api.engine.IActionParameter)

Example 54 with IActionParameter

use of org.pentaho.platform.api.engine.IActionParameter in project pentaho-platform by pentaho.

the class IPreparedComponentIT method testIPreparedComponentXQueryAvailableErrorNoDocument.

public void testIPreparedComponentXQueryAvailableErrorNoDocument() {
    startTest();
    IRuntimeContext context = // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    run("/test/ipreparedcomponents/ipreparedcomponent_xquery_available_error_nodocument.xaction");
    assertEquals(Messages.getInstance().getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_FAILURE, // $NON-NLS-1$
    context.getStatus());
    // $NON-NLS-1$
    IActionParameter rtn = context.getOutputParameter("prepared_component");
    assertNotNull(rtn);
    IPreparedComponent preparedComponent = (IPreparedComponent) rtn.getValue();
    assertNull(preparedComponent);
    finishTest();
}
Also used : IRuntimeContext(org.pentaho.platform.api.engine.IRuntimeContext) IActionParameter(org.pentaho.platform.api.engine.IActionParameter) IPreparedComponent(org.pentaho.platform.api.data.IPreparedComponent)

Example 55 with IActionParameter

use of org.pentaho.platform.api.engine.IActionParameter in project pentaho-platform by pentaho.

the class IPreparedComponentIT method testIPreparedComponentXQueryPrepareLater.

public void testIPreparedComponentXQueryPrepareLater() {
    startTest();
    // $NON-NLS-1$
    info("Expected: Successful execution with object available");
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    IRuntimeContext context = run("/test/ipreparedcomponents/ipreparedcomponent_xquery_preparelater.xaction");
    assertEquals(Messages.getInstance().getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_SUCCESS, // $NON-NLS-1$
    context.getStatus());
    // $NON-NLS-1$
    IActionParameter rtn1 = context.getOutputParameter("prepared_component");
    assertNotNull(rtn1);
    IPreparedComponent preparedComponent1 = (IPreparedComponent) rtn1.getValue();
    assertNotNull(preparedComponent1);
    IPentahoResultSet resultset1 = preparedComponent1.executePrepared(null);
    assertTrue(resultset1.getRowCount() >= 1);
    Object val1 = resultset1.getValueAt(0, 0);
    // $NON-NLS-1$
    IActionParameter rtn2 = context.getOutputParameter("second_prepared_component");
    assertNotNull(rtn2);
    IPreparedComponent preparedComponent2 = (IPreparedComponent) rtn2.getValue();
    assertNotNull(preparedComponent2);
    HashMap map = new HashMap();
    // $NON-NLS-1$ //$NON-NLS-2$
    map.put("POSITIONTITLE", "Engineer");
    IPentahoResultSet resultset2 = preparedComponent2.executePrepared(map);
    assertTrue(resultset2.getRowCount() >= 1);
    assertEquals(resultset1.getRowCount(), resultset2.getRowCount());
    Object val2 = resultset2.getValueAt(0, 0);
    // $NON-NLS-1$
    assertEquals("Values from the first and second query should be equal", val1, val2);
    finishTest();
}
Also used : IPentahoResultSet(org.pentaho.commons.connection.IPentahoResultSet) HashMap(java.util.HashMap) IRuntimeContext(org.pentaho.platform.api.engine.IRuntimeContext) IActionParameter(org.pentaho.platform.api.engine.IActionParameter) IPreparedComponent(org.pentaho.platform.api.data.IPreparedComponent)

Aggregations

IActionParameter (org.pentaho.platform.api.engine.IActionParameter)68 IRuntimeContext (org.pentaho.platform.api.engine.IRuntimeContext)24 ArrayList (java.util.ArrayList)22 HashMap (java.util.HashMap)22 Iterator (java.util.Iterator)19 Map (java.util.Map)14 IPentahoResultSet (org.pentaho.commons.connection.IPentahoResultSet)14 ISolutionEngine (org.pentaho.platform.api.engine.ISolutionEngine)13 List (java.util.List)9 SimpleUrlFactory (org.pentaho.platform.util.web.SimpleUrlFactory)9 Set (java.util.Set)8 IContentItem (org.pentaho.platform.api.repository.IContentItem)8 IOException (java.io.IOException)7 OutputStream (java.io.OutputStream)6 Test (org.junit.Test)6 SimpleOutputHandler (org.pentaho.platform.engine.core.output.SimpleOutputHandler)6 ActionParameter (org.pentaho.platform.engine.services.actionsequence.ActionParameter)6 Document (org.dom4j.Document)5 IPreparedComponent (org.pentaho.platform.api.data.IPreparedComponent)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4