Skip to content

Commit

Permalink
MONDRIAN: Remove CellSetFormatter implementation and tests; now it's …
Browse files Browse the repository at this point in the history
…in olap4j.

[git-p4: depot-paths = "//open/mondrian/": change = 12703]
  • Loading branch information
julianhyde committed May 12, 2009
1 parent 5420858 commit b4622bb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 407 deletions.
123 changes: 0 additions & 123 deletions testsrc/main/mondrian/olap/UtilTestCase.java
Expand Up @@ -15,7 +15,6 @@
import java.sql.Driver;

import mondrian.util.*;
import mondrian.test.TestContext;

/**
* Tests for methods in {@link mondrian.olap.Util}.
Expand Down Expand Up @@ -526,128 +525,6 @@ public void assertEqualsArray(int[] expected, int[] actual) {
assertEquals(expectedList, actualList);
}
}


public void testTextFormatter() {
/*
| 1997 |
| Q1 | Q2 |
| | 4 |
| Unit Sales | Store Sales | Unit Sales | Store Sales |
----+----+---------------+------------+-------------+------------+-------------+
USA | CA | Los Angeles | | | | |
| WA | Seattle | | | | |
| CA | San Francisco | | | | |
1997
Q1 Q2
4
Unit Sales Store Sales Unit Sales Store Sales
=== == ============= ========== =========== ========== ===========
USA CA Los Angeles 12 34.5 13 35.60
WA Seattle 12 34.5 13 35.60
CA San Francisco 12 34.5 13 35.60
*/
final String queryString =
"select\n"
+ " crossjoin(\n"
+ " {[Time].[1997].[Q1], [Time].[1997].[Q2].[4]},\n"
+ " {[Measures].[Unit Sales], [Measures].[Store Sales]}) on 0,\n"
+ " {[USA].[CA].[Los Angeles],\n"
+ " [USA].[WA].[Seattle],\n"
+ " [USA].[CA].[San Francisco]} on 1\n"
+ "FROM [Sales]";
assertFormat(
queryString,
TestContext.Format.TRADITIONAL,
"Axis #0:\n"
+ "{}\n"
+ "Axis #1:\n"
+ "{[Time].[1997].[Q1], [Measures].[Unit Sales]}\n"
+ "{[Time].[1997].[Q1], [Measures].[Store Sales]}\n"
+ "{[Time].[1997].[Q2].[4], [Measures].[Unit Sales]}\n"
+ "{[Time].[1997].[Q2].[4], [Measures].[Store Sales]}\n"
+ "Axis #2:\n"
+ "{[Store].[All Stores].[USA].[CA].[Los Angeles]}\n"
+ "{[Store].[All Stores].[USA].[WA].[Seattle]}\n"
+ "{[Store].[All Stores].[USA].[CA].[San Francisco]}\n"
+ "Row #0: 6,373\n"
+ "Row #0: 13,736.97\n"
+ "Row #0: 1,865\n"
+ "Row #0: 3,917.49\n"
+ "Row #1: 6,098\n"
+ "Row #1: 12,760.64\n"
+ "Row #1: 2,121\n"
+ "Row #1: 4,444.06\n"
+ "Row #2: 439\n"
+ "Row #2: 936.51\n"
+ "Row #2: 149\n"
+ "Row #2: 327.33\n");

// Same query, Rectangular format
assertFormat(
queryString,
TestContext.Format.COMPACT_RECTANGULAR,
" 1997 1997 1997 1997\n"
+ " Q1 Q1 Q2 Q2\n"
+ " 4 4\n"
+ " Unit Sales Store Sales Unit Sales Store Sales\n"
+ "=== == ============= ========== =========== ========== ===========\n"
+ "USA CA Los Angeles 6,373 13,736.97 1,865 3,917.49\n"
+ "USA WA Seattle 6,098 12,760.64 2,121 4,444.06\n"
+ "USA CA San Francisco 439 936.51 149 327.33\n");

// Similar query with an 'all' member on rows. Need an extra column.
assertFormat(
"select\n"
+ " crossjoin(\n"
+ " {[Time].[1997].[Q1], [Time].[1997].[Q2].[4]},\n"
+ " {[Measures].[Unit Sales], [Measures].[Store Sales]}) on 0,\n"
+ " {[Store],\n"
+ " [Store].[USA],\n"
+ " [Store].[USA].[CA],\n"
+ " [Store].[USA].[CA].[Los Angeles],\n"
+ " [Store].[USA].[WA]} on 1\n"
+ "FROM [Sales]",
TestContext.Format.COMPACT_RECTANGULAR,
" 1997 1997 1997 1997\n"
+ " Q1 Q1 Q2 Q2\n"
+ " 4 4\n"
+ " Unit Sales Store Sales Unit Sales Store Sales\n"
+ "========== === == =========== ========== =========== ========== ===========\n"
+ "All Stores 66,291 139,628.35 20,179 42,878.25\n"
+ "All Stores USA 66,291 139,628.35 20,179 42,878.25\n"
+ "All Stores USA CA 16,890 36,175.20 6,382 13,605.89\n"
+ "All Stores USA CA Los Angeles 6,373 13,736.97 1,865 3,917.49\n"
+ "All Stores USA WA 30,114 63,282.86 9,896 20,926.37\n");

// TODO: test with rows axis empty
// TODO: test with cols axis empty
// TODO: test with 0 axes
// TODO: test with 1 axes
// TODO: test with 3 axes
// TODO: formatter should right-justify cells
// TODO: implement & test non-compact rect formatter
// TODO: eliminate repeated captions (e.g. 'Q1 Q1' becomes 'Q1')
// but make sure that they are only eliminated if the parent
// is the same
}

private void assertFormat(
String queryString,
TestContext.Format format,
String expected)
{
Result result =
TestContext.instance().executeQuery(queryString);
String resultString =
TestContext.toString(result, format);
TestContext.assertEqualsVerbose(
expected,
resultString);
}
}

// End UtilTestCase.java

0 comments on commit b4622bb

Please sign in to comment.