Clover Coverage Report - SmartWeb
Coverage timestamp: Sun Jun 8 2008 21:20:12 CEST
53   302   25   2,12
0   114   0,47   25
25     1  
1    
 
  BusinessObjectFactoryPaginatorTest       Line # 36 53 25 2,6% 0.025641026
 
No Tests
 
1    /*
2    * The SmartWeb Framework
3    * Copyright (C) 2004-2006
4    *
5    * This library is free software; you can redistribute it and/or
6    * modify it under the terms of the GNU Lesser General Public
7    * License as published by the Free Software Foundation; either
8    * version 2.1 of the License, or (at your option) any later version.
9    *
10    * This library is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this library; if not, write to the Free Software
17    * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18    *
19    * For further informations on the SmartWeb Framework please visit
20    *
21    * http://smartweb.sourceforge.net
22    */
23    package net.smartlab.web;
24   
25    import net.smartlab.web.page.Paginator;
26    import net.smartlab.web.test.BusinessObjectFactoryTestCase;
27    import org.hibernate.Query;
28    import org.hibernate.Session;
29   
30    /**
31    * TODO documentation
32    *
33    * @author gperrone
34    *
35    */
 
36    public class BusinessObjectFactoryPaginatorTest extends BusinessObjectFactoryTestCase {
37   
38    BusinessObjectFactory factory = null;
39   
40   
 
41  22 toggle protected void setUp() throws Exception {
42  22 super.setUp();
43    // factory = GroupFactory.getInstance();
44    }
45   
 
46  0 toggle protected void tearDown() throws Exception {
47  0 super.tearDown();
48    }
49   
50    /*
51    * Test method for
52    * 'net.smartlab.web.BusinessObjectFactory.Paginator.setPage(int)'
53    */
 
54  0 toggle public void testSetPage() {
55    }
56   
57    /*
58    * Test method for
59    * 'net.smartlab.web.BusinessObjectFactory.Paginator.setSize(int)'
60    */
 
61  0 toggle public void testSetSize() {
62    }
63   
64    /*
65    * Test method for
66    * 'net.smartlab.web.BusinessObjectFactory.Paginator.setArray()'
67    */
 
68  0 toggle public void testSetArray() {
69    }
70   
71    /*
72    * Test method for
73    * 'net.smartlab.web.BusinessObjectFactory.Paginator.Paginator(Criteria)'
74    */
 
75  0 toggle public void testPaginatorCriteria() throws Exception {
76    // Criteria criteria = factory.current().createCriteria(Group.class);
77    // criteria.add(Expression.like("display", "test", MatchMode.START));
78    // Paginator paginator = factory.new Paginator(criteria, 20, 5);
79    // super.assertTrue(paginator.hasNext());
80    }
81   
82    /*
83    * Test method for
84    * 'net.smartlab.web.BusinessObjectFactory.Paginator.Paginator(Criteria)'
85    * when a ResultTrasformer was specified for the criteria.
86    */
 
87  0 toggle public void testPaginatorCriteriaResultTransformer() throws Exception {
88    /*
89    * Session session=factory.current(); Criteria criteria =
90    * session.createCriteria(Group.class); Paginator paginator =
91    * GroupFactory.getInstance().new Paginator(criteria, 20, 5); int
92    * paginatorCount = paginator.getCount(); Set set = new HashSet(); while
93    * (paginator.hasNext()) { Group g = (Group)paginator.next();
94    * g.getSize()); set.add(new Long(g.getId())); }
95    * super.assertEquals(paginatorCount, set.size());
96    */
97    }
98   
99    /*
100    * Test method for
101    * 'net.smartlab.web.BusinessObjectFactory.Paginator.Paginator(Query)'
102    */
 
103  0 toggle public void testPaginatorQuery() throws Exception {
104    // NO FILTER TEST
105  0 Session session = factory.current();
106  0 Query query = session.createQuery("select u from User u");
107  0 Paginator paginator = factory.new Paginator(query, 20, 5);
108  0 super.assertTrue(paginator.hasNext());
109    // ORDER BY TEST
110  0 query = session.createQuery("select u from User u order by u.display");
111  0 paginator = factory.new Paginator(query, 20, 5);
112  0 super.assertTrue(paginator.hasNext());
113    // varchar filter test
114  0 query = session.createQuery("select u from User u where u.username = :username");
115  0 query.setString("username", "test");
116  0 paginator = factory.new Paginator(query, 20, 5);
117  0 super.assertTrue(paginator.hasNext());
118    // int filter test
119  0 query = session.createQuery("select u from User u where id=:id");
120  0 query.setInteger("id", 1);
121  0 paginator = factory.new Paginator(query, 20, 5);
122  0 super.assertTrue(paginator.hasNext());
123    // object filter test
124  0 query = session.createQuery("select u from User u join u.groups g where g.id=:group");
125  0 query.setInteger("group", 238);
126  0 paginator = factory.new Paginator(query, 20, 5);
127  0 super.assertTrue(paginator.hasNext());
128    // multiple filter test
129  0 query = session
130    .createQuery("select u from User u join u.groups g where u.display like :partial and u.id=:id and g.id=:group");
131  0 query.setString("partial", "Amministrator%");
132  0 query.setInteger("id", 1);
133  0 query.setInteger("group", 238);
134  0 paginator = factory.new Paginator(query, 20, 5);
135  0 super.assertTrue(paginator.hasNext());
136    }
137   
 
138  0 toggle public void testPaginatorSQLQuery() throws Exception {
139  0 Session session = factory.current();
140    // NO FILTER TEST
141  0 Query query = session.createSQLQuery("select * from auth.user");
142  0 Paginator paginator = factory.new Paginator(query, 20, 5);
143  0 super.assertTrue(paginator.hasNext());
144    // ORDER BY TEST
145  0 query = session.createSQLQuery("select * from auth.user u order by u.display");
146  0 paginator = factory.new Paginator(query, 20, 5);
147  0 super.assertTrue(paginator.hasNext());
148    // varchar filter test
149  0 query = session.createSQLQuery("select * from auth.user where display = ?");
150  0 query.setString(0, "test");
151  0 paginator = factory.new Paginator(query, 20, 5);
152  0 super.assertTrue(paginator.hasNext());
153    // int filter test
154  0 query = session.createSQLQuery("select * from auth.user u where u.id=:id");
155  0 query.setInteger("id", 1);
156  0 paginator = factory.new Paginator(query, 20, 5);
157  0 super.assertTrue(paginator.hasNext());
158    // object filter test
159  0 query = session
160    .createSQLQuery("SELECT * from auth.user u left join auth.group_user ug on ug.user=u.id where ug.group=:group");
161  0 query.setInteger("group", 238);
162  0 paginator = factory.new Paginator(query, 20, 5);
163  0 super.assertTrue(paginator.hasNext());
164    // multiple filter test
165  0 query = session
166    .createSQLQuery("SELECT * from auth.user u left join auth.group_user ug on ug.user=u.id where u.display like :partial and u.id=:id and ug.group=:group");
167  0 query.setString("partial", "Amministrator%");
168  0 query.setInteger("id", 1);
169  0 query.setInteger("group", 238);
170  0 paginator = factory.new Paginator(query, 20, 5);
171  0 super.assertTrue(paginator.hasNext());
172    }
173   
174    /*
175    * Test method for
176    * 'net.smartlab.web.BusinessObjectFactory.Paginator.Paginator(Query, int,
177    * int)'
178    */
 
179  0 toggle public void testPaginatorQueryIntInt() throws Exception {
180    //
181    // Group group = (Group)factory.findByKey("5");
182    // for (int i = 0; i < 10000; i++) {
183    // Group g = new Group();
184    // g.setDisplay("test" + "-" + i);
185    // Iterator roles = group.getRoles().iterator();
186    // while (roles.hasNext()) {
187    // g.add((Role)roles.next());
188    // }
189    // Iterator users = group.getUsers().iterator();
190    // while (users.hasNext()) {
191    // g.add((User)users.next());
192    // }
193    // factory.update(g);
194    // }
195    //
196    }
197   
198    /*
199    * Test method for
200    * 'net.smartlab.web.BusinessObjectFactory.Paginator.Paginator(Criteria,
201    * int, int)'
202    */
 
203  0 toggle public void testPaginatorCriteriaIntInt() {
204    }
205   
206    /*
207    * Test method for
208    * 'net.smartlab.web.BusinessObjectFactory.Paginator.add(Object)'
209    */
 
210  0 toggle public void testAdd() {
211    }
212   
213    /*
214    * Test method for
215    * 'net.smartlab.web.BusinessObjectFactory.Paginator.addAll(Collection)'
216    */
 
217  0 toggle public void testAddAll() {
218    }
219   
220    /*
221    * Test method for
222    * 'net.smartlab.web.BusinessObjectFactory.Paginator.clear()'
223    */
 
224  0 toggle public void testClear() {
225    }
226   
227    /*
228    * Test method for
229    * 'net.smartlab.web.BusinessObjectFactory.Paginator.contains(Object)'
230    */
 
231  0 toggle public void testContains() {
232    }
233   
234    /*
235    * Test method for
236    * 'net.smartlab.web.BusinessObjectFactory.Paginator.containsAll(Collection)'
237    */
 
238  0 toggle public void testContainsAll() {
239    }
240   
241    /*
242    * Test method for
243    * 'net.smartlab.web.BusinessObjectFactory.Paginator.isEmpty()'
244    */
 
245  0 toggle public void testIsEmpty() {
246    }
247   
248    /*
249    * Test method for
250    * 'net.smartlab.web.BusinessObjectFactory.Paginator.iterator()'
251    */
 
252  0 toggle public void testIterator() {
253    }
254   
255    /*
256    * Test method for
257    * 'net.smartlab.web.BusinessObjectFactory.Paginator.remove(Object)'
258    */
 
259  0 toggle public void testRemoveObject() {
260    }
261   
262    /*
263    * Test method for
264    * 'net.smartlab.web.BusinessObjectFactory.Paginator.removeAll(Collection)'
265    */
 
266  0 toggle public void testRemoveAll() {
267    }
268   
269    /*
270    * Test method for
271    * 'net.smartlab.web.BusinessObjectFactory.Paginator.retainAll(Collection)'
272    */
 
273  0 toggle public void testRetainAll() {
274    }
275   
276    /*
277    * Test method for 'net.smartlab.web.BusinessObjectFactory.Paginator.size()'
278    */
 
279  0 toggle public void testSize() {
280    }
281   
282    /*
283    * Test method for
284    * 'net.smartlab.web.BusinessObjectFactory.Paginator.toArray()'
285    */
 
286  0 toggle public void testToArray() {
287    }
288   
289    /*
290    * Test method for
291    * 'net.smartlab.web.BusinessObjectFactory.Paginator.toArray(Object[])'
292    */
 
293  0 toggle public void testToArrayObjectArray() {
294    }
295   
296    /**
297    * @see net.smartlab.web.test.BusinessObjectFactoryTestCase#getDataSetFile()
298    */
 
299  0 toggle protected String getDataSetFile() {
300  0 return "res/auth.dat.xml";
301    }
302    }