Search in sources :

Example 1 with QueryAxis

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

the class SqlConstraintUtilsTest method testExpandSupportedCalculatedMembers2.

// test with a placeholder member
public void testExpandSupportedCalculatedMembers2() {
    final TestContext testContext = TestContext.instance();
    final Connection connection = testContext.getConnection();
    final String queryText = "SELECT {[Measures].[Customer Count]} ON 0 " + "FROM [Sales] " + "WHERE [Time].[1997]";
    final Query query = connection.parseQuery(queryText);
    final QueryAxis querySlicerAxis = query.getSlicerAxis();
    final Member slicerMember = ((MemberExpr) querySlicerAxis.getSet()).getMember();
    final RolapHierarchy slicerHierarchy = ((RolapCube) query.getCube()).getTimeHierarchy(null);
    final Execution execution = new Execution(query.getStatement(), 0L);
    final RolapEvaluatorRoot rolapEvaluatorRoot = new RolapEvaluatorRoot(execution);
    final RolapEvaluator rolapEvaluator = new RolapEvaluator(rolapEvaluatorRoot);
    final Member expectedMember = slicerMember;
    setSlicerContext(rolapEvaluator, expectedMember);
    RolapResult.CompoundSlicerRolapMember placeHolderMember = Mockito.mock(RolapResult.CompoundSlicerRolapMember.class);
    Mockito.doReturn(slicerHierarchy).when(placeHolderMember).getHierarchy();
    Member endMember0 = makeNoncalculatedMember("0");
    // (0, placeholder)
    Member[] argMembers = new Member[] { endMember0, placeHolderMember };
    Member[] expectedMembers = new Member[] { endMember0, slicerMember };
    Member[] expectedMembersOnDisjoin = new Member[] { endMember0 };
    assertApartExpandSupportedCalculatedMembers("(0, placeholder)", expectedMembers, expectedMembersOnDisjoin, argMembers, rolapEvaluator);
}
Also used : Query(mondrian.olap.Query) SqlQuery(mondrian.rolap.sql.SqlQuery) TestContext(mondrian.test.TestContext) Connection(mondrian.olap.Connection) Execution(mondrian.server.Execution) MemberExpr(mondrian.mdx.MemberExpr) Member(mondrian.olap.Member) TestMember(mondrian.olap.fun.TestMember) QueryAxis(mondrian.olap.QueryAxis)

Example 2 with QueryAxis

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

the class SqlConstraintUtilsTest method testReplaceCompoundSlicerPlaceholder.

public void testReplaceCompoundSlicerPlaceholder() {
    final TestContext testContext = TestContext.instance();
    final Connection connection = testContext.getConnection();
    final String queryText = "SELECT {[Measures].[Customer Count]} ON 0 " + "FROM [Sales] " + "WHERE [Time].[1997]";
    final Query query = connection.parseQuery(queryText);
    final QueryAxis querySlicerAxis = query.getSlicerAxis();
    final Member slicerMember = ((MemberExpr) querySlicerAxis.getSet()).getMember();
    final RolapHierarchy slicerHierarchy = ((RolapCube) query.getCube()).getTimeHierarchy(null);
    final Execution execution = new Execution(query.getStatement(), 0L);
    final RolapEvaluatorRoot rolapEvaluatorRoot = new RolapEvaluatorRoot(execution);
    final RolapEvaluator rolapEvaluator = new RolapEvaluator(rolapEvaluatorRoot);
    final Member expectedMember = slicerMember;
    setSlicerContext(rolapEvaluator, expectedMember);
    RolapResult.CompoundSlicerRolapMember placeHolderMember = Mockito.mock(RolapResult.CompoundSlicerRolapMember.class);
    Mockito.doReturn(slicerHierarchy).when(placeHolderMember).getHierarchy();
    // tested call
    Member r = SqlConstraintUtils.replaceCompoundSlicerPlaceholder(placeHolderMember, rolapEvaluator);
    // test
    Assert.assertSame(expectedMember, r);
}
Also used : Query(mondrian.olap.Query) SqlQuery(mondrian.rolap.sql.SqlQuery) TestContext(mondrian.test.TestContext) Connection(mondrian.olap.Connection) Execution(mondrian.server.Execution) MemberExpr(mondrian.mdx.MemberExpr) Member(mondrian.olap.Member) TestMember(mondrian.olap.fun.TestMember) QueryAxis(mondrian.olap.QueryAxis)

Aggregations

MemberExpr (mondrian.mdx.MemberExpr)2 Connection (mondrian.olap.Connection)2 Member (mondrian.olap.Member)2 Query (mondrian.olap.Query)2 QueryAxis (mondrian.olap.QueryAxis)2 TestMember (mondrian.olap.fun.TestMember)2 SqlQuery (mondrian.rolap.sql.SqlQuery)2 Execution (mondrian.server.Execution)2 TestContext (mondrian.test.TestContext)2