Package mondrian.test

Examples of mondrian.test.TestContext$SafeString


    public CurrentDateMemberUdfTest(String name) {
        super(name);
    }

    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"
View Full Code Here


            + "from [Sales]\n"
            + "where [Marital Status].[S]\n");
    }

    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);
    }
View Full Code Here

            + "    [Measures].[Count Distinct Store+Warehouse],"
            + "    [Measures].[Count All Store+Warehouse],"
            + "    [Measures].[Store Count]} on columns "
            + "from [Warehouse2]";

        TestContext testContext =
            TestContext.instance().create(
                null,
                cube,
                null,
                null,
                null,
                null);

        String desiredResult =
            "Axis #0:\n"
            + "{}\n"
            + "Axis #1:\n"
            + "{[Measures].[Count Distinct of Warehouses (Large Owned)]}\n"
            + "{[Measures].[Count Distinct of Warehouses (Large Independent)]}\n"
            + "{[Measures].[Count All of Warehouses (Large Independent)]}\n"
            + "{[Measures].[Count Distinct Store+Warehouse]}\n"
            + "{[Measures].[Count All Store+Warehouse]}\n"
            + "{[Measures].[Store Count]}\n"
            + "Axis #2:\n"
            + "{[Store Type].[Deluxe Supermarket]}\n"
            + "{[Store Type].[Gourmet Supermarket]}\n"
            + "{[Store Type].[HeadQuarters]}\n"
            + "{[Store Type].[Mid-Size Grocery]}\n"
            + "{[Store Type].[Small Grocery]}\n"
            + "{[Store Type].[Supermarket]}\n"
            + "Row #0: 1\n"
            + "Row #0: 0\n"
            + "Row #0: 0\n"
            + "Row #0: 6\n"
            + "Row #0: 6\n"
            + "Row #0: 6\n"
            + "Row #1: 1\n"
            + "Row #1: 0\n"
            + "Row #1: 0\n"
            + "Row #1: 2\n"
            + "Row #1: 2\n"
            + "Row #1: 2\n"
            + "Row #2: \n"
            + "Row #2: \n"
            + "Row #2: \n"
            + "Row #2: \n"
            + "Row #2: \n"
            + "Row #2: \n"
            + "Row #3: 0\n"
            + "Row #3: 1\n"
            + "Row #3: 1\n"
            + "Row #3: 4\n"
            + "Row #3: 4\n"
            + "Row #3: 4\n"
            + "Row #4: 0\n"
            + "Row #4: 1\n"
            + "Row #4: 1\n"
            + "Row #4: 4\n"
            + "Row #4: 4\n"
            + "Row #4: 4\n"
            + "Row #5: 0\n"
            + "Row #5: 1\n"
            + "Row #5: 3\n"
            + "Row #5: 8\n"
            + "Row #5: 8\n"
            + "Row #5: 8\n";

        testContext.assertQueryReturns(query, desiredResult);

        String loadCountDistinct_luciddb1 =
            "select "
            + "\"store\".\"store_type\" as \"c0\", "
            + "count(distinct "
View Full Code Here

    public void testCountDistinctAggWithOtherCountDistinctInContext() {
        // tests that Aggregate( <set>, <count-distinct measure>) aggregates
        // the correct measure when a *different* count-distinct measure is
        // in context (MONDRIAN-2128)
        TestContext testContext = TestContext.instance().create(
            null,
            "<Cube name=\"2CountDistincts\" defaultMeasure=\"Store Count\">\n"
            + "  <Table name=\"sales_fact_1997\"/>\n"
            + "    <DimensionUsage name=\"Time\" source=\"Time\" "
            + "foreignKey=\"time_id\"/>"
            + "  <DimensionUsage name=\"Store\" source=\"Store\" "
            + "foreignKey=\"store_id\"/>\n"
            + "    <DimensionUsage name=\"Product\" source=\"Product\" "
            + "  foreignKey=\"product_id\"/>"
            + "  <Measure name=\"Store Count\" column=\"store_id\" "
            + "aggregator=\"distinct-count\"/>\n"
            + "  <Measure name=\"Customer Count\" column=\"customer_id\" "
            + "aggregator=\"distinct-count\"/>\n"
            + "  <Measure name=\"Unit Sales\" column=\"unit_sales\" "
            + "aggregator=\"sum\"/>\n"
            + "</Cube>",
            null,
            null,
            null,
            null);
        // We should get the same answer whether the default [Store Count]
        // measure is in context or [Unit Sales].  The measure specified in the
        // second param of Aggregate() should be used.
        final String queryStoreCountInContext =
            "with member Store.agg as "
            + "'aggregate({[Store].[USA].[CA],[Store].[USA].[OR]}, "
            + "           measures.[Customer Count])'"
            + " select Store.agg on 0 from [2CountDistincts] ";
        final String queryUnitSalesInContext =
            "with member Store.agg as "
            + "'aggregate({[Store].[USA].[CA],[Store].[USA].[OR]}, "
            + "           measures.[Customer Count])'"
            + " select Store.agg on 0 from [2CountDistincts] where "
            + "measures.[Unit Sales] ";
        assertQueriesReturnSimilarResults(
            queryStoreCountInContext, queryUnitSalesInContext, testContext);

        final String queryCAORRollup =
            "with member measures.agg as "
            + "'aggregate({[Store].[USA].[CA],[Store].[USA].[OR]}, "
            + "           measures.[Customer Count])'"
            + " select {measures.agg, measures.[Customer Count]} on 0,  "
            + " [Product].[All Products].children on 1 "
            + "from [2CountDistincts] ";
        testContext.assertQueryReturns(
            queryCAORRollup,
            "Axis #0:\n"
            + "{}\n"
            + "Axis #1:\n"
            + "{[Measures].[agg]}\n"
            + "{[Measures].[Customer Count]}\n"
            + "Axis #2:\n"
            + "{[Product].[Drink]}\n"
            + "{[Product].[Food]}\n"
            + "{[Product].[Non-Consumable]}\n"
            + "Row #0: 2,243\n"
            + "Row #0: 3,485\n"
            + "Row #1: 3,711\n"
            + "Row #1: 5,525\n"
            + "Row #2: 2,957\n"
            + "Row #2: 4,468\n");

        // [Customer Count] should override context
        testContext.assertQueryReturns(
            "with member Store.agg as "
            + "'aggregate({[Store].[USA].[CA],[Store].[USA].[OR]}, "
            + "           measures.[Customer Count])'"
            + " select {measures.[Store Count], measures.[Customer Count]} on 0,  "
            + " [Store].agg on 1 "
            + "from [2CountDistincts] ",
            "Axis #0:\n"
            + "{}\n"
            + "Axis #1:\n"
            + "{[Measures].[Store Count]}\n"
            + "{[Measures].[Customer Count]}\n"
            + "Axis #2:\n"
            + "{[Store].[agg]}\n"
            + "Row #0: 3,753\n"
            + "Row #0: 3,753\n");
        // aggregate should pick up measure in context
        testContext.assertQueryReturns(
            "with member Store.agg as "
            + "'aggregate({[Store].[USA].[CA],[Store].[USA].[OR]})'"
            + " select {measures.[Store Count], measures.[Customer Count]} on 0,  "
            + " [Store].agg on 1 "
            + "from [2CountDistincts] ",
View Full Code Here

    private Query queryWithoutCellProps;

    protected void setUp() throws Exception {
        super.setUp();

        TestContext testContext = getTestContext();
        ConnectionBase connection =
            (ConnectionBase) testContext.getConnection();
        final Statement statement =
            connection.getInternalStatement();

        try {
            queryWithCellProps =
View Full Code Here

     * having to issue a select count() query.
     */
    public void testAggNameApproxRowCount() {
        propSaver.set(MondrianProperties.instance().UseAggregates, true);
        propSaver.set(MondrianProperties.instance().ReadAggregates, true);
        final TestContext context =
            TestContext.instance().withSchema(
                "<schema name=\"FooSchema\"><Cube name=\"Sales_Foo\" defaultMeasure=\"Unit Sales\">\n"
                + "  <Table name=\"sales_fact_1997\">\n"
                + " <AggName name=\"agg_pl_01_sales_fact_1997\" approxRowCount=\"86000\">\n"
                + "     <AggFactCount column=\"FACT_COUNT\"/>\n"
View Full Code Here

            + "</Hierarchy>\n"
            + "</Dimension>\n"
            + "<Measure name=\"Unit Sales\" column=\"unit_sales\" aggregator=\"sum\"\n"
            + "      formatString=\"Standard\"/>\n"
            + "</Cube>\n";
        final TestContext context =
            TestContext.instance().create(
                null, cube, null, null, null, null);
        final String mdx =
            "select {[Product].[Product Family].Members} on rows, {[Measures].[Unit Sales]} on columns from [Foo]";
        final String sqlOracle =
View Full Code Here

            + "<Measure name=\"Store Sales\" column=\"store_sales\" aggregator=\"sum\"\n"
            + "      formatString=\"Standard\"/>\n"
            + "<Measure name=\"Store Cost\" column=\"store_cost\" aggregator=\"sum\"\n"
            + "      formatString=\"Standard\"/>\n"
            + "</Cube></Schema>\n";
        final TestContext context = TestContext.instance().withSchema(cube);
        final String mdx =
            "select \n"
            + "{ "
            + "[Product].[Product Family].members } on rows, "
            + "{[Measures].[Unit Sales]} on columns from [Foo]";

        context.assertQueryReturns(
            mdx,
            "Axis #0:\n"
            +    "{}\n"
            +    "Axis #1:\n"
            +    "{[Measures].[Unit Sales]}\n"
View Full Code Here

            + "<Measure name=\"Store Sales\" column=\"store_sales\" aggregator=\"sum\"\n"
            + "      formatString=\"Standard\"/>\n"
            + "<Measure name=\"Store Cost\" column=\"store_cost\" aggregator=\"sum\"\n"
            + "      formatString=\"Standard\"/>\n"
            + "</Cube></Schema>\n";
        final TestContext context = TestContext.instance().withSchema(cube);
        final String mdx =
            "select \n"
            + "{ "
            + "[Promotions].[Media Type].members } on rows, {[Measures].[Unit Sales]} on columns from [Foo]";

        context.assertQueryReturns(
            mdx,
            "Axis #0:\n"
            + "{}\n"
            + "Axis #1:\n"
            + "{[Measures].[Unit Sales]}\n"
View Full Code Here

            + "    </Hierarchy>\n"
            + "  </Dimension>\n"
            + "<Measure name=\"Unit Sales\" column=\"unit_sales\" aggregator=\"sum\"\n"
            + "      formatString=\"Standard\"/>\n"
            + "</Cube>\n";
        final TestContext context =
            TestContext.instance().create(
                null, cube, null, null, null, null);
        final String mdx =
            "select {Crossjoin([Product].[Product Family].Members, [Store].[Store Id].Members)} on rows, {[Measures].[Unit Sales]} on columns from [Foo]";
        final String sqlOracle =
View Full Code Here

TOP

Related Classes of mondrian.test.TestContext$SafeString

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.