OLD | NEW |
1 library googleapis.appsactivity.v1.test; | 1 library googleapis.appsactivity.v1.test; |
2 | 2 |
3 import "dart:core" as core; | 3 import "dart:core" as core; |
4 import "dart:collection" as collection; | |
5 import "dart:async" as async; | 4 import "dart:async" as async; |
6 import "dart:convert" as convert; | 5 import "dart:convert" as convert; |
7 | 6 |
8 import 'package:http/http.dart' as http; | 7 import 'package:http/http.dart' as http; |
9 import 'package:http/testing.dart' as http_testing; | |
10 import 'package:test/test.dart' as unittest; | 8 import 'package:test/test.dart' as unittest; |
11 | 9 |
12 import 'package:googleapis/appsactivity/v1.dart' as api; | 10 import 'package:googleapis/appsactivity/v1.dart' as api; |
13 | 11 |
14 class HttpServerMock extends http.BaseClient { | 12 class HttpServerMock extends http.BaseClient { |
15 core.Function _callback; | 13 core.Function _callback; |
16 core.bool _expectJson; | 14 core.bool _expectJson; |
17 | 15 |
18 void register(core.Function callback, core.bool expectJson) { | 16 void register(core.Function callback, core.bool expectJson) { |
19 _callback = callback; | 17 _callback = callback; |
20 _expectJson = expectJson; | 18 _expectJson = expectJson; |
21 } | 19 } |
22 | 20 |
23 async.Future<http.StreamedResponse> send(http.BaseRequest request) { | 21 async.Future<http.StreamedResponse> send(http.BaseRequest request) { |
24 if (_expectJson) { | 22 if (_expectJson) { |
25 return request.finalize() | 23 return request |
| 24 .finalize() |
26 .transform(convert.UTF8.decoder) | 25 .transform(convert.UTF8.decoder) |
27 .join('') | 26 .join('') |
28 .then((core.String jsonString) { | 27 .then((core.String jsonString) { |
29 if (jsonString.isEmpty) { | 28 if (jsonString.isEmpty) { |
30 return _callback(request, null); | 29 return _callback(request, null); |
31 } else { | 30 } else { |
32 return _callback(request, convert.JSON.decode(jsonString)); | 31 return _callback(request, convert.JSON.decode(jsonString)); |
33 } | 32 } |
34 }); | 33 }); |
35 } else { | 34 } else { |
36 var stream = request.finalize(); | 35 var stream = request.finalize(); |
37 if (stream == null) { | 36 if (stream == null) { |
38 return _callback(request, []); | 37 return _callback(request, []); |
39 } else { | 38 } else { |
40 return stream.toBytes().then((data) { | 39 return stream.toBytes().then((data) { |
41 return _callback(request, data); | 40 return _callback(request, data); |
42 }); | 41 }); |
43 } | 42 } |
44 } | 43 } |
45 } | 44 } |
46 } | 45 } |
47 | 46 |
48 http.StreamedResponse stringResponse( | 47 http.StreamedResponse stringResponse(core.int status, |
49 core.int status, core.Map<core.String, core.String> headers, core.String bod
y) { | 48 core.Map<core.String, core.String> headers, core.String body) { |
50 var stream = new async.Stream.fromIterable([convert.UTF8.encode(body)]); | 49 var stream = new async.Stream.fromIterable([convert.UTF8.encode(body)]); |
51 return new http.StreamedResponse(stream, status, headers: headers); | 50 return new http.StreamedResponse(stream, status, headers: headers); |
52 } | 51 } |
53 | 52 |
54 buildUnnamed1096() { | 53 buildUnnamed1099() { |
55 var o = new core.List<api.Event>(); | 54 var o = new core.List<api.Event>(); |
56 o.add(buildEvent()); | 55 o.add(buildEvent()); |
57 o.add(buildEvent()); | 56 o.add(buildEvent()); |
58 return o; | 57 return o; |
59 } | 58 } |
60 | 59 |
61 checkUnnamed1096(core.List<api.Event> o) { | 60 checkUnnamed1099(core.List<api.Event> o) { |
62 unittest.expect(o, unittest.hasLength(2)); | 61 unittest.expect(o, unittest.hasLength(2)); |
63 checkEvent(o[0]); | 62 checkEvent(o[0]); |
64 checkEvent(o[1]); | 63 checkEvent(o[1]); |
65 } | 64 } |
66 | 65 |
67 core.int buildCounterActivity = 0; | 66 core.int buildCounterActivity = 0; |
68 buildActivity() { | 67 buildActivity() { |
69 var o = new api.Activity(); | 68 var o = new api.Activity(); |
70 buildCounterActivity++; | 69 buildCounterActivity++; |
71 if (buildCounterActivity < 3) { | 70 if (buildCounterActivity < 3) { |
72 o.combinedEvent = buildEvent(); | 71 o.combinedEvent = buildEvent(); |
73 o.singleEvents = buildUnnamed1096(); | 72 o.singleEvents = buildUnnamed1099(); |
74 } | 73 } |
75 buildCounterActivity--; | 74 buildCounterActivity--; |
76 return o; | 75 return o; |
77 } | 76 } |
78 | 77 |
79 checkActivity(api.Activity o) { | 78 checkActivity(api.Activity o) { |
80 buildCounterActivity++; | 79 buildCounterActivity++; |
81 if (buildCounterActivity < 3) { | 80 if (buildCounterActivity < 3) { |
82 checkEvent(o.combinedEvent); | 81 checkEvent(o.combinedEvent); |
83 checkUnnamed1096(o.singleEvents); | 82 checkUnnamed1099(o.singleEvents); |
84 } | 83 } |
85 buildCounterActivity--; | 84 buildCounterActivity--; |
86 } | 85 } |
87 | 86 |
88 buildUnnamed1097() { | 87 buildUnnamed1100() { |
89 var o = new core.List<core.String>(); | 88 var o = new core.List<core.String>(); |
90 o.add("foo"); | 89 o.add("foo"); |
91 o.add("foo"); | 90 o.add("foo"); |
92 return o; | 91 return o; |
93 } | 92 } |
94 | 93 |
95 checkUnnamed1097(core.List<core.String> o) { | 94 checkUnnamed1100(core.List<core.String> o) { |
96 unittest.expect(o, unittest.hasLength(2)); | 95 unittest.expect(o, unittest.hasLength(2)); |
97 unittest.expect(o[0], unittest.equals('foo')); | 96 unittest.expect(o[0], unittest.equals('foo')); |
98 unittest.expect(o[1], unittest.equals('foo')); | 97 unittest.expect(o[1], unittest.equals('foo')); |
99 } | 98 } |
100 | 99 |
101 buildUnnamed1098() { | 100 buildUnnamed1101() { |
102 var o = new core.List<api.PermissionChange>(); | 101 var o = new core.List<api.PermissionChange>(); |
103 o.add(buildPermissionChange()); | 102 o.add(buildPermissionChange()); |
104 o.add(buildPermissionChange()); | 103 o.add(buildPermissionChange()); |
105 return o; | 104 return o; |
106 } | 105 } |
107 | 106 |
108 checkUnnamed1098(core.List<api.PermissionChange> o) { | 107 checkUnnamed1101(core.List<api.PermissionChange> o) { |
109 unittest.expect(o, unittest.hasLength(2)); | 108 unittest.expect(o, unittest.hasLength(2)); |
110 checkPermissionChange(o[0]); | 109 checkPermissionChange(o[0]); |
111 checkPermissionChange(o[1]); | 110 checkPermissionChange(o[1]); |
112 } | 111 } |
113 | 112 |
114 core.int buildCounterEvent = 0; | 113 core.int buildCounterEvent = 0; |
115 buildEvent() { | 114 buildEvent() { |
116 var o = new api.Event(); | 115 var o = new api.Event(); |
117 buildCounterEvent++; | 116 buildCounterEvent++; |
118 if (buildCounterEvent < 3) { | 117 if (buildCounterEvent < 3) { |
119 o.additionalEventTypes = buildUnnamed1097(); | 118 o.additionalEventTypes = buildUnnamed1100(); |
120 o.eventTimeMillis = "foo"; | 119 o.eventTimeMillis = "foo"; |
121 o.fromUserDeletion = true; | 120 o.fromUserDeletion = true; |
122 o.move = buildMove(); | 121 o.move = buildMove(); |
123 o.permissionChanges = buildUnnamed1098(); | 122 o.permissionChanges = buildUnnamed1101(); |
124 o.primaryEventType = "foo"; | 123 o.primaryEventType = "foo"; |
125 o.rename = buildRename(); | 124 o.rename = buildRename(); |
126 o.target = buildTarget(); | 125 o.target = buildTarget(); |
127 o.user = buildUser(); | 126 o.user = buildUser(); |
128 } | 127 } |
129 buildCounterEvent--; | 128 buildCounterEvent--; |
130 return o; | 129 return o; |
131 } | 130 } |
132 | 131 |
133 checkEvent(api.Event o) { | 132 checkEvent(api.Event o) { |
134 buildCounterEvent++; | 133 buildCounterEvent++; |
135 if (buildCounterEvent < 3) { | 134 if (buildCounterEvent < 3) { |
136 checkUnnamed1097(o.additionalEventTypes); | 135 checkUnnamed1100(o.additionalEventTypes); |
137 unittest.expect(o.eventTimeMillis, unittest.equals('foo')); | 136 unittest.expect(o.eventTimeMillis, unittest.equals('foo')); |
138 unittest.expect(o.fromUserDeletion, unittest.isTrue); | 137 unittest.expect(o.fromUserDeletion, unittest.isTrue); |
139 checkMove(o.move); | 138 checkMove(o.move); |
140 checkUnnamed1098(o.permissionChanges); | 139 checkUnnamed1101(o.permissionChanges); |
141 unittest.expect(o.primaryEventType, unittest.equals('foo')); | 140 unittest.expect(o.primaryEventType, unittest.equals('foo')); |
142 checkRename(o.rename); | 141 checkRename(o.rename); |
143 checkTarget(o.target); | 142 checkTarget(o.target); |
144 checkUser(o.user); | 143 checkUser(o.user); |
145 } | 144 } |
146 buildCounterEvent--; | 145 buildCounterEvent--; |
147 } | 146 } |
148 | 147 |
149 buildUnnamed1099() { | 148 buildUnnamed1102() { |
150 var o = new core.List<api.Activity>(); | 149 var o = new core.List<api.Activity>(); |
151 o.add(buildActivity()); | 150 o.add(buildActivity()); |
152 o.add(buildActivity()); | 151 o.add(buildActivity()); |
153 return o; | 152 return o; |
154 } | 153 } |
155 | 154 |
156 checkUnnamed1099(core.List<api.Activity> o) { | 155 checkUnnamed1102(core.List<api.Activity> o) { |
157 unittest.expect(o, unittest.hasLength(2)); | 156 unittest.expect(o, unittest.hasLength(2)); |
158 checkActivity(o[0]); | 157 checkActivity(o[0]); |
159 checkActivity(o[1]); | 158 checkActivity(o[1]); |
160 } | 159 } |
161 | 160 |
162 core.int buildCounterListActivitiesResponse = 0; | 161 core.int buildCounterListActivitiesResponse = 0; |
163 buildListActivitiesResponse() { | 162 buildListActivitiesResponse() { |
164 var o = new api.ListActivitiesResponse(); | 163 var o = new api.ListActivitiesResponse(); |
165 buildCounterListActivitiesResponse++; | 164 buildCounterListActivitiesResponse++; |
166 if (buildCounterListActivitiesResponse < 3) { | 165 if (buildCounterListActivitiesResponse < 3) { |
167 o.activities = buildUnnamed1099(); | 166 o.activities = buildUnnamed1102(); |
168 o.nextPageToken = "foo"; | 167 o.nextPageToken = "foo"; |
169 } | 168 } |
170 buildCounterListActivitiesResponse--; | 169 buildCounterListActivitiesResponse--; |
171 return o; | 170 return o; |
172 } | 171 } |
173 | 172 |
174 checkListActivitiesResponse(api.ListActivitiesResponse o) { | 173 checkListActivitiesResponse(api.ListActivitiesResponse o) { |
175 buildCounterListActivitiesResponse++; | 174 buildCounterListActivitiesResponse++; |
176 if (buildCounterListActivitiesResponse < 3) { | 175 if (buildCounterListActivitiesResponse < 3) { |
177 checkUnnamed1099(o.activities); | 176 checkUnnamed1102(o.activities); |
178 unittest.expect(o.nextPageToken, unittest.equals('foo')); | 177 unittest.expect(o.nextPageToken, unittest.equals('foo')); |
179 } | 178 } |
180 buildCounterListActivitiesResponse--; | 179 buildCounterListActivitiesResponse--; |
181 } | 180 } |
182 | 181 |
183 buildUnnamed1100() { | 182 buildUnnamed1103() { |
184 var o = new core.List<api.Parent>(); | 183 var o = new core.List<api.Parent>(); |
185 o.add(buildParent()); | 184 o.add(buildParent()); |
186 o.add(buildParent()); | 185 o.add(buildParent()); |
187 return o; | 186 return o; |
188 } | 187 } |
189 | 188 |
190 checkUnnamed1100(core.List<api.Parent> o) { | 189 checkUnnamed1103(core.List<api.Parent> o) { |
191 unittest.expect(o, unittest.hasLength(2)); | 190 unittest.expect(o, unittest.hasLength(2)); |
192 checkParent(o[0]); | 191 checkParent(o[0]); |
193 checkParent(o[1]); | 192 checkParent(o[1]); |
194 } | 193 } |
195 | 194 |
196 buildUnnamed1101() { | 195 buildUnnamed1104() { |
197 var o = new core.List<api.Parent>(); | 196 var o = new core.List<api.Parent>(); |
198 o.add(buildParent()); | 197 o.add(buildParent()); |
199 o.add(buildParent()); | 198 o.add(buildParent()); |
200 return o; | 199 return o; |
201 } | 200 } |
202 | 201 |
203 checkUnnamed1101(core.List<api.Parent> o) { | 202 checkUnnamed1104(core.List<api.Parent> o) { |
204 unittest.expect(o, unittest.hasLength(2)); | 203 unittest.expect(o, unittest.hasLength(2)); |
205 checkParent(o[0]); | 204 checkParent(o[0]); |
206 checkParent(o[1]); | 205 checkParent(o[1]); |
207 } | 206 } |
208 | 207 |
209 core.int buildCounterMove = 0; | 208 core.int buildCounterMove = 0; |
210 buildMove() { | 209 buildMove() { |
211 var o = new api.Move(); | 210 var o = new api.Move(); |
212 buildCounterMove++; | 211 buildCounterMove++; |
213 if (buildCounterMove < 3) { | 212 if (buildCounterMove < 3) { |
214 o.addedParents = buildUnnamed1100(); | 213 o.addedParents = buildUnnamed1103(); |
215 o.removedParents = buildUnnamed1101(); | 214 o.removedParents = buildUnnamed1104(); |
216 } | 215 } |
217 buildCounterMove--; | 216 buildCounterMove--; |
218 return o; | 217 return o; |
219 } | 218 } |
220 | 219 |
221 checkMove(api.Move o) { | 220 checkMove(api.Move o) { |
222 buildCounterMove++; | 221 buildCounterMove++; |
223 if (buildCounterMove < 3) { | 222 if (buildCounterMove < 3) { |
224 checkUnnamed1100(o.addedParents); | 223 checkUnnamed1103(o.addedParents); |
225 checkUnnamed1101(o.removedParents); | 224 checkUnnamed1104(o.removedParents); |
226 } | 225 } |
227 buildCounterMove--; | 226 buildCounterMove--; |
228 } | 227 } |
229 | 228 |
230 core.int buildCounterParent = 0; | 229 core.int buildCounterParent = 0; |
231 buildParent() { | 230 buildParent() { |
232 var o = new api.Parent(); | 231 var o = new api.Parent(); |
233 buildCounterParent++; | 232 buildCounterParent++; |
234 if (buildCounterParent < 3) { | 233 if (buildCounterParent < 3) { |
235 o.id = "foo"; | 234 o.id = "foo"; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 unittest.expect(o.name, unittest.equals('foo')); | 271 unittest.expect(o.name, unittest.equals('foo')); |
273 unittest.expect(o.permissionId, unittest.equals('foo')); | 272 unittest.expect(o.permissionId, unittest.equals('foo')); |
274 unittest.expect(o.role, unittest.equals('foo')); | 273 unittest.expect(o.role, unittest.equals('foo')); |
275 unittest.expect(o.type, unittest.equals('foo')); | 274 unittest.expect(o.type, unittest.equals('foo')); |
276 checkUser(o.user); | 275 checkUser(o.user); |
277 unittest.expect(o.withLink, unittest.isTrue); | 276 unittest.expect(o.withLink, unittest.isTrue); |
278 } | 277 } |
279 buildCounterPermission--; | 278 buildCounterPermission--; |
280 } | 279 } |
281 | 280 |
282 buildUnnamed1102() { | 281 buildUnnamed1105() { |
283 var o = new core.List<api.Permission>(); | 282 var o = new core.List<api.Permission>(); |
284 o.add(buildPermission()); | 283 o.add(buildPermission()); |
285 o.add(buildPermission()); | 284 o.add(buildPermission()); |
286 return o; | 285 return o; |
287 } | 286 } |
288 | 287 |
289 checkUnnamed1102(core.List<api.Permission> o) { | 288 checkUnnamed1105(core.List<api.Permission> o) { |
290 unittest.expect(o, unittest.hasLength(2)); | 289 unittest.expect(o, unittest.hasLength(2)); |
291 checkPermission(o[0]); | 290 checkPermission(o[0]); |
292 checkPermission(o[1]); | 291 checkPermission(o[1]); |
293 } | 292 } |
294 | 293 |
295 buildUnnamed1103() { | 294 buildUnnamed1106() { |
296 var o = new core.List<api.Permission>(); | 295 var o = new core.List<api.Permission>(); |
297 o.add(buildPermission()); | 296 o.add(buildPermission()); |
298 o.add(buildPermission()); | 297 o.add(buildPermission()); |
299 return o; | 298 return o; |
300 } | 299 } |
301 | 300 |
302 checkUnnamed1103(core.List<api.Permission> o) { | 301 checkUnnamed1106(core.List<api.Permission> o) { |
303 unittest.expect(o, unittest.hasLength(2)); | 302 unittest.expect(o, unittest.hasLength(2)); |
304 checkPermission(o[0]); | 303 checkPermission(o[0]); |
305 checkPermission(o[1]); | 304 checkPermission(o[1]); |
306 } | 305 } |
307 | 306 |
308 core.int buildCounterPermissionChange = 0; | 307 core.int buildCounterPermissionChange = 0; |
309 buildPermissionChange() { | 308 buildPermissionChange() { |
310 var o = new api.PermissionChange(); | 309 var o = new api.PermissionChange(); |
311 buildCounterPermissionChange++; | 310 buildCounterPermissionChange++; |
312 if (buildCounterPermissionChange < 3) { | 311 if (buildCounterPermissionChange < 3) { |
313 o.addedPermissions = buildUnnamed1102(); | 312 o.addedPermissions = buildUnnamed1105(); |
314 o.removedPermissions = buildUnnamed1103(); | 313 o.removedPermissions = buildUnnamed1106(); |
315 } | 314 } |
316 buildCounterPermissionChange--; | 315 buildCounterPermissionChange--; |
317 return o; | 316 return o; |
318 } | 317 } |
319 | 318 |
320 checkPermissionChange(api.PermissionChange o) { | 319 checkPermissionChange(api.PermissionChange o) { |
321 buildCounterPermissionChange++; | 320 buildCounterPermissionChange++; |
322 if (buildCounterPermissionChange < 3) { | 321 if (buildCounterPermissionChange < 3) { |
323 checkUnnamed1102(o.addedPermissions); | 322 checkUnnamed1105(o.addedPermissions); |
324 checkUnnamed1103(o.removedPermissions); | 323 checkUnnamed1106(o.removedPermissions); |
325 } | 324 } |
326 buildCounterPermissionChange--; | 325 buildCounterPermissionChange--; |
327 } | 326 } |
328 | 327 |
329 core.int buildCounterPhoto = 0; | 328 core.int buildCounterPhoto = 0; |
330 buildPhoto() { | 329 buildPhoto() { |
331 var o = new api.Photo(); | 330 var o = new api.Photo(); |
332 buildCounterPhoto++; | 331 buildCounterPhoto++; |
333 if (buildCounterPhoto < 3) { | 332 if (buildCounterPhoto < 3) { |
334 o.url = "foo"; | 333 o.url = "foo"; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 if (buildCounterUser < 3) { | 408 if (buildCounterUser < 3) { |
410 unittest.expect(o.isDeleted, unittest.isTrue); | 409 unittest.expect(o.isDeleted, unittest.isTrue); |
411 unittest.expect(o.isMe, unittest.isTrue); | 410 unittest.expect(o.isMe, unittest.isTrue); |
412 unittest.expect(o.name, unittest.equals('foo')); | 411 unittest.expect(o.name, unittest.equals('foo')); |
413 unittest.expect(o.permissionId, unittest.equals('foo')); | 412 unittest.expect(o.permissionId, unittest.equals('foo')); |
414 checkPhoto(o.photo); | 413 checkPhoto(o.photo); |
415 } | 414 } |
416 buildCounterUser--; | 415 buildCounterUser--; |
417 } | 416 } |
418 | 417 |
419 | |
420 main() { | 418 main() { |
421 unittest.group("obj-schema-Activity", () { | 419 unittest.group("obj-schema-Activity", () { |
422 unittest.test("to-json--from-json", () { | 420 unittest.test("to-json--from-json", () { |
423 var o = buildActivity(); | 421 var o = buildActivity(); |
424 var od = new api.Activity.fromJson(o.toJson()); | 422 var od = new api.Activity.fromJson(o.toJson()); |
425 checkActivity(od); | 423 checkActivity(od); |
426 }); | 424 }); |
427 }); | 425 }); |
428 | 426 |
429 | |
430 unittest.group("obj-schema-Event", () { | 427 unittest.group("obj-schema-Event", () { |
431 unittest.test("to-json--from-json", () { | 428 unittest.test("to-json--from-json", () { |
432 var o = buildEvent(); | 429 var o = buildEvent(); |
433 var od = new api.Event.fromJson(o.toJson()); | 430 var od = new api.Event.fromJson(o.toJson()); |
434 checkEvent(od); | 431 checkEvent(od); |
435 }); | 432 }); |
436 }); | 433 }); |
437 | 434 |
438 | |
439 unittest.group("obj-schema-ListActivitiesResponse", () { | 435 unittest.group("obj-schema-ListActivitiesResponse", () { |
440 unittest.test("to-json--from-json", () { | 436 unittest.test("to-json--from-json", () { |
441 var o = buildListActivitiesResponse(); | 437 var o = buildListActivitiesResponse(); |
442 var od = new api.ListActivitiesResponse.fromJson(o.toJson()); | 438 var od = new api.ListActivitiesResponse.fromJson(o.toJson()); |
443 checkListActivitiesResponse(od); | 439 checkListActivitiesResponse(od); |
444 }); | 440 }); |
445 }); | 441 }); |
446 | 442 |
447 | |
448 unittest.group("obj-schema-Move", () { | 443 unittest.group("obj-schema-Move", () { |
449 unittest.test("to-json--from-json", () { | 444 unittest.test("to-json--from-json", () { |
450 var o = buildMove(); | 445 var o = buildMove(); |
451 var od = new api.Move.fromJson(o.toJson()); | 446 var od = new api.Move.fromJson(o.toJson()); |
452 checkMove(od); | 447 checkMove(od); |
453 }); | 448 }); |
454 }); | 449 }); |
455 | 450 |
456 | |
457 unittest.group("obj-schema-Parent", () { | 451 unittest.group("obj-schema-Parent", () { |
458 unittest.test("to-json--from-json", () { | 452 unittest.test("to-json--from-json", () { |
459 var o = buildParent(); | 453 var o = buildParent(); |
460 var od = new api.Parent.fromJson(o.toJson()); | 454 var od = new api.Parent.fromJson(o.toJson()); |
461 checkParent(od); | 455 checkParent(od); |
462 }); | 456 }); |
463 }); | 457 }); |
464 | 458 |
465 | |
466 unittest.group("obj-schema-Permission", () { | 459 unittest.group("obj-schema-Permission", () { |
467 unittest.test("to-json--from-json", () { | 460 unittest.test("to-json--from-json", () { |
468 var o = buildPermission(); | 461 var o = buildPermission(); |
469 var od = new api.Permission.fromJson(o.toJson()); | 462 var od = new api.Permission.fromJson(o.toJson()); |
470 checkPermission(od); | 463 checkPermission(od); |
471 }); | 464 }); |
472 }); | 465 }); |
473 | 466 |
474 | |
475 unittest.group("obj-schema-PermissionChange", () { | 467 unittest.group("obj-schema-PermissionChange", () { |
476 unittest.test("to-json--from-json", () { | 468 unittest.test("to-json--from-json", () { |
477 var o = buildPermissionChange(); | 469 var o = buildPermissionChange(); |
478 var od = new api.PermissionChange.fromJson(o.toJson()); | 470 var od = new api.PermissionChange.fromJson(o.toJson()); |
479 checkPermissionChange(od); | 471 checkPermissionChange(od); |
480 }); | 472 }); |
481 }); | 473 }); |
482 | 474 |
483 | |
484 unittest.group("obj-schema-Photo", () { | 475 unittest.group("obj-schema-Photo", () { |
485 unittest.test("to-json--from-json", () { | 476 unittest.test("to-json--from-json", () { |
486 var o = buildPhoto(); | 477 var o = buildPhoto(); |
487 var od = new api.Photo.fromJson(o.toJson()); | 478 var od = new api.Photo.fromJson(o.toJson()); |
488 checkPhoto(od); | 479 checkPhoto(od); |
489 }); | 480 }); |
490 }); | 481 }); |
491 | 482 |
492 | |
493 unittest.group("obj-schema-Rename", () { | 483 unittest.group("obj-schema-Rename", () { |
494 unittest.test("to-json--from-json", () { | 484 unittest.test("to-json--from-json", () { |
495 var o = buildRename(); | 485 var o = buildRename(); |
496 var od = new api.Rename.fromJson(o.toJson()); | 486 var od = new api.Rename.fromJson(o.toJson()); |
497 checkRename(od); | 487 checkRename(od); |
498 }); | 488 }); |
499 }); | 489 }); |
500 | 490 |
501 | |
502 unittest.group("obj-schema-Target", () { | 491 unittest.group("obj-schema-Target", () { |
503 unittest.test("to-json--from-json", () { | 492 unittest.test("to-json--from-json", () { |
504 var o = buildTarget(); | 493 var o = buildTarget(); |
505 var od = new api.Target.fromJson(o.toJson()); | 494 var od = new api.Target.fromJson(o.toJson()); |
506 checkTarget(od); | 495 checkTarget(od); |
507 }); | 496 }); |
508 }); | 497 }); |
509 | 498 |
510 | |
511 unittest.group("obj-schema-User", () { | 499 unittest.group("obj-schema-User", () { |
512 unittest.test("to-json--from-json", () { | 500 unittest.test("to-json--from-json", () { |
513 var o = buildUser(); | 501 var o = buildUser(); |
514 var od = new api.User.fromJson(o.toJson()); | 502 var od = new api.User.fromJson(o.toJson()); |
515 checkUser(od); | 503 checkUser(od); |
516 }); | 504 }); |
517 }); | 505 }); |
518 | 506 |
519 | |
520 unittest.group("resource-ActivitiesResourceApi", () { | 507 unittest.group("resource-ActivitiesResourceApi", () { |
521 unittest.test("method--list", () { | 508 unittest.test("method--list", () { |
522 | |
523 var mock = new HttpServerMock(); | 509 var mock = new HttpServerMock(); |
524 api.ActivitiesResourceApi res = new api.AppsactivityApi(mock).activities; | 510 api.ActivitiesResourceApi res = new api.AppsactivityApi(mock).activities; |
525 var arg_drive_ancestorId = "foo"; | 511 var arg_drive_ancestorId = "foo"; |
526 var arg_drive_fileId = "foo"; | 512 var arg_drive_fileId = "foo"; |
527 var arg_groupingStrategy = "foo"; | 513 var arg_groupingStrategy = "foo"; |
528 var arg_pageSize = 42; | 514 var arg_pageSize = 42; |
529 var arg_pageToken = "foo"; | 515 var arg_pageToken = "foo"; |
530 var arg_source = "foo"; | 516 var arg_source = "foo"; |
531 var arg_userId = "foo"; | 517 var arg_userId = "foo"; |
532 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 518 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
533 var path = (req.url).path; | 519 var path = (req.url).path; |
534 var pathOffset = 0; | 520 var pathOffset = 0; |
535 var index; | 521 var index; |
536 var subPart; | 522 var subPart; |
537 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 523 unittest.expect( |
| 524 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
538 pathOffset += 1; | 525 pathOffset += 1; |
539 unittest.expect(path.substring(pathOffset, pathOffset + 16), unittest.eq
uals("appsactivity/v1/")); | 526 unittest.expect(path.substring(pathOffset, pathOffset + 16), |
| 527 unittest.equals("appsactivity/v1/")); |
540 pathOffset += 16; | 528 pathOffset += 16; |
541 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("activities")); | 529 unittest.expect(path.substring(pathOffset, pathOffset + 10), |
| 530 unittest.equals("activities")); |
542 pathOffset += 10; | 531 pathOffset += 10; |
543 | 532 |
544 var query = (req.url).query; | 533 var query = (req.url).query; |
545 var queryOffset = 0; | 534 var queryOffset = 0; |
546 var queryMap = {}; | 535 var queryMap = {}; |
547 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 536 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
548 parseBool(n) { | 537 parseBool(n) { |
549 if (n == "true") return true; | 538 if (n == "true") return true; |
550 if (n == "false") return false; | 539 if (n == "false") return false; |
551 if (n == null) return null; | 540 if (n == null) return null; |
552 throw new core.ArgumentError("Invalid boolean: $n"); | 541 throw new core.ArgumentError("Invalid boolean: $n"); |
553 } | 542 } |
| 543 |
554 if (query.length > 0) { | 544 if (query.length > 0) { |
555 for (var part in query.split("&")) { | 545 for (var part in query.split("&")) { |
556 var keyvalue = part.split("="); | 546 var keyvalue = part.split("="); |
557 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 547 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 548 core.Uri.decodeQueryComponent(keyvalue[1])); |
558 } | 549 } |
559 } | 550 } |
560 unittest.expect(queryMap["drive.ancestorId"].first, unittest.equals(arg_
drive_ancestorId)); | 551 unittest.expect(queryMap["drive.ancestorId"].first, |
561 unittest.expect(queryMap["drive.fileId"].first, unittest.equals(arg_driv
e_fileId)); | 552 unittest.equals(arg_drive_ancestorId)); |
562 unittest.expect(queryMap["groupingStrategy"].first, unittest.equals(arg_
groupingStrategy)); | 553 unittest.expect( |
563 unittest.expect(core.int.parse(queryMap["pageSize"].first), unittest.equ
als(arg_pageSize)); | 554 queryMap["drive.fileId"].first, unittest.equals(arg_drive_fileId)); |
564 unittest.expect(queryMap["pageToken"].first, unittest.equals(arg_pageTok
en)); | 555 unittest.expect(queryMap["groupingStrategy"].first, |
| 556 unittest.equals(arg_groupingStrategy)); |
| 557 unittest.expect(core.int.parse(queryMap["pageSize"].first), |
| 558 unittest.equals(arg_pageSize)); |
| 559 unittest.expect( |
| 560 queryMap["pageToken"].first, unittest.equals(arg_pageToken)); |
565 unittest.expect(queryMap["source"].first, unittest.equals(arg_source)); | 561 unittest.expect(queryMap["source"].first, unittest.equals(arg_source)); |
566 unittest.expect(queryMap["userId"].first, unittest.equals(arg_userId)); | 562 unittest.expect(queryMap["userId"].first, unittest.equals(arg_userId)); |
567 | 563 |
568 | |
569 var h = { | 564 var h = { |
570 "content-type" : "application/json; charset=utf-8", | 565 "content-type": "application/json; charset=utf-8", |
571 }; | 566 }; |
572 var resp = convert.JSON.encode(buildListActivitiesResponse()); | 567 var resp = convert.JSON.encode(buildListActivitiesResponse()); |
573 return new async.Future.value(stringResponse(200, h, resp)); | 568 return new async.Future.value(stringResponse(200, h, resp)); |
574 }), true); | 569 }), true); |
575 res.list(drive_ancestorId: arg_drive_ancestorId, drive_fileId: arg_drive_f
ileId, groupingStrategy: arg_groupingStrategy, pageSize: arg_pageSize, pageToken
: arg_pageToken, source: arg_source, userId: arg_userId).then(unittest.expectAsy
nc1(((api.ListActivitiesResponse response) { | 570 res |
| 571 .list( |
| 572 drive_ancestorId: arg_drive_ancestorId, |
| 573 drive_fileId: arg_drive_fileId, |
| 574 groupingStrategy: arg_groupingStrategy, |
| 575 pageSize: arg_pageSize, |
| 576 pageToken: arg_pageToken, |
| 577 source: arg_source, |
| 578 userId: arg_userId) |
| 579 .then(unittest.expectAsync1(((api.ListActivitiesResponse response) { |
576 checkListActivitiesResponse(response); | 580 checkListActivitiesResponse(response); |
577 }))); | 581 }))); |
578 }); | 582 }); |
579 | |
580 }); | 583 }); |
581 | |
582 | |
583 } | 584 } |
584 | |
OLD | NEW |