Search in sources :

Example 1 with MondrianProperties

use of mondrian.olap.MondrianProperties in project mondrian by pentaho.

the class FunctionTest method testStrToMemberIgnoreInvalidMembers.

/**
 * Testcase for
 * <a href="http://jira.pentaho.com/browse/MONDRIAN-560">
 * bug MONDRIAN-560, "StrToMember function doesn't use IgnoreInvalidMembers option"</a>.
 */
public void testStrToMemberIgnoreInvalidMembers() {
    final MondrianProperties properties = MondrianProperties.instance();
    propSaver.set(properties.IgnoreInvalidMembersDuringQuery, true);
    // [Product].[Drugs] is invalid, becomes null member, and is dropped
    // from list
    assertQueryReturns("select \n" + "  {[Product].[Food],\n" + "    StrToMember(\"[Product].[Drugs]\")} on columns,\n" + "  {[Measures].[Unit Sales]} on rows\n" + "from [Sales]", "Axis #0:\n" + "{}\n" + "Axis #1:\n" + "{[Product].[Food]}\n" + "Axis #2:\n" + "{[Measures].[Unit Sales]}\n" + "Row #0: 191,940\n");
    // Hierarchy is inferred from leading edge
    assertExprReturns("StrToMember(\"[Marital Status].[Separated]\").Hierarchy.Name", "Marital Status");
    // Null member is returned
    assertExprReturns("StrToMember(\"[Marital Status].[Separated]\").Name", "#null");
    // Use longest valid prefix, so get [Time].[Weekly] rather than just
    // [Time].
    final String timeWeekly = TestContext.hierarchyName("Time", "Weekly");
    assertExprReturns("StrToMember(\"" + timeWeekly + ".[1996].[Q1]\").Hierarchy.UniqueName", timeWeekly);
    // If hierarchy is invalid, throw an error even though
    // IgnoreInvalidMembersDuringQuery is set.
    assertExprThrows("StrToMember(\"[Unknown Hierarchy].[Invalid].[Member]\").Name", "MDX object '[Unknown Hierarchy].[Invalid].[Member]' not found in cube 'Sales'");
    assertExprThrows("StrToMember(\"[Unknown Hierarchy].[Invalid]\").Name", "MDX object '[Unknown Hierarchy].[Invalid]' not found in cube 'Sales'");
    assertExprThrows("StrToMember(\"[Unknown Hierarchy]\").Name", "MDX object '[Unknown Hierarchy]' not found in cube 'Sales'");
    assertAxisThrows("StrToMember(\"\")", "MDX object '' not found in cube 'Sales'");
    propSaver.set(properties.IgnoreInvalidMembersDuringQuery, false);
    assertQueryThrows("select \n" + "  {[Product].[Food],\n" + "    StrToMember(\"[Product].[Drugs]\")} on columns,\n" + "  {[Measures].[Unit Sales]} on rows\n" + "from [Sales]", "Member '[Product].[Drugs]' not found");
    assertExprThrows("StrToMember(\"[Marital Status].[Separated]\").Hierarchy.Name", "Member '[Marital Status].[Separated]' not found");
}
Also used : MondrianProperties(mondrian.olap.MondrianProperties)

Example 2 with MondrianProperties

use of mondrian.olap.MondrianProperties in project mondrian by pentaho.

the class FunctionTest method testStrToSetIgnoreInvalidMembers.

public void testStrToSetIgnoreInvalidMembers() {
    final MondrianProperties properties = MondrianProperties.instance();
    propSaver.set(properties.IgnoreInvalidMembersDuringQuery, true);
    assertAxisReturns("StrToSet(" + "\"" + "{" + " [Product].[Food]," + " [Product].[Food].[You wouldn't like]," + " [Product].[Drink].[You would like]," + " [Product].[Drink].[Dairy]" + "}" + "\"," + " [Product])", "[Product].[Food]\n" + "[Product].[Drink].[Dairy]");
    assertAxisReturns("StrToSet(" + "\"" + "{" + " ([Gender].[M], [Product].[Food])," + " ([Gender].[F], [Product].[Food].[You wouldn't like])," + " ([Gender].[M], [Product].[Drink].[You would like])," + " ([Gender].[F], [Product].[Drink].[Dairy])" + "}" + "\"," + " [Gender], [Product])", "{[Gender].[M], [Product].[Food]}\n" + "{[Gender].[F], [Product].[Drink].[Dairy]}");
}
Also used : MondrianProperties(mondrian.olap.MondrianProperties)

Example 3 with MondrianProperties

use of mondrian.olap.MondrianProperties in project mondrian by pentaho.

the class FunctionTest method testStrToTupleIgnoreInvalidMembers.

public void testStrToTupleIgnoreInvalidMembers() {
    final MondrianProperties properties = MondrianProperties.instance();
    propSaver.set(properties.IgnoreInvalidMembersDuringQuery, true);
    // If any member is invalid, the whole tuple is null.
    assertAxisReturns("StrToTuple(\"([Gender].[M], [Marital Status].[Separated])\"," + " [Gender], [Marital Status])", "");
}
Also used : MondrianProperties(mondrian.olap.MondrianProperties)

Example 4 with MondrianProperties

use of mondrian.olap.MondrianProperties in project mondrian by pentaho.

the class AggTableTestCase method setUp.

protected void setUp() throws Exception {
    // Schema needs to be flushed before DBLoader is created is super.setUp,
    // otherwise AggTableManager can end up loading an old JdbcSchema
    getConnection().getCacheControl(null).flushSchemaCache();
    super.setUp();
    // store current property values
    MondrianProperties props = MondrianProperties.instance();
    // turn off caching
    propSaver.set(props.DisableCaching, true);
    propSaver.set(props.UseAggregates, true);
    propSaver.set(props.ReadAggregates, false);
    propSaver.set(props.ReadAggregates, true);
}
Also used : MondrianProperties(mondrian.olap.MondrianProperties)

Example 5 with MondrianProperties

use of mondrian.olap.MondrianProperties in project mondrian by pentaho.

the class BUG_1541077 method testStoreCount.

public void testStoreCount() throws Exception {
    if (!isApplicable()) {
        return;
    }
    MondrianProperties props = MondrianProperties.instance();
    // get value without aggregates
    propSaver.set(props.UseAggregates, false);
    String mdx = "select {[Measures].[Store Count]} on columns from Cheques";
    Result result = getTestContext().executeQuery(mdx);
    Object v = result.getCell(new int[] { 0 }).getValue();
    propSaver.set(props.UseAggregates, true);
    Result result1 = getTestContext().executeQuery(mdx);
    Object v1 = result1.getCell(new int[] { 0 }).getValue();
    assertTrue(v.equals(v1));
}
Also used : MondrianProperties(mondrian.olap.MondrianProperties) Result(mondrian.olap.Result)

Aggregations

MondrianProperties (mondrian.olap.MondrianProperties)16 Result (mondrian.olap.Result)5 Method (java.lang.reflect.Method)1 Pattern (java.util.regex.Pattern)1 TestCase (junit.framework.TestCase)1 TestSuite (junit.framework.TestSuite)1 UtilTestCase (mondrian.olap.UtilTestCase)1