Search in sources :

Example 66 with IRuntimeContext

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();
}
Also used : IRuntimeContext(org.pentaho.platform.api.engine.IRuntimeContext)

Example 67 with IRuntimeContext

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();
}
Also used : IRuntimeContext(org.pentaho.platform.api.engine.IRuntimeContext) SimpleParameterProvider(org.pentaho.platform.engine.core.solution.SimpleParameterProvider)

Example 68 with IRuntimeContext

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();
}
Also used : IRuntimeContext(org.pentaho.platform.api.engine.IRuntimeContext)

Example 69 with IRuntimeContext

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();
}
Also used : IPentahoResultSet(org.pentaho.commons.connection.IPentahoResultSet) IPentahoMetaData(org.pentaho.commons.connection.IPentahoMetaData) IRuntimeContext(org.pentaho.platform.api.engine.IRuntimeContext)

Example 70 with IRuntimeContext

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