use of org.pentaho.platform.api.engine.IRuntimeContext in project pentaho-platform by pentaho.
the class RulesIT method testScriptRuleError4.
public void testScriptRuleError4() {
startTest();
// $NON-NLS-1$
info("This should generate errors because the input to the script has a minus sign in the input name.");
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
IRuntimeContext context = run("/test/rules/script_rule_error4.xaction");
assertEquals(Messages.getInstance().getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_FAILURE, // $NON-NLS-1$
context.getStatus());
assertEquals(Messages.getInstance().getString("RulesTest.ERROR_0005_RESULT_WHEN_NULL_EXPECTED"), null, // $NON-NLS-1$//$NON-NLS-2$
context.getOutputParameter("rule-result").getStringValue());
finishTest();
}
use of org.pentaho.platform.api.engine.IRuntimeContext in project pentaho-platform by pentaho.
the class RulesIT method testScriptRule.
public void testScriptRule() {
startTest();
SimpleParameterProvider parameterProvider = new SimpleParameterProvider();
// $NON-NLS-1$ //$NON-NLS-2$
parameterProvider.setParameter("customer", "Acme");
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
IRuntimeContext context = run("/test/rules/script_rule1.xaction", parameterProvider);
assertEquals(Messages.getInstance().getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_SUCCESS, // $NON-NLS-1$
context.getStatus());
assertNotNull(Messages.getInstance().getString("RulesTest.ERROR_0001_NULL_RESULT"), // $NON-NLS-1$ //$NON-NLS-2$
context.getOutputParameter("rule-result"));
assertEquals(Messages.getInstance().getString("RulesTest.ERROR_0002_WRONG_RESULT"), "Central", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
context.getOutputParameter("rule-result").getStringValue());
info(Messages.getInstance().getString("RulesTest.DEBUG_0003_SCRIPT_RULE_SUCCESS", // $NON-NLS-1$ //$NON-NLS-2$
context.getOutputParameter("rule-result").getStringValue()));
finishTest();
}
use of org.pentaho.platform.api.engine.IRuntimeContext in project pentaho-platform by pentaho.
the class RulesIT method testScriptRuleError3.
public void testScriptRuleError3() {
startTest();
// $NON-NLS-1$
info(Messages.getInstance().getString("RulesTest.USER_ERRORS_EXPECTED_SCRIPT_INVALID"));
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
IRuntimeContext context = run("/test/rules/script_rule_error3.xaction");
assertEquals(Messages.getInstance().getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_FAILURE, // $NON-NLS-1$
context.getStatus());
assertEquals(Messages.getInstance().getString("RulesTest.ERROR_0005_RESULT_WHEN_NULL_EXPECTED"), null, // $NON-NLS-1$//$NON-NLS-2$
context.getOutputParameter("rule-result").getStringValue());
finishTest();
}
use of org.pentaho.platform.api.engine.IRuntimeContext in project pentaho-platform by pentaho.
the class RulesIT method testQueryRule2.
public void testQueryRule2() {
startTest();
IPentahoResultSet resultSet = null;
try {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
IRuntimeContext context = run("/test/rules/query_rule2.xaction");
// $NON-NLS-1$
assertEquals(Messages.getInstance().getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_SUCCESS, context.getStatus());
// $NON-NLS-1$
Object result = context.getOutputParameter("rule-result").getValue();
// $NON-NLS-1$
assertNotNull(Messages.getInstance().getString("RulesTest.ERROR_0001_NULL_RESULT"), result);
// $NON-NLS-1$
assertTrue(Messages.getInstance().getString("RulesTest.ERROR_0007_LOOKUP_RULE_INVALID_RESULT"), (result instanceof IPentahoResultSet));
resultSet = (IPentahoResultSet) result;
IPentahoMetaData metaData = resultSet.getMetaData();
Object[][] columnHeaders = metaData.getColumnHeaders();
String regionHeader = columnHeaders[0][0].toString();
String departmentHeader = columnHeaders[0][1].toString();
// $NON-NLS-1$ //$NON-NLS-2$
assertEquals(Messages.getInstance().getString("RulesTest.ERROR_0009_LOOKUP_RULE_COLUMN_MISSING"), "REGION", regionHeader);
assertEquals(Messages.getInstance().getString("RulesTest.ERROR_0009_LOOKUP_RULE_COLUMN_MISSING"), "DEPARTMENT", // $NON-NLS-1$ //$NON-NLS-2$
departmentHeader);
Object[] row = resultSet.next();
while (row != null) {
String region = row[0].toString();
String department = row[1].toString();
// $NON-NLS-1$
assertNotNull(Messages.getInstance().getString("RulesTest.ERROR_0009_LOOKUP_RULE_COLUMN_MISSING"), region);
// $NON-NLS-1$
assertNotNull(Messages.getInstance().getString("RulesTest.ERROR_0009_LOOKUP_RULE_COLUMN_MISSING"), department);
// $NON-NLS-1$
info(region + ", " + department);
row = resultSet.next();
}
} finally {
if (resultSet != null) {
resultSet.closeConnection();
}
}
finishTest();
}
use of org.pentaho.platform.api.engine.IRuntimeContext in project pentaho-platform by pentaho.
the class RuntimeIT method testLooping.
/*
* public void testMultiComponentLoop() { startTest(); IRuntimeContext context = run("test", "platform",
* "MultiComponentTestLoop.xaction"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ assertEquals(
* Messages.getInstance().getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_SUCCESS,
* context.getStatus()); //$NON-NLS-1$ finishTest(); }
*/
public void testLooping() {
startTest();
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
IRuntimeContext context = run("/test/platform/LoopingTest.xaction");
assertEquals(Messages.getInstance().getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_SUCCESS, // $NON-NLS-1$
context.getStatus());
finishTest();
}
Aggregations