Search in sources :

Example 31 with TestContext

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);
}
Also used : SqlPattern(mondrian.test.SqlPattern) TestContext(mondrian.test.TestContext)

Example 32 with TestContext

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);
}
Also used : SqlPattern(mondrian.test.SqlPattern) TestContext(mondrian.test.TestContext)

Example 33 with TestContext

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);
}
Also used : TestContext(mondrian.test.TestContext) SqlPattern(mondrian.test.SqlPattern)

Example 34 with TestContext

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);
}
Also used : TestContext(mondrian.test.TestContext) Properties(java.util.Properties)

Example 35 with TestContext

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");
}
Also used : TestContext(mondrian.test.TestContext)

Aggregations

TestContext (mondrian.test.TestContext)167 SqlPattern (mondrian.test.SqlPattern)37 Result (mondrian.olap.Result)4 Member (mondrian.olap.Member)3 AggStar (mondrian.rolap.aggmatcher.AggStar)3 MemberExpr (mondrian.mdx.MemberExpr)2 Connection (mondrian.olap.Connection)2 Query (mondrian.olap.Query)2 QueryAxis (mondrian.olap.QueryAxis)2 TestMember (mondrian.olap.fun.TestMember)2 Execution (mondrian.server.Execution)2 Dialect (mondrian.spi.Dialect)2 SoftReference (java.lang.ref.SoftReference)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Properties (java.util.Properties)1 mondrian.olap (mondrian.olap)1 Axis (mondrian.olap.Axis)1 MondrianException (mondrian.olap.MondrianException)1 Position (mondrian.olap.Position)1