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