Skip to content

Commit 19495f5

Browse files
committed
Update ConstraintsSpec
Declared qualified name for the constants inside Grails constraints closure.
1 parent d5174e7 commit 19495f5

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

grails-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/ConstraintsSpec.groovy

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ import grails.persistence.Entity
55
class ConstraintsSpec extends GormDatastoreSpec {
66

77
void "Test constraints with static default values"() {
8-
given: "A Test class with static constraint values"
9-
def ce = new ConstrainedEntity(num:1000, str:"ABC")
8+
given: "A Test class with static constraint values"
9+
def ce = new ConstrainedEntity(num: 1000, str: "ABC")
1010

11-
when: "saved is called"
12-
ce.save()
11+
when: "saved is called"
12+
ce.save()
1313

14-
then:
15-
ce.hasErrors() == false
14+
then:
15+
!ce.hasErrors()
1616
}
1717

1818
@Override
@@ -21,6 +21,7 @@ class ConstraintsSpec extends GormDatastoreSpec {
2121
}
2222
}
2323

24+
@SuppressWarnings(["ClashingTraitMethods", "UnnecessaryQualifiedReference"])
2425
@Entity
2526
class ConstrainedEntity implements Serializable {
2627

@@ -33,9 +34,9 @@ class ConstrainedEntity implements Serializable {
3334

3435
static constraints = {
3536

36-
num(maxSize: MAX_VALUE) /*Must be MyDomainClass.MAX_VALUE in order work with redis*/
37+
num(maxSize: ConstrainedEntity.MAX_VALUE)
3738
str validator: { val, obj ->
38-
if (val != null && !ALLOWABLE_VALUES.contains(val)) {/*Must be MyDomainClass.ALLOWABLE_VALUES in order work with redis */
39+
if (val != null && !ConstrainedEntity.ALLOWABLE_VALUES.contains(val)) {
3940
return ['not.valid']
4041
}
4142
}

0 commit comments

Comments
 (0)