Skip to content

Commit

Permalink
MONDRIAN: additional tests for AllMembers
Browse files Browse the repository at this point in the history
[git-p4: depot-paths = "//open/mondrian/": change = 4004]
  • Loading branch information
Sherman Wood committed Aug 22, 2005
1 parent c4a026a commit 69860b2
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 0 deletions.
65 changes: 65 additions & 0 deletions testsrc/main/mondrian/olap/fun/FunctionTest.java
Expand Up @@ -771,6 +771,11 @@ public void testBasic2() {
Assert.assertTrue(result.getAxes()[0].positions[0].members[0].getName().equals("M"));
}

public void testBasic2AllMembers() {
Result result = runQuery("select {[Gender].[F].NextMember} ON COLUMNS from Sales");
Assert.assertTrue(result.getAxes()[0].positions[0].members[0].getName().equals("M"));
}

public void testFirstInLevel2() {
Result result = runQuery("select {[Gender].[M].NextMember} ON COLUMNS from Sales");
Assert.assertTrue(result.getAxes()[0].positions.length == 0);
Expand Down Expand Up @@ -898,6 +903,66 @@ public void testAggregate2() {
"Row #2: -1,609.27" + nl +
"Row #2: 12,234.22" + nl);
}

public void testAggregate2AllMembers() {
runQueryCheckResult("WITH" + nl +
" MEMBER [Time].[1st Half Sales] AS 'Aggregate({Time.[1997].[Q1], Time.[1997].[Q2]})'" + nl +
" MEMBER [Time].[2nd Half Sales] AS 'Aggregate({Time.[1997].[Q3], Time.[1997].[Q4]})'" + nl +
" MEMBER [Time].[Difference] AS 'Time.[2nd Half Sales] - Time.[1st Half Sales]'" + nl +
"SELECT" + nl +
" { [Store].[Store State].AllMembers} ON COLUMNS," + nl +
" { Time.[1st Half Sales], Time.[2nd Half Sales], Time.[Difference]} ON ROWS" + nl +
"FROM Sales" + nl +
"WHERE [Measures].[Store Sales]",
"Axis #0:" + nl +
"{[Measures].[Store Sales]}" + nl +
"Axis #1:" + nl +
"{[Store].[All Stores].[Canada].[BC]}" + nl +
"{[Store].[All Stores].[Mexico].[DF]}" + nl +
"{[Store].[All Stores].[Mexico].[Guerrero]}" + nl +
"{[Store].[All Stores].[Mexico].[Jalisco]}" + nl +
"{[Store].[All Stores].[Mexico].[Veracruz]}" + nl +
"{[Store].[All Stores].[Mexico].[Yucatan]}" + nl +
"{[Store].[All Stores].[Mexico].[Zacatecas]}" + nl +
"{[Store].[All Stores].[USA].[CA]}" + nl +
"{[Store].[All Stores].[USA].[OR]}" + nl +
"{[Store].[All Stores].[USA].[WA]}" + nl +
"Axis #2:" + nl +
"{[Time].[1st Half Sales]}" + nl +
"{[Time].[2nd Half Sales]}" + nl +
"{[Time].[Difference]}" + nl +
"Row #0: (null)" + nl +
"Row #0: (null)" + nl +
"Row #0: (null)" + nl +
"Row #0: (null)" + nl +
"Row #0: (null)" + nl +
"Row #0: (null)" + nl +
"Row #0: (null)" + nl +
"Row #0: 74,571.95" + nl +
"Row #0: 71,943.17" + nl +
"Row #0: 125,779.50" + nl +
"Row #1: (null)" + nl +
"Row #1: (null)" + nl +
"Row #1: (null)" + nl +
"Row #1: (null)" + nl +
"Row #1: (null)" + nl +
"Row #1: (null)" + nl +
"Row #1: (null)" + nl +
"Row #1: 84,595.89" + nl +
"Row #1: 70,333.90" + nl +
"Row #1: 138,013.72" + nl +
"Row #2: (null)" + nl +
"Row #2: (null)" + nl +
"Row #2: (null)" + nl +
"Row #2: (null)" + nl +
"Row #2: (null)" + nl +
"Row #2: (null)" + nl +
"Row #2: (null)" + nl +
"Row #2: 10,023.94" + nl +
"Row #2: -1,609.27" + nl +
"Row #2: 12,234.22" + nl);
}


public void testAggregateToSimulateCompoundSlicer() {
runQueryCheckResult("WITH MEMBER [Time].[1997 H1] as 'Aggregate({[Time].[1997].[Q1], [Time].[1997].[Q2]})'"
Expand Down
18 changes: 18 additions & 0 deletions testsrc/main/mondrian/test/AccessControlTest.java
Expand Up @@ -78,6 +78,15 @@ public void testGrantHierarchy1a() {
"[Store].[All Stores].[USA]");
}

public void testGrantHierarchy1aAllMembers() {
// assert: can access Mexico (explicitly granted)
// assert: can not access Canada (explicitly denied)
// assert: can access USA (rule 3 - parent of allowed member San Francisco)
assertAxisReturns(getRestrictedConnection(), "[Store].level.allmembers",
"[Store].[All Stores].[Mexico]" + nl +
"[Store].[All Stores].[USA]");
}

public void testGrantHierarchy1b() {
// can access Mexico (explicitly granted) which is the first accessible one
assertAxisReturns(getRestrictedConnection(), "[Store].defaultMember",
Expand Down Expand Up @@ -167,6 +176,15 @@ public void testGrantHierarchy8() {
Assert.assertEquals(122, axis.positions.length); // 13 states, 109 cities
}

public void testGrantHierarchy8AllMembers() {
// assert: can not access Catherine Abel in San Francisco (below bottom level)
final Connection restrictedConnection = getRestrictedConnection();
assertAxisThrows(restrictedConnection, "[Customers].[USA].[CA].[San Francisco].[Catherine Abel]", "not found");
assertAxisReturns(restrictedConnection, "[Customers].[USA].[CA].[San Francisco].children", "");
Axis axis = executeAxis2(restrictedConnection, "[Customers].allmembers");
Assert.assertEquals(122, axis.positions.length); // 13 states, 109 cities
}

/** Test that we only aggregate over SF, LA, even when called from functions. */
public void testGrantHierarchy9() {
// Analysis services doesn't allow aggregation within calculated
Expand Down

0 comments on commit 69860b2

Please sign in to comment.