use of mondrian.test.TestContext in project mondrian by pentaho.
the class VirtualCubeTest method testDefaultMeasureProperty.
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\" " + "name=\"[Measures].[Warehouse Sales]\"/>\n" + "<VirtualCubeMeasure cubeName=\"Sales\" " + "name=\"[Measures].[Unit Sales]\"/>\n" + "<VirtualCubeMeasure cubeName=\"Sales\" " + "name=\"[Measures].[Profit]\"/>\n" + "</VirtualCube>", null, null, null);
String queryWithoutFilter = "select" + " from [Sales vs Warehouse]";
String queryWithDeflaultMeasureFilter = "select " + "from [Sales vs Warehouse] where measures.[Unit Sales]";
assertQueriesReturnSimilarResults(queryWithoutFilter, queryWithDeflaultMeasureFilter, testContext);
}
use of mondrian.test.TestContext in project mondrian by pentaho.
the class VirtualCubeTest method testDefaultMeasureInVCForIncorrectMeasureName.
public void testDefaultMeasureInVCForIncorrectMeasureName() {
TestContext testContext = TestContext.instance().create(null, null, "<VirtualCube name=\"Sales vs Warehouse\" defaultMeasure=\"Profit Error\">\n" + "<VirtualCubeDimension name=\"Product\"/>\n" + "<VirtualCubeMeasure cubeName=\"Warehouse\" " + "name=\"[Measures].[Warehouse Sales]\"/>\n" + "<VirtualCubeMeasure cubeName=\"Sales\" " + "name=\"[Measures].[Unit Sales]\"/>\n" + "<VirtualCubeMeasure cubeName=\"Sales\" " + "name=\"[Measures].[Profit]\"/>\n" + "</VirtualCube>", null, null, null);
String query1 = "select from [Sales vs Warehouse]";
String query2 = "select from [Sales vs Warehouse] " + "where measures.[Warehouse Sales]";
assertQueriesReturnSimilarResults(query1, query2, testContext);
}
use of mondrian.test.TestContext in project mondrian by pentaho.
the class VirtualCubeTest method testFormatStringExpressionCubeNoCache.
/**
* Test an expression for the format_string of a calculated member that
* evaluates calculated members based on a virtual cube. One cube has cache
* turned on, the other cache turned off.
*
* <p>Since evaluation of the format_string used to happen after the
* aggregate cache was cleared, this used to fail, this should be solved
* with the caching of the format string.
*
* <p>Without caching of format string, the query returns green for all
* styles.
*/
public void testFormatStringExpressionCubeNoCache() {
TestContext testContext = TestContext.instance().create(null, null, "<Cube name=\"Warehouse No Cache\" cache=\"false\">\n" + " <Table name=\"inventory_fact_1997\"/>\n" + "\n" + " <DimensionUsage name=\"Time\" source=\"Time\" foreignKey=\"time_id\"/>\n" + " <DimensionUsage name=\"Store\" source=\"Store\" foreignKey=\"store_id\"/>\n" + " <Measure name=\"Units Shipped\" column=\"units_shipped\" aggregator=\"sum\" formatString=\"#.0\"/>\n" + "</Cube>\n" + "<VirtualCube name=\"Warehouse and Sales Format Expression Cube No Cache\">\n" + " <VirtualCubeDimension name=\"Store\"/>\n" + " <VirtualCubeDimension name=\"Time\"/>\n" + " <VirtualCubeMeasure cubeName=\"Sales\" name=\"[Measures].[Store Cost]\"/>\n" + " <VirtualCubeMeasure cubeName=\"Sales\" name=\"[Measures].[Store Sales]\"/>\n" + " <VirtualCubeMeasure cubeName=\"Warehouse No Cache\" name=\"[Measures].[Units Shipped]\"/>\n" + " <CalculatedMember name=\"Profit\" dimension=\"Measures\">\n" + " <Formula>[Measures].[Store Sales] - [Measures].[Store Cost]</Formula>\n" + " </CalculatedMember>\n" + " <CalculatedMember name=\"Profit Per Unit Shipped\" dimension=\"Measures\">\n" + " <Formula>[Measures].[Profit] / [Measures].[Units Shipped]</Formula>\n" + " <CalculatedMemberProperty name=\"FORMAT_STRING\" expression=\"IIf(([Measures].[Profit Per Unit Shipped] > 2.0), '|0.#|style=green', '|0.#|style=red')\"/>\n" + " </CalculatedMember>\n" + "</VirtualCube>", null, null, null);
testContext.assertQueryReturns("select {[Measures].[Profit Per Unit Shipped]} ON COLUMNS, " + "{[Store].[All Stores].[USA].[CA], [Store].[All Stores].[USA].[OR], [Store].[All Stores].[USA].[WA]} ON ROWS " + "from [Warehouse and Sales Format Expression Cube No Cache] " + "where [Time].[1997]", "Axis #0:\n" + "{[Time].[1997]}\n" + "Axis #1:\n" + "{[Measures].[Profit Per Unit Shipped]}\n" + "Axis #2:\n" + "{[Store].[USA].[CA]}\n" + "{[Store].[USA].[OR]}\n" + "{[Store].[USA].[WA]}\n" + "Row #0: |1.6|style=red\n" + "Row #1: |2.1|style=green\n" + "Row #2: |1.5|style=red\n");
}
use of mondrian.test.TestContext in project mondrian by pentaho.
the class VirtualCubeTest method testNonDefaultAllMember2.
public void testNonDefaultAllMember2() {
TestContext testContext = createContextWithNonDefaultAllMember();
testContext.assertQueryReturns("select { measures.[unit sales] } on 0 \n" + "from [warehouse (Default USA) and Sales]", "Axis #0:\n" + "{}\n" + "Axis #1:\n" + "{[Measures].[Unit Sales]}\n" + "Row #0: 266,773\n");
}
use of mondrian.test.TestContext in project mondrian by pentaho.
the class VirtualCubeTest method testOrdinalColumn.
/**
* 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" + "{}\n" + "Axis #1:\n" + "{[Measures].[Org Salary]}\n" + "Axis #2:\n" + "{[Store].[Canada], [Position].[Store Management].[Store Manager]}\n" + "{[Store].[Canada], [Position].[Store Management].[Store Assistant Manager]}\n" + "{[Store].[Canada], [Position].[Store Management].[Store Shift Supervisor]}\n" + "{[Store].[Mexico], [Position].[Store Management].[Store Manager]}\n" + "{[Store].[Mexico], [Position].[Store Management].[Store Assistant Manager]}\n" + "{[Store].[Mexico], [Position].[Store Management].[Store Shift Supervisor]}\n" + "{[Store].[USA], [Position].[Store Management].[Store Manager]}\n" + "{[Store].[USA], [Position].[Store Management].[Store Assistant Manager]}\n" + "{[Store].[USA], [Position].[Store Management].[Store Shift Supervisor]}\n" + "Row #0: $462.86\n" + "Row #1: $394.29\n" + "Row #2: $565.71\n" + "Row #3: $13,254.55\n" + "Row #4: $11,443.64\n" + "Row #5: $17,705.46\n" + "Row #6: $4,069.80\n" + "Row #7: $3,417.72\n" + "Row #8: $5,145.96\n");
}
Aggregations