Search in sources :

Example 61 with IRuntimeContext

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

the class ResultsetIT method testResultSetTestWithDifferentDataTypes.

public void testResultSetTestWithDifferentDataTypes() {
    startTest();
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    IRuntimeContext context = run("/test/rules/ResultSetTestWithDifferentDataTypes.xaction");
    assertEquals(Messages.getInstance().getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_SUCCESS, // $NON-NLS-1$
    context.getStatus());
    finishTest();
}
Also used : IRuntimeContext(org.pentaho.platform.api.engine.IRuntimeContext)

Example 62 with IRuntimeContext

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

the class ResultsetIT method testResultSetWithoutColumnHeader.

public void testResultSetWithoutColumnHeader() {
    startTest();
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    IRuntimeContext context = run("/test/rules/ResultSetTest_without_columnheader.xaction");
    assertEquals(Messages.getInstance().getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_FAILURE, // $NON-NLS-1$
    context.getStatus());
    finishTest();
}
Also used : IRuntimeContext(org.pentaho.platform.api.engine.IRuntimeContext)

Example 63 with IRuntimeContext

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

the class RulesIT method testScriptRuleError2.

public void testScriptRuleError2() {
    startTest();
    // $NON-NLS-1$
    info(Messages.getInstance().getString("RulesTest.USER_ERRORS_EXPECTED_OUTPUT_NOT_DEFINED"));
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    IRuntimeContext context = run("/test/rules/script_rule_error2.xaction");
    assertEquals(Messages.getInstance().getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_CONTEXT_VALIDATE_FAIL, // $NON-NLS-1$
    context.getStatus());
    assertEquals(Messages.getInstance().getString("RulesTest.ERROR_0006_RESULT_WHEN_ERROR_EXPECTED"), false, // $NON-NLS-1$//$NON-NLS-2$
    context.getOutputNames().contains("rule-result"));
    finishTest();
}
Also used : IRuntimeContext(org.pentaho.platform.api.engine.IRuntimeContext)

Example 64 with IRuntimeContext

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

the class RulesIT method testQueryRule.

public void testQueryRule() {
    startTest();
    IPentahoResultSet resultSet = null;
    try {
        // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        IRuntimeContext context = run("/test/rules/query_rule1.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 columnHeader = columnHeaders[0][0].toString();
        // $NON-NLS-1$ //$NON-NLS-2$
        assertEquals(Messages.getInstance().getString("RulesTest.ERROR_0009_LOOKUP_RULE_COLUMN_MISSING"), "POSITIONTITLE", columnHeader);
        Object[] row = resultSet.next();
        // $NON-NLS-1$
        assertNotNull(Messages.getInstance().getString("RulesTest.ERROR_0007_LOOKUP_RULE_INVALID_RESULT"), row);
        // $NON-NLS-1$
        info(Messages.getInstance().getString("RulesTest.DEBUG_LOOKUP_RULE_SUCCESS", row[0].toString()));
    } finally {
        if (resultSet != null) {
            resultSet.closeConnection();
        }
    }
    finishTest();
}
Also used : IPentahoResultSet(org.pentaho.commons.connection.IPentahoResultSet) IPentahoMetaData(org.pentaho.commons.connection.IPentahoMetaData) IRuntimeContext(org.pentaho.platform.api.engine.IRuntimeContext)

Example 65 with IRuntimeContext

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

the class RulesIT method testScriptCompoundResult.

public void testScriptCompoundResult() {
    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_rule3.xaction");
    assertEquals(Messages.getInstance().getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_SUCCESS, // $NON-NLS-1$
    context.getStatus());
    // $NON-NLS-1$
    assertNotNull(context.getOutputParameter("fruit"));
    // $NON-NLS-1$
    assertNotNull(context.getOutputParameter("veg"));
    // $NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
    assertEquals("bad", "apples", context.getOutputParameter("fruit").getStringValue());
    // $NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
    assertEquals("bad", "carrots", context.getOutputParameter("veg").getStringValue());
    finishTest();
}
Also used : IRuntimeContext(org.pentaho.platform.api.engine.IRuntimeContext)

Aggregations

IRuntimeContext (org.pentaho.platform.api.engine.IRuntimeContext)100 ArrayList (java.util.ArrayList)28 HashMap (java.util.HashMap)28 ISolutionEngine (org.pentaho.platform.api.engine.ISolutionEngine)28 IActionParameter (org.pentaho.platform.api.engine.IActionParameter)24 SimpleParameterProvider (org.pentaho.platform.engine.core.solution.SimpleParameterProvider)21 SimpleUrlFactory (org.pentaho.platform.util.web.SimpleUrlFactory)20 SimpleOutputHandler (org.pentaho.platform.engine.core.output.SimpleOutputHandler)17 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)14 OutputStream (java.io.OutputStream)12 StandaloneSession (org.pentaho.platform.engine.core.system.StandaloneSession)12 List (java.util.List)10 IPentahoUrlFactory (org.pentaho.platform.api.engine.IPentahoUrlFactory)9 IOException (java.io.IOException)8 Map (java.util.Map)8 IPentahoResultSet (org.pentaho.commons.connection.IPentahoResultSet)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)7 IOutputHandler (org.pentaho.platform.api.engine.IOutputHandler)7 IParameterProvider (org.pentaho.platform.api.engine.IParameterProvider)6 Document (org.dom4j.Document)5