Skip to content

Commit cce0174

Browse files
GRAILS-6691 - added test
1 parent 0c20d8d commit cce0174

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/test/org/codehaus/groovy/grails/orm/hibernate/HibernateCriteriaBuilderTests.groovy

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,20 @@ class CriteriaBuilderTestClass2 {
4646
['bart']
4747
}
4848

49+
void testSizeErrorMessages() {
50+
// GRAILS-6691
51+
def domainClass = ga.getDomainClass("CriteriaBuilderTestClass").clazz
52+
def crit = domainClass.createCriteria()
53+
54+
def methodNames = ['sizeGt', 'sizeGe', 'sizeLe', 'sizeLt', 'sizeNe']
55+
methodNames.each { methodName ->
56+
def errorMessage = shouldFail(IllegalArgumentException) {
57+
crit."$methodName"('somePropertyName', 0)
58+
}
59+
assertEquals "Call to [${methodName}] with propertyName [somePropertyName] and size [0] not allowed here.", errorMessage
60+
}
61+
}
62+
4963
void testSqlRestriction() {
5064
createDomainData()
5165

@@ -1455,4 +1469,4 @@ class CriteriaBuilderTestClass2 {
14551469
return parse(groovy,testClassName,criteriaClassName,false);
14561470
}
14571471

1458-
}
1472+
}

0 commit comments

Comments
 (0)