Package mondrian.test

Examples of mondrian.test.TestContext$SnoopingSchemaProcessor


    /**
     * Tests a calc member defined in the cube.
     */
    public void testCalculatedMemberInSchema() {
        TestContext testContext = TestContext.instance().createSubstitutingCube(
            "Warehouse and Sales",
            null,
            "  <CalculatedMember name=\"Shipped per Ordered\" dimension=\"Measures\">\n"
            + "    <Formula>[Measures].[Units Shipped] / [Measures].[Unit Sales]</Formula>\n"
            + "    <CalculatedMemberProperty name=\"FORMAT_STRING\" value=\"#.0%\"/>\n"
            + "  </CalculatedMember>\n");
        testContext.assertQueryReturns(
            "select\n"
            + " {[Measures].[Unit Sales], \n"
            + "  [Measures].[Shipped per Ordered]} on 0,\n"
            + " NON EMPTY Crossjoin([Product].Children, [Time].[1997].Children) on 1\n"
            + "from [Warehouse and Sales]",
View Full Code Here


    /**
     * Test a virtual cube where one of the dimensions contains an
     * ordinalColumn property
     */
    public void testOrdinalColumn() {
        TestContext testContext = TestContext.instance().create(
            null,
            null,
            "<VirtualCube name=\"Sales vs HR\">\n"
            + "<VirtualCubeDimension name=\"Store\"/>\n"
            + "<VirtualCubeDimension cubeName=\"HR\" name=\"Position\"/>\n"
            + "<VirtualCubeMeasure cubeName=\"HR\" name=\"[Measures].[Org Salary]\"/>\n"
            + "</VirtualCube>",
            null,
            null,
            null);
        testContext.assertQueryReturns(
            "select {[Measures].[Org Salary]} on columns, "
            + "non empty "
            + "crossjoin([Store].[Store Country].members, [Position].[Store Management].children) "
            + "on rows from [Sales vs HR]",
            "Axis #0:\n"
View Full Code Here

            + "Row #7: $3,417.72\n"
            + "Row #8: $5,145.96\n");
    }

    public void testDefaultMeasureProperty() {
        TestContext testContext = TestContext.instance().create(
            null,
            null,
            "<VirtualCube name=\"Sales vs Warehouse\" defaultMeasure=\"Unit Sales\">\n"
            + "<VirtualCubeDimension name=\"Product\"/>\n"
            + "<VirtualCubeMeasure cubeName=\"Warehouse\" "
View Full Code Here

     * Test case for bug <a href="http://jira.pentaho.com/browse/MONDRIAN-322">
     * MONDRIAN-322, "cube.getStar() throws NullPointerException"</a>.
     * Happens when you aggregate distinct-count measures in a virtual cube.
     */
    public void testBugMondrian322() {
        final TestContext testContext = TestContext.instance().create(
            null,
            null,
            "<VirtualCube name=\"Warehouse and Sales2\" defaultMeasure=\"Store Sales\">\n"
            + "  <VirtualCubeDimension cubeName=\"Sales\" name=\"Customers\"/>\n"
            + "  <VirtualCubeDimension name=\"Time\"/>\n"
            + "  <VirtualCubeDimension cubeName=\"Warehouse\" name=\"Warehouse\"/>\n"
            + "  <VirtualCubeMeasure cubeName=\"Sales\" name=\"[Measures].[Customer Count]\"/>\n"
            + "  <VirtualCubeMeasure cubeName=\"Sales\" name=\"[Measures].[Store Sales]\"/>\n"
            + "</VirtualCube>",
            null,
            null,
            null);

        /*
         * This test case does not actually reject the dimension constraint from
         * an unrelated base cube. The reason is that the constraint contains an
         * AllLevel member. Even though semantically constraining Cells using an
         * non-existent dimension perhaps does not make sense; however, in the
         * case where the constraint contains AllLevel member, the constraint
         * can be considered "always true".
         *
         * See the next test case for a constraint that does not contain
         * AllLevel member and hence cannot be satisfied. The cell should be
         * empty.
         */
        testContext.assertQueryReturns(
            "with member [Warehouse].[x] as 'Aggregate([Warehouse].members)'\n"
            + "member [Measures].[foo] AS '([Warehouse].[x],[Measures].[Customer Count])'\n"
            + "select {[Measures].[foo]} on 0 from [Warehouse And Sales2]",
            "Axis #0:\n"
            + "{}\n"
View Full Code Here

            + "{[Measures].[foo]}\n"
            + "Row #0: 5,581\n");
    }

    public void testBugMondrian322a() {
        final TestContext testContext = TestContext.instance().create(
            null,
            null,
            "<VirtualCube name=\"Warehouse and Sales2\" defaultMeasure=\"Store Sales\">\n"
            + "  <VirtualCubeDimension cubeName=\"Sales\" name=\"Customers\"/>\n"
            + "  <VirtualCubeDimension name=\"Time\"/>\n"
            + "  <VirtualCubeDimension cubeName=\"Warehouse\" name=\"Warehouse\"/>\n"
            + "  <VirtualCubeMeasure cubeName=\"Sales\" name=\"[Measures].[Customer Count]\"/>\n"
            + "  <VirtualCubeMeasure cubeName=\"Sales\" name=\"[Measures].[Store Sales]\"/>\n"
            + "</VirtualCube>",
            null,
            null,
            null);
        testContext.assertQueryReturns(
            "with member [Warehouse].[x] as 'Aggregate({[Warehouse].[Canada], [Warehouse].[USA]})'\n"
            + "member [Measures].[foo] AS '([Warehouse].[x],[Measures].[Customer Count])'\n"
            + "select {[Measures].[foo]} on 0 from [Warehouse And Sales2]",
            "Axis #0:\n"
            + "{}\n"
View Full Code Here

    /**
     * Test case for bug <a href="http://jira.pentaho.com/browse/MONDRIAN-352">
     * MONDRIAN-352, "Caption is not set on RolapVirtualCubeMesure"</a>.
     */
    public void testVirtualCubeMeasureCaption() {
        TestContext testContext = TestContext.instance().create(
            null,
            "<Cube name=\"TestStore\">\n"
            + "  <Table name=\"store\"/>\n"
            + "  <Dimension name=\"HCB\" caption=\"Has coffee bar caption\">\n"
            + "    <Hierarchy hasAll=\"true\">\n"
            + "      <Level name=\"Has coffee bar\" column=\"coffee_bar\" uniqueMembers=\"true\"\n"
            + "          type=\"Boolean\"/>\n"
            + "    </Hierarchy>\n"
            + "  </Dimension>\n"
            + "  <Measure name=\"Store Sqft\" caption=\"Store Sqft Caption\" column=\"store_sqft\" aggregator=\"sum\" formatString=\"#,###\"/>\n"
            + "</Cube>\n",

            "<VirtualCube name=\"VirtualTestStore\">\n"
            + "  <VirtualCubeDimension cubeName=\"TestStore\" name=\"HCB\"/>\n"
            + "  <VirtualCubeMeasure   cubeName=\"TestStore\" name=\"[Measures].[Store Sqft]\"/>\n"
            + "</VirtualCube>",
            null,
            null,
            null);

        Result result = testContext.executeQuery(
            "select {[Measures].[Store Sqft]} ON COLUMNS,"
            + "{[HCB]} ON ROWS "
            + "from [VirtualTestStore]");

        Axis[] axes = result.getAxes();
View Full Code Here

          + "</VirtualCubeDimension>"
          + "<VirtualCubeMeasure cubeName=\"Sales\" name=\"[Measures].[recurse]\" visible=\"true\">"
          + "</VirtualCubeMeasure>"
          + "</VirtualCube>"
          + "</Schema>";
      TestContext context = getTestContext().withSchema(schema);
      final String query = "SELECT {[Time].[1998].Children} on columns,"
          + " {[recurse]} on rows "
          + "FROM [Warehouse and Sales]";
      final String expected = "Axis #0:\n"
        + "{}\n"
        + "Axis #1:\n"
        + "{[Time].[1998].[Q1]}\n"
        + "{[Time].[1998].[Q2]}\n"
        + "{[Time].[1998].[Q3]}\n"
        + "{[Time].[1998].[Q4]}\n"
        + "Axis #2:\n"
        + "{[Measures].[recurse]}\n"
        + "Row #0: 72,024\n"
        + "Row #0: 72,024\n"
        + "Row #0: 72,024\n"
        + "Row #0: 72,024\n";
      context.assertQueryReturns(query, expected);
    }
View Full Code Here

    * MONDRIAN-897, "ClassCastException in
    * CrossJoinArgFactory.allArgsCheapToExpand when defining a NamedSet as
    * another NamedSet"</a>.
    */
    public void testBugMondrian897DoubleNamedSetDefinitions() {
        TestContext ctx = getTestContext();
        ctx.assertQueryReturns(
            "WITH SET [CustomerSet] as {[Customers].[Canada].[BC].[Burnaby].[Alexandra Wellington], [Customers].[USA].[WA].[Tacoma].[Eric Coleman]} "
            + "SET [InterestingCustomers] as [CustomerSet] "
            + "SET [TimeRange] as {[Time].[1998].[Q1], [Time].[1998].[Q2]} "
            + "SELECT {[Measures].[Store Sales]} ON COLUMNS, "
            + "CrossJoin([InterestingCustomers], [TimeRange]) ON ROWS "
View Full Code Here

            new SqlPattern(
                Dialect.DatabaseProduct.ORACLE,
                oracleWithFactJoin, oracleWithFactJoin)
        };

        final TestContext context =
            TestContext.instance().withSchema(schema);

        // The filter condition does not require a join to the fact table.
        assertQuerySql(context, query, patterns);
        assertQuerySql(context.withRole("Role1"), query, patterns);

        // in a non-empty context where a role is in effect, the query
        // will pessimistically join the fact table and apply the
        // constraint, since the filter condition could be influenced by
        // role limitations.
        assertQuerySql(
            context.withRole("Role1"), nonEmptyQuery, patternsWithFactJoin);
    }
View Full Code Here

            new SqlPattern(
                Dialect.DatabaseProduct.ORACLE,
                oracleWithFactJoin, oracleWithFactJoin)
        };

        final TestContext context =
            TestContext.instance().withSchema(schema);

        // The filter condition does not require a join to the fact table.
        assertQuerySql(context, query, patterns);
        assertQuerySql(context.withRole("Role1"), query, patterns);

        // in a non-empty context where a role is in effect, the query
        // will pessimistically join the fact table and apply the
        // constraint, since the filter condition could be influenced by
        // role limitations.
        assertQuerySql(
            context.withRole("Role1"), nonEmptyQuery, patternsWithFactJoin);
    }
View Full Code Here

TOP

Related Classes of mondrian.test.TestContext$SnoopingSchemaProcessor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.