query.getAxis(Axis.ROWS).addDimension(productDimension);
query.getAxis(Axis.COLUMNS).addDimension(measuresDimension);
query.validate();
SelectNode mdx = query.getSelect();
String mdxString = mdx.toString();
TestContext.assertEqualsVerbose(
"SELECT\n"
+ "{[Measures].[Store Sales]} ON COLUMNS,\n"
+ "{[Product].[Drink].Children} ON ROWS\n"
+ "FROM [Sales]",
mdxString);
// TEST ANCESTORS SELECTION
productDimension.clearInclusions();
productDimension.include(
Selection.Operator.ANCESTORS, nameList("Product", "Drink"));
query.validate();
mdx = query.getSelect();
mdxString = mdx.toString();
TestContext.assertEqualsVerbose(
"SELECT\n"
+ "{[Measures].[Store Sales]} ON COLUMNS,\n"
+ "{Ascendants([Product].[Drink])} ON ROWS\n"
+ "FROM [Sales]",
mdxString);
// TEST DESCENDANTS SELECTION
productDimension.clearInclusions();
productDimension.include(
Selection.Operator.DESCENDANTS, nameList("Product", "Drink"));
query.validate();
mdx = query.getSelect();
mdxString = mdx.toString();
TestContext.assertEqualsVerbose(
"SELECT\n"
+ "{[Measures].[Store Sales]} ON COLUMNS,\n"
+ "{Descendants([Product].[Drink])} ON ROWS\n"
+ "FROM [Sales]",
mdxString);
// TEST INCLUDE_CHILDREN SELECTION
productDimension.clearInclusions();
productDimension.include(
Selection.Operator.INCLUDE_CHILDREN,
nameList("Product", "Drink"));
query.validate();
mdx = query.getSelect();
mdxString = mdx.toString();
TestContext.assertEqualsVerbose(
"SELECT\n"
+ "{[Measures].[Store Sales]} ON COLUMNS,\n"
+ "{{[Product].[Drink], [Product].[Drink].Children}} ON ROWS\n"
+ "FROM [Sales]",
mdxString);
// TEST SIBLINGS SELECTION
productDimension.clearInclusions();
productDimension.include(
Selection.Operator.SIBLINGS, nameList("Product", "Drink"));
query.validate();
mdx = query.getSelect();
mdxString = mdx.toString();
TestContext.assertEqualsVerbose(
"SELECT\n"
+ "{[Measures].[Store Sales]} ON COLUMNS,\n"
+ "{[Product].[Drink].Siblings} ON ROWS\n"
+ "FROM [Sales]",
mdxString);
// TEST LEVEL MEMBERS SELECTION
NamedList<Level> productLevels =
productDimension.getDimension().getDefaultHierarchy().getLevels();
Level productDepartments = productLevels.get("Product Department");
productDimension.include(productDepartments);
query.validate();
mdx = query.getSelect();
mdxString = mdx.toString();
TestContext.assertEqualsVerbose(
"SELECT\n"
+ "{[Measures].[Store Sales]} ON COLUMNS,\n"
+ "{[Product].[Drink].Siblings, [Product].[Product Department].Members} ON ROWS\n"
+ "FROM [Sales]", mdxString);