Guest User

Untitled

a guest
Jun 25th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. class Client implements Bindable{
  2.  
  3. static hasMany = [...]
  4.  
  5. String cName
  6.  
  7. String dName
  8.  
  9. Date created
  10.  
  11. static constraints = {
  12. cName unique:true, blank:false, maxSize:255
  13. dName unique:true, blank:false, maxSize:255
  14. }
  15.  
  16.  
  17. static mapping = {
  18. ....
  19. }
  20.  
  21. String toString(){
  22. return cName
  23. }
  24. }
  25.  
  26. trait Bindable {
  27. def bindFrom(source) {
  28. def thisz = this
  29.  
  30. source.properties.each { key, value ->
  31. if (thisz.hasProperty(key) && !(key in ['class', 'metaClass'])){
  32. thisz[key] = value
  33. }
  34. }
  35. }
  36. }
  37.  
  38. void "test cName cannot be blank"() {
  39. when:
  40. domain.cName = ""
  41.  
  42. then:
  43. !domain.validate(['cName'])
  44. }
Add Comment
Please, Sign In to add comment