use of mondrian.test.TestContext in project mondrian by pentaho.
the class HierarchyBugTest method verifyMemberLevelNamesIdentityOlap4jDateDim.
private void verifyMemberLevelNamesIdentityOlap4jDateDim() throws SQLException {
String mdx = "SELECT\n" + " [Measures].[Unit Sales] ON COLUMNS,\n" + " [Date].[Date].[Year].Members ON ROWS\n" + "FROM [Sales]";
TestContext context = getTestContext();
String dateDim = "<Dimension name=\"Date\" type=\"TimeDimension\" foreignKey=\"time_id\">\n" + " <Hierarchy hasAll=\"false\" primaryKey=\"time_id\">\n" + " <Table name=\"time_by_day\"/>\n" + " <Level name=\"Year\" column=\"the_year\" type=\"Numeric\" uniqueMembers=\"true\"\n" + " levelType=\"TimeYears\"/>\n" + " <Level name=\"Quarter\" column=\"quarter\" uniqueMembers=\"false\"\n" + " levelType=\"TimeQuarters\"/>\n" + " <Level name=\"Month\" column=\"month_of_year\" uniqueMembers=\"false\" type=\"Numeric\"\n" + " levelType=\"TimeMonths\"/>\n" + " </Hierarchy>\n" + " </Dimension>";
context = context.createSubstitutingCube("Sales", dateDim);
verifyLevelMemberNamesIdentityOlap4j(mdx, context, "[Date]");
}
use of mondrian.test.TestContext in project mondrian by pentaho.
the class ParserTest method checkUnparse.
private void checkUnparse(String queryString, final String expected) {
final TestContext testContext = TestContext.instance();
final Query query = testContext.getConnection().parseQuery(queryString);
String unparsedQueryString = Util.unparse(query);
TestContext.assertEqualsVerbose(expected, unparsedQueryString);
}
use of mondrian.test.TestContext in project mondrian by pentaho.
the class FunctionTest method testOrderMemberMemberValueExpNew1.
public void testOrderMemberMemberValueExpNew1() {
// sort by default measure
propSaver.set(MondrianProperties.instance().CompareSiblingsByOrderKey, true);
// Use a fresh connection to make sure bad member ordinals haven't
// been assigned by previous tests.
final TestContext context = getTestContext().withFreshConnection();
try {
context.assertQueryReturns("select \n" + " Order(" + " {[Customers].[All Customers].[USA].[CA].[Woodland Hills].[Abel Young]," + " [Customers].[All Customers].[USA].[CA].[Santa Monica].[Adeline Chun]}," + " [Customers].currentMember, BDESC) \n" + "on 0 from [Sales]", "Axis #0:\n" + "{}\n" + "Axis #1:\n" + "{[Customers].[USA].[CA].[Woodland Hills].[Abel Young]}\n" + "{[Customers].[USA].[CA].[Santa Monica].[Adeline Chun]}\n" + "Row #0: 75\n" + "Row #0: 33\n");
} finally {
context.close();
}
}
use of mondrian.test.TestContext in project mondrian by pentaho.
the class FunctionTest method testComplexSlicer_X_CalcBase_BaseBase.
public void testComplexSlicer_X_CalcBase_BaseBase() {
TestContext context = getTestContext().createSubstitutingCube("Sales", null, "<CalculatedMember " + "name='H1 1997' " + "formula='Aggregate([Time].[1997].[Q1]:[Time].[1997].[Q2])' " + "dimension='Time' />");
String query = "SELECT " + "{[Measures].[Customer Count]} ON 0 " + "FROM [Sales] " + "WHERE CROSSJOIN ({[Time].[H1 1997],[Time].[1998].[Q1]} , {[Education Level].[Partial College],[Education Level].[Partial High School]})";
String expectedResult = "Axis #0:\n" + "{[Time].[H1 1997], [Education Level].[Partial College]}\n" + "{[Time].[H1 1997], [Education Level].[Partial High School]}\n" + "{[Time].[1998].[Q1], [Education Level].[Partial College]}\n" + "{[Time].[1998].[Q1], [Education Level].[Partial High School]}\n" + "Axis #1:\n" + "{[Measures].[Customer Count]}\n" + "Row #0: 1,671\n";
context.assertQueryReturns(query, expectedResult);
}
use of mondrian.test.TestContext in project mondrian by pentaho.
the class FunctionTest method testMondrian_1187.
/**
* This is a test for
* <a href="http://jira.pentaho.com/browse/MONDRIAN-1187">MONDRIAN-1187</a>
* <p/>
* <p>The results should be equivalent</p>
*/
public void testMondrian_1187() {
final String queryWithoutAlias = "WITH\n" + "SET [Top Count] AS\n" + "{\n" + "TOPCOUNT(\n" + "DISTINCT([Customers].[Name].Members),\n" + "5,\n" + "[Measures].[Unit Sales]\n" + ")\n" + "}\n" + "SELECT\n" + "[Top Count] * [Measures].[Unit Sales] on 0\n" + "FROM [Sales]\n" + "WHERE [Time].[1997].[Q1].[1] : [Time].[1997].[Q3].[8]";
String queryWithAlias = "SELECT\n" + "TOPCOUNT( DISTINCT( [Customers].[Name].Members), 5, [Measures].[Unit Sales]) * [Measures].[Unit Sales] on 0\n" + "FROM [Sales]\n" + "WHERE [Time].[1997].[Q1].[1]:[Time].[1997].[Q3].[8]";
final TestContext context = TestContext.instance();
final Result result = context.executeQuery(queryWithoutAlias);
context.assertQueryReturns(queryWithAlias, context.toString(result));
}
Aggregations