forked from agrohe21/olap4js
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test-xmla-qm-hierarchy.html
166 lines (163 loc) · 6.33 KB
/
test-xmla-qm-hierarchy.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "https://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>OLAP4JS: Query Model Test</title>
</head>
<body>
<h1>OLAP Xmla Query Model Testing</h1>
<script src="../olap.js"></script>
<script src="../../xmla4js/src/Xmla.js"></script>
<script src="../olap-xmla.js"></script>
<script src="/pentaho/js/yui/yui/yui-min.js"></script>
<script type="text/javascript">
YUI().use('test', function (Y) {
var suite = new Y.Test.Suite("Test of olap4js Xmla Driver");
var testCase5 = new Y.Test.Case({
name: "Basic query with metadata members and expressions",
setUp : function () {
var olapConn = new olapXmla.Connection({});
this.hiers = olapXmla.Hierarchy.getHierarchies(olapConn);
var cube = new olap.Cube({CUBE_NAME:'SteelWheelsSales'});
this.qry = new olapXmla.Query({name:"All Customers"}, cube, olapConn,'SteelWheels');
},
tearDown: function() {
delete this.qry;
},
"members of hierarchy is valid": function () {
this.qry.createAxis({name:'COLUMN',location:0});
var axis = this.qry.getAxes()[0];
var hier = this.hiers[0];
var expr = new olap.Expression({method:'Members', base:hier});
axis.addExpression(expr)
this.qry.execute(function(result){
Y.Assert.areEqual(true, result instanceof olap.CellSet);
});
},
"1st cell is value": function () {
this.qry.createAxis({name:'COLUMN',location:0});
var axis = this.qry.getAxes()[0];
var hier = this.hiers[0];
var expr = new olap.Expression({method:'Members', base:hier});
axis.addExpression(expr)
this.qry.execute(function(result){
var cell = result.getCell(0);
Y.Assert.areEqual(105331, cell.Value);
});
},
"2nd cell is value": function () {
this.qry.createAxis({name:'COLUMN',location:0});
var axis = this.qry.getAxes()[0];
var hier = this.hiers[0];
var expr = new olap.Expression({method:'AllMembers', base:hier});
axis.addExpression(expr)
this.qry.execute(function(result){
var cell = result.getCell(1);
Y.Assert.areEqual(1778, cell.Value);
});
},
"AllMembers of hierarchy is valid": function () {
this.qry.createAxis({name:'COLUMN',location:0});
var axis = this.qry.getAxes()[0];
var hier = this.hiers[0];
var expr = new olap.Expression({method:'AllMembers', base:hier});
axis.addExpression(expr)
this.qry.execute(function(result){
Y.Assert.areEqual(true, result instanceof olap.CellSet);
});
},
"AllMember of hierarchy is valid": function () {
this.qry.createAxis({name:'COLUMN',location:0});
var axis = this.qry.getAxes()[0];
var hier = this.hiers[0];
var expr = new olap.Expression({method:'AllMember', base:hier});
axis.addExpression(expr)
this.qry.execute(function(result){
Y.Assert.areEqual(true, result instanceof olap.CellSet);
});
},
"AllMember cell is value": function () {
this.qry.createAxis({name:'COLUMN',location:0});
var axis = this.qry.getAxes()[0];
var hier = this.hiers[0];
var expr = new olap.Expression({method:'AllMember', base:hier});
axis.addExpression(expr)
this.qry.execute(function(result){
var cell = result.getCell(0);
Y.Assert.areEqual(105331, cell.Value);
});
},
"DefaultMember of hierarchy is valid": function () {
this.qry.createAxis({name:'COLUMN',location:0});
var axis = this.qry.getAxes()[0];
var hier = this.hiers[0];
var expr = new olap.Expression({method:'DefaultMember', base:hier});
axis.addExpression(expr)
this.qry.execute(function(result){
Y.Assert.areEqual(true, result instanceof olap.CellSet);
});
},
"DefaultMember cell is value": function () {
this.qry.createAxis({name:'COLUMN',location:0});
var axis = this.qry.getAxes()[0];
var hier = this.hiers[0];
var expr = new olap.Expression({method:'DefaultMember', base:hier});
axis.addExpression(expr)
this.qry.execute(function(result){
var cell = result.getCell(0);
Y.Assert.areEqual(105331, cell.Value);
});
},
"Multiple expressions per axis": function () {
this.qry.createAxis({name:'COLUMN',location:0});
var axis = this.qry.getAxes()[0];
var hier = this.hiers[0];
var expr1 = new olap.Expression({method:'DefaultMember', base:hier}),
expr2 = new olap.Expression({method:'AllMember', base:hier});
axis.addExpression(expr1);
axis.addExpression(expr2);
this.qry.execute(function(result){
Y.Assert.areEqual(true, result instanceof olap.CellSet);
});
},
"Multiple Hierarchies per axis": function () {
this.qry.createAxis({name:'COLUMN',location:0});
var axis = this.qry.getAxes()[0];
var hier1 = this.hiers[0], hier2 = this.hiers[1];
var expr1 = new olap.Expression({method:'DefaultMember', base:hier1}),
expr2 = new olap.Expression({method:'AllMember', base:hier2});
axis.addExpression(expr1);
axis.addExpression(expr2);
this.qry.execute(function(result){
Y.Assert.areEqual(true, result instanceof olap.CellSet);
});
},
"Multiple Hierarchies and dimensions per axis": function () {
this.qry.createAxis({name:'COLUMN',location:0});
var axis = this.qry.getAxes()[0];
var hier1 = this.hiers[0],
hier2 = this.hiers[1],
hier3 = this.hiers[2],
hier4 = this.hiers[3];
var expr1 = new olap.Expression({method:'DefaultMember', base:hier1}),
expr2 = new olap.Expression({method:'AllMember', base:hier2}),
expr3 = new olap.Expression({method:'DefaultMember', base:hier3}),
expr4 = new olap.Expression({method:'AllMember', base:hier4});
axis.addExpression(expr1);
axis.addExpression(expr2);
axis.addExpression(expr3);
axis.addExpression(expr4);
this.qry.execute(function(result){
Y.Assert.areEqual(true, result instanceof olap.CellSet);
});
}
});
suite.add(testCase5);
//add the test cases and suites
Y.Test.Runner.add(suite);
//run all tests
Y.Test.Runner.run();
});
</script>
</body>
</html>