use of mondrian.calc.impl.AbstractTupleCursor in project mondrian by pentaho.
the class SqlConstraintUtilsTest method getCalculatedMember.
public TupleConstraintStruct getCalculatedMember(final List<List<Member>> table, int arity) {
Member memberMock = mock(Member.class);
Exp[] funCallArgExps = new Exp[0];
ResolvedFunCall funCallArgMock = new ResolvedFunCall(mock(FunDef.class), funCallArgExps, mock(TupleType.class));
Exp[] funCallExps = { funCallArgMock };
ResolvedFunCall funCallMock = new ResolvedFunCall(mock(FunDef.class), funCallExps, mock(TupleType.class));
when(memberMock.getExpression()).thenReturn(funCallMock);
Evaluator evaluatorMock = mock(Evaluator.class);
Evaluator.SetEvaluator setEvaluatorMock = mock(Evaluator.SetEvaluator.class);
TupleIterable tupleIterableMock = mock(TupleIterable.class);
when(tupleIterableMock.iterator()).thenReturn(table.iterator());
when(tupleIterableMock.getArity()).thenReturn(arity);
AbstractTupleCursor cursor = new AbstractTupleCursor(arity) {
Iterator<List<Member>> iterator = table.iterator();
List<Member> curList;
@Override
public boolean forward() {
boolean hasNext = iterator.hasNext();
if (hasNext) {
curList = iterator.next();
} else {
curList = null;
}
return hasNext;
}
@Override
public List<Member> current() {
return curList;
}
};
when(tupleIterableMock.tupleCursor()).thenReturn(cursor);
when(setEvaluatorMock.evaluateTupleIterable()).thenReturn(tupleIterableMock);
when(evaluatorMock.getSetEvaluator(eq(funCallArgMock), anyBoolean())).thenReturn(setEvaluatorMock);
TupleConstraintStruct constraint = new TupleConstraintStruct();
SqlConstraintUtils.expandSetFromCalculatedMember(evaluatorMock, memberMock, constraint);
return constraint;
}
Aggregations