Search in sources :

Example 16 with TestContext

use of mondrian.test.TestContext in project mondrian by pentaho.

the class VirtualCubeTest method testBugMondrian322a.

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" + "Axis #1:\n" + "{[Measures].[foo]}\n" + "Row #0: \n");
}
Also used : TestContext(mondrian.test.TestContext)

Example 17 with TestContext

use of mondrian.test.TestContext in project mondrian by pentaho.

the class VirtualCubeTest method testVirtualCubeMeasureInvalidCubeName.

public void testVirtualCubeMeasureInvalidCubeName() {
    TestContext testContext = TestContext.instance().create(null, null, "<VirtualCube name=\"Sales vs Warehouse\">\n" + "<VirtualCubeDimension name=\"Product\"/>\n" + "<VirtualCubeMeasure cubeName=\"Warehouse\" " + "name=\"[Measures].[Warehouse Sales]\"/>\n" + "<VirtualCubeMeasure cubeName=\"Bad cube\" " + "name=\"[Measures].[Unit Sales]\"/>\n" + "</VirtualCube>", null, null, null);
    testContext.assertQueryThrows("select from [Sales vs Warehouse]", "Cube 'Bad cube' not found");
}
Also used : TestContext(mondrian.test.TestContext)

Example 18 with TestContext

use of mondrian.test.TestContext in project mondrian by pentaho.

the class VirtualCubeTest method testCalculatedMemberInSchema.

/**
 * 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]", "Axis #0:\n" + "{}\n" + "Axis #1:\n" + "{[Measures].[Unit Sales]}\n" + "{[Measures].[Shipped per Ordered]}\n" + "Axis #2:\n" + "{[Product].[Drink], [Time].[1997].[Q1]}\n" + "{[Product].[Drink], [Time].[1997].[Q2]}\n" + "{[Product].[Drink], [Time].[1997].[Q3]}\n" + "{[Product].[Drink], [Time].[1997].[Q4]}\n" + "{[Product].[Food], [Time].[1997].[Q1]}\n" + "{[Product].[Food], [Time].[1997].[Q2]}\n" + "{[Product].[Food], [Time].[1997].[Q3]}\n" + "{[Product].[Food], [Time].[1997].[Q4]}\n" + "{[Product].[Non-Consumable], [Time].[1997].[Q1]}\n" + "{[Product].[Non-Consumable], [Time].[1997].[Q2]}\n" + "{[Product].[Non-Consumable], [Time].[1997].[Q3]}\n" + "{[Product].[Non-Consumable], [Time].[1997].[Q4]}\n" + "Row #0: 5,976\n" + "Row #0: 77.6%\n" + "Row #1: 5,895\n" + "Row #1: 76.4%\n" + "Row #2: 6,065\n" + "Row #2: 103.2%\n" + "Row #3: 6,661\n" + "Row #3: 87.1%\n" + "Row #4: 47,809\n" + "Row #4: 77.7%\n" + "Row #5: 44,825\n" + "Row #5: 79.1%\n" + "Row #6: 47,440\n" + "Row #6: 87.6%\n" + "Row #7: 51,866\n" + "Row #7: 66.9%\n" + "Row #8: 12,506\n" + "Row #8: 73.3%\n" + "Row #9: 11,890\n" + "Row #9: 77.6%\n" + "Row #10: 12,343\n" + "Row #10: 80.9%\n" + "Row #11: 13,497\n" + "Row #11: 68.8%\n");
}
Also used : TestContext(mondrian.test.TestContext)

Example 19 with TestContext

use of mondrian.test.TestContext in project mondrian by pentaho.

the class VirtualCubeTest method testCrossjoinOptimizerWithVirtualCube.

public void testCrossjoinOptimizerWithVirtualCube() {
    final TestContext context = TestContext.instance().createSubstitutingCube("Warehouse and Sales", null, "<VirtualCubeMeasure cubeName=\"Sales\" name=\"[Measures].[Customer Count]\"/>", null, null);
    context.assertQueryReturns("WITH member measures.ratio as 'measures.[Store Cost]/measures.[warehouse cost]' " + " member [marital status].agg as 'aggregate({[marital status].M})' " + " select non empty [Warehouse].[USA] " + " * {[marital status].[marital status].members, [marital status].agg }  on 0 " + "FROM [warehouse and sales] where [measures].[Customer Count]", "Axis #0:\n" + "{[Measures].[Customer Count]}\n" + "Axis #1:\n");
}
Also used : TestContext(mondrian.test.TestContext)

Example 20 with TestContext

use of mondrian.test.TestContext in project mondrian by pentaho.

the class VirtualCubeTest method testWithTimeDimension.

public void testWithTimeDimension() {
    TestContext testContext = TestContext.instance().create(null, null, "<VirtualCube name=\"Sales vs Warehouse\">\n" + "<VirtualCubeDimension name=\"Time\"/>\n" + "<VirtualCubeDimension name=\"Product\"/>\n" + "<VirtualCubeMeasure cubeName=\"Warehouse\" name=\"[Measures].[Warehouse Sales]\"/>\n" + "<VirtualCubeMeasure cubeName=\"Sales\" name=\"[Measures].[Unit Sales]\"/>\n" + "</VirtualCube>", null, null, null);
    checkXxx(testContext);
}
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