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