use of mondrian.test.TestContext in project mondrian by pentaho.
the class SelectNotInGroupByTest method testGroupByNotSkippedIfIndependentProperty.
public void testGroupByNotSkippedIfIndependentProperty() {
SqlPattern[] sqlPatterns = { new SqlPattern(Dialect.DatabaseProduct.MYSQL, sqlWithAllGroupBy, sqlWithAllGroupBy) };
// Use dimension with unique level but level-indpendent property
TestContext tc = TestContext.instance().create(storeDimensionUniqueLevelIndependentProp, cubeA, null, null, null, null);
assertQuerySqlOrNot(tc, queryCubeA, sqlPatterns, false, false, true);
}
use of mondrian.test.TestContext in project mondrian by pentaho.
the class SelectNotInGroupByTest method testDependentPropertySkipped.
public void testDependentPropertySkipped() {
// Property group by should be skipped only if dialect supports it
String sqlpat;
if (dialectAllowsSelectNotInGroupBy()) {
sqlpat = sqlWithLevelGroupBy;
} else {
sqlpat = sqlWithAllGroupBy;
}
SqlPattern[] sqlPatterns = { new SqlPattern(Dialect.DatabaseProduct.MYSQL, sqlpat, sqlpat) };
// Use dimension with level-dependent property
TestContext tc = TestContext.instance().create(storeDimensionLevelDependent, cubeA, null, null, null, null);
assertQuerySqlOrNot(tc, queryCubeA, sqlPatterns, false, false, true);
}
use of mondrian.test.TestContext in project mondrian by pentaho.
the class SqlQueryTest method testLimitedRollupMemberRetrievableFromCache.
public void testLimitedRollupMemberRetrievableFromCache() throws Exception {
final String mdx = "select NON EMPTY { [Store].[Store].[Store State].members } on 0 from [Sales]";
final TestContext context = TestContext.instance().create(null, null, null, null, null, " <Role name='justCA'>\n" + " <SchemaGrant access='all'>\n" + " <CubeGrant cube='Sales' access='all'>\n" + " <HierarchyGrant hierarchy='[Store]' access='custom' rollupPolicy='partial'>\n" + " <MemberGrant member='[Store].[USA].[CA]' access='all'/>\n" + " </HierarchyGrant>\n" + " </CubeGrant>\n" + " </SchemaGrant>\n" + " </Role>\n").withRole("justCA");
String pgSql = "select \"store\".\"store_country\" as \"c0\"," + " \"store\".\"store_state\" as \"c1\"" + " from \"sales_fact_1997\" as \"sales_fact_1997\"," + " \"store\" as \"store\" " + "where (\"store\".\"store_country\" = 'USA') " + "and (\"store\".\"store_state\" = 'CA') " + "and \"sales_fact_1997\".\"store_id\" = \"store\".\"store_id\" " + "group by \"store\".\"store_country\", \"store\".\"store_state\" " + "order by \"store\".\"store_country\" ASC NULLS LAST," + " \"store\".\"store_state\" ASC NULLS LAST";
SqlPattern pgPattern = new SqlPattern(POSTGRESQL, pgSql, pgSql.length());
String mySql = "select `store`.`store_country` as `c0`," + " `store`.`store_state` as `c1`" + " from `store` as `store`, `sales_fact_1997` as `sales_fact_1997` " + "where `sales_fact_1997`.`store_id` = `store`.`store_id` " + "and `store`.`store_country` = 'USA' " + "and `store`.`store_state` = 'CA' " + "group by `store`.`store_country`, `store`.`store_state` " + "order by ISNULL(`store`.`store_country`) ASC," + " `store`.`store_country` ASC," + " ISNULL(`store`.`store_state`) ASC, `store`.`store_state` ASC";
SqlPattern myPattern = new SqlPattern(MYSQL, mySql, mySql.length());
SqlPattern[] patterns = { pgPattern, myPattern };
context.executeQuery(mdx);
assertQuerySqlOrNot(context, mdx, patterns, true, false, false);
}
use of mondrian.test.TestContext in project mondrian by pentaho.
the class XmlaDimensionPropertiesTest method executeTest.
private void executeTest() throws Exception {
TestContext context = getTestContext().withCube("HR");
String requestType = "EXECUTE";
Properties props = getDefaultRequestProperties(requestType);
doTest(requestType, props, context);
}
use of mondrian.test.TestContext in project mondrian by pentaho.
the class CurrentDateMemberUdfTest method testCurrentDateMemberUdf.
public void testCurrentDateMemberUdf() {
TestContext context = TestContext.instance().create(null, null, null, null, "<UserDefinedFunction name=\"MockCurrentDateMember\" " + "className=\"mondrian.udf.MockCurrentDateMember\" /> ", null);
context.assertQueryReturns("SELECT NON EMPTY {[Measures].[Org Salary]} ON COLUMNS, " + "NON EMPTY {MockCurrentDateMember([Time].[Time], \"[yyyy]\")} ON ROWS " + "FROM [HR] ", "Axis #0:\n" + "{}\n" + "Axis #1:\n" + "{[Measures].[Org Salary]}\n" + "Axis #2:\n" + "{[Time].[1997]}\n" + "Row #0: $39,431.67\n");
}
Aggregations