OLD | NEW |
| (Empty) |
1 library googleapis.appsactivity.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/appsactivity/v1.dart' as api; | |
16 | |
17 | |
18 | |
19 buildUnnamed656() { | |
20 var o = new core.List<api.Event>(); | |
21 o.add(buildEvent()); | |
22 o.add(buildEvent()); | |
23 return o; | |
24 } | |
25 | |
26 checkUnnamed656(core.List<api.Event> o) { | |
27 unittest.expect(o, unittest.hasLength(2)); | |
28 checkEvent(o[0]); | |
29 checkEvent(o[1]); | |
30 } | |
31 | |
32 core.int buildCounterActivity = 0; | |
33 buildActivity() { | |
34 var o = new api.Activity(); | |
35 buildCounterActivity++; | |
36 if (buildCounterActivity < 3) { | |
37 o.combinedEvent = buildEvent(); | |
38 o.singleEvents = buildUnnamed656(); | |
39 } | |
40 buildCounterActivity--; | |
41 return o; | |
42 } | |
43 | |
44 checkActivity(api.Activity o) { | |
45 buildCounterActivity++; | |
46 if (buildCounterActivity < 3) { | |
47 checkEvent(o.combinedEvent); | |
48 checkUnnamed656(o.singleEvents); | |
49 } | |
50 buildCounterActivity--; | |
51 } | |
52 | |
53 buildUnnamed657() { | |
54 var o = new core.List<core.String>(); | |
55 o.add("foo"); | |
56 o.add("foo"); | |
57 return o; | |
58 } | |
59 | |
60 checkUnnamed657(core.List<core.String> o) { | |
61 unittest.expect(o, unittest.hasLength(2)); | |
62 unittest.expect(o[0], unittest.equals('foo')); | |
63 unittest.expect(o[1], unittest.equals('foo')); | |
64 } | |
65 | |
66 buildUnnamed658() { | |
67 var o = new core.List<api.PermissionChange>(); | |
68 o.add(buildPermissionChange()); | |
69 o.add(buildPermissionChange()); | |
70 return o; | |
71 } | |
72 | |
73 checkUnnamed658(core.List<api.PermissionChange> o) { | |
74 unittest.expect(o, unittest.hasLength(2)); | |
75 checkPermissionChange(o[0]); | |
76 checkPermissionChange(o[1]); | |
77 } | |
78 | |
79 core.int buildCounterEvent = 0; | |
80 buildEvent() { | |
81 var o = new api.Event(); | |
82 buildCounterEvent++; | |
83 if (buildCounterEvent < 3) { | |
84 o.additionalEventTypes = buildUnnamed657(); | |
85 o.eventTimeMillis = "foo"; | |
86 o.fromUserDeletion = true; | |
87 o.move = buildMove(); | |
88 o.permissionChanges = buildUnnamed658(); | |
89 o.primaryEventType = "foo"; | |
90 o.rename = buildRename(); | |
91 o.target = buildTarget(); | |
92 o.user = buildUser(); | |
93 } | |
94 buildCounterEvent--; | |
95 return o; | |
96 } | |
97 | |
98 checkEvent(api.Event o) { | |
99 buildCounterEvent++; | |
100 if (buildCounterEvent < 3) { | |
101 checkUnnamed657(o.additionalEventTypes); | |
102 unittest.expect(o.eventTimeMillis, unittest.equals('foo')); | |
103 unittest.expect(o.fromUserDeletion, unittest.isTrue); | |
104 checkMove(o.move); | |
105 checkUnnamed658(o.permissionChanges); | |
106 unittest.expect(o.primaryEventType, unittest.equals('foo')); | |
107 checkRename(o.rename); | |
108 checkTarget(o.target); | |
109 checkUser(o.user); | |
110 } | |
111 buildCounterEvent--; | |
112 } | |
113 | |
114 buildUnnamed659() { | |
115 var o = new core.List<api.Activity>(); | |
116 o.add(buildActivity()); | |
117 o.add(buildActivity()); | |
118 return o; | |
119 } | |
120 | |
121 checkUnnamed659(core.List<api.Activity> o) { | |
122 unittest.expect(o, unittest.hasLength(2)); | |
123 checkActivity(o[0]); | |
124 checkActivity(o[1]); | |
125 } | |
126 | |
127 core.int buildCounterListActivitiesResponse = 0; | |
128 buildListActivitiesResponse() { | |
129 var o = new api.ListActivitiesResponse(); | |
130 buildCounterListActivitiesResponse++; | |
131 if (buildCounterListActivitiesResponse < 3) { | |
132 o.activities = buildUnnamed659(); | |
133 o.nextPageToken = "foo"; | |
134 } | |
135 buildCounterListActivitiesResponse--; | |
136 return o; | |
137 } | |
138 | |
139 checkListActivitiesResponse(api.ListActivitiesResponse o) { | |
140 buildCounterListActivitiesResponse++; | |
141 if (buildCounterListActivitiesResponse < 3) { | |
142 checkUnnamed659(o.activities); | |
143 unittest.expect(o.nextPageToken, unittest.equals('foo')); | |
144 } | |
145 buildCounterListActivitiesResponse--; | |
146 } | |
147 | |
148 buildUnnamed660() { | |
149 var o = new core.List<api.Parent>(); | |
150 o.add(buildParent()); | |
151 o.add(buildParent()); | |
152 return o; | |
153 } | |
154 | |
155 checkUnnamed660(core.List<api.Parent> o) { | |
156 unittest.expect(o, unittest.hasLength(2)); | |
157 checkParent(o[0]); | |
158 checkParent(o[1]); | |
159 } | |
160 | |
161 buildUnnamed661() { | |
162 var o = new core.List<api.Parent>(); | |
163 o.add(buildParent()); | |
164 o.add(buildParent()); | |
165 return o; | |
166 } | |
167 | |
168 checkUnnamed661(core.List<api.Parent> o) { | |
169 unittest.expect(o, unittest.hasLength(2)); | |
170 checkParent(o[0]); | |
171 checkParent(o[1]); | |
172 } | |
173 | |
174 core.int buildCounterMove = 0; | |
175 buildMove() { | |
176 var o = new api.Move(); | |
177 buildCounterMove++; | |
178 if (buildCounterMove < 3) { | |
179 o.addedParents = buildUnnamed660(); | |
180 o.removedParents = buildUnnamed661(); | |
181 } | |
182 buildCounterMove--; | |
183 return o; | |
184 } | |
185 | |
186 checkMove(api.Move o) { | |
187 buildCounterMove++; | |
188 if (buildCounterMove < 3) { | |
189 checkUnnamed660(o.addedParents); | |
190 checkUnnamed661(o.removedParents); | |
191 } | |
192 buildCounterMove--; | |
193 } | |
194 | |
195 core.int buildCounterParent = 0; | |
196 buildParent() { | |
197 var o = new api.Parent(); | |
198 buildCounterParent++; | |
199 if (buildCounterParent < 3) { | |
200 o.id = "foo"; | |
201 o.isRoot = true; | |
202 o.title = "foo"; | |
203 } | |
204 buildCounterParent--; | |
205 return o; | |
206 } | |
207 | |
208 checkParent(api.Parent o) { | |
209 buildCounterParent++; | |
210 if (buildCounterParent < 3) { | |
211 unittest.expect(o.id, unittest.equals('foo')); | |
212 unittest.expect(o.isRoot, unittest.isTrue); | |
213 unittest.expect(o.title, unittest.equals('foo')); | |
214 } | |
215 buildCounterParent--; | |
216 } | |
217 | |
218 core.int buildCounterPermission = 0; | |
219 buildPermission() { | |
220 var o = new api.Permission(); | |
221 buildCounterPermission++; | |
222 if (buildCounterPermission < 3) { | |
223 o.name = "foo"; | |
224 o.permissionId = "foo"; | |
225 o.role = "foo"; | |
226 o.type = "foo"; | |
227 o.user = buildUser(); | |
228 o.withLink = true; | |
229 } | |
230 buildCounterPermission--; | |
231 return o; | |
232 } | |
233 | |
234 checkPermission(api.Permission o) { | |
235 buildCounterPermission++; | |
236 if (buildCounterPermission < 3) { | |
237 unittest.expect(o.name, unittest.equals('foo')); | |
238 unittest.expect(o.permissionId, unittest.equals('foo')); | |
239 unittest.expect(o.role, unittest.equals('foo')); | |
240 unittest.expect(o.type, unittest.equals('foo')); | |
241 checkUser(o.user); | |
242 unittest.expect(o.withLink, unittest.isTrue); | |
243 } | |
244 buildCounterPermission--; | |
245 } | |
246 | |
247 buildUnnamed662() { | |
248 var o = new core.List<api.Permission>(); | |
249 o.add(buildPermission()); | |
250 o.add(buildPermission()); | |
251 return o; | |
252 } | |
253 | |
254 checkUnnamed662(core.List<api.Permission> o) { | |
255 unittest.expect(o, unittest.hasLength(2)); | |
256 checkPermission(o[0]); | |
257 checkPermission(o[1]); | |
258 } | |
259 | |
260 buildUnnamed663() { | |
261 var o = new core.List<api.Permission>(); | |
262 o.add(buildPermission()); | |
263 o.add(buildPermission()); | |
264 return o; | |
265 } | |
266 | |
267 checkUnnamed663(core.List<api.Permission> o) { | |
268 unittest.expect(o, unittest.hasLength(2)); | |
269 checkPermission(o[0]); | |
270 checkPermission(o[1]); | |
271 } | |
272 | |
273 core.int buildCounterPermissionChange = 0; | |
274 buildPermissionChange() { | |
275 var o = new api.PermissionChange(); | |
276 buildCounterPermissionChange++; | |
277 if (buildCounterPermissionChange < 3) { | |
278 o.addedPermissions = buildUnnamed662(); | |
279 o.removedPermissions = buildUnnamed663(); | |
280 } | |
281 buildCounterPermissionChange--; | |
282 return o; | |
283 } | |
284 | |
285 checkPermissionChange(api.PermissionChange o) { | |
286 buildCounterPermissionChange++; | |
287 if (buildCounterPermissionChange < 3) { | |
288 checkUnnamed662(o.addedPermissions); | |
289 checkUnnamed663(o.removedPermissions); | |
290 } | |
291 buildCounterPermissionChange--; | |
292 } | |
293 | |
294 core.int buildCounterPhoto = 0; | |
295 buildPhoto() { | |
296 var o = new api.Photo(); | |
297 buildCounterPhoto++; | |
298 if (buildCounterPhoto < 3) { | |
299 o.url = "foo"; | |
300 } | |
301 buildCounterPhoto--; | |
302 return o; | |
303 } | |
304 | |
305 checkPhoto(api.Photo o) { | |
306 buildCounterPhoto++; | |
307 if (buildCounterPhoto < 3) { | |
308 unittest.expect(o.url, unittest.equals('foo')); | |
309 } | |
310 buildCounterPhoto--; | |
311 } | |
312 | |
313 core.int buildCounterRename = 0; | |
314 buildRename() { | |
315 var o = new api.Rename(); | |
316 buildCounterRename++; | |
317 if (buildCounterRename < 3) { | |
318 o.newTitle = "foo"; | |
319 o.oldTitle = "foo"; | |
320 } | |
321 buildCounterRename--; | |
322 return o; | |
323 } | |
324 | |
325 checkRename(api.Rename o) { | |
326 buildCounterRename++; | |
327 if (buildCounterRename < 3) { | |
328 unittest.expect(o.newTitle, unittest.equals('foo')); | |
329 unittest.expect(o.oldTitle, unittest.equals('foo')); | |
330 } | |
331 buildCounterRename--; | |
332 } | |
333 | |
334 core.int buildCounterTarget = 0; | |
335 buildTarget() { | |
336 var o = new api.Target(); | |
337 buildCounterTarget++; | |
338 if (buildCounterTarget < 3) { | |
339 o.id = "foo"; | |
340 o.mimeType = "foo"; | |
341 o.name = "foo"; | |
342 } | |
343 buildCounterTarget--; | |
344 return o; | |
345 } | |
346 | |
347 checkTarget(api.Target o) { | |
348 buildCounterTarget++; | |
349 if (buildCounterTarget < 3) { | |
350 unittest.expect(o.id, unittest.equals('foo')); | |
351 unittest.expect(o.mimeType, unittest.equals('foo')); | |
352 unittest.expect(o.name, unittest.equals('foo')); | |
353 } | |
354 buildCounterTarget--; | |
355 } | |
356 | |
357 core.int buildCounterUser = 0; | |
358 buildUser() { | |
359 var o = new api.User(); | |
360 buildCounterUser++; | |
361 if (buildCounterUser < 3) { | |
362 o.name = "foo"; | |
363 o.photo = buildPhoto(); | |
364 } | |
365 buildCounterUser--; | |
366 return o; | |
367 } | |
368 | |
369 checkUser(api.User o) { | |
370 buildCounterUser++; | |
371 if (buildCounterUser < 3) { | |
372 unittest.expect(o.name, unittest.equals('foo')); | |
373 checkPhoto(o.photo); | |
374 } | |
375 buildCounterUser--; | |
376 } | |
377 | |
378 | |
379 main() { | |
380 unittest.group("obj-schema-Activity", () { | |
381 unittest.test("to-json--from-json", () { | |
382 var o = buildActivity(); | |
383 var od = new api.Activity.fromJson(o.toJson()); | |
384 checkActivity(od); | |
385 }); | |
386 }); | |
387 | |
388 | |
389 unittest.group("obj-schema-Event", () { | |
390 unittest.test("to-json--from-json", () { | |
391 var o = buildEvent(); | |
392 var od = new api.Event.fromJson(o.toJson()); | |
393 checkEvent(od); | |
394 }); | |
395 }); | |
396 | |
397 | |
398 unittest.group("obj-schema-ListActivitiesResponse", () { | |
399 unittest.test("to-json--from-json", () { | |
400 var o = buildListActivitiesResponse(); | |
401 var od = new api.ListActivitiesResponse.fromJson(o.toJson()); | |
402 checkListActivitiesResponse(od); | |
403 }); | |
404 }); | |
405 | |
406 | |
407 unittest.group("obj-schema-Move", () { | |
408 unittest.test("to-json--from-json", () { | |
409 var o = buildMove(); | |
410 var od = new api.Move.fromJson(o.toJson()); | |
411 checkMove(od); | |
412 }); | |
413 }); | |
414 | |
415 | |
416 unittest.group("obj-schema-Parent", () { | |
417 unittest.test("to-json--from-json", () { | |
418 var o = buildParent(); | |
419 var od = new api.Parent.fromJson(o.toJson()); | |
420 checkParent(od); | |
421 }); | |
422 }); | |
423 | |
424 | |
425 unittest.group("obj-schema-Permission", () { | |
426 unittest.test("to-json--from-json", () { | |
427 var o = buildPermission(); | |
428 var od = new api.Permission.fromJson(o.toJson()); | |
429 checkPermission(od); | |
430 }); | |
431 }); | |
432 | |
433 | |
434 unittest.group("obj-schema-PermissionChange", () { | |
435 unittest.test("to-json--from-json", () { | |
436 var o = buildPermissionChange(); | |
437 var od = new api.PermissionChange.fromJson(o.toJson()); | |
438 checkPermissionChange(od); | |
439 }); | |
440 }); | |
441 | |
442 | |
443 unittest.group("obj-schema-Photo", () { | |
444 unittest.test("to-json--from-json", () { | |
445 var o = buildPhoto(); | |
446 var od = new api.Photo.fromJson(o.toJson()); | |
447 checkPhoto(od); | |
448 }); | |
449 }); | |
450 | |
451 | |
452 unittest.group("obj-schema-Rename", () { | |
453 unittest.test("to-json--from-json", () { | |
454 var o = buildRename(); | |
455 var od = new api.Rename.fromJson(o.toJson()); | |
456 checkRename(od); | |
457 }); | |
458 }); | |
459 | |
460 | |
461 unittest.group("obj-schema-Target", () { | |
462 unittest.test("to-json--from-json", () { | |
463 var o = buildTarget(); | |
464 var od = new api.Target.fromJson(o.toJson()); | |
465 checkTarget(od); | |
466 }); | |
467 }); | |
468 | |
469 | |
470 unittest.group("obj-schema-User", () { | |
471 unittest.test("to-json--from-json", () { | |
472 var o = buildUser(); | |
473 var od = new api.User.fromJson(o.toJson()); | |
474 checkUser(od); | |
475 }); | |
476 }); | |
477 | |
478 | |
479 unittest.group("resource-ActivitiesResourceApi", () { | |
480 unittest.test("method--list", () { | |
481 | |
482 var mock = new common_test.HttpServerMock(); | |
483 api.ActivitiesResourceApi res = new api.AppsactivityApi(mock).activities; | |
484 var arg_drive_ancestorId = "foo"; | |
485 var arg_drive_fileId = "foo"; | |
486 var arg_groupingStrategy = "foo"; | |
487 var arg_pageSize = 42; | |
488 var arg_pageToken = "foo"; | |
489 var arg_source = "foo"; | |
490 var arg_userId = "foo"; | |
491 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
492 var path = (req.url).path; | |
493 var pathOffset = 0; | |
494 var index; | |
495 var subPart; | |
496 unittest.expect(path.substring(pathOffset, pathOffset + 17), unittest.eq
uals("/appsactivity/v1/")); | |
497 pathOffset += 17; | |
498 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("activities")); | |
499 pathOffset += 10; | |
500 | |
501 var query = (req.url).query; | |
502 var queryOffset = 0; | |
503 var queryMap = {}; | |
504 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
505 parseBool(n) { | |
506 if (n == "true") return true; | |
507 if (n == "false") return false; | |
508 if (n == null) return null; | |
509 throw new core.ArgumentError("Invalid boolean: $n"); | |
510 } | |
511 if (query.length > 0) { | |
512 for (var part in query.split("&")) { | |
513 var keyvalue = part.split("="); | |
514 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
515 } | |
516 } | |
517 unittest.expect(queryMap["drive.ancestorId"].first, unittest.equals(arg_
drive_ancestorId)); | |
518 unittest.expect(queryMap["drive.fileId"].first, unittest.equals(arg_driv
e_fileId)); | |
519 unittest.expect(queryMap["groupingStrategy"].first, unittest.equals(arg_
groupingStrategy)); | |
520 unittest.expect(core.int.parse(queryMap["pageSize"].first), unittest.equ
als(arg_pageSize)); | |
521 unittest.expect(queryMap["pageToken"].first, unittest.equals(arg_pageTok
en)); | |
522 unittest.expect(queryMap["source"].first, unittest.equals(arg_source)); | |
523 unittest.expect(queryMap["userId"].first, unittest.equals(arg_userId)); | |
524 | |
525 | |
526 var h = { | |
527 "content-type" : "application/json; charset=utf-8", | |
528 }; | |
529 var resp = convert.JSON.encode(buildListActivitiesResponse()); | |
530 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
531 }), true); | |
532 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
nc(((api.ListActivitiesResponse response) { | |
533 checkListActivitiesResponse(response); | |
534 }))); | |
535 }); | |
536 | |
537 }); | |
538 | |
539 | |
540 } | |
541 | |
OLD | NEW |