1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package net.smartlab.web;
24
25 import net.smartlab.web.page.Paginator;
26 import net.smartlab.web.test.BusinessObjectFactoryTestCase;
27
28 import org.hibernate.Query;
29 import org.hibernate.Session;
30
31
32
33
34
35
36 public class BusinessObjectFactoryPaginatorTest extends BusinessObjectFactoryTestCase {
37
38 private BusinessObjectFactory factory = null;
39
40
41 protected void setUp() throws Exception {
42 super.setUp();
43 factory = MockFactory.getInstance();
44 }
45
46
47
48
49
50 public void testSetPage() {
51 }
52
53
54
55
56
57 public void testSetSize() {
58 }
59
60
61
62
63
64 public void testSetArray() {
65 }
66
67
68
69
70
71 public void testPaginatorCriteria() throws Exception {
72
73
74
75
76 }
77
78
79
80
81
82
83 public void testPaginatorCriteriaResultTransformer() throws Exception {
84
85
86
87
88
89
90
91
92
93 }
94
95
96
97
98
99 public void testPaginatorQuery() throws Exception {
100
101 Session session = factory.current();
102 Query query = session.createQuery("select from Mock");
103 Paginator paginator = factory.new Paginator(query, 20, 5);
104 super.assertTrue(paginator.hasNext());
105
106 query = session.createQuery("select from Mock order by code");
107 paginator = factory.new Paginator(query, 20, 5);
108 super.assertTrue(paginator.hasNext());
109
110 query = session.createQuery("select from Mock where code LIKE :code");
111 query.setString("code", "code%");
112 paginator = factory.new Paginator(query, 20, 5);
113 super.assertTrue(paginator.hasNext());
114
115 query = session
116 .createQuery("select from Code where code like :code and id>:id order by code");
117 query.setString("code", "code%");
118 query.setInteger("id", 1);
119 paginator = factory.new Paginator(query, 20, 5);
120 super.assertTrue(paginator.hasNext());
121 }
122
123 public void testPaginatorSQLQuery() throws Exception {
124 Session session = factory.current();
125
126 Query query = session.createSQLQuery("select * from mock");
127 Paginator paginator = factory.new Paginator(query, 20, 5);
128 super.assertTrue(paginator.hasNext());
129
130 query = session.createSQLQuery("select * from mock order by code");
131 paginator = factory.new Paginator(query, 20, 5);
132 super.assertTrue(paginator.hasNext());
133
134 query = session.createSQLQuery("select * from mock where code like ?");
135 query.setString(0, "code%");
136 paginator = factory.new Paginator(query, 20, 5);
137 super.assertTrue(paginator.hasNext());
138
139 query = session
140 .createSQLQuery("select * from mock where code like :code and id > :id order by code");
141 query.setString("code", "code%");
142 query.setInteger("id", 1);
143 paginator = factory.new Paginator(query, 20, 5);
144 super.assertTrue(paginator.hasNext());
145 }
146
147
148
149
150
151
152 public void testPaginatorQueryIntInt() throws Exception {
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169 }
170
171
172
173
174
175
176 public void testPaginatorCriteriaIntInt() {
177 fail("Not yet implemented");
178 }
179
180
181
182
183
184 public void testAdd() {
185 fail("Not yet implemented");
186 }
187
188
189
190
191
192 public void testAddAll() {
193 fail("Not yet implemented");
194 }
195
196
197
198
199
200 public void testClear() {
201 fail("Not yet implemented");
202 }
203
204
205
206
207
208 public void testContains() {
209 fail("Not yet implemented");
210 }
211
212
213
214
215
216 public void testContainsAll() {
217 fail("Not yet implemented");
218 }
219
220
221
222
223
224 public void testIsEmpty() {
225 fail("Not yet implemented");
226 }
227
228
229
230
231
232 public void testIterator() {
233 fail("Not yet implemented");
234 }
235
236
237
238
239
240 public void testRemoveObject() {
241 }
242
243
244
245
246
247 public void testRemoveAll() {
248 fail("Not yet implemented");
249 }
250
251
252
253
254
255 public void testRetainAll() {
256 fail("Not yet implemented");
257 }
258
259
260
261
262 public void testSize() {
263 fail("Not yet implemented");
264 }
265
266
267
268
269
270 public void testToArray() {
271 fail("Not yet implemented");
272 }
273
274
275
276
277
278 public void testToArrayObjectArray() {
279 fail("Not yet implemented");
280 }
281
282
283
284
285 protected String getDataSetFile() {
286 return "res/dataset.xml";
287 }
288
289
290
291
292 public static class Mock extends BusinessObject {
293
294 private static final long serialVersionUID = 1L;
295
296 private long id;
297
298 private String code;
299
300 public void setId(long id) {
301 this.id = id;
302 }
303
304
305
306
307 public long getId() {
308 return id;
309 }
310
311 public void setCode(String code) {
312 this.code = code;
313 }
314
315
316
317
318 public String getCode() {
319 return code;
320 }
321 }
322
323 public static class MockFactory extends BusinessObjectFactory {
324
325 public Class getMappedClass() {
326 return Mock.class;
327 }
328
329 public static BusinessObjectFactory getInstance() {
330 return new MockFactory();
331 }
332 }
333 }