use of mondrian.olap.Evaluator in project mondrian by pentaho.
the class SqlConstraintUtilsTest method testExpandSupportedCalculatedMember_calculated_memberExpr.
public void testExpandSupportedCalculatedMember_calculated_memberExpr() {
Evaluator evaluator = Mockito.mock(Evaluator.class);
Member resultMember = makeNoncalculatedMember("0");
Member member = makeMemberExprMember(resultMember);
// tested call
TupleConstraintStruct constraint = new TupleConstraintStruct();
SqlConstraintUtils.expandSupportedCalculatedMember(member, evaluator, constraint);
List<Member> r = constraint.getMembers();
// test
Assert.assertNotNull(r);
Assert.assertEquals(1, r.size());
Assert.assertSame(resultMember, r.get(0));
}
use of mondrian.olap.Evaluator in project mondrian by pentaho.
the class SqlConstraintUtilsTest method testExpandSupportedCalculatedMember_calculated_parentheses.
public void testExpandSupportedCalculatedMember_calculated_parentheses() {
Evaluator evaluator = Mockito.mock(Evaluator.class);
Member resultMember = Mockito.mock(Member.class);
Member member = this.makeParenthesesExprMember(evaluator, resultMember, "0");
// tested call
TupleConstraintStruct constraint = new TupleConstraintStruct();
SqlConstraintUtils.expandSupportedCalculatedMember(member, evaluator, constraint);
List<Member> r = constraint.getMembers();
// test
Assert.assertNotNull(r);
Assert.assertEquals(1, r.size());
Assert.assertSame(resultMember, r.get(0));
}
use of mondrian.olap.Evaluator 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;
}
use of mondrian.olap.Evaluator in project mondrian by pentaho.
the class SqlConstraintUtilsTest method testExpandSupportedCalculatedMember_calculated_unsupported.
public void testExpandSupportedCalculatedMember_calculated_unsupported() {
Evaluator evaluator = Mockito.mock(Evaluator.class);
Member member = makeUnsupportedCalculatedMember("0");
// tested call
TupleConstraintStruct constraint = new TupleConstraintStruct();
SqlConstraintUtils.expandSupportedCalculatedMember(member, evaluator, constraint);
List<Member> r = constraint.getMembers();
// test
Assert.assertNotNull(r);
Assert.assertEquals(1, r.size());
Assert.assertSame(member, r.get(0));
}
use of mondrian.olap.Evaluator in project mondrian by pentaho.
the class SqlConstraintUtilsTest method testExpandSupportedCalculatedMembers.
public void testExpandSupportedCalculatedMembers() {
Evaluator evaluator = Mockito.mock(Evaluator.class);
Member endMember0 = Mockito.mock(Member.class);
Member endMember1 = Mockito.mock(Member.class);
Member endMember2 = Mockito.mock(Member.class);
Member endMember3 = Mockito.mock(Member.class);
Member argMember0 = null;
Member argMember1 = null;
Member[] argMembers = null;
Member[] expectedMembers = null;
// ()
argMembers = new Member[] {};
expectedMembers = new Member[] {};
assertEveryExpandSupportedCalculatedMembers("()", expectedMembers, argMembers, evaluator);
// (0, 2)
argMember0 = endMember0;
argMember1 = endMember2;
argMembers = new Member[] { argMember0, argMember1 };
expectedMembers = new Member[] { endMember0, endMember2 };
assertEveryExpandSupportedCalculatedMembers("(0, 2)", expectedMembers, argMembers, evaluator);
// (Aggr(0, 1), 2)
argMember0 = makeAggregateExprMember(evaluator, Arrays.asList(new Member[] { endMember0, endMember1 }));
argMember1 = endMember2;
argMembers = new Member[] { argMember0, argMember1 };
expectedMembers = new Member[] { endMember0, endMember1, endMember2 };
assertEveryExpandSupportedCalculatedMembers("(Aggr(0, 1), 2)", expectedMembers, argMembers, evaluator);
// (Aggr(0, 1), Aggr(3, 2))
argMember0 = makeAggregateExprMember(evaluator, Arrays.asList(new Member[] { endMember0, endMember1 }));
argMember1 = makeAggregateExprMember(evaluator, Arrays.asList(new Member[] { endMember3, endMember2 }));
argMember1 = endMember2;
argMembers = new Member[] { argMember0, argMember1 };
expectedMembers = new Member[] { endMember0, endMember1, endMember2 };
assertEveryExpandSupportedCalculatedMembers("(Aggr(0, 1), Aggr(3, 2))", expectedMembers, argMembers, evaluator);
}
Aggregations