-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathasMapBlogConsoleTestScript.groovy
More file actions
59 lines (45 loc) · 1.6 KB
/
asMapBlogConsoleTestScript.groovy
File metadata and controls
59 lines (45 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import test.blog.*
Category catScience = new Category(name: "Science")
catScience.save(flush: true, failOnError: true)
Category catSport = new Category(name: "Sport")
catSport.save(flush: true, failOnError: true)
Category catProgramming = new Category(name: "Programming")
catProgramming.save(flush: true, failOnError: true)
Category catFun = new Category(name: "Fun")
catFun.save(flush: true, failOnError: true)
Tag tagSoccer = new Tag(name: "Soccer")
tagSoccer.save(flush: true, failOnError: true)
Tag tagGroovy = new Tag(name: "Groovy")
tagGroovy.save(flush: true, failOnError: true)
Tag tagJava = new Tag(name: "Java")
tagJava.save(flush: true, failOnError: true)
User user1 = new User(username: "Tom", email: "tom@test.com")
user1.save(flush: true, failOnError: true)
Blog blog1User1 = new Blog(title: "A blog about Java", summary: "Post about Java and related")
user1.addToBlogs(blog1User1)
user1.save(flush: true, failOnError: true)
Post post
post = new Post(title: "post1", content: "Great content Post 1")
post.category = catProgramming
post.addToTags(tagJava)
post.addToTags(tagGroovy)
blog1User1.addToPosts(post)
post = new Post(title: "post2", content: "Great content Post 2")
post.category = catProgramming
post.addToTags(tagGroovy)
blog1User1.addToPosts(post)
blog1User1.save(flush: true, failOnError: true)
User user = User.findByEMail("tom@test.com")
userMap user.asMap {
include "id", "username"
load("blogs") {
include "id", "title"
load("posts") {
include "id", "title"
load("category") {
include "name"
}
}
}
}
println