OLD | NEW |
| (Empty) |
1 library googleapis.groupssettings.v1.test; | |
2 | |
3 import "dart:core" as core; | |
4 import "dart:collection" as collection; | |
5 import "dart:async" as async; | |
6 import "dart:convert" as convert; | |
7 | |
8 import 'package:http/http.dart' as http; | |
9 import 'package:http/testing.dart' as http_testing; | |
10 import 'package:unittest/unittest.dart' as unittest; | |
11 import 'package:googleapis/common/common.dart' as common; | |
12 import 'package:googleapis/src/common_internal.dart' as common_internal; | |
13 import '../common/common_internal_test.dart' as common_test; | |
14 | |
15 import 'package:googleapis/groupssettings/v1.dart' as api; | |
16 | |
17 | |
18 | |
19 core.int buildCounterGroups = 0; | |
20 buildGroups() { | |
21 var o = new api.Groups(); | |
22 buildCounterGroups++; | |
23 if (buildCounterGroups < 3) { | |
24 o.allowExternalMembers = "foo"; | |
25 o.allowGoogleCommunication = "foo"; | |
26 o.allowWebPosting = "foo"; | |
27 o.archiveOnly = "foo"; | |
28 o.customReplyTo = "foo"; | |
29 o.defaultMessageDenyNotificationText = "foo"; | |
30 o.description = "foo"; | |
31 o.email = "foo"; | |
32 o.includeInGlobalAddressList = "foo"; | |
33 o.isArchived = "foo"; | |
34 o.kind = "foo"; | |
35 o.maxMessageBytes = 42; | |
36 o.membersCanPostAsTheGroup = "foo"; | |
37 o.messageDisplayFont = "foo"; | |
38 o.messageModerationLevel = "foo"; | |
39 o.name = "foo"; | |
40 o.primaryLanguage = "foo"; | |
41 o.replyTo = "foo"; | |
42 o.sendMessageDenyNotification = "foo"; | |
43 o.showInGroupDirectory = "foo"; | |
44 o.spamModerationLevel = "foo"; | |
45 o.whoCanContactOwner = "foo"; | |
46 o.whoCanInvite = "foo"; | |
47 o.whoCanJoin = "foo"; | |
48 o.whoCanLeaveGroup = "foo"; | |
49 o.whoCanPostMessage = "foo"; | |
50 o.whoCanViewGroup = "foo"; | |
51 o.whoCanViewMembership = "foo"; | |
52 } | |
53 buildCounterGroups--; | |
54 return o; | |
55 } | |
56 | |
57 checkGroups(api.Groups o) { | |
58 buildCounterGroups++; | |
59 if (buildCounterGroups < 3) { | |
60 unittest.expect(o.allowExternalMembers, unittest.equals('foo')); | |
61 unittest.expect(o.allowGoogleCommunication, unittest.equals('foo')); | |
62 unittest.expect(o.allowWebPosting, unittest.equals('foo')); | |
63 unittest.expect(o.archiveOnly, unittest.equals('foo')); | |
64 unittest.expect(o.customReplyTo, unittest.equals('foo')); | |
65 unittest.expect(o.defaultMessageDenyNotificationText, unittest.equals('foo')
); | |
66 unittest.expect(o.description, unittest.equals('foo')); | |
67 unittest.expect(o.email, unittest.equals('foo')); | |
68 unittest.expect(o.includeInGlobalAddressList, unittest.equals('foo')); | |
69 unittest.expect(o.isArchived, unittest.equals('foo')); | |
70 unittest.expect(o.kind, unittest.equals('foo')); | |
71 unittest.expect(o.maxMessageBytes, unittest.equals(42)); | |
72 unittest.expect(o.membersCanPostAsTheGroup, unittest.equals('foo')); | |
73 unittest.expect(o.messageDisplayFont, unittest.equals('foo')); | |
74 unittest.expect(o.messageModerationLevel, unittest.equals('foo')); | |
75 unittest.expect(o.name, unittest.equals('foo')); | |
76 unittest.expect(o.primaryLanguage, unittest.equals('foo')); | |
77 unittest.expect(o.replyTo, unittest.equals('foo')); | |
78 unittest.expect(o.sendMessageDenyNotification, unittest.equals('foo')); | |
79 unittest.expect(o.showInGroupDirectory, unittest.equals('foo')); | |
80 unittest.expect(o.spamModerationLevel, unittest.equals('foo')); | |
81 unittest.expect(o.whoCanContactOwner, unittest.equals('foo')); | |
82 unittest.expect(o.whoCanInvite, unittest.equals('foo')); | |
83 unittest.expect(o.whoCanJoin, unittest.equals('foo')); | |
84 unittest.expect(o.whoCanLeaveGroup, unittest.equals('foo')); | |
85 unittest.expect(o.whoCanPostMessage, unittest.equals('foo')); | |
86 unittest.expect(o.whoCanViewGroup, unittest.equals('foo')); | |
87 unittest.expect(o.whoCanViewMembership, unittest.equals('foo')); | |
88 } | |
89 buildCounterGroups--; | |
90 } | |
91 | |
92 | |
93 main() { | |
94 unittest.group("obj-schema-Groups", () { | |
95 unittest.test("to-json--from-json", () { | |
96 var o = buildGroups(); | |
97 var od = new api.Groups.fromJson(o.toJson()); | |
98 checkGroups(od); | |
99 }); | |
100 }); | |
101 | |
102 | |
103 unittest.group("resource-GroupsResourceApi", () { | |
104 unittest.test("method--get", () { | |
105 | |
106 var mock = new common_test.HttpServerMock(); | |
107 api.GroupsResourceApi res = new api.GroupssettingsApi(mock).groups; | |
108 var arg_groupUniqueId = "foo"; | |
109 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
110 var path = (req.url).path; | |
111 var pathOffset = 0; | |
112 var index; | |
113 var subPart; | |
114 unittest.expect(path.substring(pathOffset, pathOffset + 18), unittest.eq
uals("/groups/v1/groups/")); | |
115 pathOffset += 18; | |
116 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); | |
117 pathOffset = path.length; | |
118 unittest.expect(subPart, unittest.equals("$arg_groupUniqueId")); | |
119 | |
120 var query = (req.url).query; | |
121 var queryOffset = 0; | |
122 var queryMap = {}; | |
123 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
124 parseBool(n) { | |
125 if (n == "true") return true; | |
126 if (n == "false") return false; | |
127 if (n == null) return null; | |
128 throw new core.ArgumentError("Invalid boolean: $n"); | |
129 } | |
130 if (query.length > 0) { | |
131 for (var part in query.split("&")) { | |
132 var keyvalue = part.split("="); | |
133 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
134 } | |
135 } | |
136 | |
137 | |
138 var h = { | |
139 "content-type" : "application/json; charset=utf-8", | |
140 }; | |
141 var resp = convert.JSON.encode(buildGroups()); | |
142 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
143 }), true); | |
144 res.get(arg_groupUniqueId).then(unittest.expectAsync(((api.Groups response
) { | |
145 checkGroups(response); | |
146 }))); | |
147 }); | |
148 | |
149 unittest.test("method--patch", () { | |
150 | |
151 var mock = new common_test.HttpServerMock(); | |
152 api.GroupsResourceApi res = new api.GroupssettingsApi(mock).groups; | |
153 var arg_request = buildGroups(); | |
154 var arg_groupUniqueId = "foo"; | |
155 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
156 var obj = new api.Groups.fromJson(json); | |
157 checkGroups(obj); | |
158 | |
159 var path = (req.url).path; | |
160 var pathOffset = 0; | |
161 var index; | |
162 var subPart; | |
163 unittest.expect(path.substring(pathOffset, pathOffset + 18), unittest.eq
uals("/groups/v1/groups/")); | |
164 pathOffset += 18; | |
165 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); | |
166 pathOffset = path.length; | |
167 unittest.expect(subPart, unittest.equals("$arg_groupUniqueId")); | |
168 | |
169 var query = (req.url).query; | |
170 var queryOffset = 0; | |
171 var queryMap = {}; | |
172 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
173 parseBool(n) { | |
174 if (n == "true") return true; | |
175 if (n == "false") return false; | |
176 if (n == null) return null; | |
177 throw new core.ArgumentError("Invalid boolean: $n"); | |
178 } | |
179 if (query.length > 0) { | |
180 for (var part in query.split("&")) { | |
181 var keyvalue = part.split("="); | |
182 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
183 } | |
184 } | |
185 | |
186 | |
187 var h = { | |
188 "content-type" : "application/json; charset=utf-8", | |
189 }; | |
190 var resp = convert.JSON.encode(buildGroups()); | |
191 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
192 }), true); | |
193 res.patch(arg_request, arg_groupUniqueId).then(unittest.expectAsync(((api.
Groups response) { | |
194 checkGroups(response); | |
195 }))); | |
196 }); | |
197 | |
198 unittest.test("method--update", () { | |
199 | |
200 var mock = new common_test.HttpServerMock(); | |
201 api.GroupsResourceApi res = new api.GroupssettingsApi(mock).groups; | |
202 var arg_request = buildGroups(); | |
203 var arg_groupUniqueId = "foo"; | |
204 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
205 var obj = new api.Groups.fromJson(json); | |
206 checkGroups(obj); | |
207 | |
208 var path = (req.url).path; | |
209 var pathOffset = 0; | |
210 var index; | |
211 var subPart; | |
212 unittest.expect(path.substring(pathOffset, pathOffset + 18), unittest.eq
uals("/groups/v1/groups/")); | |
213 pathOffset += 18; | |
214 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); | |
215 pathOffset = path.length; | |
216 unittest.expect(subPart, unittest.equals("$arg_groupUniqueId")); | |
217 | |
218 var query = (req.url).query; | |
219 var queryOffset = 0; | |
220 var queryMap = {}; | |
221 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
222 parseBool(n) { | |
223 if (n == "true") return true; | |
224 if (n == "false") return false; | |
225 if (n == null) return null; | |
226 throw new core.ArgumentError("Invalid boolean: $n"); | |
227 } | |
228 if (query.length > 0) { | |
229 for (var part in query.split("&")) { | |
230 var keyvalue = part.split("="); | |
231 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
232 } | |
233 } | |
234 | |
235 | |
236 var h = { | |
237 "content-type" : "application/json; charset=utf-8", | |
238 }; | |
239 var resp = convert.JSON.encode(buildGroups()); | |
240 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
241 }), true); | |
242 res.update(arg_request, arg_groupUniqueId).then(unittest.expectAsync(((api
.Groups response) { | |
243 checkGroups(response); | |
244 }))); | |
245 }); | |
246 | |
247 }); | |
248 | |
249 | |
250 } | |
251 | |
OLD | NEW |