@@ -76,12 +76,15 @@ class RestProtocolTest extends BaseServiceTest {
7676 }
7777
7878 def " map argument body test" () {
79- expect :
80- runner. post(path, body) contains output
79+ when :
80+ def result = runner. post(path, body)
81+ then :
82+ result. contains(' 1:[2,3]' )
83+ result. contains(' 4:[5,6]' )
8184 where :
82- path | body | output
83- ' /mapArgBodyTest?age=2' | ' {"1":["2",3],"4":[5,"6"]}' | ' {4:[5,6],1:[2,3]} '
84- ' /mapArgBodyTest2?age=1' | ' [{"1":[2,3],"4":[5,6]},2]' | ' {4:[5,6],1:[2,3]} '
85+ path | body
86+ ' /mapArgBodyTest?age=2' | ' {"1":["2",3],"4":[5,"6"]}'
87+ ' /mapArgBodyTest2?age=1' | ' [{"1":[2,3],"4":[5,6]},2]'
8588 }
8689
8790 def " bean argument test" () {
@@ -121,34 +124,42 @@ class RestProtocolTest extends BaseServiceTest {
121124 }
122125
123126 def " advance bean argument get test" () {
124- expect :
125- runner. get(path) contains output
127+ when :
128+ def result = runner. get(path)
129+ then :
130+ if (fragments == null ) {
131+ assert result. contains(output)
132+ } else {
133+ fragments. each { frag ->
134+ assert result. contains(frag)
135+ }
136+ }
126137 where :
127- path | output
128- ' /bean?id=1&name=sam' | ' "id":1,"name":"sam"'
129- ' /bean?user.id=1&user.name=sam' | ' "id":1,"name":"sam"'
130- ' /bean?name=sam&p=123&[email protected] ' |
' "email":"[email protected] ","name":"sam","phone":"123"' 131- ' /bean?group.name=g1&group.owner.name=jack' | ' "group":{"id":0,"name":"g1","owner":{"name":"jack"'
132- ' /bean?group.parent.parent.children[0].name=xx' | ' "group":{"id":0,"parent":{"id":0,"parent":{"children":[{"id":0,"name":"xx"}],"id":0}}}'
133- ' /bean?group={"name":"g1","id":2}' | ' "group":{"id":2,"name":"g1"}'
134- ' /bean?ids=3&ids=4' | ' "ids":[3,4]'
135- ' /bean?ids[]=3&ids[]=4' | ' "ids":[3,4]'
136- ' /bean?ids[1]=3&ids[2]=4' | ' "ids":[0,3,4]'
137- ' /bean?scores=3&scores=4' | ' "scores":[3,4]'
138- ' /bean?scores[]=3&scores[]=4' | ' "scores":[3,4]'
139- ' /bean?scores[1]=3&scores[2]=4' | ' "scores":[null,3,4]'
140- ' /bean?tags[0].name=a&tags[0].value=b&tags[1].name=c&tags[1].value=d' | ' "tags":[{"name":"a","value":"b"},{"name":"c","value":"d"}]'
141- ' /bean?tagsA[0].name=a&tagsA[0].value=b&tagsA[1].name=c&tagsA[1].value=d' | ' "tagsA":[{"name":"a","value":"b"},{"name":"c","value":"d"}]'
142- ' /bean?tagsB[0].name=e&tagsB[1].name=c&tagsB[1].value=d' | ' "tagsB":[{"name":"e","value":"b"},{"name":"c","value":"d"}]'
143- ' /bean?tagsC[0].name=e&tagsC[1].name=c&tagsC[1].value=d' | ' "tagsC":[{"name":"e","value":"b"},{"name":"c","value":"d"}]'
144- ' /bean?groupMaps[0].one.name=a&groupMaps[1].two.name=b' | ' "groupMaps":[{"one":{"id":0,"name":"a"}},{"two":{"id":0,"name":"b"}}]'
145- ' /bean?id=1&features.a=xx&features.b=2' | ' "features":{ "a":"xx", "b":"2"} '
146- ' /bean?id=1&features[a]=xx&features[b]=2' | ' "features":{ "a":"xx", "b":"2"} '
147- ' /bean?group.id=2&group.features.a=1&group.features.b=xx' | ' "group":{ "features":{ "a":"1", "b":"xx"},"id":2} '
148- ' /bean?tagMap.a.name=a&tagMap.a.value=b&tagMap.b.name=c&tagMap.b.value=d' | ' "tagMap":{"a":{" name":"a", "value":"b"},"b":{" name":"c", "value":"d"}} '
149- ' /bean?tagMapA.a.name=e&tagMapA.b.name=c&tagMapA.b.value=d' | ' "tagMapA":{"a":{" name":"e", "value":"b"},"b":{" name":"c", "value":"d"}} '
150- ' /bean?tagMapB[2].name=a&tagMapB[2].value=b&tagMapB[3].name=c' | ' "tagMapB":{2:{ "name":"a", "value":"b"},3:{ "name":"c"}} '
151- ' /bean?groupsMap.one[0].name=a&groupsMap.one[1].name=b&groupsMap.two[1].name=c' | ' "groupsMap":{ "one":[{"id":0,"name":"a"},{"id":0," name":"b"}], "two":[null,{"id":0,"name":"c"}]} '
138+ path | output | fragments
139+ ' /bean?id=1&name=sam' | ' "id":1,"name":"sam"' | null
140+ ' /bean?user.id=1&user.name=sam' | ' "id":1,"name":"sam"' | null
141+ ' /bean?name=sam&p=123&[email protected] ' |
' "email":"[email protected] ","name":"sam","phone":"123"' | null 142+ ' /bean?group.name=g1&group.owner.name=jack' | ' "group":{"id":0,"name":"g1","owner":{"name":"jack"' | null
143+ ' /bean?group.parent.parent.children[0].name=xx' | ' "group":{"id":0,"parent":{"id":0,"parent":{"children":[{"id":0,"name":"xx"}],"id":0}}}' | null
144+ ' /bean?group={"name":"g1","id":2}' | ' "group":{"id":2,"name":"g1"}' | null
145+ ' /bean?ids=3&ids=4' | ' "ids":[3,4]' | null
146+ ' /bean?ids[]=3&ids[]=4' | ' "ids":[3,4]' | null
147+ ' /bean?ids[1]=3&ids[2]=4' | ' "ids":[0,3,4]' | null
148+ ' /bean?scores=3&scores=4' | ' "scores":[3,4]' | null
149+ ' /bean?scores[]=3&scores[]=4' | ' "scores":[3,4]' | null
150+ ' /bean?scores[1]=3&scores[2]=4' | ' "scores":[null,3,4]' | null
151+ ' /bean?tags[0].name=a&tags[0].value=b&tags[1].name=c&tags[1].value=d' | ' "tags":[{"name":"a","value":"b"},{"name":"c","value":"d"}]' | null
152+ ' /bean?tagsA[0].name=a&tagsA[0].value=b&tagsA[1].name=c&tagsA[1].value=d' | ' "tagsA":[{"name":"a","value":"b"},{"name":"c","value":"d"}]' | null
153+ ' /bean?tagsB[0].name=e&tagsB[1].name=c&tagsB[1].value=d' | ' "tagsB":[{"name":"e","value":"b"},{"name":"c","value":"d"}]' | null
154+ ' /bean?tagsC[0].name=e&tagsC[1].name=c&tagsC[1].value=d' | ' "tagsC":[{"name":"e","value":"b"},{"name":"c","value":"d"}]' | null
155+ ' /bean?groupMaps[0].one.name=a&groupMaps[1].two.name=b' | ' "groupMaps":[{"one":{"id":0,"name":"a"}},{"two":{"id":0,"name":"b"}}]' | null
156+ ' /bean?id=1&features.a=xx&features.b=2' | null | [ ' "features"' , ' "a":"xx"' , ' "b":"2"' ]
157+ ' /bean?id=1&features[a]=xx&features[b]=2' | null | [ ' "features"' , ' "a":"xx"' , ' "b":"2"' ]
158+ ' /bean?group.id=2&group.features.a=1&group.features.b=xx' | null | [ ' "group"' , ' "features"' , ' "a":"1"' , ' "b":"xx"' ]
159+ ' /bean?tagMap.a.name=a&tagMap.a.value=b&tagMap.b.name=c&tagMap.b.value=d' | null | [ ' "tagMap"' , ' " name":"a"' , ' "value":"b"' , ' " name":"c"' , ' "value":"d"' ]
160+ ' /bean?tagMapA.a.name=e&tagMapA.b.name=c&tagMapA.b.value=d' | null | [ ' "tagMapA"' , ' " name":"e"' , ' "value":"b"' , ' " name":"c"' , ' "value":"d"' ]
161+ ' /bean?tagMapB[2].name=a&tagMapB[2].value=b&tagMapB[3].name=c' | null | [ ' "tagMapB"' , ' "name":"a"' , ' "value":"b"' , ' "name":"c"' ]
162+ ' /bean?groupsMap.one[0].name=a&groupsMap.one[1].name=b&groupsMap.two[1].name=c' | null | [ ' "groupsMap"' , ' "one":[{"id":0,"name":"a"}' , ' " name":"b"' , ' "two":[null,{"id":0,"name":"c"}]' ]
152163 }
153164
154165 def " bean body test" () {
0 commit comments