18 package testsuite.clusterj;
20 import com.mysql.clusterj.Query;
21 import com.mysql.clusterj.Session;
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;
28 import java.util.HashSet;
29 import java.util.List;
32 import testsuite.clusterj.model.IdBase;
40 abstract void createInstances(
int number);
54 abstract Class<?> getInstanceType();
59 private boolean autotransaction;
63 setAutotransaction(
false);
64 createSessionFactory();
68 createInstances(numberOfInstances);
71 if (getCleanupAfterTest())
72 addTearDownClasses(getInstanceType());
75 protected void setAutotransaction(
boolean b) {
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;
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;
140 builder = session.getQueryBuilder();
142 dobj = builder.createQueryDefinition(type);
143 this.expectedIndex = expectedIndex;
145 paramEqualPredicate = dobj.param(
"equal");
146 paramLowerPredicate = dobj.param(
"lower");
147 paramUpperPredicate = dobj.param(
"upper");
148 paramInPredicate = dobj.param(
"in");
150 propertyPredicate = dobj.get(propertyName);
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));
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");
186 this.extraProperty = dobj.get(extraPropertyName);
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);
205 public void createQuery(Session session) {
206 query = session.createQuery(dobj);
208 public void setParameterEqual(Object parameter) {
209 query.setParameter(
"equal", parameter);
211 public void setParameterLower(Object parameter) {
212 query.setParameter(
"lower", parameter);
214 public void setParameterUpper(Object parameter) {
215 query.setParameter(
"upper", parameter);
217 public void setParameterIn(Object parameter) {
218 query.setParameter(
"in", parameter);
220 public void setExpectedResultIds(
int... expecteds) {
221 for (
int expected:expecteds) {
222 expectedSet.add(expected);
225 public void setExtraParameterEqual(Object parameter) {
226 query.setParameter(
"extraEqual", parameter);
228 public void setExtraParameterLower(Object parameter) {
229 query.setParameter(
"extraLower", parameter);
231 public void setExtraParameterUpper(Object parameter) {
232 query.setParameter(
"extraUpper", parameter);
235 public void setExtraParameterIn(Object parameter) {
236 query.setParameter(
"extraIn", parameter);
239 @SuppressWarnings(
"unchecked")
240 public
void checkResults(
String theQuery) {
243 for (IdBase result: resultList) {
245 actualSet.add(result.getId());
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);
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);
273 return holder.extraEqual;
275 public String toString() {
280 PredicateProvider extraNotEqualPredicateProvider =
281 new PredicateProvider() {
282 public Predicate getPredicate(QueryHolder
holder) {
283 return holder.extraEqual.not();
285 public String toString() {
290 PredicateProvider extraBetweenPredicateProvider =
291 new PredicateProvider() {
292 public Predicate getPredicate(QueryHolder
holder) {
293 return holder.extraBetween;
295 public String toString() {
300 PredicateProvider extraInPredicateProvider =
301 new PredicateProvider() {
302 public Predicate getPredicate(QueryHolder
holder) {
303 return holder.extraIn;
305 public String toString() {
317 public void equalQuery(
String propertyName,
String expectedIndex,
318 Object parameterValue,
int... expected) {
320 QueryHolder
holder =
new QueryHolder(getInstanceType(), propertyName, expectedIndex);
322 holder.dobj.where(holder.equal);
324 holder.createQuery(session);
326 holder.setParameterEqual(parameterValue);
328 holder.setExpectedResultIds(expected);
329 holder.checkResults(propertyName +
" equal");
333 public void likeQuery(
String propertyName,
String expectedIndex,
334 Object parameterValue,
int... expected) {
336 QueryHolder holder =
new QueryHolder(getInstanceType(), propertyName, expectedIndex);
338 holder.dobj.where(holder.like);
340 holder.createQuery(session);
342 holder.setParameterEqual(parameterValue);
344 holder.setExpectedResultIds(expected);
345 holder.checkResults(propertyName +
" like");
349 public void deleteEqualQuery(
String propertyName,
String expectedIndex,
350 Object parameterValue,
int expected) {
351 if (!autotransaction) {
354 QueryHolder holder =
new QueryHolder(getInstanceType(), propertyName, expectedIndex);
356 holder.dobj.where(holder.equal);
358 holder.createQuery(session);
360 holder.setParameterEqual(parameterValue);
362 holder.checkDeletePersistentAll(propertyName +
" delete equal", expected);
363 if (!autotransaction) {
368 public void equalOrEqualQuery(
String propertyName, Object parameterValue1,
369 String extraPropertyName, Object parameterValue2,
370 String expectedIndex,
int... expected) {
372 QueryHolder holder =
new QueryHolder(getInstanceType(), propertyName, expectedIndex, extraPropertyName);
374 holder.dobj.where(holder.equalOrEqual);
376 holder.createQuery(session);
378 holder.setParameterEqual(parameterValue1);
379 holder.setExtraParameterEqual(parameterValue2);
381 holder.setExpectedResultIds(expected);
382 holder.checkResults(propertyName +
" equal or equal");
386 public void equalOrInQuery(
String propertyName, Object parameterValue1,
387 String extraPropertyName, Object parameterValue2,
388 String expectedIndex,
int... expected) {
390 QueryHolder holder =
new QueryHolder(getInstanceType(), propertyName, expectedIndex, extraPropertyName);
392 holder.dobj.where(holder.equalOrIn);
394 holder.createQuery(session);
396 holder.setParameterEqual(parameterValue1);
397 holder.setExtraParameterIn(parameterValue2);
399 holder.setExpectedResultIds(expected);
400 holder.checkResults(propertyName +
" equal or in");
404 public void inQuery(
String propertyName, Object parameterValue1,
405 String expectedIndex,
int... expected) {
407 QueryHolder holder =
new QueryHolder(getInstanceType(), propertyName, expectedIndex);
409 holder.dobj.where(holder.in);
411 holder.createQuery(session);
413 holder.setParameterIn(parameterValue1);
415 holder.setExpectedResultIds(expected);
416 holder.checkResults(propertyName +
" in");
420 public void inAndInQuery(
String propertyName, Object parameterValue1,
421 String extraPropertyName, Object parameterValue2,
422 String expectedIndex,
int... expected) {
424 QueryHolder holder =
new QueryHolder(getInstanceType(), propertyName, expectedIndex, extraPropertyName);
426 holder.dobj.where(holder.inAndIn);
428 holder.createQuery(session);
430 holder.setParameterIn(parameterValue1);
431 holder.setExtraParameterIn(parameterValue2);
433 holder.setExpectedResultIds(expected);
434 holder.checkResults(propertyName +
" in and " + extraPropertyName +
" in");
438 public void inAndBetweenQuery(
String propertyName, Object parameterValue1,
439 String extraPropertyName, Object parameterValue2, Object parameterValue3,
440 String expectedIndex,
int...expected) {
442 QueryHolder holder =
new QueryHolder(getInstanceType(), propertyName, expectedIndex, extraPropertyName);
444 holder.dobj.where(holder.inAndBetween);
446 holder.createQuery(session);
448 holder.setParameterIn(parameterValue1);
449 holder.setExtraParameterLower(parameterValue2);
450 holder.setExtraParameterUpper(parameterValue3);
452 holder.setExpectedResultIds(expected);
453 holder.checkResults(propertyName +
" in and " + extraPropertyName +
" between");
457 public void betweenAndInQuery(
String propertyName, Object parameterValue1, Object parameterValue2,
458 String extraPropertyName, Object parameterValue3,
459 String expectedIndex,
int... expected) {
461 QueryHolder holder =
new QueryHolder(getInstanceType(), propertyName, expectedIndex, extraPropertyName);
463 holder.dobj.where(holder.betweenAndIn);
465 holder.createQuery(session);
467 holder.setParameterLower(parameterValue1);
468 holder.setParameterUpper(parameterValue2);
469 holder.setExtraParameterIn(parameterValue3);
471 holder.setExpectedResultIds(expected);
472 holder.checkResults(propertyName +
" between and " + extraPropertyName +
" in");
476 public void greaterThanQuery(
String propertyName,
String expectedIndex,
477 Object parameterValue,
int... expected) {
480 QueryHolder holder =
new QueryHolder(getInstanceType(), propertyName, expectedIndex);
482 holder.dobj.where(holder.greaterThan);
484 holder.createQuery(session);
486 holder.setParameterLower(parameterValue);
488 holder.setExpectedResultIds(expected);
489 holder.checkResults(propertyName +
" greaterThan");
493 public void greaterEqualQuery(
String propertyName,
String expectedIndex,
494 Object parameterValue,
int... expected) {
497 QueryHolder holder =
new QueryHolder(getInstanceType(), propertyName, expectedIndex);
499 holder.dobj.where(holder.greaterEqual);
501 holder.createQuery(session);
503 holder.setParameterLower(parameterValue);
505 holder.setExpectedResultIds(expected);
506 holder.checkResults(propertyName +
" greaterEqual");
510 public void lessThanQuery(
String propertyName,
String expectedIndex,
511 Object parameterValue,
int... expected) {
514 QueryHolder holder =
new QueryHolder(getInstanceType(), propertyName, expectedIndex);
516 holder.dobj.where(holder.lessThan);
518 holder.createQuery(session);
520 holder.setParameterUpper(parameterValue);
522 holder.setExpectedResultIds(expected);
523 holder.checkResults(propertyName +
" lessThan");
527 public void lessEqualQuery(
String propertyName,
String expectedIndex,
528 Object parameterValue,
int... expected) {
531 QueryHolder holder =
new QueryHolder(getInstanceType(), propertyName, expectedIndex);
533 holder.dobj.where(holder.lessEqual);
535 holder.createQuery(session);
537 holder.setParameterUpper(parameterValue);
539 holder.setExpectedResultIds(expected);
540 holder.checkResults(propertyName +
" lessEqual");
544 public void betweenQuery(
String propertyName,
String expectedIndex,
545 Object parameterLowerValue, Object parameterUpperValue,
549 QueryHolder holder =
new QueryHolder(getInstanceType(), propertyName, expectedIndex);
551 holder.dobj.where(holder.between);
553 holder.createQuery(session);
555 holder.setParameterUpper(parameterUpperValue);
556 holder.setParameterLower(parameterLowerValue);
558 holder.setExpectedResultIds(expected);
559 holder.checkResults(propertyName +
" between");
563 public void greaterThanAndLessThanQuery(
String propertyName,
String expectedIndex,
564 Object parameterLowerValue, Object parameterUpperValue,
568 QueryHolder holder =
new QueryHolder(getInstanceType(), propertyName, expectedIndex);
570 holder.dobj.where(holder.greaterThanAndLessThan);
572 holder.createQuery(session);
574 holder.setParameterUpper(parameterUpperValue);
575 holder.setParameterLower(parameterLowerValue);
577 holder.setExpectedResultIds(expected);
578 holder.checkResults(propertyName +
" lessThanAndGreaterThan");
582 public void greaterThanAndLikeQuery(
String propertyName,
String expectedIndex,
583 Object parameterLowerValue, Object parameterUpperValue,
587 QueryHolder holder =
new QueryHolder(getInstanceType(), propertyName, expectedIndex);
589 holder.dobj.where(holder.greaterThanAndLike);
591 holder.createQuery(session);
593 holder.setParameterUpper(parameterUpperValue);
594 holder.setParameterLower(parameterLowerValue);
596 holder.setExpectedResultIds(expected);
597 holder.checkResults(propertyName +
" greaterThanAndLike");
601 public void deleteGreaterThanAndLessThanQuery(
String propertyName,
String expectedIndex,
602 Object parameterLowerValue, Object parameterUpperValue,
604 if (!autotransaction) {
607 QueryHolder holder =
new QueryHolder(getInstanceType(), propertyName, expectedIndex);
609 holder.dobj.where(holder.greaterThanAndLessThan);
611 holder.createQuery(session);
613 holder.setParameterUpper(parameterUpperValue);
614 holder.setParameterLower(parameterLowerValue);
616 holder.checkDeletePersistentAll(propertyName +
" delete lessThanAndGreaterThan", expected);
617 if (!autotransaction) {
622 public void greaterEqualAndLessThanQuery(
String propertyName,
String expectedIndex,
623 Object parameterLowerValue, Object parameterUpperValue,
627 QueryHolder holder =
new QueryHolder(getInstanceType(), propertyName, expectedIndex);
629 holder.dobj.where(holder.greaterEqualAndLessThan);
631 holder.createQuery(session);
633 holder.setParameterUpper(parameterUpperValue);
634 holder.setParameterLower(parameterLowerValue);
636 holder.setExpectedResultIds(expected);
637 holder.checkResults(propertyName +
" lessThanAndGreaterEqual");
641 public void greaterThanAndLessEqualQuery(
String propertyName,
String expectedIndex,
642 Object parameterLowerValue, Object parameterUpperValue,
646 QueryHolder holder =
new QueryHolder(getInstanceType(), propertyName, expectedIndex);
648 holder.dobj.where(holder.greaterThanAndLessEqual);
650 holder.createQuery(session);
652 holder.setParameterUpper(parameterUpperValue);
653 holder.setParameterLower(parameterLowerValue);
655 holder.setExpectedResultIds(expected);
656 holder.checkResults(propertyName +
" lessEqualAndGreaterThan");
660 public void greaterEqualAndLessEqualQuery(
String propertyName,
String expectedIndex,
661 Object parameterLowerValue, Object parameterUpperValue,
665 QueryHolder holder =
new QueryHolder(getInstanceType(), propertyName, expectedIndex);
667 holder.dobj.where(holder.greaterEqualAndLessEqual);
669 holder.createQuery(session);
671 holder.setParameterUpper(parameterUpperValue);
672 holder.setParameterLower(parameterLowerValue);
674 holder.setExpectedResultIds(expected);
675 holder.checkResults(propertyName +
" lessEqualAndGreaterEqual");
679 public void greaterEqualAndLikeQuery(
String propertyName,
String expectedIndex,
680 Object parameterLowerValue, Object parameterUpperValue,
684 QueryHolder holder =
new QueryHolder(getInstanceType(), propertyName, expectedIndex);
686 holder.dobj.where(holder.greaterEqualAndLike);
688 holder.createQuery(session);
690 holder.setParameterUpper(parameterUpperValue);
691 holder.setParameterLower(parameterLowerValue);
693 holder.setExpectedResultIds(expected);
694 holder.checkResults(propertyName +
" greaterEqualAndLike");
698 public void equalAnd1ExtraQuery(
String propertyName, Object parameterValue,
699 String extraPropertyName, PredicateProvider extraPredicateProvider, Object extraParameterValue,
700 String expectedIndex,
int... expected) {
702 holder =
new QueryHolder(getInstanceType(), propertyName, expectedIndex,
705 Predicate extraPredicate = extraPredicateProvider.getPredicate(holder);
706 holder.dobj.where(holder.equal.and(extraPredicate));
708 holder.createQuery(session);
710 holder.setParameterEqual(parameterValue);
711 holder.setParameterLower(parameterValue);
712 holder.setParameterUpper(parameterValue);
713 holder.setExtraParameterEqual(extraParameterValue);
714 holder.setExtraParameterLower(extraParameterValue);
715 holder.setExtraParameterUpper(extraParameterValue);
717 holder.setExpectedResultIds(expected);
718 holder.checkResults(propertyName +
" equal and " + extraPredicate);
722 public void greaterThanAnd1ExtraQuery(
String propertyName, Object parameterValue,
723 String extraPropertyName, PredicateProvider extraPredicateProvider, Object extraParameterValue,
724 String expectedIndex,
int... expected) {
726 holder =
new QueryHolder(getInstanceType(), propertyName, expectedIndex,
729 Predicate extraPredicate = extraPredicateProvider.getPredicate(holder);
730 holder.dobj.where(holder.greaterThan.and(extraPredicate));
732 holder.createQuery(session);
734 holder.setParameterEqual(parameterValue);
735 holder.setParameterLower(parameterValue);
736 holder.setParameterUpper(parameterValue);
737 holder.setExtraParameterEqual(extraParameterValue);
738 holder.setExtraParameterLower(extraParameterValue);
739 holder.setExtraParameterUpper(extraParameterValue);
741 holder.setExpectedResultIds(expected);
742 holder.checkResults(propertyName +
" greater than and " + extraPropertyName + extraPredicateProvider.toString());
746 public void greaterEqualAnd1ExtraQuery(
String propertyName, Object parameterValue,
747 String extraPropertyName, PredicateProvider extraPredicateProvider, Object extraParameterValue,
748 String expectedIndex,
int... expected) {
750 holder =
new QueryHolder(getInstanceType(), propertyName, expectedIndex,
753 Predicate extraPredicate = extraPredicateProvider.getPredicate(holder);
754 holder.dobj.where(holder.greaterEqual.and(extraPredicate));
756 holder.createQuery(session);
758 holder.setParameterEqual(parameterValue);
759 holder.setParameterLower(parameterValue);
760 holder.setParameterUpper(parameterValue);
761 holder.setExtraParameterEqual(extraParameterValue);
762 holder.setExtraParameterLower(extraParameterValue);
763 holder.setExtraParameterUpper(extraParameterValue);
765 holder.setExpectedResultIds(expected);
766 holder.checkResults(propertyName +
" greater equal and " + extraPropertyName + extraPredicateProvider.toString());
770 public void lessThanAnd1ExtraQuery(
String propertyName, Object parameterValue,
771 String extraPropertyName, PredicateProvider extraPredicateProvider, Object extraParameterValue,
772 String expectedIndex,
int... expected) {
774 holder =
new QueryHolder(getInstanceType(), propertyName, expectedIndex,
777 Predicate extraPredicate = extraPredicateProvider.getPredicate(holder);
778 holder.dobj.where(holder.lessThan.and(extraPredicate));
780 holder.createQuery(session);
782 holder.setParameterEqual(parameterValue);
783 holder.setParameterLower(parameterValue);
784 holder.setParameterUpper(parameterValue);
785 holder.setExtraParameterEqual(extraParameterValue);
786 holder.setExtraParameterLower(extraParameterValue);
787 holder.setExtraParameterUpper(extraParameterValue);
789 holder.setExpectedResultIds(expected);
790 holder.checkResults(propertyName +
" less than and " + extraPropertyName + extraPredicateProvider.toString());
794 public void lessEqualAnd1ExtraQuery(
String propertyName, Object parameterValue,
795 String extraPropertyName, PredicateProvider extraPredicateProvider, Object extraParameterValue,
796 String expectedIndex,
int... expected) {
798 holder =
new QueryHolder(getInstanceType(), propertyName, expectedIndex,
801 Predicate extraPredicate = extraPredicateProvider.getPredicate(holder);
802 holder.dobj.where(holder.lessEqual.and(extraPredicate));
804 holder.createQuery(session);
806 holder.setParameterEqual(parameterValue);
807 holder.setParameterLower(parameterValue);
808 holder.setParameterUpper(parameterValue);
809 holder.setExtraParameterEqual(extraParameterValue);
810 holder.setExtraParameterLower(extraParameterValue);
811 holder.setExtraParameterUpper(extraParameterValue);
813 holder.setExpectedResultIds(expected);
814 holder.checkResults(propertyName +
" less equal and " + extraPropertyName + extraPredicateProvider.toString());
818 public void equalAnd2ExtraQuery(
String propertyName, Object parameterValue,
819 String extraPropertyName, PredicateProvider extraPredicateProvider,
820 Object extraParameterValue1, Object extraParameterValue2,
821 String expectedIndex,
int... expected) {
823 QueryHolder holder =
new QueryHolder(getInstanceType(), propertyName, expectedIndex,
826 Predicate extraPredicate = extraPredicateProvider.getPredicate(holder);
827 holder.dobj.where(holder.equal.and(extraPredicate));
829 holder.createQuery(session);
831 holder.setParameterEqual(parameterValue);
832 holder.setParameterLower(parameterValue);
833 holder.setParameterUpper(parameterValue);
834 holder.setExtraParameterEqual(extraParameterValue1);
835 holder.setExtraParameterLower(extraParameterValue1);
836 holder.setExtraParameterUpper(extraParameterValue2);
838 holder.setExpectedResultIds(expected);
839 holder.checkResults(propertyName +
" equal and " + extraPredicate);
843 public void notEqualQuery(
String propertyName,
String expectedIndex,
844 Object parameterValue,
int... expected) {
846 QueryHolder holder =
new QueryHolder(getInstanceType(), propertyName, expectedIndex);
848 holder.dobj.where(holder.notEqual);
850 holder.createQuery(session);
852 holder.setParameterEqual(parameterValue);
854 holder.setExpectedResultIds(expected);
855 holder.checkResults(propertyName +
" not equal");
859 public void notNotEqualQuery(
String propertyName,
String expectedIndex,
860 Object parameterValue,
int... expected) {
862 QueryHolder holder =
new QueryHolder(getInstanceType(), propertyName, expectedIndex);
864 holder.dobj.where(holder.notEqual.not());
866 holder.createQuery(session);
868 holder.setParameterEqual(parameterValue);
870 holder.setExpectedResultIds(expected);
871 holder.checkResults(propertyName +
" not not equal");
875 public void notNotNotEqualQuery(
String propertyName,
String expectedIndex,
876 Object parameterValue,
int... expected) {
878 QueryHolder holder =
new QueryHolder(getInstanceType(), propertyName, expectedIndex);
880 holder.dobj.where(holder.dobj.not(holder.notEqual.not()));
882 holder.createQuery(session);
884 holder.setParameterEqual(parameterValue);
886 holder.setExpectedResultIds(expected);
887 holder.checkResults(propertyName +
" not not not equal");
891 public void notGreaterThanQuery(
String propertyName,
String expectedIndex,
892 Object parameterValue,
int... expected) {
895 QueryHolder holder =
new QueryHolder(getInstanceType(), propertyName, expectedIndex);
897 holder.dobj.where(holder.notGreaterThan);
899 holder.createQuery(session);
901 holder.setParameterLower(parameterValue);
903 holder.setExpectedResultIds(expected);
904 holder.checkResults(propertyName +
" not greaterThan");
908 public void notGreaterEqualQuery(
String propertyName,
String expectedIndex,
909 Object parameterValue,
int... expected) {
912 QueryHolder holder =
new QueryHolder(getInstanceType(), propertyName, expectedIndex);
914 holder.dobj.where(holder.notGreaterEqual);
916 holder.createQuery(session);
918 holder.setParameterLower(parameterValue);
920 holder.setExpectedResultIds(expected);
921 holder.checkResults(propertyName +
" not greaterEqual");
925 public void notLessThanQuery(
String propertyName,
String expectedIndex,
926 Object parameterValue,
int... expected) {
929 QueryHolder holder =
new QueryHolder(getInstanceType(), propertyName, expectedIndex);
931 holder.dobj.where(holder.notLessThan);
933 holder.createQuery(session);
935 holder.setParameterUpper(parameterValue);
937 holder.setExpectedResultIds(expected);
938 holder.checkResults(propertyName +
" not lessThan");
942 public void notLessEqualQuery(
String propertyName,
String expectedIndex,
943 Object parameterValue,
int... expected) {
946 QueryHolder holder =
new QueryHolder(getInstanceType(), propertyName, expectedIndex);
948 holder.dobj.where(holder.notLessEqual);
950 holder.createQuery(session);
952 holder.setParameterUpper(parameterValue);
954 holder.setExpectedResultIds(expected);
955 holder.checkResults(propertyName +
" not lessEqual");
959 public void notBetweenQuery(
String propertyName,
String expectedIndex,
960 Object parameterLowerValue, Object parameterUpperValue,
964 QueryHolder holder =
new QueryHolder(getInstanceType(), propertyName, expectedIndex);
966 holder.dobj.where(holder.notBetween);
968 holder.createQuery(session);
970 holder.setParameterUpper(parameterUpperValue);
971 holder.setParameterLower(parameterLowerValue);
973 holder.setExpectedResultIds(expected);
974 holder.checkResults(propertyName +
" not between");
978 public void greaterThanAndNotGreaterThanQuery(
String propertyName,
String expectedIndex,
979 Object parameterLowerValue, Object parameterUpperValue,
983 QueryHolder holder =
new QueryHolder(getInstanceType(), propertyName, expectedIndex);
985 holder.dobj.where(holder.greaterThanAndNotGreaterThan);
987 holder.createQuery(session);
989 holder.setParameterUpper(parameterUpperValue);
990 holder.setParameterLower(parameterLowerValue);
992 holder.setExpectedResultIds(expected);
993 holder.checkResults(propertyName +
" greaterThanAndNotGreaterThan");
997 public void greaterEqualAndNotGreaterThanQuery(
String propertyName,
String expectedIndex,
998 Object parameterLowerValue, Object parameterUpperValue,
1002 QueryHolder holder =
new QueryHolder(getInstanceType(), propertyName, expectedIndex);
1004 holder.dobj.where(holder.greaterEqualAndNotGreaterThan);
1006 holder.createQuery(session);
1008 holder.setParameterUpper(parameterUpperValue);
1009 holder.setParameterLower(parameterLowerValue);
1011 holder.setExpectedResultIds(expected);
1012 holder.checkResults(propertyName +
" greaterEqualAndNotGreaterThan");
1016 public void greaterThanAndNotGreaterEqualQuery(
String propertyName,
String expectedIndex,
1017 Object parameterLowerValue, Object parameterUpperValue,
1021 QueryHolder holder =
new QueryHolder(getInstanceType(), propertyName, expectedIndex);
1023 holder.dobj.where(holder.greaterThanAndNotGreaterEqual);
1025 holder.createQuery(session);
1027 holder.setParameterUpper(parameterUpperValue);
1028 holder.setParameterLower(parameterLowerValue);
1030 holder.setExpectedResultIds(expected);
1031 holder.checkResults(propertyName +
" greaterThanAndNotGreaterEqual");
1035 public void greaterEqualAndNotGreaterEqualQuery(
String propertyName,
String expectedIndex,
1036 Object parameterLowerValue, Object parameterUpperValue,
1040 QueryHolder holder =
new QueryHolder(getInstanceType(), propertyName, expectedIndex);
1042 holder.dobj.where(holder.greaterEqualAndNotGreaterEqual);
1044 holder.createQuery(session);
1046 holder.setParameterUpper(parameterUpperValue);
1047 holder.setParameterLower(parameterLowerValue);
1049 holder.setExpectedResultIds(expected);
1050 holder.checkResults(propertyName +
" greaterEqualAndNotGreaterEqual");