Search in sources :

Example 1 with SetEvaluator

use of mondrian.olap.Evaluator.SetEvaluator in project mondrian by pentaho.

the class SqlConstraintUtilsTest method makeAggregateExprMember.

private Member makeAggregateExprMember(Evaluator mockEvaluator, List<Member> endMembers) {
    Member member = Mockito.mock(Member.class);
    Mockito.doReturn(true).when(member).isCalculated();
    Member aggregatedMember0 = Mockito.mock(Member.class);
    Exp aggregateArg0 = new MemberExpr(aggregatedMember0);
    FunDef dummy = Mockito.mock(FunDef.class);
    Mockito.doReturn(Syntax.Function).when(dummy).getSyntax();
    Mockito.doReturn("dummy").when(dummy).getName();
    FunDef funDef = new AggregateFunDef(dummy);
    Exp[] args = new Exp[] { aggregateArg0 };
    Type returnType = new DecimalType(1, 1);
    Exp memberExp = new ResolvedFunCall(funDef, args, returnType);
    Mockito.doReturn(memberExp).when(member).getExpression();
    SetEvaluator setEvaluator = Mockito.mock(SetEvaluator.class);
    Mockito.doReturn(setEvaluator).when(mockEvaluator).getSetEvaluator(aggregateArg0, true);
    Mockito.doReturn(new UnaryTupleList(endMembers)).when(setEvaluator).evaluateTupleIterable();
    Assert.assertEquals(true, member.isCalculated());
    Assert.assertEquals(true, SqlConstraintUtils.isSupportedCalculatedMember(member));
    return member;
}
Also used : SetEvaluator(mondrian.olap.Evaluator.SetEvaluator) FunDef(mondrian.olap.FunDef) ParenthesesFunDef(mondrian.olap.fun.ParenthesesFunDef) AggregateFunDef(mondrian.olap.fun.AggregateFunDef) NullFunDef(mondrian.olap.fun.CrossJoinTest.NullFunDef) NullType(mondrian.olap.type.NullType) DecimalType(mondrian.olap.type.DecimalType) TupleType(mondrian.olap.type.TupleType) Type(mondrian.olap.type.Type) UnaryTupleList(mondrian.calc.impl.UnaryTupleList) MemberExpr(mondrian.mdx.MemberExpr) DecimalType(mondrian.olap.type.DecimalType) AggregateFunDef(mondrian.olap.fun.AggregateFunDef) ResolvedFunCall(mondrian.mdx.ResolvedFunCall) Exp(mondrian.olap.Exp) Member(mondrian.olap.Member) TestMember(mondrian.olap.fun.TestMember)

Aggregations

UnaryTupleList (mondrian.calc.impl.UnaryTupleList)1 MemberExpr (mondrian.mdx.MemberExpr)1 ResolvedFunCall (mondrian.mdx.ResolvedFunCall)1 SetEvaluator (mondrian.olap.Evaluator.SetEvaluator)1 Exp (mondrian.olap.Exp)1 FunDef (mondrian.olap.FunDef)1 Member (mondrian.olap.Member)1 AggregateFunDef (mondrian.olap.fun.AggregateFunDef)1 NullFunDef (mondrian.olap.fun.CrossJoinTest.NullFunDef)1 ParenthesesFunDef (mondrian.olap.fun.ParenthesesFunDef)1 TestMember (mondrian.olap.fun.TestMember)1 DecimalType (mondrian.olap.type.DecimalType)1 NullType (mondrian.olap.type.NullType)1 TupleType (mondrian.olap.type.TupleType)1 Type (mondrian.olap.type.Type)1