Skip to content

Commit

Permalink
add unit test for found bug in the olap4jNodeConverter regarding comp…
Browse files Browse the repository at this point in the history
…lex selections that contain a selectioncontext

git-svn-id: https://olap4j.svn.sourceforge.net/svnroot/olap4j/trunk@358 c6a108a4-781c-0410-a6c6-c2d559e19af0
  • Loading branch information
pstoellberger committed Oct 14, 2010
1 parent 5732212 commit f8e0a0a
Showing 1 changed file with 93 additions and 0 deletions.
93 changes: 93 additions & 0 deletions testsrc/org/olap4j/OlapTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,99 @@ public void testSelectionContext() throws Exception {
s);
}

public void testComplexSelectionContext() throws Exception {
Cube cube = getFoodmartCube("Sales");
if (cube == null) {
fail("Could not find Sales cube");
}
Query query = new Query("my query", cube);

// create selections
QueryDimension productDimension = query.getDimension("Product");


productDimension.include(
Selection.Operator.MEMBER, "Product", "All Products");
productDimension.include(
Selection.Operator.CHILDREN, "Product", "All Products");
QueryDimension timeDimension = query.getDimension("Time");
Selection selection = timeDimension.include(
Selection.Operator.CHILDREN, "Time", "Year", "1997");
selection.addContext(
productDimension.createSelection(
"Product", "All Products"));

QueryDimension measuresDimension = query.getDimension("Measures");
measuresDimension.include("Measures", "Store Sales");

query.getAxis(Axis.ROWS).addDimension(productDimension);
query.getAxis(Axis.ROWS).addDimension(timeDimension);

query.getAxis(Axis.COLUMNS).addDimension(measuresDimension);

query.validate();

assertEquals(
Axis.ROWS,
productDimension.getAxis().getLocation());
assertEquals(
Axis.ROWS,
timeDimension.getAxis().getLocation());
assertEquals(
Axis.COLUMNS,
measuresDimension.getAxis().getLocation());

SelectNode mdx = query.getSelect();
String mdxString = mdx.toString();
TestContext.assertEqualsVerbose(
"SELECT\n"
+ "{[Measures].[Store Sales]} ON COLUMNS,\n"
+ "Hierarchize(Union(CrossJoin({[Product].[All Products]}, [Time].[1997].Children), CrossJoin([Product].[All Products].Children, [Time].[1997].Children))) ON ROWS\n"
+ "FROM [Sales]",
mdxString);

CellSet results = query.execute();
String s = TestContext.toString(results);
TestContext.assertEqualsVerbose(
"Axis #0:\n"
+ "{}\n"
+ "Axis #1:\n"
+ "{[Measures].[Store Sales]}\n"
+ "Axis #2:\n"
+ "{[Product].[All Products], [Time].[1997].[Q1]}\n"
+ "{[Product].[All Products], [Time].[1997].[Q2]}\n"
+ "{[Product].[All Products], [Time].[1997].[Q3]}\n"
+ "{[Product].[All Products], [Time].[1997].[Q4]}\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: 139,628.35\n"
+ "Row #1: 132,666.27\n"
+ "Row #2: 140,271.89\n"
+ "Row #3: 152,671.62\n"
+ "Row #4: 11,585.80\n"
+ "Row #5: 11,914.58\n"
+ "Row #6: 11,994.00\n"
+ "Row #7: 13,341.83\n"
+ "Row #8: 101,261.32\n"
+ "Row #9: 95,436.00\n"
+ "Row #10: 101,807.60\n"
+ "Row #11: 110,530.67\n"
+ "Row #12: 26,781.23\n"
+ "Row #13: 25,315.69\n"
+ "Row #14: 26,470.29\n"
+ "Row #15: 28,799.12\n",
s);
}
public void testSortAxis() {
try {
Cube cube = getFoodmartCube("Sales");
Expand Down

0 comments on commit f8e0a0a

Please sign in to comment.