Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Side by Side Diff: generated/googleapis/test/admin/reports_v1.dart

Issue 559053002: Generate 0.1.0 version of googleapis/googleapis_beta (Closed) Base URL: git@github.com:dart-lang/googleapis.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 library googleapis.admin.reports_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/admin/reports_v1.dart' as api;
16
17
18
19 buildUnnamed384() {
20 var o = new core.List<api.Activity>();
21 o.add(buildActivity());
22 o.add(buildActivity());
23 return o;
24 }
25
26 checkUnnamed384(core.List<api.Activity> o) {
27 unittest.expect(o, unittest.hasLength(2));
28 checkActivity(o[0]);
29 checkActivity(o[1]);
30 }
31
32 core.int buildCounterActivities = 0;
33 buildActivities() {
34 var o = new api.Activities();
35 buildCounterActivities++;
36 if (buildCounterActivities < 3) {
37 o.etag = "foo";
38 o.items = buildUnnamed384();
39 o.kind = "foo";
40 o.nextPageToken = "foo";
41 }
42 buildCounterActivities--;
43 return o;
44 }
45
46 checkActivities(api.Activities o) {
47 buildCounterActivities++;
48 if (buildCounterActivities < 3) {
49 unittest.expect(o.etag, unittest.equals('foo'));
50 checkUnnamed384(o.items);
51 unittest.expect(o.kind, unittest.equals('foo'));
52 unittest.expect(o.nextPageToken, unittest.equals('foo'));
53 }
54 buildCounterActivities--;
55 }
56
57 core.int buildCounterActivityActor = 0;
58 buildActivityActor() {
59 var o = new api.ActivityActor();
60 buildCounterActivityActor++;
61 if (buildCounterActivityActor < 3) {
62 o.callerType = "foo";
63 o.email = "foo";
64 o.key = "foo";
65 o.profileId = "foo";
66 }
67 buildCounterActivityActor--;
68 return o;
69 }
70
71 checkActivityActor(api.ActivityActor o) {
72 buildCounterActivityActor++;
73 if (buildCounterActivityActor < 3) {
74 unittest.expect(o.callerType, unittest.equals('foo'));
75 unittest.expect(o.email, unittest.equals('foo'));
76 unittest.expect(o.key, unittest.equals('foo'));
77 unittest.expect(o.profileId, unittest.equals('foo'));
78 }
79 buildCounterActivityActor--;
80 }
81
82 core.int buildCounterActivityEventsParameters = 0;
83 buildActivityEventsParameters() {
84 var o = new api.ActivityEventsParameters();
85 buildCounterActivityEventsParameters++;
86 if (buildCounterActivityEventsParameters < 3) {
87 o.boolValue = true;
88 o.intValue = "foo";
89 o.name = "foo";
90 o.value = "foo";
91 }
92 buildCounterActivityEventsParameters--;
93 return o;
94 }
95
96 checkActivityEventsParameters(api.ActivityEventsParameters o) {
97 buildCounterActivityEventsParameters++;
98 if (buildCounterActivityEventsParameters < 3) {
99 unittest.expect(o.boolValue, unittest.isTrue);
100 unittest.expect(o.intValue, unittest.equals('foo'));
101 unittest.expect(o.name, unittest.equals('foo'));
102 unittest.expect(o.value, unittest.equals('foo'));
103 }
104 buildCounterActivityEventsParameters--;
105 }
106
107 buildUnnamed385() {
108 var o = new core.List<api.ActivityEventsParameters>();
109 o.add(buildActivityEventsParameters());
110 o.add(buildActivityEventsParameters());
111 return o;
112 }
113
114 checkUnnamed385(core.List<api.ActivityEventsParameters> o) {
115 unittest.expect(o, unittest.hasLength(2));
116 checkActivityEventsParameters(o[0]);
117 checkActivityEventsParameters(o[1]);
118 }
119
120 core.int buildCounterActivityEvents = 0;
121 buildActivityEvents() {
122 var o = new api.ActivityEvents();
123 buildCounterActivityEvents++;
124 if (buildCounterActivityEvents < 3) {
125 o.name = "foo";
126 o.parameters = buildUnnamed385();
127 o.type = "foo";
128 }
129 buildCounterActivityEvents--;
130 return o;
131 }
132
133 checkActivityEvents(api.ActivityEvents o) {
134 buildCounterActivityEvents++;
135 if (buildCounterActivityEvents < 3) {
136 unittest.expect(o.name, unittest.equals('foo'));
137 checkUnnamed385(o.parameters);
138 unittest.expect(o.type, unittest.equals('foo'));
139 }
140 buildCounterActivityEvents--;
141 }
142
143 buildUnnamed386() {
144 var o = new core.List<api.ActivityEvents>();
145 o.add(buildActivityEvents());
146 o.add(buildActivityEvents());
147 return o;
148 }
149
150 checkUnnamed386(core.List<api.ActivityEvents> o) {
151 unittest.expect(o, unittest.hasLength(2));
152 checkActivityEvents(o[0]);
153 checkActivityEvents(o[1]);
154 }
155
156 core.int buildCounterActivityId = 0;
157 buildActivityId() {
158 var o = new api.ActivityId();
159 buildCounterActivityId++;
160 if (buildCounterActivityId < 3) {
161 o.applicationName = "foo";
162 o.customerId = "foo";
163 o.time = core.DateTime.parse("2002-02-27T14:01:02");
164 o.uniqueQualifier = "foo";
165 }
166 buildCounterActivityId--;
167 return o;
168 }
169
170 checkActivityId(api.ActivityId o) {
171 buildCounterActivityId++;
172 if (buildCounterActivityId < 3) {
173 unittest.expect(o.applicationName, unittest.equals('foo'));
174 unittest.expect(o.customerId, unittest.equals('foo'));
175 unittest.expect(o.time, unittest.equals(core.DateTime.parse("2002-02-27T14:0 1:02")));
176 unittest.expect(o.uniqueQualifier, unittest.equals('foo'));
177 }
178 buildCounterActivityId--;
179 }
180
181 core.int buildCounterActivity = 0;
182 buildActivity() {
183 var o = new api.Activity();
184 buildCounterActivity++;
185 if (buildCounterActivity < 3) {
186 o.actor = buildActivityActor();
187 o.etag = "foo";
188 o.events = buildUnnamed386();
189 o.id = buildActivityId();
190 o.ipAddress = "foo";
191 o.kind = "foo";
192 o.ownerDomain = "foo";
193 }
194 buildCounterActivity--;
195 return o;
196 }
197
198 checkActivity(api.Activity o) {
199 buildCounterActivity++;
200 if (buildCounterActivity < 3) {
201 checkActivityActor(o.actor);
202 unittest.expect(o.etag, unittest.equals('foo'));
203 checkUnnamed386(o.events);
204 checkActivityId(o.id);
205 unittest.expect(o.ipAddress, unittest.equals('foo'));
206 unittest.expect(o.kind, unittest.equals('foo'));
207 unittest.expect(o.ownerDomain, unittest.equals('foo'));
208 }
209 buildCounterActivity--;
210 }
211
212 buildUnnamed387() {
213 var o = new core.Map<core.String, core.String>();
214 o["x"] = "foo";
215 o["y"] = "foo";
216 return o;
217 }
218
219 checkUnnamed387(core.Map<core.String, core.String> o) {
220 unittest.expect(o, unittest.hasLength(2));
221 unittest.expect(o["x"], unittest.equals('foo'));
222 unittest.expect(o["y"], unittest.equals('foo'));
223 }
224
225 core.int buildCounterChannel = 0;
226 buildChannel() {
227 var o = new api.Channel();
228 buildCounterChannel++;
229 if (buildCounterChannel < 3) {
230 o.address = "foo";
231 o.expiration = "foo";
232 o.id = "foo";
233 o.kind = "foo";
234 o.params = buildUnnamed387();
235 o.payload = true;
236 o.resourceId = "foo";
237 o.resourceUri = "foo";
238 o.token = "foo";
239 o.type = "foo";
240 }
241 buildCounterChannel--;
242 return o;
243 }
244
245 checkChannel(api.Channel o) {
246 buildCounterChannel++;
247 if (buildCounterChannel < 3) {
248 unittest.expect(o.address, unittest.equals('foo'));
249 unittest.expect(o.expiration, unittest.equals('foo'));
250 unittest.expect(o.id, unittest.equals('foo'));
251 unittest.expect(o.kind, unittest.equals('foo'));
252 checkUnnamed387(o.params);
253 unittest.expect(o.payload, unittest.isTrue);
254 unittest.expect(o.resourceId, unittest.equals('foo'));
255 unittest.expect(o.resourceUri, unittest.equals('foo'));
256 unittest.expect(o.token, unittest.equals('foo'));
257 unittest.expect(o.type, unittest.equals('foo'));
258 }
259 buildCounterChannel--;
260 }
261
262 core.int buildCounterUsageReportEntity = 0;
263 buildUsageReportEntity() {
264 var o = new api.UsageReportEntity();
265 buildCounterUsageReportEntity++;
266 if (buildCounterUsageReportEntity < 3) {
267 o.customerId = "foo";
268 o.profileId = "foo";
269 o.type = "foo";
270 o.userEmail = "foo";
271 }
272 buildCounterUsageReportEntity--;
273 return o;
274 }
275
276 checkUsageReportEntity(api.UsageReportEntity o) {
277 buildCounterUsageReportEntity++;
278 if (buildCounterUsageReportEntity < 3) {
279 unittest.expect(o.customerId, unittest.equals('foo'));
280 unittest.expect(o.profileId, unittest.equals('foo'));
281 unittest.expect(o.type, unittest.equals('foo'));
282 unittest.expect(o.userEmail, unittest.equals('foo'));
283 }
284 buildCounterUsageReportEntity--;
285 }
286
287 buildUnnamed388() {
288 var o = new core.Map<core.String, core.Object>();
289 o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'};
290 o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'};
291 return o;
292 }
293
294 checkUnnamed388(core.Map<core.String, core.Object> o) {
295 unittest.expect(o, unittest.hasLength(2));
296 var casted1 = (o["x"]) as core.Map; unittest.expect(casted1, unittest.hasLengt h(3)); unittest.expect(casted1["list"], unittest.equals([1, 2, 3])); unittest.ex pect(casted1["bool"], unittest.equals(true)); unittest.expect(casted1["string"], unittest.equals('foo'));
297 var casted2 = (o["y"]) as core.Map; unittest.expect(casted2, unittest.hasLengt h(3)); unittest.expect(casted2["list"], unittest.equals([1, 2, 3])); unittest.ex pect(casted2["bool"], unittest.equals(true)); unittest.expect(casted2["string"], unittest.equals('foo'));
298 }
299
300 buildUnnamed389() {
301 var o = new core.List<core.Map<core.String, core.Object>>();
302 o.add(buildUnnamed388());
303 o.add(buildUnnamed388());
304 return o;
305 }
306
307 checkUnnamed389(core.List<core.Map<core.String, core.Object>> o) {
308 unittest.expect(o, unittest.hasLength(2));
309 checkUnnamed388(o[0]);
310 checkUnnamed388(o[1]);
311 }
312
313 core.int buildCounterUsageReportParameters = 0;
314 buildUsageReportParameters() {
315 var o = new api.UsageReportParameters();
316 buildCounterUsageReportParameters++;
317 if (buildCounterUsageReportParameters < 3) {
318 o.boolValue = true;
319 o.datetimeValue = core.DateTime.parse("2002-02-27T14:01:02");
320 o.intValue = "foo";
321 o.msgValue = buildUnnamed389();
322 o.name = "foo";
323 o.stringValue = "foo";
324 }
325 buildCounterUsageReportParameters--;
326 return o;
327 }
328
329 checkUsageReportParameters(api.UsageReportParameters o) {
330 buildCounterUsageReportParameters++;
331 if (buildCounterUsageReportParameters < 3) {
332 unittest.expect(o.boolValue, unittest.isTrue);
333 unittest.expect(o.datetimeValue, unittest.equals(core.DateTime.parse("2002-0 2-27T14:01:02")));
334 unittest.expect(o.intValue, unittest.equals('foo'));
335 checkUnnamed389(o.msgValue);
336 unittest.expect(o.name, unittest.equals('foo'));
337 unittest.expect(o.stringValue, unittest.equals('foo'));
338 }
339 buildCounterUsageReportParameters--;
340 }
341
342 buildUnnamed390() {
343 var o = new core.List<api.UsageReportParameters>();
344 o.add(buildUsageReportParameters());
345 o.add(buildUsageReportParameters());
346 return o;
347 }
348
349 checkUnnamed390(core.List<api.UsageReportParameters> o) {
350 unittest.expect(o, unittest.hasLength(2));
351 checkUsageReportParameters(o[0]);
352 checkUsageReportParameters(o[1]);
353 }
354
355 core.int buildCounterUsageReport = 0;
356 buildUsageReport() {
357 var o = new api.UsageReport();
358 buildCounterUsageReport++;
359 if (buildCounterUsageReport < 3) {
360 o.date = "foo";
361 o.entity = buildUsageReportEntity();
362 o.etag = "foo";
363 o.kind = "foo";
364 o.parameters = buildUnnamed390();
365 }
366 buildCounterUsageReport--;
367 return o;
368 }
369
370 checkUsageReport(api.UsageReport o) {
371 buildCounterUsageReport++;
372 if (buildCounterUsageReport < 3) {
373 unittest.expect(o.date, unittest.equals('foo'));
374 checkUsageReportEntity(o.entity);
375 unittest.expect(o.etag, unittest.equals('foo'));
376 unittest.expect(o.kind, unittest.equals('foo'));
377 checkUnnamed390(o.parameters);
378 }
379 buildCounterUsageReport--;
380 }
381
382 buildUnnamed391() {
383 var o = new core.List<api.UsageReport>();
384 o.add(buildUsageReport());
385 o.add(buildUsageReport());
386 return o;
387 }
388
389 checkUnnamed391(core.List<api.UsageReport> o) {
390 unittest.expect(o, unittest.hasLength(2));
391 checkUsageReport(o[0]);
392 checkUsageReport(o[1]);
393 }
394
395 core.int buildCounterUsageReportsWarningsData = 0;
396 buildUsageReportsWarningsData() {
397 var o = new api.UsageReportsWarningsData();
398 buildCounterUsageReportsWarningsData++;
399 if (buildCounterUsageReportsWarningsData < 3) {
400 o.key = "foo";
401 o.value = "foo";
402 }
403 buildCounterUsageReportsWarningsData--;
404 return o;
405 }
406
407 checkUsageReportsWarningsData(api.UsageReportsWarningsData o) {
408 buildCounterUsageReportsWarningsData++;
409 if (buildCounterUsageReportsWarningsData < 3) {
410 unittest.expect(o.key, unittest.equals('foo'));
411 unittest.expect(o.value, unittest.equals('foo'));
412 }
413 buildCounterUsageReportsWarningsData--;
414 }
415
416 buildUnnamed392() {
417 var o = new core.List<api.UsageReportsWarningsData>();
418 o.add(buildUsageReportsWarningsData());
419 o.add(buildUsageReportsWarningsData());
420 return o;
421 }
422
423 checkUnnamed392(core.List<api.UsageReportsWarningsData> o) {
424 unittest.expect(o, unittest.hasLength(2));
425 checkUsageReportsWarningsData(o[0]);
426 checkUsageReportsWarningsData(o[1]);
427 }
428
429 core.int buildCounterUsageReportsWarnings = 0;
430 buildUsageReportsWarnings() {
431 var o = new api.UsageReportsWarnings();
432 buildCounterUsageReportsWarnings++;
433 if (buildCounterUsageReportsWarnings < 3) {
434 o.code = "foo";
435 o.data = buildUnnamed392();
436 o.message = "foo";
437 }
438 buildCounterUsageReportsWarnings--;
439 return o;
440 }
441
442 checkUsageReportsWarnings(api.UsageReportsWarnings o) {
443 buildCounterUsageReportsWarnings++;
444 if (buildCounterUsageReportsWarnings < 3) {
445 unittest.expect(o.code, unittest.equals('foo'));
446 checkUnnamed392(o.data);
447 unittest.expect(o.message, unittest.equals('foo'));
448 }
449 buildCounterUsageReportsWarnings--;
450 }
451
452 buildUnnamed393() {
453 var o = new core.List<api.UsageReportsWarnings>();
454 o.add(buildUsageReportsWarnings());
455 o.add(buildUsageReportsWarnings());
456 return o;
457 }
458
459 checkUnnamed393(core.List<api.UsageReportsWarnings> o) {
460 unittest.expect(o, unittest.hasLength(2));
461 checkUsageReportsWarnings(o[0]);
462 checkUsageReportsWarnings(o[1]);
463 }
464
465 core.int buildCounterUsageReports = 0;
466 buildUsageReports() {
467 var o = new api.UsageReports();
468 buildCounterUsageReports++;
469 if (buildCounterUsageReports < 3) {
470 o.etag = "foo";
471 o.kind = "foo";
472 o.nextPageToken = "foo";
473 o.usageReports = buildUnnamed391();
474 o.warnings = buildUnnamed393();
475 }
476 buildCounterUsageReports--;
477 return o;
478 }
479
480 checkUsageReports(api.UsageReports o) {
481 buildCounterUsageReports++;
482 if (buildCounterUsageReports < 3) {
483 unittest.expect(o.etag, unittest.equals('foo'));
484 unittest.expect(o.kind, unittest.equals('foo'));
485 unittest.expect(o.nextPageToken, unittest.equals('foo'));
486 checkUnnamed391(o.usageReports);
487 checkUnnamed393(o.warnings);
488 }
489 buildCounterUsageReports--;
490 }
491
492
493 main() {
494 unittest.group("obj-schema-Activities", () {
495 unittest.test("to-json--from-json", () {
496 var o = buildActivities();
497 var od = new api.Activities.fromJson(o.toJson());
498 checkActivities(od);
499 });
500 });
501
502
503 unittest.group("obj-schema-ActivityActor", () {
504 unittest.test("to-json--from-json", () {
505 var o = buildActivityActor();
506 var od = new api.ActivityActor.fromJson(o.toJson());
507 checkActivityActor(od);
508 });
509 });
510
511
512 unittest.group("obj-schema-ActivityEventsParameters", () {
513 unittest.test("to-json--from-json", () {
514 var o = buildActivityEventsParameters();
515 var od = new api.ActivityEventsParameters.fromJson(o.toJson());
516 checkActivityEventsParameters(od);
517 });
518 });
519
520
521 unittest.group("obj-schema-ActivityEvents", () {
522 unittest.test("to-json--from-json", () {
523 var o = buildActivityEvents();
524 var od = new api.ActivityEvents.fromJson(o.toJson());
525 checkActivityEvents(od);
526 });
527 });
528
529
530 unittest.group("obj-schema-ActivityId", () {
531 unittest.test("to-json--from-json", () {
532 var o = buildActivityId();
533 var od = new api.ActivityId.fromJson(o.toJson());
534 checkActivityId(od);
535 });
536 });
537
538
539 unittest.group("obj-schema-Activity", () {
540 unittest.test("to-json--from-json", () {
541 var o = buildActivity();
542 var od = new api.Activity.fromJson(o.toJson());
543 checkActivity(od);
544 });
545 });
546
547
548 unittest.group("obj-schema-Channel", () {
549 unittest.test("to-json--from-json", () {
550 var o = buildChannel();
551 var od = new api.Channel.fromJson(o.toJson());
552 checkChannel(od);
553 });
554 });
555
556
557 unittest.group("obj-schema-UsageReportEntity", () {
558 unittest.test("to-json--from-json", () {
559 var o = buildUsageReportEntity();
560 var od = new api.UsageReportEntity.fromJson(o.toJson());
561 checkUsageReportEntity(od);
562 });
563 });
564
565
566 unittest.group("obj-schema-UsageReportParameters", () {
567 unittest.test("to-json--from-json", () {
568 var o = buildUsageReportParameters();
569 var od = new api.UsageReportParameters.fromJson(o.toJson());
570 checkUsageReportParameters(od);
571 });
572 });
573
574
575 unittest.group("obj-schema-UsageReport", () {
576 unittest.test("to-json--from-json", () {
577 var o = buildUsageReport();
578 var od = new api.UsageReport.fromJson(o.toJson());
579 checkUsageReport(od);
580 });
581 });
582
583
584 unittest.group("obj-schema-UsageReportsWarningsData", () {
585 unittest.test("to-json--from-json", () {
586 var o = buildUsageReportsWarningsData();
587 var od = new api.UsageReportsWarningsData.fromJson(o.toJson());
588 checkUsageReportsWarningsData(od);
589 });
590 });
591
592
593 unittest.group("obj-schema-UsageReportsWarnings", () {
594 unittest.test("to-json--from-json", () {
595 var o = buildUsageReportsWarnings();
596 var od = new api.UsageReportsWarnings.fromJson(o.toJson());
597 checkUsageReportsWarnings(od);
598 });
599 });
600
601
602 unittest.group("obj-schema-UsageReports", () {
603 unittest.test("to-json--from-json", () {
604 var o = buildUsageReports();
605 var od = new api.UsageReports.fromJson(o.toJson());
606 checkUsageReports(od);
607 });
608 });
609
610
611 unittest.group("resource-ActivitiesResourceApi", () {
612 unittest.test("method--list", () {
613
614 var mock = new common_test.HttpServerMock();
615 api.ActivitiesResourceApi res = new api.AdminApi(mock).activities;
616 var arg_userKey = "foo";
617 var arg_applicationName = "foo";
618 var arg_actorIpAddress = "foo";
619 var arg_customerId = "foo";
620 var arg_endTime = "foo";
621 var arg_eventName = "foo";
622 var arg_filters = "foo";
623 var arg_maxResults = 42;
624 var arg_pageToken = "foo";
625 var arg_startTime = "foo";
626 mock.register(unittest.expectAsync((http.BaseRequest req, json) {
627 var path = (req.url).path;
628 var pathOffset = 0;
629 var index;
630 var subPart;
631 unittest.expect(path.substring(pathOffset, pathOffset + 18), unittest.eq uals("/admin/reports/v1/"));
632 pathOffset += 18;
633 unittest.expect(path.substring(pathOffset, pathOffset + 15), unittest.eq uals("activity/users/"));
634 pathOffset += 15;
635 index = path.indexOf("/applications/", pathOffset);
636 unittest.expect(index >= 0, unittest.isTrue);
637 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index ));
638 pathOffset = index;
639 unittest.expect(subPart, unittest.equals("$arg_userKey"));
640 unittest.expect(path.substring(pathOffset, pathOffset + 14), unittest.eq uals("/applications/"));
641 pathOffset += 14;
642 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset));
643 pathOffset = path.length;
644 unittest.expect(subPart, unittest.equals("$arg_applicationName"));
645
646 var query = (req.url).query;
647 var queryOffset = 0;
648 var queryMap = {};
649 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
650 parseBool(n) {
651 if (n == "true") return true;
652 if (n == "false") return false;
653 if (n == null) return null;
654 throw new core.ArgumentError("Invalid boolean: $n");
655 }
656 if (query.length > 0) {
657 for (var part in query.split("&")) {
658 var keyvalue = part.split("=");
659 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
660 }
661 }
662 unittest.expect(queryMap["actorIpAddress"].first, unittest.equals(arg_ac torIpAddress));
663 unittest.expect(queryMap["customerId"].first, unittest.equals(arg_custom erId));
664 unittest.expect(queryMap["endTime"].first, unittest.equals(arg_endTime)) ;
665 unittest.expect(queryMap["eventName"].first, unittest.equals(arg_eventNa me));
666 unittest.expect(queryMap["filters"].first, unittest.equals(arg_filters)) ;
667 unittest.expect(core.int.parse(queryMap["maxResults"].first), unittest.e quals(arg_maxResults));
668 unittest.expect(queryMap["pageToken"].first, unittest.equals(arg_pageTok en));
669 unittest.expect(queryMap["startTime"].first, unittest.equals(arg_startTi me));
670
671
672 var h = {
673 "content-type" : "application/json; charset=utf-8",
674 };
675 var resp = convert.JSON.encode(buildActivities());
676 return new async.Future.value(common_test.stringResponse(200, h, resp));
677 }), true);
678 res.list(arg_userKey, arg_applicationName, actorIpAddress: arg_actorIpAddr ess, customerId: arg_customerId, endTime: arg_endTime, eventName: arg_eventName, filters: arg_filters, maxResults: arg_maxResults, pageToken: arg_pageToken, sta rtTime: arg_startTime).then(unittest.expectAsync(((api.Activities response) {
679 checkActivities(response);
680 })));
681 });
682
683 unittest.test("method--watch", () {
684
685 var mock = new common_test.HttpServerMock();
686 api.ActivitiesResourceApi res = new api.AdminApi(mock).activities;
687 var arg_request = buildChannel();
688 var arg_userKey = "foo";
689 var arg_applicationName = "foo";
690 var arg_actorIpAddress = "foo";
691 var arg_customerId = "foo";
692 var arg_endTime = "foo";
693 var arg_eventName = "foo";
694 var arg_filters = "foo";
695 var arg_maxResults = 42;
696 var arg_pageToken = "foo";
697 var arg_startTime = "foo";
698 mock.register(unittest.expectAsync((http.BaseRequest req, json) {
699 var obj = new api.Channel.fromJson(json);
700 checkChannel(obj);
701
702 var path = (req.url).path;
703 var pathOffset = 0;
704 var index;
705 var subPart;
706 unittest.expect(path.substring(pathOffset, pathOffset + 18), unittest.eq uals("/admin/reports/v1/"));
707 pathOffset += 18;
708 unittest.expect(path.substring(pathOffset, pathOffset + 15), unittest.eq uals("activity/users/"));
709 pathOffset += 15;
710 index = path.indexOf("/applications/", pathOffset);
711 unittest.expect(index >= 0, unittest.isTrue);
712 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index ));
713 pathOffset = index;
714 unittest.expect(subPart, unittest.equals("$arg_userKey"));
715 unittest.expect(path.substring(pathOffset, pathOffset + 14), unittest.eq uals("/applications/"));
716 pathOffset += 14;
717 index = path.indexOf("/watch", pathOffset);
718 unittest.expect(index >= 0, unittest.isTrue);
719 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index ));
720 pathOffset = index;
721 unittest.expect(subPart, unittest.equals("$arg_applicationName"));
722 unittest.expect(path.substring(pathOffset, pathOffset + 6), unittest.equ als("/watch"));
723 pathOffset += 6;
724
725 var query = (req.url).query;
726 var queryOffset = 0;
727 var queryMap = {};
728 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
729 parseBool(n) {
730 if (n == "true") return true;
731 if (n == "false") return false;
732 if (n == null) return null;
733 throw new core.ArgumentError("Invalid boolean: $n");
734 }
735 if (query.length > 0) {
736 for (var part in query.split("&")) {
737 var keyvalue = part.split("=");
738 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
739 }
740 }
741 unittest.expect(queryMap["actorIpAddress"].first, unittest.equals(arg_ac torIpAddress));
742 unittest.expect(queryMap["customerId"].first, unittest.equals(arg_custom erId));
743 unittest.expect(queryMap["endTime"].first, unittest.equals(arg_endTime)) ;
744 unittest.expect(queryMap["eventName"].first, unittest.equals(arg_eventNa me));
745 unittest.expect(queryMap["filters"].first, unittest.equals(arg_filters)) ;
746 unittest.expect(core.int.parse(queryMap["maxResults"].first), unittest.e quals(arg_maxResults));
747 unittest.expect(queryMap["pageToken"].first, unittest.equals(arg_pageTok en));
748 unittest.expect(queryMap["startTime"].first, unittest.equals(arg_startTi me));
749
750
751 var h = {
752 "content-type" : "application/json; charset=utf-8",
753 };
754 var resp = convert.JSON.encode(buildChannel());
755 return new async.Future.value(common_test.stringResponse(200, h, resp));
756 }), true);
757 res.watch(arg_request, arg_userKey, arg_applicationName, actorIpAddress: a rg_actorIpAddress, customerId: arg_customerId, endTime: arg_endTime, eventName: arg_eventName, filters: arg_filters, maxResults: arg_maxResults, pageToken: arg_ pageToken, startTime: arg_startTime).then(unittest.expectAsync(((api.Channel res ponse) {
758 checkChannel(response);
759 })));
760 });
761
762 });
763
764
765 unittest.group("resource-ChannelsResourceApi", () {
766 unittest.test("method--stop", () {
767
768 var mock = new common_test.HttpServerMock();
769 api.ChannelsResourceApi res = new api.AdminApi(mock).channels;
770 var arg_request = buildChannel();
771 mock.register(unittest.expectAsync((http.BaseRequest req, json) {
772 var obj = new api.Channel.fromJson(json);
773 checkChannel(obj);
774
775 var path = (req.url).path;
776 var pathOffset = 0;
777 var index;
778 var subPart;
779 unittest.expect(path.substring(pathOffset, pathOffset + 31), unittest.eq uals("/admin/reports_v1/channels/stop"));
780 pathOffset += 31;
781
782 var query = (req.url).query;
783 var queryOffset = 0;
784 var queryMap = {};
785 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
786 parseBool(n) {
787 if (n == "true") return true;
788 if (n == "false") return false;
789 if (n == null) return null;
790 throw new core.ArgumentError("Invalid boolean: $n");
791 }
792 if (query.length > 0) {
793 for (var part in query.split("&")) {
794 var keyvalue = part.split("=");
795 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
796 }
797 }
798
799
800 var h = {
801 "content-type" : "application/json; charset=utf-8",
802 };
803 var resp = "";
804 return new async.Future.value(common_test.stringResponse(200, h, resp));
805 }), true);
806 res.stop(arg_request).then(unittest.expectAsync((_) {}));
807 });
808
809 });
810
811
812 unittest.group("resource-CustomerUsageReportsResourceApi", () {
813 unittest.test("method--get", () {
814
815 var mock = new common_test.HttpServerMock();
816 api.CustomerUsageReportsResourceApi res = new api.AdminApi(mock).customerU sageReports;
817 var arg_date = "foo";
818 var arg_customerId = "foo";
819 var arg_pageToken = "foo";
820 var arg_parameters = "foo";
821 mock.register(unittest.expectAsync((http.BaseRequest req, json) {
822 var path = (req.url).path;
823 var pathOffset = 0;
824 var index;
825 var subPart;
826 unittest.expect(path.substring(pathOffset, pathOffset + 18), unittest.eq uals("/admin/reports/v1/"));
827 pathOffset += 18;
828 unittest.expect(path.substring(pathOffset, pathOffset + 12), unittest.eq uals("usage/dates/"));
829 pathOffset += 12;
830 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset));
831 pathOffset = path.length;
832 unittest.expect(subPart, unittest.equals("$arg_date"));
833
834 var query = (req.url).query;
835 var queryOffset = 0;
836 var queryMap = {};
837 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
838 parseBool(n) {
839 if (n == "true") return true;
840 if (n == "false") return false;
841 if (n == null) return null;
842 throw new core.ArgumentError("Invalid boolean: $n");
843 }
844 if (query.length > 0) {
845 for (var part in query.split("&")) {
846 var keyvalue = part.split("=");
847 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
848 }
849 }
850 unittest.expect(queryMap["customerId"].first, unittest.equals(arg_custom erId));
851 unittest.expect(queryMap["pageToken"].first, unittest.equals(arg_pageTok en));
852 unittest.expect(queryMap["parameters"].first, unittest.equals(arg_parame ters));
853
854
855 var h = {
856 "content-type" : "application/json; charset=utf-8",
857 };
858 var resp = convert.JSON.encode(buildUsageReports());
859 return new async.Future.value(common_test.stringResponse(200, h, resp));
860 }), true);
861 res.get(arg_date, customerId: arg_customerId, pageToken: arg_pageToken, pa rameters: arg_parameters).then(unittest.expectAsync(((api.UsageReports response) {
862 checkUsageReports(response);
863 })));
864 });
865
866 });
867
868
869 unittest.group("resource-UserUsageReportResourceApi", () {
870 unittest.test("method--get", () {
871
872 var mock = new common_test.HttpServerMock();
873 api.UserUsageReportResourceApi res = new api.AdminApi(mock).userUsageRepor t;
874 var arg_userKey = "foo";
875 var arg_date = "foo";
876 var arg_customerId = "foo";
877 var arg_filters = "foo";
878 var arg_maxResults = 42;
879 var arg_pageToken = "foo";
880 var arg_parameters = "foo";
881 mock.register(unittest.expectAsync((http.BaseRequest req, json) {
882 var path = (req.url).path;
883 var pathOffset = 0;
884 var index;
885 var subPart;
886 unittest.expect(path.substring(pathOffset, pathOffset + 18), unittest.eq uals("/admin/reports/v1/"));
887 pathOffset += 18;
888 unittest.expect(path.substring(pathOffset, pathOffset + 12), unittest.eq uals("usage/users/"));
889 pathOffset += 12;
890 index = path.indexOf("/dates/", pathOffset);
891 unittest.expect(index >= 0, unittest.isTrue);
892 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index ));
893 pathOffset = index;
894 unittest.expect(subPart, unittest.equals("$arg_userKey"));
895 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ als("/dates/"));
896 pathOffset += 7;
897 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset));
898 pathOffset = path.length;
899 unittest.expect(subPart, unittest.equals("$arg_date"));
900
901 var query = (req.url).query;
902 var queryOffset = 0;
903 var queryMap = {};
904 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
905 parseBool(n) {
906 if (n == "true") return true;
907 if (n == "false") return false;
908 if (n == null) return null;
909 throw new core.ArgumentError("Invalid boolean: $n");
910 }
911 if (query.length > 0) {
912 for (var part in query.split("&")) {
913 var keyvalue = part.split("=");
914 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
915 }
916 }
917 unittest.expect(queryMap["customerId"].first, unittest.equals(arg_custom erId));
918 unittest.expect(queryMap["filters"].first, unittest.equals(arg_filters)) ;
919 unittest.expect(core.int.parse(queryMap["maxResults"].first), unittest.e quals(arg_maxResults));
920 unittest.expect(queryMap["pageToken"].first, unittest.equals(arg_pageTok en));
921 unittest.expect(queryMap["parameters"].first, unittest.equals(arg_parame ters));
922
923
924 var h = {
925 "content-type" : "application/json; charset=utf-8",
926 };
927 var resp = convert.JSON.encode(buildUsageReports());
928 return new async.Future.value(common_test.stringResponse(200, h, resp));
929 }), true);
930 res.get(arg_userKey, arg_date, customerId: arg_customerId, filters: arg_fi lters, maxResults: arg_maxResults, pageToken: arg_pageToken, parameters: arg_par ameters).then(unittest.expectAsync(((api.UsageReports response) {
931 checkUsageReports(response);
932 })));
933 });
934
935 });
936
937
938 }
939
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698