Search in sources :

Example 81 with IPentahoResultSet

use of org.pentaho.commons.connection.IPentahoResultSet in project pentaho-platform by pentaho.

the class PentahoFlashChartTest method getRelationBogusData.

public static IPentahoResultSet getRelationBogusData() {
    IPentahoResultSet ips = null;
    ArrayList<String> colHeaders = new ArrayList();
    colHeaders.add(0, "DEPARTMENT");
    colHeaders.add(1, "ACTUAL");
    colHeaders.add(2, "BUDGET");
    ArrayList r1 = new ArrayList();
    r1.add("Sales");
    r1.add("11");
    ArrayList r2 = new ArrayList();
    r2.add("Finance");
    r1.add("14");
    ArrayList r3 = new ArrayList();
    r3.add("Human Resource");
    r1.add("15");
    ArrayList data = new ArrayList();
    data.add(r1);
    data.add(r2);
    data.add(r3);
    ips = MemoryResultSet.createFromLists(colHeaders, data);
    System.out.println(ips.getRowCount());
    return ips;
}
Also used : IPentahoResultSet(org.pentaho.commons.connection.IPentahoResultSet) ArrayList(java.util.ArrayList)

Example 82 with IPentahoResultSet

use of org.pentaho.commons.connection.IPentahoResultSet in project pentaho-platform by pentaho.

the class PentahoFlashChartTest method testLineChart.

@Test
public void testLineChart() {
    String chart = "<chart>" + "<chart-type>LineChart</chart-type>" + "</chart>";
    IPentahoResultSet rs = getRelationData();
    Node chartNode = getChartNode(chart);
    String c2 = PentahoOFC4JChartHelper.generateChartJson(chartNode, rs, false, null);
    assertJsonEquals("{\"y_axis\":{\"min\":0,\"colour\":\"#000000\",\"grid-colour\":\"#aaaaaa\",\"stroke\":1,\"max\":110," + "\"steps\":10},\"x_legend\":{\"text\":\"DEPARTMENT\",\"style\":\"font-family: Arial; font-size: 14px; " + "font-weight: normal; font-style: normal;\"},\"elements\":[{\"colour\":\"#006666\",\"text\":\"ACTUAL\"," + "\"values\":[{\"value\":11},{\"value\":14},{\"value\":7}],\"font-size\":10,\"type\":\"line\"}," + "{\"colour\":\"#0066CC\",\"text\":\"BUDGET\",\"values\":[{\"value\":12},{\"value\":9},{\"value\":100}]," + "\"font-size\":10,\"type\":\"line\"}],\"x_axis\":{\"colour\":\"#000000\",\"grid-colour\":\"#aaaaaa\"," + "\"stroke\":1,\"labels\":{\"labels\":[\"Sales\",\"Finance\",\"Human Resource\"]}}}", c2, when(IGNORING_ARRAY_ORDER));
}
Also used : IPentahoResultSet(org.pentaho.commons.connection.IPentahoResultSet) Node(org.dom4j.Node) Test(org.junit.Test)

Example 83 with IPentahoResultSet

use of org.pentaho.commons.connection.IPentahoResultSet in project pentaho-platform by pentaho.

the class MultipleComponentIT method testDataUtility1.

public void testDataUtility1() {
    startTest();
    IPentahoResultSet rs1 = getResultSetFromArray();
    String xmlString1 = DataUtilities.getXMLString(rs1);
    // $NON-NLS-1$
    assertTrue(xmlString1.indexOf("VAL1") > 0);
    finishTest();
}
Also used : IPentahoResultSet(org.pentaho.commons.connection.IPentahoResultSet)

Example 84 with IPentahoResultSet

use of org.pentaho.commons.connection.IPentahoResultSet 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 85 with IPentahoResultSet

use of org.pentaho.commons.connection.IPentahoResultSet 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)

Aggregations

IPentahoResultSet (org.pentaho.commons.connection.IPentahoResultSet)113 Test (org.junit.Test)26 Node (org.dom4j.Node)18 ArrayList (java.util.ArrayList)17 IPentahoMetaData (org.pentaho.commons.connection.IPentahoMetaData)12 Iterator (java.util.Iterator)10 List (java.util.List)10 IPentahoConnection (org.pentaho.commons.connection.IPentahoConnection)10 IActionParameter (org.pentaho.platform.api.engine.IActionParameter)10 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)10 OutputStream (java.io.OutputStream)9 ResultSetCompareAction (org.pentaho.actionsequence.dom.actions.ResultSetCompareAction)8 IRuntimeContext (org.pentaho.platform.api.engine.IRuntimeContext)8 XQConnection (org.pentaho.platform.plugin.services.connections.xquery.XQConnection)8 SQLException (java.sql.SQLException)7 HashMap (java.util.HashMap)6 StandaloneSession (org.pentaho.platform.engine.core.system.StandaloneSession)6 Map (java.util.Map)5 Set (java.util.Set)5 IPreparedComponent (org.pentaho.platform.api.data.IPreparedComponent)5