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; | 4 import "dart:collection" as collection; |
5 import "dart:async" as async; | 5 import "dart:async" as async; |
6 import "dart:convert" as convert; | 6 import "dart:convert" as convert; |
7 | 7 |
8 import 'package:http/http.dart' as http; | 8 import 'package:http/http.dart' as http; |
9 import 'package:http/testing.dart' as http_testing; | 9 import 'package:http/testing.dart' as http_testing; |
10 import 'package:unittest/unittest.dart' as unittest; | 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 | 11 |
15 import 'package:googleapis/appsactivity/v1.dart' as api; | 12 import 'package:googleapis/appsactivity/v1.dart' as api; |
16 | 13 |
| 14 class HttpServerMock extends http.BaseClient { |
| 15 core.Function _callback; |
| 16 core.bool _expectJson; |
17 | 17 |
| 18 void register(core.Function callback, core.bool expectJson) { |
| 19 _callback = callback; |
| 20 _expectJson = expectJson; |
| 21 } |
18 | 22 |
19 buildUnnamed970() { | 23 async.Future<http.StreamedResponse> send(http.BaseRequest request) { |
| 24 if (_expectJson) { |
| 25 return request.finalize() |
| 26 .transform(convert.UTF8.decoder) |
| 27 .join('') |
| 28 .then((core.String jsonString) { |
| 29 if (jsonString.isEmpty) { |
| 30 return _callback(request, null); |
| 31 } else { |
| 32 return _callback(request, convert.JSON.decode(jsonString)); |
| 33 } |
| 34 }); |
| 35 } else { |
| 36 var stream = request.finalize(); |
| 37 if (stream == null) { |
| 38 return _callback(request, []); |
| 39 } else { |
| 40 return stream.toBytes().then((data) { |
| 41 return _callback(request, data); |
| 42 }); |
| 43 } |
| 44 } |
| 45 } |
| 46 } |
| 47 |
| 48 http.StreamedResponse stringResponse( |
| 49 core.int status, core.Map headers, core.String body) { |
| 50 var stream = new async.Stream.fromIterable([convert.UTF8.encode(body)]); |
| 51 return new http.StreamedResponse(stream, status, headers: headers); |
| 52 } |
| 53 |
| 54 buildUnnamed276() { |
20 var o = new core.List<api.Event>(); | 55 var o = new core.List<api.Event>(); |
21 o.add(buildEvent()); | 56 o.add(buildEvent()); |
22 o.add(buildEvent()); | 57 o.add(buildEvent()); |
23 return o; | 58 return o; |
24 } | 59 } |
25 | 60 |
26 checkUnnamed970(core.List<api.Event> o) { | 61 checkUnnamed276(core.List<api.Event> o) { |
27 unittest.expect(o, unittest.hasLength(2)); | 62 unittest.expect(o, unittest.hasLength(2)); |
28 checkEvent(o[0]); | 63 checkEvent(o[0]); |
29 checkEvent(o[1]); | 64 checkEvent(o[1]); |
30 } | 65 } |
31 | 66 |
32 core.int buildCounterActivity = 0; | 67 core.int buildCounterActivity = 0; |
33 buildActivity() { | 68 buildActivity() { |
34 var o = new api.Activity(); | 69 var o = new api.Activity(); |
35 buildCounterActivity++; | 70 buildCounterActivity++; |
36 if (buildCounterActivity < 3) { | 71 if (buildCounterActivity < 3) { |
37 o.combinedEvent = buildEvent(); | 72 o.combinedEvent = buildEvent(); |
38 o.singleEvents = buildUnnamed970(); | 73 o.singleEvents = buildUnnamed276(); |
39 } | 74 } |
40 buildCounterActivity--; | 75 buildCounterActivity--; |
41 return o; | 76 return o; |
42 } | 77 } |
43 | 78 |
44 checkActivity(api.Activity o) { | 79 checkActivity(api.Activity o) { |
45 buildCounterActivity++; | 80 buildCounterActivity++; |
46 if (buildCounterActivity < 3) { | 81 if (buildCounterActivity < 3) { |
47 checkEvent(o.combinedEvent); | 82 checkEvent(o.combinedEvent); |
48 checkUnnamed970(o.singleEvents); | 83 checkUnnamed276(o.singleEvents); |
49 } | 84 } |
50 buildCounterActivity--; | 85 buildCounterActivity--; |
51 } | 86 } |
52 | 87 |
53 buildUnnamed971() { | 88 buildUnnamed277() { |
54 var o = new core.List<core.String>(); | 89 var o = new core.List<core.String>(); |
55 o.add("foo"); | 90 o.add("foo"); |
56 o.add("foo"); | 91 o.add("foo"); |
57 return o; | 92 return o; |
58 } | 93 } |
59 | 94 |
60 checkUnnamed971(core.List<core.String> o) { | 95 checkUnnamed277(core.List<core.String> o) { |
61 unittest.expect(o, unittest.hasLength(2)); | 96 unittest.expect(o, unittest.hasLength(2)); |
62 unittest.expect(o[0], unittest.equals('foo')); | 97 unittest.expect(o[0], unittest.equals('foo')); |
63 unittest.expect(o[1], unittest.equals('foo')); | 98 unittest.expect(o[1], unittest.equals('foo')); |
64 } | 99 } |
65 | 100 |
66 buildUnnamed972() { | 101 buildUnnamed278() { |
67 var o = new core.List<api.PermissionChange>(); | 102 var o = new core.List<api.PermissionChange>(); |
68 o.add(buildPermissionChange()); | 103 o.add(buildPermissionChange()); |
69 o.add(buildPermissionChange()); | 104 o.add(buildPermissionChange()); |
70 return o; | 105 return o; |
71 } | 106 } |
72 | 107 |
73 checkUnnamed972(core.List<api.PermissionChange> o) { | 108 checkUnnamed278(core.List<api.PermissionChange> o) { |
74 unittest.expect(o, unittest.hasLength(2)); | 109 unittest.expect(o, unittest.hasLength(2)); |
75 checkPermissionChange(o[0]); | 110 checkPermissionChange(o[0]); |
76 checkPermissionChange(o[1]); | 111 checkPermissionChange(o[1]); |
77 } | 112 } |
78 | 113 |
79 core.int buildCounterEvent = 0; | 114 core.int buildCounterEvent = 0; |
80 buildEvent() { | 115 buildEvent() { |
81 var o = new api.Event(); | 116 var o = new api.Event(); |
82 buildCounterEvent++; | 117 buildCounterEvent++; |
83 if (buildCounterEvent < 3) { | 118 if (buildCounterEvent < 3) { |
84 o.additionalEventTypes = buildUnnamed971(); | 119 o.additionalEventTypes = buildUnnamed277(); |
85 o.eventTimeMillis = "foo"; | 120 o.eventTimeMillis = "foo"; |
86 o.fromUserDeletion = true; | 121 o.fromUserDeletion = true; |
87 o.move = buildMove(); | 122 o.move = buildMove(); |
88 o.permissionChanges = buildUnnamed972(); | 123 o.permissionChanges = buildUnnamed278(); |
89 o.primaryEventType = "foo"; | 124 o.primaryEventType = "foo"; |
90 o.rename = buildRename(); | 125 o.rename = buildRename(); |
91 o.target = buildTarget(); | 126 o.target = buildTarget(); |
92 o.user = buildUser(); | 127 o.user = buildUser(); |
93 } | 128 } |
94 buildCounterEvent--; | 129 buildCounterEvent--; |
95 return o; | 130 return o; |
96 } | 131 } |
97 | 132 |
98 checkEvent(api.Event o) { | 133 checkEvent(api.Event o) { |
99 buildCounterEvent++; | 134 buildCounterEvent++; |
100 if (buildCounterEvent < 3) { | 135 if (buildCounterEvent < 3) { |
101 checkUnnamed971(o.additionalEventTypes); | 136 checkUnnamed277(o.additionalEventTypes); |
102 unittest.expect(o.eventTimeMillis, unittest.equals('foo')); | 137 unittest.expect(o.eventTimeMillis, unittest.equals('foo')); |
103 unittest.expect(o.fromUserDeletion, unittest.isTrue); | 138 unittest.expect(o.fromUserDeletion, unittest.isTrue); |
104 checkMove(o.move); | 139 checkMove(o.move); |
105 checkUnnamed972(o.permissionChanges); | 140 checkUnnamed278(o.permissionChanges); |
106 unittest.expect(o.primaryEventType, unittest.equals('foo')); | 141 unittest.expect(o.primaryEventType, unittest.equals('foo')); |
107 checkRename(o.rename); | 142 checkRename(o.rename); |
108 checkTarget(o.target); | 143 checkTarget(o.target); |
109 checkUser(o.user); | 144 checkUser(o.user); |
110 } | 145 } |
111 buildCounterEvent--; | 146 buildCounterEvent--; |
112 } | 147 } |
113 | 148 |
114 buildUnnamed973() { | 149 buildUnnamed279() { |
115 var o = new core.List<api.Activity>(); | 150 var o = new core.List<api.Activity>(); |
116 o.add(buildActivity()); | 151 o.add(buildActivity()); |
117 o.add(buildActivity()); | 152 o.add(buildActivity()); |
118 return o; | 153 return o; |
119 } | 154 } |
120 | 155 |
121 checkUnnamed973(core.List<api.Activity> o) { | 156 checkUnnamed279(core.List<api.Activity> o) { |
122 unittest.expect(o, unittest.hasLength(2)); | 157 unittest.expect(o, unittest.hasLength(2)); |
123 checkActivity(o[0]); | 158 checkActivity(o[0]); |
124 checkActivity(o[1]); | 159 checkActivity(o[1]); |
125 } | 160 } |
126 | 161 |
127 core.int buildCounterListActivitiesResponse = 0; | 162 core.int buildCounterListActivitiesResponse = 0; |
128 buildListActivitiesResponse() { | 163 buildListActivitiesResponse() { |
129 var o = new api.ListActivitiesResponse(); | 164 var o = new api.ListActivitiesResponse(); |
130 buildCounterListActivitiesResponse++; | 165 buildCounterListActivitiesResponse++; |
131 if (buildCounterListActivitiesResponse < 3) { | 166 if (buildCounterListActivitiesResponse < 3) { |
132 o.activities = buildUnnamed973(); | 167 o.activities = buildUnnamed279(); |
133 o.nextPageToken = "foo"; | 168 o.nextPageToken = "foo"; |
134 } | 169 } |
135 buildCounterListActivitiesResponse--; | 170 buildCounterListActivitiesResponse--; |
136 return o; | 171 return o; |
137 } | 172 } |
138 | 173 |
139 checkListActivitiesResponse(api.ListActivitiesResponse o) { | 174 checkListActivitiesResponse(api.ListActivitiesResponse o) { |
140 buildCounterListActivitiesResponse++; | 175 buildCounterListActivitiesResponse++; |
141 if (buildCounterListActivitiesResponse < 3) { | 176 if (buildCounterListActivitiesResponse < 3) { |
142 checkUnnamed973(o.activities); | 177 checkUnnamed279(o.activities); |
143 unittest.expect(o.nextPageToken, unittest.equals('foo')); | 178 unittest.expect(o.nextPageToken, unittest.equals('foo')); |
144 } | 179 } |
145 buildCounterListActivitiesResponse--; | 180 buildCounterListActivitiesResponse--; |
146 } | 181 } |
147 | 182 |
148 buildUnnamed974() { | 183 buildUnnamed280() { |
149 var o = new core.List<api.Parent>(); | 184 var o = new core.List<api.Parent>(); |
150 o.add(buildParent()); | 185 o.add(buildParent()); |
151 o.add(buildParent()); | 186 o.add(buildParent()); |
152 return o; | 187 return o; |
153 } | 188 } |
154 | 189 |
155 checkUnnamed974(core.List<api.Parent> o) { | 190 checkUnnamed280(core.List<api.Parent> o) { |
156 unittest.expect(o, unittest.hasLength(2)); | 191 unittest.expect(o, unittest.hasLength(2)); |
157 checkParent(o[0]); | 192 checkParent(o[0]); |
158 checkParent(o[1]); | 193 checkParent(o[1]); |
159 } | 194 } |
160 | 195 |
161 buildUnnamed975() { | 196 buildUnnamed281() { |
162 var o = new core.List<api.Parent>(); | 197 var o = new core.List<api.Parent>(); |
163 o.add(buildParent()); | 198 o.add(buildParent()); |
164 o.add(buildParent()); | 199 o.add(buildParent()); |
165 return o; | 200 return o; |
166 } | 201 } |
167 | 202 |
168 checkUnnamed975(core.List<api.Parent> o) { | 203 checkUnnamed281(core.List<api.Parent> o) { |
169 unittest.expect(o, unittest.hasLength(2)); | 204 unittest.expect(o, unittest.hasLength(2)); |
170 checkParent(o[0]); | 205 checkParent(o[0]); |
171 checkParent(o[1]); | 206 checkParent(o[1]); |
172 } | 207 } |
173 | 208 |
174 core.int buildCounterMove = 0; | 209 core.int buildCounterMove = 0; |
175 buildMove() { | 210 buildMove() { |
176 var o = new api.Move(); | 211 var o = new api.Move(); |
177 buildCounterMove++; | 212 buildCounterMove++; |
178 if (buildCounterMove < 3) { | 213 if (buildCounterMove < 3) { |
179 o.addedParents = buildUnnamed974(); | 214 o.addedParents = buildUnnamed280(); |
180 o.removedParents = buildUnnamed975(); | 215 o.removedParents = buildUnnamed281(); |
181 } | 216 } |
182 buildCounterMove--; | 217 buildCounterMove--; |
183 return o; | 218 return o; |
184 } | 219 } |
185 | 220 |
186 checkMove(api.Move o) { | 221 checkMove(api.Move o) { |
187 buildCounterMove++; | 222 buildCounterMove++; |
188 if (buildCounterMove < 3) { | 223 if (buildCounterMove < 3) { |
189 checkUnnamed974(o.addedParents); | 224 checkUnnamed280(o.addedParents); |
190 checkUnnamed975(o.removedParents); | 225 checkUnnamed281(o.removedParents); |
191 } | 226 } |
192 buildCounterMove--; | 227 buildCounterMove--; |
193 } | 228 } |
194 | 229 |
195 core.int buildCounterParent = 0; | 230 core.int buildCounterParent = 0; |
196 buildParent() { | 231 buildParent() { |
197 var o = new api.Parent(); | 232 var o = new api.Parent(); |
198 buildCounterParent++; | 233 buildCounterParent++; |
199 if (buildCounterParent < 3) { | 234 if (buildCounterParent < 3) { |
200 o.id = "foo"; | 235 o.id = "foo"; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 unittest.expect(o.name, unittest.equals('foo')); | 272 unittest.expect(o.name, unittest.equals('foo')); |
238 unittest.expect(o.permissionId, unittest.equals('foo')); | 273 unittest.expect(o.permissionId, unittest.equals('foo')); |
239 unittest.expect(o.role, unittest.equals('foo')); | 274 unittest.expect(o.role, unittest.equals('foo')); |
240 unittest.expect(o.type, unittest.equals('foo')); | 275 unittest.expect(o.type, unittest.equals('foo')); |
241 checkUser(o.user); | 276 checkUser(o.user); |
242 unittest.expect(o.withLink, unittest.isTrue); | 277 unittest.expect(o.withLink, unittest.isTrue); |
243 } | 278 } |
244 buildCounterPermission--; | 279 buildCounterPermission--; |
245 } | 280 } |
246 | 281 |
247 buildUnnamed976() { | 282 buildUnnamed282() { |
248 var o = new core.List<api.Permission>(); | 283 var o = new core.List<api.Permission>(); |
249 o.add(buildPermission()); | 284 o.add(buildPermission()); |
250 o.add(buildPermission()); | 285 o.add(buildPermission()); |
251 return o; | 286 return o; |
252 } | 287 } |
253 | 288 |
254 checkUnnamed976(core.List<api.Permission> o) { | 289 checkUnnamed282(core.List<api.Permission> o) { |
255 unittest.expect(o, unittest.hasLength(2)); | 290 unittest.expect(o, unittest.hasLength(2)); |
256 checkPermission(o[0]); | 291 checkPermission(o[0]); |
257 checkPermission(o[1]); | 292 checkPermission(o[1]); |
258 } | 293 } |
259 | 294 |
260 buildUnnamed977() { | 295 buildUnnamed283() { |
261 var o = new core.List<api.Permission>(); | 296 var o = new core.List<api.Permission>(); |
262 o.add(buildPermission()); | 297 o.add(buildPermission()); |
263 o.add(buildPermission()); | 298 o.add(buildPermission()); |
264 return o; | 299 return o; |
265 } | 300 } |
266 | 301 |
267 checkUnnamed977(core.List<api.Permission> o) { | 302 checkUnnamed283(core.List<api.Permission> o) { |
268 unittest.expect(o, unittest.hasLength(2)); | 303 unittest.expect(o, unittest.hasLength(2)); |
269 checkPermission(o[0]); | 304 checkPermission(o[0]); |
270 checkPermission(o[1]); | 305 checkPermission(o[1]); |
271 } | 306 } |
272 | 307 |
273 core.int buildCounterPermissionChange = 0; | 308 core.int buildCounterPermissionChange = 0; |
274 buildPermissionChange() { | 309 buildPermissionChange() { |
275 var o = new api.PermissionChange(); | 310 var o = new api.PermissionChange(); |
276 buildCounterPermissionChange++; | 311 buildCounterPermissionChange++; |
277 if (buildCounterPermissionChange < 3) { | 312 if (buildCounterPermissionChange < 3) { |
278 o.addedPermissions = buildUnnamed976(); | 313 o.addedPermissions = buildUnnamed282(); |
279 o.removedPermissions = buildUnnamed977(); | 314 o.removedPermissions = buildUnnamed283(); |
280 } | 315 } |
281 buildCounterPermissionChange--; | 316 buildCounterPermissionChange--; |
282 return o; | 317 return o; |
283 } | 318 } |
284 | 319 |
285 checkPermissionChange(api.PermissionChange o) { | 320 checkPermissionChange(api.PermissionChange o) { |
286 buildCounterPermissionChange++; | 321 buildCounterPermissionChange++; |
287 if (buildCounterPermissionChange < 3) { | 322 if (buildCounterPermissionChange < 3) { |
288 checkUnnamed976(o.addedPermissions); | 323 checkUnnamed282(o.addedPermissions); |
289 checkUnnamed977(o.removedPermissions); | 324 checkUnnamed283(o.removedPermissions); |
290 } | 325 } |
291 buildCounterPermissionChange--; | 326 buildCounterPermissionChange--; |
292 } | 327 } |
293 | 328 |
294 core.int buildCounterPhoto = 0; | 329 core.int buildCounterPhoto = 0; |
295 buildPhoto() { | 330 buildPhoto() { |
296 var o = new api.Photo(); | 331 var o = new api.Photo(); |
297 buildCounterPhoto++; | 332 buildCounterPhoto++; |
298 if (buildCounterPhoto < 3) { | 333 if (buildCounterPhoto < 3) { |
299 o.url = "foo"; | 334 o.url = "foo"; |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 var o = buildUser(); | 507 var o = buildUser(); |
473 var od = new api.User.fromJson(o.toJson()); | 508 var od = new api.User.fromJson(o.toJson()); |
474 checkUser(od); | 509 checkUser(od); |
475 }); | 510 }); |
476 }); | 511 }); |
477 | 512 |
478 | 513 |
479 unittest.group("resource-ActivitiesResourceApi", () { | 514 unittest.group("resource-ActivitiesResourceApi", () { |
480 unittest.test("method--list", () { | 515 unittest.test("method--list", () { |
481 | 516 |
482 var mock = new common_test.HttpServerMock(); | 517 var mock = new HttpServerMock(); |
483 api.ActivitiesResourceApi res = new api.AppsactivityApi(mock).activities; | 518 api.ActivitiesResourceApi res = new api.AppsactivityApi(mock).activities; |
484 var arg_drive_ancestorId = "foo"; | 519 var arg_drive_ancestorId = "foo"; |
485 var arg_drive_fileId = "foo"; | 520 var arg_drive_fileId = "foo"; |
486 var arg_groupingStrategy = "foo"; | 521 var arg_groupingStrategy = "foo"; |
487 var arg_pageSize = 42; | 522 var arg_pageSize = 42; |
488 var arg_pageToken = "foo"; | 523 var arg_pageToken = "foo"; |
489 var arg_source = "foo"; | 524 var arg_source = "foo"; |
490 var arg_userId = "foo"; | 525 var arg_userId = "foo"; |
491 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | 526 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
492 var path = (req.url).path; | 527 var path = (req.url).path; |
(...skipping 29 matching lines...) Expand all Loading... |
522 unittest.expect(core.int.parse(queryMap["pageSize"].first), unittest.equ
als(arg_pageSize)); | 557 unittest.expect(core.int.parse(queryMap["pageSize"].first), unittest.equ
als(arg_pageSize)); |
523 unittest.expect(queryMap["pageToken"].first, unittest.equals(arg_pageTok
en)); | 558 unittest.expect(queryMap["pageToken"].first, unittest.equals(arg_pageTok
en)); |
524 unittest.expect(queryMap["source"].first, unittest.equals(arg_source)); | 559 unittest.expect(queryMap["source"].first, unittest.equals(arg_source)); |
525 unittest.expect(queryMap["userId"].first, unittest.equals(arg_userId)); | 560 unittest.expect(queryMap["userId"].first, unittest.equals(arg_userId)); |
526 | 561 |
527 | 562 |
528 var h = { | 563 var h = { |
529 "content-type" : "application/json; charset=utf-8", | 564 "content-type" : "application/json; charset=utf-8", |
530 }; | 565 }; |
531 var resp = convert.JSON.encode(buildListActivitiesResponse()); | 566 var resp = convert.JSON.encode(buildListActivitiesResponse()); |
532 return new async.Future.value(common_test.stringResponse(200, h, resp)); | 567 return new async.Future.value(stringResponse(200, h, resp)); |
533 }), true); | 568 }), true); |
534 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) { | 569 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) { |
535 checkListActivitiesResponse(response); | 570 checkListActivitiesResponse(response); |
536 }))); | 571 }))); |
537 }); | 572 }); |
538 | 573 |
539 }); | 574 }); |
540 | 575 |
541 | 576 |
542 } | 577 } |
543 | 578 |
OLD | NEW |