]> review.fuel-infra Code Review - packages/trusty/mysql-wsrep-5.6.git/blob
3938d59ba8d53e1a4ded95321f3fd0d48d3c7b6f
[packages/trusty/mysql-wsrep-5.6.git] /
1 /*
2    Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
3
4    This program is free software; you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation; version 2 of the License.
7
8    This program is distributed in the hope that it will be useful,
9    but WITHOUT ANY WARRANTY; without even the implied warranty of
10    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11    GNU General Public License for more details.
12
13    You should have received a copy of the GNU General Public License
14    along with this program; if not, write to the Free Software
15    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
16 */
17
18 package testsuite.clusterj;
19
20 import com.mysql.clusterj.Query;
21 import com.mysql.clusterj.Session;
22
23 import com.mysql.clusterj.query.QueryBuilder;
24 import com.mysql.clusterj.query.QueryDomainType;
25 import com.mysql.clusterj.query.Predicate;
26 import com.mysql.clusterj.query.PredicateOperand;
27
28 import java.util.HashSet;
29 import java.util.List;
30 import java.util.Set;
31
32 import testsuite.clusterj.model.IdBase;
33
34 abstract public class AbstractQueryTest extends AbstractClusterJModelTest {
35
36     /**
37      * Create instances required by the test, used for the queries.
38      * @param number the number of instances to create
39      */
40     abstract void createInstances(int number);
41
42     /** Most query tests use the same number of instances (10).
43      * 
44      */
45     @Override
46     protected int getNumberOfInstances() {
47         return 10;
48     }
49
50     /**
51      * Return the type of instances used for the queries.
52      * @return the type of instances for the test
53      */
54     abstract Class<?> getInstanceType();
55
56     /** The QueryHolder for this test */
57     protected QueryHolder holder;
58
59     private boolean autotransaction;
60
61     @Override
62     public void localSetUp() {
63         setAutotransaction(false);
64         createSessionFactory();
65         session = sessionFactory.getSession();
66         tx = session.currentTransaction();
67         int numberOfInstances = getNumberOfInstances();
68         createInstances(numberOfInstances);
69         session.deletePersistentAll(getInstanceType());
70         session.makePersistentAll(instances);
71         if (getCleanupAfterTest())
72             addTearDownClasses(getInstanceType());
73     }
74
75     protected void setAutotransaction(boolean b) {
76         autotransaction = b;
77     }
78
79     class QueryHolder {
80         public QueryBuilder builder;
81         public QueryDomainType<?> dobj;
82         public String propertyName;
83         public String extraPropertyName;
84         public PredicateOperand propertyPredicate;
85         public PredicateOperand paramEqualPredicate;
86         public PredicateOperand paramLowerPredicate;
87         public PredicateOperand paramUpperPredicate;
88         public PredicateOperand paramInPredicate;
89         public Predicate equal;
90         public Predicate equalOrEqual;
91         public Predicate greaterThan;
92         public Predicate greaterEqual;
93         public Predicate in;
94         public Predicate lessThan;
95         public Predicate lessEqual;
96         public Predicate between;
97         public Predicate greaterThanAndLessThan;
98         public Predicate greaterEqualAndLessThan;
99         public Predicate greaterThanAndLessEqual;
100         public Predicate greaterThanAndLike;
101         public Predicate greaterEqualAndLessEqual;
102         public Predicate greaterEqualAndLike;
103         public Predicate notEqual;
104         public Predicate notGreaterThan;
105         public Predicate notGreaterEqual;
106         public Predicate notLessThan;
107         public Predicate notLessEqual;
108         public Predicate notBetween;
109         public Predicate like;
110         public Predicate greaterThanAndNotGreaterThan;
111         public Predicate greaterEqualAndNotGreaterThan;
112         public Predicate greaterThanAndNotGreaterEqual;
113         public Predicate greaterEqualAndNotGreaterEqual;
114         public PredicateOperand extraParamEqualPredicate;
115         public PredicateOperand extraParamLowerPredicate;
116         public PredicateOperand extraParamUpperPredicate;
117         public PredicateOperand extraParamInPredicate;
118         public PredicateOperand extraProperty;
119         public Predicate extraEqual;
120         public Predicate extraGreaterThan;
121         public Predicate extraGreaterEqual;
122         public Predicate extraLessThan;
123         public Predicate extraLessEqual;
124         public Predicate extraBetween;
125         public Predicate extraGreaterThanAndLessThan;
126         public Predicate extraGreaterEqualAndLessThan;
127         public Predicate extraGreaterThanAndLessEqual;
128         public Predicate extraGreaterEqualAndLessEqual;
129         public Query<?> query;
130         public Set<Integer> expectedSet = new HashSet<Integer>();
131         public String expectedIndex;
132         private Predicate equalOrIn;
133         private Predicate extraIn;
134         private Predicate inAndIn;
135         private Predicate inAndBetween;
136         private Predicate betweenAndIn;
137         public QueryHolder(Class<?> type, String propertyName, String expectedIndex) {
138             this.propertyName = propertyName;
139             // QueryBuilder is the sessionFactory for queries
140             builder = session.getQueryBuilder();
141             // QueryDomainType is the main interface
142             dobj = builder.createQueryDefinition(type);
143             this.expectedIndex = expectedIndex;
144             // parameter
145             paramEqualPredicate = dobj.param("equal");
146             paramLowerPredicate = dobj.param("lower");
147             paramUpperPredicate = dobj.param("upper");
148             paramInPredicate = dobj.param("in");
149             // property
150             propertyPredicate = dobj.get(propertyName);
151             // comparison operations
152             equal = propertyPredicate.equal(paramEqualPredicate);
153             greaterThan = propertyPredicate.greaterThan(paramLowerPredicate);
154             greaterEqual = propertyPredicate.greaterEqual(paramLowerPredicate);
155             lessThan = propertyPredicate.lessThan(paramUpperPredicate);
156             lessEqual = propertyPredicate.lessEqual(paramUpperPredicate);
157             between = propertyPredicate.between(paramLowerPredicate, paramUpperPredicate);
158             greaterThanAndLessThan = lessThan.and(greaterThan);
159             greaterEqualAndLessThan = lessThan.and(greaterEqual);
160             greaterThanAndLessEqual = lessEqual.and(greaterThan);
161             greaterEqualAndLessEqual = lessEqual.and(greaterEqual);
162             in = propertyPredicate.in(paramInPredicate);
163             notEqual = equal.not();
164             notGreaterThan = greaterThan.not();
165             notGreaterEqual = greaterEqual.not();
166             notLessThan = lessThan.not();
167             notLessEqual = lessEqual.not();
168             notBetween = between.not();
169             like = propertyPredicate.like(paramEqualPredicate);
170             greaterThanAndNotGreaterThan = greaterThan.and(propertyPredicate.greaterThan(paramUpperPredicate).not());
171             greaterEqualAndNotGreaterThan = greaterEqual.and(propertyPredicate.greaterThan(paramUpperPredicate).not());
172             greaterThanAndNotGreaterEqual = greaterThan.and(propertyPredicate.greaterEqual(paramUpperPredicate).not());
173             greaterEqualAndNotGreaterEqual = greaterEqual.and(propertyPredicate.greaterEqual(paramUpperPredicate).not());
174             greaterThanAndLike = greaterThan.and(propertyPredicate.like(paramUpperPredicate));
175             greaterEqualAndLike = greaterEqual.and(propertyPredicate.like(paramUpperPredicate));
176         }
177         public QueryHolder(Class<?> type, String propertyName, String expectedIndex,
178                 String extraPropertyName) {
179             this(type, propertyName, expectedIndex);
180             this.extraPropertyName = extraPropertyName;
181             this.extraParamEqualPredicate = dobj.param("extraEqual");
182             this.extraParamLowerPredicate = dobj.param("extraLower");
183             this.extraParamUpperPredicate = dobj.param("extraUpper");
184             this.extraParamInPredicate = dobj.param("extraIn");
185             // property
186             this.extraProperty = dobj.get(extraPropertyName);
187             // comparison operations
188             this.extraEqual = extraProperty.equal(extraParamEqualPredicate);
189             this.extraGreaterThan = extraProperty.greaterThan(extraParamLowerPredicate);
190             this.extraGreaterEqual = extraProperty.greaterEqual(extraParamLowerPredicate);
191             this.extraLessThan = extraProperty.lessThan(extraParamUpperPredicate);
192             this.extraLessEqual = extraProperty.lessEqual(extraParamUpperPredicate);
193             this.extraBetween = extraProperty.between(extraParamLowerPredicate, extraParamUpperPredicate);
194             this.extraGreaterThanAndLessThan = extraLessThan.and(extraGreaterThan);
195             this.extraGreaterEqualAndLessThan = extraLessThan.and(extraGreaterEqual);
196             this.extraGreaterThanAndLessEqual = extraLessEqual.and(extraGreaterThan);
197             this.extraGreaterEqualAndLessEqual = extraLessEqual.and(extraGreaterEqual);
198             this.equalOrEqual = equal.or(extraEqual);
199             this.extraIn = extraProperty.in(extraParamInPredicate);
200             this.equalOrIn = equal.or(extraIn);
201             this.inAndIn = in.and(extraIn);
202             this.inAndBetween = in.and(extraBetween);
203             this.betweenAndIn = between.and(extraIn);
204         }
205         public void createQuery(Session session) {
206             query = session.createQuery(dobj);
207         }
208         public void setParameterEqual(Object parameter) {
209             query.setParameter("equal", parameter);
210         }
211         public void setParameterLower(Object parameter) {
212             query.setParameter("lower", parameter);
213         }
214         public void setParameterUpper(Object parameter) {
215             query.setParameter("upper", parameter);
216         }
217         public void setParameterIn(Object parameter) {
218             query.setParameter("in", parameter);
219         }
220         public void setExpectedResultIds(int... expecteds) {
221             for (int expected:expecteds) {
222                 expectedSet.add(expected);
223             }
224         }
225         public void setExtraParameterEqual(Object parameter) {
226             query.setParameter("extraEqual", parameter);
227         }
228         public void setExtraParameterLower(Object parameter) {
229             query.setParameter("extraLower", parameter);
230         }
231         public void setExtraParameterUpper(Object parameter) {
232             query.setParameter("extraUpper", parameter);
233         }
234
235         public void setExtraParameterIn(Object parameter) {
236             query.setParameter("extraIn", parameter);
237         }
238
239         @SuppressWarnings("unchecked")
240         public void checkResults(String theQuery) {
241             Set<Integer> actualSet = new HashSet<Integer>();
242             List<IdBase> resultList = (List<IdBase>) query.getResultList();
243             for (IdBase result: resultList) {
244                 printResultInstance(result);
245                 actualSet.add(result.getId());
246             }
247             errorIfNotEqual("Wrong index used for " + theQuery + " query: ",
248                     expectedIndex, query.explain().get("IndexUsed"));
249             errorIfNotEqual("Wrong ids returned from " + theQuery + " query: ",
250                     expectedSet, actualSet);
251             }
252
253         public void checkDeletePersistentAll(String where, int expectedNumberOfDeletedInstances) {
254             int result = query.deletePersistentAll();
255             errorIfNotEqual("Wrong index used for " + where + " delete  query: ",
256                     expectedIndex, query.explain().get("IndexUsed"));
257             errorIfNotEqual("Wrong number of instances deleted for " + where, 
258                     expectedNumberOfDeletedInstances, result);
259         }
260     }
261
262     /** This interface is for extra predicates. When the method is invoked, the
263      * QueryHolder has not been created, so this callback is executed to
264      * provide an extra query predicate after the holder is created.
265      */
266     public interface PredicateProvider {
267         public Predicate getPredicate(QueryHolder holder);
268     }
269
270     PredicateProvider extraEqualPredicateProvider = 
271         new PredicateProvider() {
272             public Predicate getPredicate(QueryHolder holder) {
273                 return holder.extraEqual;
274                 }
275             public String toString() {
276                 return " equal";
277             }
278             };
279     
280     PredicateProvider extraNotEqualPredicateProvider = 
281         new PredicateProvider() {
282             public Predicate getPredicate(QueryHolder holder) {
283                 return holder.extraEqual.not();
284                 }
285             public String toString() {
286                 return " not equal";
287             }
288             };
289     
290     PredicateProvider extraBetweenPredicateProvider = 
291         new PredicateProvider() {
292             public Predicate getPredicate(QueryHolder holder) {
293                 return holder.extraBetween;
294                 }
295             public String toString() {
296                 return " between";
297             }
298             };
299             
300     PredicateProvider extraInPredicateProvider = 
301         new PredicateProvider() {
302             public Predicate getPredicate(QueryHolder holder) {
303                 return holder.extraIn;
304                 }
305             public String toString() {
306                 return " in";
307             }
308             };
309                     
310     /** Print the result instance. Override this in a subclass if needed.
311      * 
312      * @param instance the instance to print if needed
313      */
314     protected void printResultInstance(IdBase instance) {
315     }
316
317     public void equalQuery(String propertyName, String expectedIndex,
318             Object parameterValue, int... expected) {
319         tx.begin();
320         QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex);
321         // specify the where clause
322         holder.dobj.where(holder.equal);
323         // create the query
324         holder.createQuery(session);
325         // set the parameter value
326         holder.setParameterEqual(parameterValue);
327         // get the results
328         holder.setExpectedResultIds(expected);
329         holder.checkResults(propertyName + " equal");
330         tx.commit();
331     }
332
333     public void likeQuery(String propertyName, String expectedIndex,
334             Object parameterValue, int... expected) {
335         tx.begin();
336         QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex);
337         // specify the where clause
338         holder.dobj.where(holder.like);
339         // create the query
340         holder.createQuery(session);
341         // set the parameter value
342         holder.setParameterEqual(parameterValue);
343         // get the results
344         holder.setExpectedResultIds(expected);
345         holder.checkResults(propertyName + " like");
346         tx.commit();
347     }
348
349     public void deleteEqualQuery(String propertyName, String expectedIndex,
350             Object parameterValue, int expected) {
351         if (!autotransaction) {
352             tx.begin();
353         }
354         QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex);
355         // specify the where clause
356         holder.dobj.where(holder.equal);
357         // create the query
358         holder.createQuery(session);
359         // set the parameter value
360         holder.setParameterEqual(parameterValue);
361         // get the results
362         holder.checkDeletePersistentAll(propertyName + " delete equal", expected);
363         if (!autotransaction) {
364             tx.commit();
365         }
366     }
367
368     public void equalOrEqualQuery(String propertyName, Object parameterValue1,
369             String extraPropertyName, Object parameterValue2, 
370             String expectedIndex, int... expected) {
371         tx.begin();
372         QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex, extraPropertyName);
373         // specify the where clause
374         holder.dobj.where(holder.equalOrEqual);
375         // create the query
376         holder.createQuery(session);
377         // set the parameter value
378         holder.setParameterEqual(parameterValue1);
379         holder.setExtraParameterEqual(parameterValue2);
380         // get the results
381         holder.setExpectedResultIds(expected);
382         holder.checkResults(propertyName + " equal or equal");
383         tx.commit();
384     }
385
386     public void equalOrInQuery(String propertyName, Object parameterValue1,
387             String extraPropertyName, Object parameterValue2, 
388             String expectedIndex, int... expected) {
389         tx.begin();
390         QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex, extraPropertyName);
391         // specify the where clause
392         holder.dobj.where(holder.equalOrIn);
393         // create the query
394         holder.createQuery(session);
395         // set the parameter value
396         holder.setParameterEqual(parameterValue1);
397         holder.setExtraParameterIn(parameterValue2);
398         // get the results
399         holder.setExpectedResultIds(expected);
400         holder.checkResults(propertyName + " equal or in");
401         tx.commit();
402     }
403
404     public void inQuery(String propertyName, Object parameterValue1,
405             String expectedIndex, int... expected) {
406         tx.begin();
407         QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex);
408         // specify the where clause
409         holder.dobj.where(holder.in);
410         // create the query
411         holder.createQuery(session);
412         // set the parameter value
413         holder.setParameterIn(parameterValue1);
414         // get the results
415         holder.setExpectedResultIds(expected);
416         holder.checkResults(propertyName + " in");
417         tx.commit();
418     }
419
420     public void inAndInQuery(String propertyName, Object parameterValue1,
421             String extraPropertyName, Object parameterValue2, 
422             String expectedIndex, int... expected) {
423         tx.begin();
424         QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex, extraPropertyName);
425         // specify the where clause
426         holder.dobj.where(holder.inAndIn);
427         // create the query
428         holder.createQuery(session);
429         // set the parameter value
430         holder.setParameterIn(parameterValue1);
431         holder.setExtraParameterIn(parameterValue2);
432         // get the results
433         holder.setExpectedResultIds(expected);
434         holder.checkResults(propertyName + " in and " + extraPropertyName + " in");
435         tx.commit();
436     }
437
438     public void inAndBetweenQuery(String propertyName, Object parameterValue1,
439             String extraPropertyName, Object parameterValue2, Object parameterValue3,
440             String expectedIndex, int...expected) {
441         tx.begin();
442         QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex, extraPropertyName);
443         // specify the where clause
444         holder.dobj.where(holder.inAndBetween);
445         // create the query
446         holder.createQuery(session);
447         // set the parameter value
448         holder.setParameterIn(parameterValue1);
449         holder.setExtraParameterLower(parameterValue2);
450         holder.setExtraParameterUpper(parameterValue3);
451         // get the results
452         holder.setExpectedResultIds(expected);
453         holder.checkResults(propertyName + " in and " + extraPropertyName + " between");
454         tx.commit();
455     }
456
457     public void betweenAndInQuery(String propertyName, Object parameterValue1, Object parameterValue2,
458             String extraPropertyName, Object parameterValue3, 
459             String expectedIndex, int... expected) {
460         tx.begin();
461         QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex, extraPropertyName);
462         // specify the where clause
463         holder.dobj.where(holder.betweenAndIn);
464         // create the query
465         holder.createQuery(session);
466         // set the parameter value
467         holder.setParameterLower(parameterValue1);
468         holder.setParameterUpper(parameterValue2);
469         holder.setExtraParameterIn(parameterValue3);
470         // get the results
471         holder.setExpectedResultIds(expected);
472         holder.checkResults(propertyName + " between and " + extraPropertyName + " in");
473         tx.commit();
474     }
475
476     public void greaterThanQuery(String propertyName, String expectedIndex,
477             Object parameterValue, int... expected) {
478
479         tx.begin();
480         QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex);
481         // set the where clause into the query 
482         holder.dobj.where(holder.greaterThan);
483         // create the query
484         holder.createQuery(session);
485         // set the parameter value
486         holder.setParameterLower(parameterValue);
487         // get the results
488         holder.setExpectedResultIds(expected);
489         holder.checkResults(propertyName + " greaterThan");
490         tx.commit();
491     }
492
493     public void greaterEqualQuery(String propertyName, String expectedIndex,
494             Object parameterValue, int... expected) {
495
496         tx.begin();
497         QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex);
498         // set the where clause into the query
499         holder.dobj.where(holder.greaterEqual);
500         // create the query
501         holder.createQuery(session);
502         // set the parameter value
503         holder.setParameterLower(parameterValue);
504         // get the results
505         holder.setExpectedResultIds(expected);
506         holder.checkResults(propertyName + " greaterEqual");
507         tx.commit();
508     }
509
510     public void lessThanQuery(String propertyName, String expectedIndex,
511             Object parameterValue, int... expected) {
512
513         tx.begin();
514         QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex);
515         // set the where clause into the query
516         holder.dobj.where(holder.lessThan);
517         // create the query
518         holder.createQuery(session);
519         // set the parameter value
520         holder.setParameterUpper(parameterValue);
521         // get the results
522         holder.setExpectedResultIds(expected);
523         holder.checkResults(propertyName + " lessThan");
524         tx.commit();
525     }
526
527     public void lessEqualQuery(String propertyName, String expectedIndex,
528             Object parameterValue, int... expected) {
529
530         tx.begin();
531         QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex);
532         // set the where clause into the query
533         holder.dobj.where(holder.lessEqual);
534         // create the query
535         holder.createQuery(session);
536         // set the parameter value
537         holder.setParameterUpper(parameterValue);
538         // get the results
539         holder.setExpectedResultIds(expected);
540         holder.checkResults(propertyName + " lessEqual");
541         tx.commit();
542     }
543
544     public void betweenQuery(String propertyName, String expectedIndex,
545             Object parameterLowerValue, Object parameterUpperValue,
546             int... expected) {
547
548         tx.begin();
549         QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex);
550         // set the where clause into the query
551         holder.dobj.where(holder.between);
552         // create the query
553         holder.createQuery(session);
554         // set the parameter value
555         holder.setParameterUpper(parameterUpperValue);
556         holder.setParameterLower(parameterLowerValue);
557         // get the results
558         holder.setExpectedResultIds(expected);
559         holder.checkResults(propertyName + " between");
560         tx.commit();
561     }
562
563     public void greaterThanAndLessThanQuery(String propertyName, String expectedIndex,
564             Object parameterLowerValue, Object parameterUpperValue,
565             int... expected) {
566
567         tx.begin();
568         QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex);
569         // set the where clause into the query
570         holder.dobj.where(holder.greaterThanAndLessThan);
571         // create the query
572         holder.createQuery(session);
573         // set the parameter value
574         holder.setParameterUpper(parameterUpperValue);
575         holder.setParameterLower(parameterLowerValue);
576         // get the results
577         holder.setExpectedResultIds(expected);
578         holder.checkResults(propertyName + " lessThanAndGreaterThan");
579         tx.commit();
580     }
581
582     public void greaterThanAndLikeQuery(String propertyName, String expectedIndex,
583             Object parameterLowerValue, Object parameterUpperValue,
584             int... expected) {
585
586         tx.begin();
587         QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex);
588         // set the where clause into the query
589         holder.dobj.where(holder.greaterThanAndLike);
590         // create the query
591         holder.createQuery(session);
592         // set the parameter value
593         holder.setParameterUpper(parameterUpperValue);
594         holder.setParameterLower(parameterLowerValue);
595         // get the results
596         holder.setExpectedResultIds(expected);
597         holder.checkResults(propertyName + " greaterThanAndLike");
598         tx.commit();
599     }
600
601     public void deleteGreaterThanAndLessThanQuery(String propertyName, String expectedIndex,
602             Object parameterLowerValue, Object parameterUpperValue,
603             int expected) {
604         if (!autotransaction) {
605             tx.begin();
606         }
607         QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex);
608         // set the where clause into the query
609         holder.dobj.where(holder.greaterThanAndLessThan);
610         // create the query
611         holder.createQuery(session);
612         // set the parameter value
613         holder.setParameterUpper(parameterUpperValue);
614         holder.setParameterLower(parameterLowerValue);
615         // get the results
616         holder.checkDeletePersistentAll(propertyName + " delete lessThanAndGreaterThan", expected);
617         if (!autotransaction) {
618             tx.commit();
619         }
620     }
621
622     public void greaterEqualAndLessThanQuery(String propertyName, String expectedIndex,
623             Object parameterLowerValue, Object parameterUpperValue,
624             int... expected) {
625
626         tx.begin();
627         QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex);
628         // set the where clause into the query
629         holder.dobj.where(holder.greaterEqualAndLessThan);
630         // create the query
631         holder.createQuery(session);
632         // set the parameter value
633         holder.setParameterUpper(parameterUpperValue);
634         holder.setParameterLower(parameterLowerValue);
635         // get the results
636         holder.setExpectedResultIds(expected);
637         holder.checkResults(propertyName + " lessThanAndGreaterEqual");
638         tx.commit();
639     }
640
641     public void greaterThanAndLessEqualQuery(String propertyName, String expectedIndex,
642             Object parameterLowerValue, Object parameterUpperValue,
643             int... expected) {
644
645         tx.begin();
646         QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex);
647         // set the where clause into the query
648         holder.dobj.where(holder.greaterThanAndLessEqual);
649         // create the query
650         holder.createQuery(session);
651         // set the parameter value
652         holder.setParameterUpper(parameterUpperValue);
653         holder.setParameterLower(parameterLowerValue);
654         // get the results
655         holder.setExpectedResultIds(expected);
656         holder.checkResults(propertyName + " lessEqualAndGreaterThan");
657         tx.commit();
658     }
659
660     public void greaterEqualAndLessEqualQuery(String propertyName, String expectedIndex,
661             Object parameterLowerValue, Object parameterUpperValue,
662             int... expected) {
663
664         tx.begin();
665         QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex);
666         // set the where clause into the query
667         holder.dobj.where(holder.greaterEqualAndLessEqual);
668         // create the query
669         holder.createQuery(session);
670         // set the parameter value
671         holder.setParameterUpper(parameterUpperValue);
672         holder.setParameterLower(parameterLowerValue);
673         // get the results
674         holder.setExpectedResultIds(expected);
675         holder.checkResults(propertyName + " lessEqualAndGreaterEqual");
676         tx.commit();
677     }
678
679     public void greaterEqualAndLikeQuery(String propertyName, String expectedIndex,
680             Object parameterLowerValue, Object parameterUpperValue,
681             int... expected) {
682
683         tx.begin();
684         QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex);
685         // set the where clause into the query
686         holder.dobj.where(holder.greaterEqualAndLike);
687         // create the query
688         holder.createQuery(session);
689         // set the parameter value
690         holder.setParameterUpper(parameterUpperValue);
691         holder.setParameterLower(parameterLowerValue);
692         // get the results
693         holder.setExpectedResultIds(expected);
694         holder.checkResults(propertyName + " greaterEqualAndLike");
695         tx.commit();
696     }
697
698     public void equalAnd1ExtraQuery(String propertyName, Object parameterValue,
699             String extraPropertyName, PredicateProvider extraPredicateProvider, Object extraParameterValue, 
700             String expectedIndex, int... expected) {
701         tx.begin();
702         holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex,
703                 extraPropertyName);
704         // specify the where clause
705         Predicate extraPredicate = extraPredicateProvider.getPredicate(holder);
706         holder.dobj.where(holder.equal.and(extraPredicate));
707         // create the query
708         holder.createQuery(session);
709         // set the parameter value
710         holder.setParameterEqual(parameterValue);
711         holder.setParameterLower(parameterValue);
712         holder.setParameterUpper(parameterValue);
713         holder.setExtraParameterEqual(extraParameterValue);
714         holder.setExtraParameterLower(extraParameterValue);
715         holder.setExtraParameterUpper(extraParameterValue);
716         // get the results
717         holder.setExpectedResultIds(expected);
718         holder.checkResults(propertyName + " equal and " + extraPredicate);
719         tx.commit();
720     }
721
722     public void greaterThanAnd1ExtraQuery(String propertyName, Object parameterValue,
723             String extraPropertyName, PredicateProvider extraPredicateProvider, Object extraParameterValue, 
724             String expectedIndex, int... expected) {
725         tx.begin();
726         holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex,
727                 extraPropertyName);
728         // specify the where clause
729         Predicate extraPredicate = extraPredicateProvider.getPredicate(holder);
730         holder.dobj.where(holder.greaterThan.and(extraPredicate));
731         // create the query
732         holder.createQuery(session);
733         // set the parameter value
734         holder.setParameterEqual(parameterValue);
735         holder.setParameterLower(parameterValue);
736         holder.setParameterUpper(parameterValue);
737         holder.setExtraParameterEqual(extraParameterValue);
738         holder.setExtraParameterLower(extraParameterValue);
739         holder.setExtraParameterUpper(extraParameterValue);
740         // get the results
741         holder.setExpectedResultIds(expected);
742         holder.checkResults(propertyName + " greater than and " + extraPropertyName + extraPredicateProvider.toString());
743         tx.commit();
744     }
745
746     public void greaterEqualAnd1ExtraQuery(String propertyName, Object parameterValue,
747             String extraPropertyName, PredicateProvider extraPredicateProvider, Object extraParameterValue, 
748             String expectedIndex, int... expected) {
749         tx.begin();
750         holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex,
751                 extraPropertyName);
752         // specify the where clause
753         Predicate extraPredicate = extraPredicateProvider.getPredicate(holder);
754         holder.dobj.where(holder.greaterEqual.and(extraPredicate));
755         // create the query
756         holder.createQuery(session);
757         // set the parameter value
758         holder.setParameterEqual(parameterValue);
759         holder.setParameterLower(parameterValue);
760         holder.setParameterUpper(parameterValue);
761         holder.setExtraParameterEqual(extraParameterValue);
762         holder.setExtraParameterLower(extraParameterValue);
763         holder.setExtraParameterUpper(extraParameterValue);
764         // get the results
765         holder.setExpectedResultIds(expected);
766         holder.checkResults(propertyName + " greater equal and " + extraPropertyName + extraPredicateProvider.toString());
767         tx.commit();
768     }
769
770     public void lessThanAnd1ExtraQuery(String propertyName, Object parameterValue,
771             String extraPropertyName, PredicateProvider extraPredicateProvider, Object extraParameterValue, 
772             String expectedIndex, int... expected) {
773         tx.begin();
774         holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex,
775                 extraPropertyName);
776         // specify the where clause
777         Predicate extraPredicate = extraPredicateProvider.getPredicate(holder);
778         holder.dobj.where(holder.lessThan.and(extraPredicate));
779         // create the query
780         holder.createQuery(session);
781         // set the parameter value
782         holder.setParameterEqual(parameterValue);
783         holder.setParameterLower(parameterValue);
784         holder.setParameterUpper(parameterValue);
785         holder.setExtraParameterEqual(extraParameterValue);
786         holder.setExtraParameterLower(extraParameterValue);
787         holder.setExtraParameterUpper(extraParameterValue);
788         // get the results
789         holder.setExpectedResultIds(expected);
790         holder.checkResults(propertyName + " less than and " + extraPropertyName + extraPredicateProvider.toString());
791         tx.commit();
792     }
793
794     public void lessEqualAnd1ExtraQuery(String propertyName, Object parameterValue,
795             String extraPropertyName, PredicateProvider extraPredicateProvider, Object extraParameterValue, 
796             String expectedIndex, int... expected) {
797         tx.begin();
798         holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex,
799                 extraPropertyName);
800         // specify the where clause
801         Predicate extraPredicate = extraPredicateProvider.getPredicate(holder);
802         holder.dobj.where(holder.lessEqual.and(extraPredicate));
803         // create the query
804         holder.createQuery(session);
805         // set the parameter value
806         holder.setParameterEqual(parameterValue);
807         holder.setParameterLower(parameterValue);
808         holder.setParameterUpper(parameterValue);
809         holder.setExtraParameterEqual(extraParameterValue);
810         holder.setExtraParameterLower(extraParameterValue);
811         holder.setExtraParameterUpper(extraParameterValue);
812         // get the results
813         holder.setExpectedResultIds(expected);
814         holder.checkResults(propertyName + " less equal and " + extraPropertyName + extraPredicateProvider.toString());
815         tx.commit();
816     }
817
818     public void equalAnd2ExtraQuery(String propertyName, Object parameterValue,
819             String extraPropertyName, PredicateProvider extraPredicateProvider,
820             Object extraParameterValue1, Object extraParameterValue2,
821             String expectedIndex, int... expected) {
822         tx.begin();
823         QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex,
824                 extraPropertyName);
825         // specify the where clause
826         Predicate extraPredicate = extraPredicateProvider.getPredicate(holder);
827         holder.dobj.where(holder.equal.and(extraPredicate));
828         // create the query
829         holder.createQuery(session);
830         // set the parameter value
831         holder.setParameterEqual(parameterValue);
832         holder.setParameterLower(parameterValue);
833         holder.setParameterUpper(parameterValue);
834         holder.setExtraParameterEqual(extraParameterValue1);
835         holder.setExtraParameterLower(extraParameterValue1);
836         holder.setExtraParameterUpper(extraParameterValue2);
837         // get the results
838         holder.setExpectedResultIds(expected);
839         holder.checkResults(propertyName + " equal and " + extraPredicate);
840         tx.commit();
841     }
842
843     public void notEqualQuery(String propertyName, String expectedIndex,
844             Object parameterValue, int... expected) {
845         tx.begin();
846         QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex);
847         // specify the where clause
848         holder.dobj.where(holder.notEqual);
849         // create the query
850         holder.createQuery(session);
851         // set the parameter value
852         holder.setParameterEqual(parameterValue);
853         // get the results
854         holder.setExpectedResultIds(expected);
855         holder.checkResults(propertyName + " not equal");
856         tx.commit();
857     }
858
859     public void notNotEqualQuery(String propertyName, String expectedIndex,
860             Object parameterValue, int... expected) {
861         tx.begin();
862         QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex);
863         // specify the where clause
864         holder.dobj.where(holder.notEqual.not());
865         // create the query
866         holder.createQuery(session);
867         // set the parameter value
868         holder.setParameterEqual(parameterValue);
869         // get the results
870         holder.setExpectedResultIds(expected);
871         holder.checkResults(propertyName + " not not equal");
872         tx.commit();
873     }
874
875     public void notNotNotEqualQuery(String propertyName, String expectedIndex,
876             Object parameterValue, int... expected) {
877         tx.begin();
878         QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex);
879         // specify the where clause
880         holder.dobj.where(holder.dobj.not(holder.notEqual.not()));
881         // create the query
882         holder.createQuery(session);
883         // set the parameter value
884         holder.setParameterEqual(parameterValue);
885         // get the results
886         holder.setExpectedResultIds(expected);
887         holder.checkResults(propertyName + " not not not equal");
888         tx.commit();
889     }
890
891     public void notGreaterThanQuery(String propertyName, String expectedIndex,
892             Object parameterValue, int... expected) {
893
894         tx.begin();
895         QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex);
896         // set the where clause into the query 
897         holder.dobj.where(holder.notGreaterThan);
898         // create the query
899         holder.createQuery(session);
900         // set the parameter value
901         holder.setParameterLower(parameterValue);
902         // get the results
903         holder.setExpectedResultIds(expected);
904         holder.checkResults(propertyName + " not greaterThan");
905         tx.commit();
906     }
907
908     public void notGreaterEqualQuery(String propertyName, String expectedIndex,
909             Object parameterValue, int... expected) {
910
911         tx.begin();
912         QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex);
913         // set the where clause into the query
914         holder.dobj.where(holder.notGreaterEqual);
915         // create the query
916         holder.createQuery(session);
917         // set the parameter value
918         holder.setParameterLower(parameterValue);
919         // get the results
920         holder.setExpectedResultIds(expected);
921         holder.checkResults(propertyName + " not greaterEqual");
922         tx.commit();
923     }
924
925     public void notLessThanQuery(String propertyName, String expectedIndex,
926             Object parameterValue, int... expected) {
927
928         tx.begin();
929         QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex);
930         // set the where clause into the query
931         holder.dobj.where(holder.notLessThan);
932         // create the query
933         holder.createQuery(session);
934         // set the parameter value
935         holder.setParameterUpper(parameterValue);
936         // get the results
937         holder.setExpectedResultIds(expected);
938         holder.checkResults(propertyName + " not lessThan");
939         tx.commit();
940     }
941
942     public void notLessEqualQuery(String propertyName, String expectedIndex,
943             Object parameterValue, int... expected) {
944
945         tx.begin();
946         QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex);
947         // set the where clause into the query
948         holder.dobj.where(holder.notLessEqual);
949         // create the query
950         holder.createQuery(session);
951         // set the parameter value
952         holder.setParameterUpper(parameterValue);
953         // get the results
954         holder.setExpectedResultIds(expected);
955         holder.checkResults(propertyName + " not lessEqual");
956         tx.commit();
957     }
958
959     public void notBetweenQuery(String propertyName, String expectedIndex,
960             Object parameterLowerValue, Object parameterUpperValue,
961             int... expected) {
962
963         tx.begin();
964         QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex);
965         // set the where clause into the query
966         holder.dobj.where(holder.notBetween);
967         // create the query
968         holder.createQuery(session);
969         // set the parameter value
970         holder.setParameterUpper(parameterUpperValue);
971         holder.setParameterLower(parameterLowerValue);
972         // get the results
973         holder.setExpectedResultIds(expected);
974         holder.checkResults(propertyName + " not between");
975         tx.commit();
976     }
977
978     public void greaterThanAndNotGreaterThanQuery(String propertyName, String expectedIndex,
979             Object parameterLowerValue, Object parameterUpperValue,
980             int... expected) {
981
982         tx.begin();
983         QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex);
984         // set the where clause into the query
985         holder.dobj.where(holder.greaterThanAndNotGreaterThan);
986         // create the query
987         holder.createQuery(session);
988         // set the parameter value
989         holder.setParameterUpper(parameterUpperValue);
990         holder.setParameterLower(parameterLowerValue);
991         // get the results
992         holder.setExpectedResultIds(expected);
993         holder.checkResults(propertyName + " greaterThanAndNotGreaterThan");
994         tx.commit();
995     }
996
997     public void greaterEqualAndNotGreaterThanQuery(String propertyName, String expectedIndex,
998             Object parameterLowerValue, Object parameterUpperValue,
999             int... expected) {
1000
1001         tx.begin();
1002         QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex);
1003         // set the where clause into the query
1004         holder.dobj.where(holder.greaterEqualAndNotGreaterThan);
1005         // create the query
1006         holder.createQuery(session);
1007         // set the parameter value
1008         holder.setParameterUpper(parameterUpperValue);
1009         holder.setParameterLower(parameterLowerValue);
1010         // get the results
1011         holder.setExpectedResultIds(expected);
1012         holder.checkResults(propertyName + " greaterEqualAndNotGreaterThan");
1013         tx.commit();
1014     }
1015
1016     public void greaterThanAndNotGreaterEqualQuery(String propertyName, String expectedIndex,
1017             Object parameterLowerValue, Object parameterUpperValue,
1018             int... expected) {
1019
1020         tx.begin();
1021         QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex);
1022         // set the where clause into the query
1023         holder.dobj.where(holder.greaterThanAndNotGreaterEqual);
1024         // create the query
1025         holder.createQuery(session);
1026         // set the parameter value
1027         holder.setParameterUpper(parameterUpperValue);
1028         holder.setParameterLower(parameterLowerValue);
1029         // get the results
1030         holder.setExpectedResultIds(expected);
1031         holder.checkResults(propertyName + " greaterThanAndNotGreaterEqual");
1032         tx.commit();
1033     }
1034
1035     public void greaterEqualAndNotGreaterEqualQuery(String propertyName, String expectedIndex,
1036             Object parameterLowerValue, Object parameterUpperValue,
1037             int... expected) {
1038
1039         tx.begin();
1040         QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex);
1041         // set the where clause into the query
1042         holder.dobj.where(holder.greaterEqualAndNotGreaterEqual);
1043         // create the query
1044         holder.createQuery(session);
1045         // set the parameter value
1046         holder.setParameterUpper(parameterUpperValue);
1047         holder.setParameterLower(parameterLowerValue);
1048         // get the results
1049         holder.setExpectedResultIds(expected);
1050         holder.checkResults(propertyName + " greaterEqualAndNotGreaterEqual");
1051         tx.commit();
1052     }
1053
1054 }