Search in sources :

Example 16 with Result

use of mondrian.olap.Result in project mondrian by pentaho.

the class FunctionTest method testBasic5.

public void testBasic5() {
    Result result = executeQuery("select{ [Product].[All Products].[Drink].Parent} on columns " + "from Sales");
    assertEquals("All Products", result.getAxes()[0].getPositions().get(0).get(0).getName());
}
Also used : Result(mondrian.olap.Result)

Example 17 with Result

use of mondrian.olap.Result in project mondrian by pentaho.

the class FunctionTest method testFirstInLevel2.

public void testFirstInLevel2() {
    Result result = executeQuery("select {[Gender].[M].NextMember} ON COLUMNS from Sales");
    assertEquals(0, result.getAxes()[0].getPositions().size());
}
Also used : Result(mondrian.olap.Result)

Example 18 with Result

use of mondrian.olap.Result in project mondrian by pentaho.

the class FunctionTest method testVisualTotalsAll.

/**
 * Test case for bug
 * <a href="http://jira.pentaho.com/browse/MONDRIAN-615">MONDRIAN-615</a>,
 * "VisualTotals doesn't work for the all member".
 */
public void testVisualTotalsAll() {
    final String query = "SELECT \n" + "  {[Measures].[Unit Sales]} ON 0, \n" + "  VisualTotals(\n" + "    {[Customers].[All Customers],\n" + "     [Customers].[USA],\n" + "     [Customers].[USA].[CA],\n" + "     [Customers].[USA].[OR]}) ON 1\n" + "FROM [Sales]";
    assertQueryReturns(query, "Axis #0:\n" + "{}\n" + "Axis #1:\n" + "{[Measures].[Unit Sales]}\n" + "Axis #2:\n" + "{[Customers].[All Customers]}\n" + "{[Customers].[USA]}\n" + "{[Customers].[USA].[CA]}\n" + "{[Customers].[USA].[OR]}\n" + "Row #0: 142,407\n" + "Row #1: 142,407\n" + "Row #2: 74,748\n" + "Row #3: 67,659\n");
    // Check captions
    final Result result = getTestContext().executeQuery(query);
    final List<Position> positionList = result.getAxes()[1].getPositions();
    assertEquals("All Customers", positionList.get(0).get(0).getCaption());
    assertEquals("USA", positionList.get(1).get(0).getCaption());
    assertEquals("CA", positionList.get(2).get(0).getCaption());
}
Also used : Position(mondrian.olap.Position) Result(mondrian.olap.Result)

Example 19 with Result

use of mondrian.olap.Result in project mondrian by pentaho.

the class CrossJoinTest method testCrossJoinIterCalc_IterationCancellationOnForward.

// The test to verify that cancellation/timeout is checked
// in CrossJoinFunDef$CrossJoinIterCalc$1$1.forward()
public void testCrossJoinIterCalc_IterationCancellationOnForward() {
    propSaver.set(propSaver.properties.CheckCancelOrTimeoutInterval, 1);
    // Get product members as TupleList
    RolapCube salesCube = (RolapCube) cubeByName(getTestContext().getConnection(), SALES_CUBE);
    SchemaReader salesCubeSchemaReader = salesCube.getSchemaReader(getTestContext().getConnection().getRole()).withLocus();
    TupleList productMembers = productMembersPotScrubbersPotsAndPans(salesCubeSchemaReader);
    // Get genders members as TupleList
    Result genders = executeQuery(SELECT_GENDER_MEMBERS);
    TupleList genderMembers = getGenderMembers(genders);
    // Test execution to track cancellation/timeout calls
    Execution execution = spy(new Execution(genders.getQuery().getStatement(), 0));
    // check no execution of checkCancelOrTimeout has been yet
    verify(execution, times(0)).checkCancelOrTimeout();
    Integer crossJoinIterCalc = crossJoinIterCalcIterate(productMembers, genderMembers, execution);
    // checkCancelOrTimeout should be called once for the left tuple
    // from CrossJoinIterCalc$1$1.forward() since phase
    // interval is 1
    verify(execution, times(productMembers.size())).checkCancelOrTimeout();
    assertEquals(productMembers.size() * genderMembers.size(), crossJoinIterCalc.intValue());
}
Also used : UnaryTupleList(mondrian.calc.impl.UnaryTupleList) ArrayTupleList(mondrian.calc.impl.ArrayTupleList) TupleList(mondrian.calc.TupleList) SchemaReader(mondrian.olap.SchemaReader) Execution(mondrian.server.Execution) RolapCube(mondrian.rolap.RolapCube) Result(mondrian.olap.Result)

Example 20 with Result

use of mondrian.olap.Result in project mondrian by pentaho.

the class FunctionTest method testCurrentMemberFromSlicer.

public void testCurrentMemberFromSlicer() {
    Result result = executeQuery("with member [Measures].[Foo] as '[Gender].CurrentMember.Name'\n" + "select {[Measures].[Foo]} on columns\n" + "from Sales where ([Gender].[F])");
    Assert.assertEquals("F", result.getCell(new int[] { 0 }).getValue());
}
Also used : Result(mondrian.olap.Result)

Aggregations

Result (mondrian.olap.Result)113 Axis (mondrian.olap.Axis)24 Member (mondrian.olap.Member)10 Test (org.junit.Test)10 Cell (mondrian.olap.Cell)9 Connection (mondrian.olap.Connection)9 Query (mondrian.olap.Query)9 Position (mondrian.olap.Position)8 TestContext (mondrian.test.TestContext)7 ArrayList (java.util.ArrayList)5 MondrianProperties (mondrian.olap.MondrianProperties)5 OlapElement (mondrian.olap.OlapElement)5 RolapCell (mondrian.rolap.RolapCell)5 NonEmptyResult (mondrian.rolap.RolapConnection.NonEmptyResult)5 Execution (mondrian.server.Execution)5 Dialect (mondrian.spi.Dialect)5 OlapConnection (org.olap4j.OlapConnection)5 List (java.util.List)4 ResultBase (mondrian.olap.ResultBase)4 Evaluator (mondrian.olap.Evaluator)3