use of mondrian.olap.Result in project mondrian by pentaho.
the class Checkin_7641 method testImplicitMember.
public void testImplicitMember() throws Exception {
// explicit use of [Product].[Class1]
String mdx = " select NON EMPTY Crossjoin(" + " Hierarchize(Union({[Product].[Class1]}, " + "[Product].[Class1].Children)), " + " {[Measures].[Requested Value], " + " [Measures].[Shipped Value]}" + ") ON COLUMNS," + " NON EMPTY Hierarchize(Union({[Geography].[All Regions]}," + "[Geography].[All Regions].Children)) ON ROWS" + " from [ImplicitMember]";
Result result1 = getTestContext().executeQuery(mdx);
String resultString1 = TestContext.toString(result1);
Result result2 = getTestContext().executeQuery(mdx);
String resultString2 = TestContext.toString(result2);
assertEquals(resultString1, resultString2);
}
use of mondrian.olap.Result in project mondrian by pentaho.
the class MultipleColsInTupleAggTest method testTotal.
public void testTotal() throws Exception {
if (!isApplicable()) {
return;
}
MondrianProperties props = MondrianProperties.instance();
// get value without aggregates
propSaver.set(props.UseAggregates, false);
propSaver.set(props.ReadAggregates, false);
String mdx = "select {[Measures].[Total]} on columns from [Fact]";
Result result = getTestContext().executeQuery(mdx);
Object v = result.getCell(new int[] { 0 }).getValue();
String mdx2 = "select {[Measures].[Total]} on columns from [Fact] where " + "{[Product].[Cat One].[Prod Cat One].[One]}";
Result aresult = getTestContext().executeQuery(mdx2);
Object av = aresult.getCell(new int[] { 0 }).getValue();
// unless there is a way to flush the cache,
// I'm skeptical about these results
propSaver.set(props.UseAggregates, true);
propSaver.set(props.ReadAggregates, false);
Result result1 = getTestContext().executeQuery(mdx);
Object v1 = result1.getCell(new int[] { 0 }).getValue();
assertTrue(v.equals(v1));
Result aresult2 = getTestContext().executeQuery(mdx2);
Object av1 = aresult2.getCell(new int[] { 0 }).getValue();
assertTrue(av.equals(av1));
}
use of mondrian.olap.Result in project mondrian by pentaho.
the class TestContext method assertQueryReturns.
/**
* Executes a query and checks that the result is a given string, displaying a message if result does not match
* desiredResult.
*/
public void assertQueryReturns(String message, String query, String desiredResult) {
Result result = executeQuery(query);
String resultString = toString(result);
if (desiredResult != null) {
assertEqualsVerbose(desiredResult, upgradeActual(resultString), true, message);
}
}
use of mondrian.olap.Result in project mondrian by pentaho.
the class TestContext method databaseIsValid.
/**
* Tests whether the database is valid. Allows tests that depend on optional databases to figure out whether to
* proceed.
*
* @return whether a database is present and correct
*/
public boolean databaseIsValid() {
try {
Connection connection = getConnection();
String cubeName = getDefaultCubeName();
if (cubeName.indexOf(' ') >= 0) {
cubeName = Util.quoteMdxIdentifier(cubeName);
}
Query query = connection.parseQuery("select from " + cubeName);
Result result = connection.execute(query);
Util.discard(result);
connection.close();
return true;
} catch (RuntimeException e) {
Util.discard(e);
return false;
}
}
use of mondrian.olap.Result in project mondrian by pentaho.
the class TestContext method executeSingletonAxis.
/**
* Executes a set expression which is expected to return 0 or 1 members. It is an error if the expression returns
* tuples (as opposed to members), or if it returns two or more members.
*
* @param expression Expression string
* @return Null if axis returns the empty set, member if axis returns one member. Throws otherwise.
*/
public Member executeSingletonAxis(String expression) {
final String cubeName = getDefaultCubeName();
Result result = executeQuery("select {" + expression + "} on columns from " + cubeName);
Axis axis = result.getAxes()[0];
switch(axis.getPositions().size()) {
case 0:
// yielded just the null member, the array will be empty.
return null;
case 1:
// Java nulls should never happen during expression evaluation.
Position position = axis.getPositions().get(0);
Util.assertTrue(position.size() == 1);
Member member = position.get(0);
Util.assertTrue(member != null);
return member;
default:
throw Util.newInternal("expression " + expression + " yielded " + axis.getPositions().size() + " positions");
}
}
Aggregations