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

Side by Side Diff: generated/googleapis_beta/test/autoscaler/v1beta2_test.dart

Issue 2159673002: Api-roll 39: 2016-07-18 (Closed) Base URL: git@github.com:dart-lang/googleapis.git@master
Patch Set: Created 4 years, 5 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_beta.autoscaler.v1beta2.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
12 import 'package:googleapis_beta/autoscaler/v1beta2.dart' as api;
13
14 class HttpServerMock extends http.BaseClient {
15 core.Function _callback;
16 core.bool _expectJson;
17
18 void register(core.Function callback, core.bool expectJson) {
19 _callback = callback;
20 _expectJson = expectJson;
21 }
22
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 core.int buildCounterAutoscaler = 0;
55 buildAutoscaler() {
56 var o = new api.Autoscaler();
57 buildCounterAutoscaler++;
58 if (buildCounterAutoscaler < 3) {
59 o.autoscalingPolicy = buildAutoscalingPolicy();
60 o.creationTimestamp = "foo";
61 o.description = "foo";
62 o.id = "foo";
63 o.kind = "foo";
64 o.name = "foo";
65 o.selfLink = "foo";
66 o.target = "foo";
67 }
68 buildCounterAutoscaler--;
69 return o;
70 }
71
72 checkAutoscaler(api.Autoscaler o) {
73 buildCounterAutoscaler++;
74 if (buildCounterAutoscaler < 3) {
75 checkAutoscalingPolicy(o.autoscalingPolicy);
76 unittest.expect(o.creationTimestamp, unittest.equals('foo'));
77 unittest.expect(o.description, unittest.equals('foo'));
78 unittest.expect(o.id, unittest.equals('foo'));
79 unittest.expect(o.kind, unittest.equals('foo'));
80 unittest.expect(o.name, unittest.equals('foo'));
81 unittest.expect(o.selfLink, unittest.equals('foo'));
82 unittest.expect(o.target, unittest.equals('foo'));
83 }
84 buildCounterAutoscaler--;
85 }
86
87 buildUnnamed3036() {
88 var o = new core.List<api.Autoscaler>();
89 o.add(buildAutoscaler());
90 o.add(buildAutoscaler());
91 return o;
92 }
93
94 checkUnnamed3036(core.List<api.Autoscaler> o) {
95 unittest.expect(o, unittest.hasLength(2));
96 checkAutoscaler(o[0]);
97 checkAutoscaler(o[1]);
98 }
99
100 core.int buildCounterAutoscalerListResponse = 0;
101 buildAutoscalerListResponse() {
102 var o = new api.AutoscalerListResponse();
103 buildCounterAutoscalerListResponse++;
104 if (buildCounterAutoscalerListResponse < 3) {
105 o.items = buildUnnamed3036();
106 o.kind = "foo";
107 o.nextPageToken = "foo";
108 }
109 buildCounterAutoscalerListResponse--;
110 return o;
111 }
112
113 checkAutoscalerListResponse(api.AutoscalerListResponse o) {
114 buildCounterAutoscalerListResponse++;
115 if (buildCounterAutoscalerListResponse < 3) {
116 checkUnnamed3036(o.items);
117 unittest.expect(o.kind, unittest.equals('foo'));
118 unittest.expect(o.nextPageToken, unittest.equals('foo'));
119 }
120 buildCounterAutoscalerListResponse--;
121 }
122
123 buildUnnamed3037() {
124 var o = new core.List<api.AutoscalingPolicyCustomMetricUtilization>();
125 o.add(buildAutoscalingPolicyCustomMetricUtilization());
126 o.add(buildAutoscalingPolicyCustomMetricUtilization());
127 return o;
128 }
129
130 checkUnnamed3037(core.List<api.AutoscalingPolicyCustomMetricUtilization> o) {
131 unittest.expect(o, unittest.hasLength(2));
132 checkAutoscalingPolicyCustomMetricUtilization(o[0]);
133 checkAutoscalingPolicyCustomMetricUtilization(o[1]);
134 }
135
136 core.int buildCounterAutoscalingPolicy = 0;
137 buildAutoscalingPolicy() {
138 var o = new api.AutoscalingPolicy();
139 buildCounterAutoscalingPolicy++;
140 if (buildCounterAutoscalingPolicy < 3) {
141 o.coolDownPeriodSec = 42;
142 o.cpuUtilization = buildAutoscalingPolicyCpuUtilization();
143 o.customMetricUtilizations = buildUnnamed3037();
144 o.loadBalancingUtilization = buildAutoscalingPolicyLoadBalancingUtilization( );
145 o.maxNumReplicas = 42;
146 o.minNumReplicas = 42;
147 }
148 buildCounterAutoscalingPolicy--;
149 return o;
150 }
151
152 checkAutoscalingPolicy(api.AutoscalingPolicy o) {
153 buildCounterAutoscalingPolicy++;
154 if (buildCounterAutoscalingPolicy < 3) {
155 unittest.expect(o.coolDownPeriodSec, unittest.equals(42));
156 checkAutoscalingPolicyCpuUtilization(o.cpuUtilization);
157 checkUnnamed3037(o.customMetricUtilizations);
158 checkAutoscalingPolicyLoadBalancingUtilization(o.loadBalancingUtilization);
159 unittest.expect(o.maxNumReplicas, unittest.equals(42));
160 unittest.expect(o.minNumReplicas, unittest.equals(42));
161 }
162 buildCounterAutoscalingPolicy--;
163 }
164
165 core.int buildCounterAutoscalingPolicyCpuUtilization = 0;
166 buildAutoscalingPolicyCpuUtilization() {
167 var o = new api.AutoscalingPolicyCpuUtilization();
168 buildCounterAutoscalingPolicyCpuUtilization++;
169 if (buildCounterAutoscalingPolicyCpuUtilization < 3) {
170 o.utilizationTarget = 42.0;
171 }
172 buildCounterAutoscalingPolicyCpuUtilization--;
173 return o;
174 }
175
176 checkAutoscalingPolicyCpuUtilization(api.AutoscalingPolicyCpuUtilization o) {
177 buildCounterAutoscalingPolicyCpuUtilization++;
178 if (buildCounterAutoscalingPolicyCpuUtilization < 3) {
179 unittest.expect(o.utilizationTarget, unittest.equals(42.0));
180 }
181 buildCounterAutoscalingPolicyCpuUtilization--;
182 }
183
184 core.int buildCounterAutoscalingPolicyCustomMetricUtilization = 0;
185 buildAutoscalingPolicyCustomMetricUtilization() {
186 var o = new api.AutoscalingPolicyCustomMetricUtilization();
187 buildCounterAutoscalingPolicyCustomMetricUtilization++;
188 if (buildCounterAutoscalingPolicyCustomMetricUtilization < 3) {
189 o.metric = "foo";
190 o.utilizationTarget = 42.0;
191 o.utilizationTargetType = "foo";
192 }
193 buildCounterAutoscalingPolicyCustomMetricUtilization--;
194 return o;
195 }
196
197 checkAutoscalingPolicyCustomMetricUtilization(api.AutoscalingPolicyCustomMetricU tilization o) {
198 buildCounterAutoscalingPolicyCustomMetricUtilization++;
199 if (buildCounterAutoscalingPolicyCustomMetricUtilization < 3) {
200 unittest.expect(o.metric, unittest.equals('foo'));
201 unittest.expect(o.utilizationTarget, unittest.equals(42.0));
202 unittest.expect(o.utilizationTargetType, unittest.equals('foo'));
203 }
204 buildCounterAutoscalingPolicyCustomMetricUtilization--;
205 }
206
207 core.int buildCounterAutoscalingPolicyLoadBalancingUtilization = 0;
208 buildAutoscalingPolicyLoadBalancingUtilization() {
209 var o = new api.AutoscalingPolicyLoadBalancingUtilization();
210 buildCounterAutoscalingPolicyLoadBalancingUtilization++;
211 if (buildCounterAutoscalingPolicyLoadBalancingUtilization < 3) {
212 o.utilizationTarget = 42.0;
213 }
214 buildCounterAutoscalingPolicyLoadBalancingUtilization--;
215 return o;
216 }
217
218 checkAutoscalingPolicyLoadBalancingUtilization(api.AutoscalingPolicyLoadBalancin gUtilization o) {
219 buildCounterAutoscalingPolicyLoadBalancingUtilization++;
220 if (buildCounterAutoscalingPolicyLoadBalancingUtilization < 3) {
221 unittest.expect(o.utilizationTarget, unittest.equals(42.0));
222 }
223 buildCounterAutoscalingPolicyLoadBalancingUtilization--;
224 }
225
226 core.int buildCounterDeprecationStatus = 0;
227 buildDeprecationStatus() {
228 var o = new api.DeprecationStatus();
229 buildCounterDeprecationStatus++;
230 if (buildCounterDeprecationStatus < 3) {
231 o.deleted = "foo";
232 o.deprecated = "foo";
233 o.obsolete = "foo";
234 o.replacement = "foo";
235 o.state = "foo";
236 }
237 buildCounterDeprecationStatus--;
238 return o;
239 }
240
241 checkDeprecationStatus(api.DeprecationStatus o) {
242 buildCounterDeprecationStatus++;
243 if (buildCounterDeprecationStatus < 3) {
244 unittest.expect(o.deleted, unittest.equals('foo'));
245 unittest.expect(o.deprecated, unittest.equals('foo'));
246 unittest.expect(o.obsolete, unittest.equals('foo'));
247 unittest.expect(o.replacement, unittest.equals('foo'));
248 unittest.expect(o.state, unittest.equals('foo'));
249 }
250 buildCounterDeprecationStatus--;
251 }
252
253 core.int buildCounterOperationErrorErrors = 0;
254 buildOperationErrorErrors() {
255 var o = new api.OperationErrorErrors();
256 buildCounterOperationErrorErrors++;
257 if (buildCounterOperationErrorErrors < 3) {
258 o.code = "foo";
259 o.location = "foo";
260 o.message = "foo";
261 }
262 buildCounterOperationErrorErrors--;
263 return o;
264 }
265
266 checkOperationErrorErrors(api.OperationErrorErrors o) {
267 buildCounterOperationErrorErrors++;
268 if (buildCounterOperationErrorErrors < 3) {
269 unittest.expect(o.code, unittest.equals('foo'));
270 unittest.expect(o.location, unittest.equals('foo'));
271 unittest.expect(o.message, unittest.equals('foo'));
272 }
273 buildCounterOperationErrorErrors--;
274 }
275
276 buildUnnamed3038() {
277 var o = new core.List<api.OperationErrorErrors>();
278 o.add(buildOperationErrorErrors());
279 o.add(buildOperationErrorErrors());
280 return o;
281 }
282
283 checkUnnamed3038(core.List<api.OperationErrorErrors> o) {
284 unittest.expect(o, unittest.hasLength(2));
285 checkOperationErrorErrors(o[0]);
286 checkOperationErrorErrors(o[1]);
287 }
288
289 core.int buildCounterOperationError = 0;
290 buildOperationError() {
291 var o = new api.OperationError();
292 buildCounterOperationError++;
293 if (buildCounterOperationError < 3) {
294 o.errors = buildUnnamed3038();
295 }
296 buildCounterOperationError--;
297 return o;
298 }
299
300 checkOperationError(api.OperationError o) {
301 buildCounterOperationError++;
302 if (buildCounterOperationError < 3) {
303 checkUnnamed3038(o.errors);
304 }
305 buildCounterOperationError--;
306 }
307
308 core.int buildCounterOperationWarningsData = 0;
309 buildOperationWarningsData() {
310 var o = new api.OperationWarningsData();
311 buildCounterOperationWarningsData++;
312 if (buildCounterOperationWarningsData < 3) {
313 o.key = "foo";
314 o.value = "foo";
315 }
316 buildCounterOperationWarningsData--;
317 return o;
318 }
319
320 checkOperationWarningsData(api.OperationWarningsData o) {
321 buildCounterOperationWarningsData++;
322 if (buildCounterOperationWarningsData < 3) {
323 unittest.expect(o.key, unittest.equals('foo'));
324 unittest.expect(o.value, unittest.equals('foo'));
325 }
326 buildCounterOperationWarningsData--;
327 }
328
329 buildUnnamed3039() {
330 var o = new core.List<api.OperationWarningsData>();
331 o.add(buildOperationWarningsData());
332 o.add(buildOperationWarningsData());
333 return o;
334 }
335
336 checkUnnamed3039(core.List<api.OperationWarningsData> o) {
337 unittest.expect(o, unittest.hasLength(2));
338 checkOperationWarningsData(o[0]);
339 checkOperationWarningsData(o[1]);
340 }
341
342 core.int buildCounterOperationWarnings = 0;
343 buildOperationWarnings() {
344 var o = new api.OperationWarnings();
345 buildCounterOperationWarnings++;
346 if (buildCounterOperationWarnings < 3) {
347 o.code = "foo";
348 o.data = buildUnnamed3039();
349 o.message = "foo";
350 }
351 buildCounterOperationWarnings--;
352 return o;
353 }
354
355 checkOperationWarnings(api.OperationWarnings o) {
356 buildCounterOperationWarnings++;
357 if (buildCounterOperationWarnings < 3) {
358 unittest.expect(o.code, unittest.equals('foo'));
359 checkUnnamed3039(o.data);
360 unittest.expect(o.message, unittest.equals('foo'));
361 }
362 buildCounterOperationWarnings--;
363 }
364
365 buildUnnamed3040() {
366 var o = new core.List<api.OperationWarnings>();
367 o.add(buildOperationWarnings());
368 o.add(buildOperationWarnings());
369 return o;
370 }
371
372 checkUnnamed3040(core.List<api.OperationWarnings> o) {
373 unittest.expect(o, unittest.hasLength(2));
374 checkOperationWarnings(o[0]);
375 checkOperationWarnings(o[1]);
376 }
377
378 core.int buildCounterOperation = 0;
379 buildOperation() {
380 var o = new api.Operation();
381 buildCounterOperation++;
382 if (buildCounterOperation < 3) {
383 o.clientOperationId = "foo";
384 o.creationTimestamp = "foo";
385 o.description = "foo";
386 o.endTime = "foo";
387 o.error = buildOperationError();
388 o.httpErrorMessage = "foo";
389 o.httpErrorStatusCode = 42;
390 o.id = "foo";
391 o.insertTime = "foo";
392 o.kind = "foo";
393 o.name = "foo";
394 o.operationType = "foo";
395 o.progress = 42;
396 o.region = "foo";
397 o.selfLink = "foo";
398 o.startTime = "foo";
399 o.status = "foo";
400 o.statusMessage = "foo";
401 o.targetId = "foo";
402 o.targetLink = "foo";
403 o.user = "foo";
404 o.warnings = buildUnnamed3040();
405 o.zone = "foo";
406 }
407 buildCounterOperation--;
408 return o;
409 }
410
411 checkOperation(api.Operation o) {
412 buildCounterOperation++;
413 if (buildCounterOperation < 3) {
414 unittest.expect(o.clientOperationId, unittest.equals('foo'));
415 unittest.expect(o.creationTimestamp, unittest.equals('foo'));
416 unittest.expect(o.description, unittest.equals('foo'));
417 unittest.expect(o.endTime, unittest.equals('foo'));
418 checkOperationError(o.error);
419 unittest.expect(o.httpErrorMessage, unittest.equals('foo'));
420 unittest.expect(o.httpErrorStatusCode, unittest.equals(42));
421 unittest.expect(o.id, unittest.equals('foo'));
422 unittest.expect(o.insertTime, unittest.equals('foo'));
423 unittest.expect(o.kind, unittest.equals('foo'));
424 unittest.expect(o.name, unittest.equals('foo'));
425 unittest.expect(o.operationType, unittest.equals('foo'));
426 unittest.expect(o.progress, unittest.equals(42));
427 unittest.expect(o.region, unittest.equals('foo'));
428 unittest.expect(o.selfLink, unittest.equals('foo'));
429 unittest.expect(o.startTime, unittest.equals('foo'));
430 unittest.expect(o.status, unittest.equals('foo'));
431 unittest.expect(o.statusMessage, unittest.equals('foo'));
432 unittest.expect(o.targetId, unittest.equals('foo'));
433 unittest.expect(o.targetLink, unittest.equals('foo'));
434 unittest.expect(o.user, unittest.equals('foo'));
435 checkUnnamed3040(o.warnings);
436 unittest.expect(o.zone, unittest.equals('foo'));
437 }
438 buildCounterOperation--;
439 }
440
441 buildUnnamed3041() {
442 var o = new core.List<api.Operation>();
443 o.add(buildOperation());
444 o.add(buildOperation());
445 return o;
446 }
447
448 checkUnnamed3041(core.List<api.Operation> o) {
449 unittest.expect(o, unittest.hasLength(2));
450 checkOperation(o[0]);
451 checkOperation(o[1]);
452 }
453
454 core.int buildCounterOperationList = 0;
455 buildOperationList() {
456 var o = new api.OperationList();
457 buildCounterOperationList++;
458 if (buildCounterOperationList < 3) {
459 o.id = "foo";
460 o.items = buildUnnamed3041();
461 o.kind = "foo";
462 o.nextPageToken = "foo";
463 o.selfLink = "foo";
464 }
465 buildCounterOperationList--;
466 return o;
467 }
468
469 checkOperationList(api.OperationList o) {
470 buildCounterOperationList++;
471 if (buildCounterOperationList < 3) {
472 unittest.expect(o.id, unittest.equals('foo'));
473 checkUnnamed3041(o.items);
474 unittest.expect(o.kind, unittest.equals('foo'));
475 unittest.expect(o.nextPageToken, unittest.equals('foo'));
476 unittest.expect(o.selfLink, unittest.equals('foo'));
477 }
478 buildCounterOperationList--;
479 }
480
481 core.int buildCounterZone = 0;
482 buildZone() {
483 var o = new api.Zone();
484 buildCounterZone++;
485 if (buildCounterZone < 3) {
486 o.creationTimestamp = "foo";
487 o.deprecated = buildDeprecationStatus();
488 o.description = "foo";
489 o.id = "foo";
490 o.kind = "foo";
491 o.name = "foo";
492 o.region = "foo";
493 o.selfLink = "foo";
494 o.status = "foo";
495 }
496 buildCounterZone--;
497 return o;
498 }
499
500 checkZone(api.Zone o) {
501 buildCounterZone++;
502 if (buildCounterZone < 3) {
503 unittest.expect(o.creationTimestamp, unittest.equals('foo'));
504 checkDeprecationStatus(o.deprecated);
505 unittest.expect(o.description, unittest.equals('foo'));
506 unittest.expect(o.id, unittest.equals('foo'));
507 unittest.expect(o.kind, unittest.equals('foo'));
508 unittest.expect(o.name, unittest.equals('foo'));
509 unittest.expect(o.region, unittest.equals('foo'));
510 unittest.expect(o.selfLink, unittest.equals('foo'));
511 unittest.expect(o.status, unittest.equals('foo'));
512 }
513 buildCounterZone--;
514 }
515
516 buildUnnamed3042() {
517 var o = new core.List<api.Zone>();
518 o.add(buildZone());
519 o.add(buildZone());
520 return o;
521 }
522
523 checkUnnamed3042(core.List<api.Zone> o) {
524 unittest.expect(o, unittest.hasLength(2));
525 checkZone(o[0]);
526 checkZone(o[1]);
527 }
528
529 core.int buildCounterZoneList = 0;
530 buildZoneList() {
531 var o = new api.ZoneList();
532 buildCounterZoneList++;
533 if (buildCounterZoneList < 3) {
534 o.id = "foo";
535 o.items = buildUnnamed3042();
536 o.kind = "foo";
537 o.nextPageToken = "foo";
538 o.selfLink = "foo";
539 }
540 buildCounterZoneList--;
541 return o;
542 }
543
544 checkZoneList(api.ZoneList o) {
545 buildCounterZoneList++;
546 if (buildCounterZoneList < 3) {
547 unittest.expect(o.id, unittest.equals('foo'));
548 checkUnnamed3042(o.items);
549 unittest.expect(o.kind, unittest.equals('foo'));
550 unittest.expect(o.nextPageToken, unittest.equals('foo'));
551 unittest.expect(o.selfLink, unittest.equals('foo'));
552 }
553 buildCounterZoneList--;
554 }
555
556
557 main() {
558 unittest.group("obj-schema-Autoscaler", () {
559 unittest.test("to-json--from-json", () {
560 var o = buildAutoscaler();
561 var od = new api.Autoscaler.fromJson(o.toJson());
562 checkAutoscaler(od);
563 });
564 });
565
566
567 unittest.group("obj-schema-AutoscalerListResponse", () {
568 unittest.test("to-json--from-json", () {
569 var o = buildAutoscalerListResponse();
570 var od = new api.AutoscalerListResponse.fromJson(o.toJson());
571 checkAutoscalerListResponse(od);
572 });
573 });
574
575
576 unittest.group("obj-schema-AutoscalingPolicy", () {
577 unittest.test("to-json--from-json", () {
578 var o = buildAutoscalingPolicy();
579 var od = new api.AutoscalingPolicy.fromJson(o.toJson());
580 checkAutoscalingPolicy(od);
581 });
582 });
583
584
585 unittest.group("obj-schema-AutoscalingPolicyCpuUtilization", () {
586 unittest.test("to-json--from-json", () {
587 var o = buildAutoscalingPolicyCpuUtilization();
588 var od = new api.AutoscalingPolicyCpuUtilization.fromJson(o.toJson());
589 checkAutoscalingPolicyCpuUtilization(od);
590 });
591 });
592
593
594 unittest.group("obj-schema-AutoscalingPolicyCustomMetricUtilization", () {
595 unittest.test("to-json--from-json", () {
596 var o = buildAutoscalingPolicyCustomMetricUtilization();
597 var od = new api.AutoscalingPolicyCustomMetricUtilization.fromJson(o.toJso n());
598 checkAutoscalingPolicyCustomMetricUtilization(od);
599 });
600 });
601
602
603 unittest.group("obj-schema-AutoscalingPolicyLoadBalancingUtilization", () {
604 unittest.test("to-json--from-json", () {
605 var o = buildAutoscalingPolicyLoadBalancingUtilization();
606 var od = new api.AutoscalingPolicyLoadBalancingUtilization.fromJson(o.toJs on());
607 checkAutoscalingPolicyLoadBalancingUtilization(od);
608 });
609 });
610
611
612 unittest.group("obj-schema-DeprecationStatus", () {
613 unittest.test("to-json--from-json", () {
614 var o = buildDeprecationStatus();
615 var od = new api.DeprecationStatus.fromJson(o.toJson());
616 checkDeprecationStatus(od);
617 });
618 });
619
620
621 unittest.group("obj-schema-OperationErrorErrors", () {
622 unittest.test("to-json--from-json", () {
623 var o = buildOperationErrorErrors();
624 var od = new api.OperationErrorErrors.fromJson(o.toJson());
625 checkOperationErrorErrors(od);
626 });
627 });
628
629
630 unittest.group("obj-schema-OperationError", () {
631 unittest.test("to-json--from-json", () {
632 var o = buildOperationError();
633 var od = new api.OperationError.fromJson(o.toJson());
634 checkOperationError(od);
635 });
636 });
637
638
639 unittest.group("obj-schema-OperationWarningsData", () {
640 unittest.test("to-json--from-json", () {
641 var o = buildOperationWarningsData();
642 var od = new api.OperationWarningsData.fromJson(o.toJson());
643 checkOperationWarningsData(od);
644 });
645 });
646
647
648 unittest.group("obj-schema-OperationWarnings", () {
649 unittest.test("to-json--from-json", () {
650 var o = buildOperationWarnings();
651 var od = new api.OperationWarnings.fromJson(o.toJson());
652 checkOperationWarnings(od);
653 });
654 });
655
656
657 unittest.group("obj-schema-Operation", () {
658 unittest.test("to-json--from-json", () {
659 var o = buildOperation();
660 var od = new api.Operation.fromJson(o.toJson());
661 checkOperation(od);
662 });
663 });
664
665
666 unittest.group("obj-schema-OperationList", () {
667 unittest.test("to-json--from-json", () {
668 var o = buildOperationList();
669 var od = new api.OperationList.fromJson(o.toJson());
670 checkOperationList(od);
671 });
672 });
673
674
675 unittest.group("obj-schema-Zone", () {
676 unittest.test("to-json--from-json", () {
677 var o = buildZone();
678 var od = new api.Zone.fromJson(o.toJson());
679 checkZone(od);
680 });
681 });
682
683
684 unittest.group("obj-schema-ZoneList", () {
685 unittest.test("to-json--from-json", () {
686 var o = buildZoneList();
687 var od = new api.ZoneList.fromJson(o.toJson());
688 checkZoneList(od);
689 });
690 });
691
692
693 unittest.group("resource-AutoscalersResourceApi", () {
694 unittest.test("method--delete", () {
695
696 var mock = new HttpServerMock();
697 api.AutoscalersResourceApi res = new api.AutoscalerApi(mock).autoscalers;
698 var arg_project = "foo";
699 var arg_zone = "foo";
700 var arg_autoscaler = "foo";
701 mock.register(unittest.expectAsync((http.BaseRequest req, json) {
702 var path = (req.url).path;
703 var pathOffset = 0;
704 var index;
705 var subPart;
706 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ als("/"));
707 pathOffset += 1;
708 unittest.expect(path.substring(pathOffset, pathOffset + 19), unittest.eq uals("autoscaler/v1beta2/"));
709 pathOffset += 19;
710 unittest.expect(path.substring(pathOffset, pathOffset + 9), unittest.equ als("projects/"));
711 pathOffset += 9;
712 index = path.indexOf("/zones/", pathOffset);
713 unittest.expect(index >= 0, unittest.isTrue);
714 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index ));
715 pathOffset = index;
716 unittest.expect(subPart, unittest.equals("$arg_project"));
717 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ als("/zones/"));
718 pathOffset += 7;
719 index = path.indexOf("/autoscalers/", pathOffset);
720 unittest.expect(index >= 0, unittest.isTrue);
721 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index ));
722 pathOffset = index;
723 unittest.expect(subPart, unittest.equals("$arg_zone"));
724 unittest.expect(path.substring(pathOffset, pathOffset + 13), unittest.eq uals("/autoscalers/"));
725 pathOffset += 13;
726 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset));
727 pathOffset = path.length;
728 unittest.expect(subPart, unittest.equals("$arg_autoscaler"));
729
730 var query = (req.url).query;
731 var queryOffset = 0;
732 var queryMap = {};
733 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
734 parseBool(n) {
735 if (n == "true") return true;
736 if (n == "false") return false;
737 if (n == null) return null;
738 throw new core.ArgumentError("Invalid boolean: $n");
739 }
740 if (query.length > 0) {
741 for (var part in query.split("&")) {
742 var keyvalue = part.split("=");
743 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
744 }
745 }
746
747
748 var h = {
749 "content-type" : "application/json; charset=utf-8",
750 };
751 var resp = convert.JSON.encode(buildOperation());
752 return new async.Future.value(stringResponse(200, h, resp));
753 }), true);
754 res.delete(arg_project, arg_zone, arg_autoscaler).then(unittest.expectAsyn c(((api.Operation response) {
755 checkOperation(response);
756 })));
757 });
758
759 unittest.test("method--get", () {
760
761 var mock = new HttpServerMock();
762 api.AutoscalersResourceApi res = new api.AutoscalerApi(mock).autoscalers;
763 var arg_project = "foo";
764 var arg_zone = "foo";
765 var arg_autoscaler = "foo";
766 mock.register(unittest.expectAsync((http.BaseRequest req, json) {
767 var path = (req.url).path;
768 var pathOffset = 0;
769 var index;
770 var subPart;
771 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ als("/"));
772 pathOffset += 1;
773 unittest.expect(path.substring(pathOffset, pathOffset + 19), unittest.eq uals("autoscaler/v1beta2/"));
774 pathOffset += 19;
775 unittest.expect(path.substring(pathOffset, pathOffset + 9), unittest.equ als("projects/"));
776 pathOffset += 9;
777 index = path.indexOf("/zones/", pathOffset);
778 unittest.expect(index >= 0, unittest.isTrue);
779 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index ));
780 pathOffset = index;
781 unittest.expect(subPart, unittest.equals("$arg_project"));
782 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ als("/zones/"));
783 pathOffset += 7;
784 index = path.indexOf("/autoscalers/", pathOffset);
785 unittest.expect(index >= 0, unittest.isTrue);
786 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index ));
787 pathOffset = index;
788 unittest.expect(subPart, unittest.equals("$arg_zone"));
789 unittest.expect(path.substring(pathOffset, pathOffset + 13), unittest.eq uals("/autoscalers/"));
790 pathOffset += 13;
791 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset));
792 pathOffset = path.length;
793 unittest.expect(subPart, unittest.equals("$arg_autoscaler"));
794
795 var query = (req.url).query;
796 var queryOffset = 0;
797 var queryMap = {};
798 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
799 parseBool(n) {
800 if (n == "true") return true;
801 if (n == "false") return false;
802 if (n == null) return null;
803 throw new core.ArgumentError("Invalid boolean: $n");
804 }
805 if (query.length > 0) {
806 for (var part in query.split("&")) {
807 var keyvalue = part.split("=");
808 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
809 }
810 }
811
812
813 var h = {
814 "content-type" : "application/json; charset=utf-8",
815 };
816 var resp = convert.JSON.encode(buildAutoscaler());
817 return new async.Future.value(stringResponse(200, h, resp));
818 }), true);
819 res.get(arg_project, arg_zone, arg_autoscaler).then(unittest.expectAsync(( (api.Autoscaler response) {
820 checkAutoscaler(response);
821 })));
822 });
823
824 unittest.test("method--insert", () {
825
826 var mock = new HttpServerMock();
827 api.AutoscalersResourceApi res = new api.AutoscalerApi(mock).autoscalers;
828 var arg_request = buildAutoscaler();
829 var arg_project = "foo";
830 var arg_zone = "foo";
831 mock.register(unittest.expectAsync((http.BaseRequest req, json) {
832 var obj = new api.Autoscaler.fromJson(json);
833 checkAutoscaler(obj);
834
835 var path = (req.url).path;
836 var pathOffset = 0;
837 var index;
838 var subPart;
839 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ als("/"));
840 pathOffset += 1;
841 unittest.expect(path.substring(pathOffset, pathOffset + 19), unittest.eq uals("autoscaler/v1beta2/"));
842 pathOffset += 19;
843 unittest.expect(path.substring(pathOffset, pathOffset + 9), unittest.equ als("projects/"));
844 pathOffset += 9;
845 index = path.indexOf("/zones/", pathOffset);
846 unittest.expect(index >= 0, unittest.isTrue);
847 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index ));
848 pathOffset = index;
849 unittest.expect(subPart, unittest.equals("$arg_project"));
850 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ als("/zones/"));
851 pathOffset += 7;
852 index = path.indexOf("/autoscalers", pathOffset);
853 unittest.expect(index >= 0, unittest.isTrue);
854 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index ));
855 pathOffset = index;
856 unittest.expect(subPart, unittest.equals("$arg_zone"));
857 unittest.expect(path.substring(pathOffset, pathOffset + 12), unittest.eq uals("/autoscalers"));
858 pathOffset += 12;
859
860 var query = (req.url).query;
861 var queryOffset = 0;
862 var queryMap = {};
863 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
864 parseBool(n) {
865 if (n == "true") return true;
866 if (n == "false") return false;
867 if (n == null) return null;
868 throw new core.ArgumentError("Invalid boolean: $n");
869 }
870 if (query.length > 0) {
871 for (var part in query.split("&")) {
872 var keyvalue = part.split("=");
873 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
874 }
875 }
876
877
878 var h = {
879 "content-type" : "application/json; charset=utf-8",
880 };
881 var resp = convert.JSON.encode(buildOperation());
882 return new async.Future.value(stringResponse(200, h, resp));
883 }), true);
884 res.insert(arg_request, arg_project, arg_zone).then(unittest.expectAsync(( (api.Operation response) {
885 checkOperation(response);
886 })));
887 });
888
889 unittest.test("method--list", () {
890
891 var mock = new HttpServerMock();
892 api.AutoscalersResourceApi res = new api.AutoscalerApi(mock).autoscalers;
893 var arg_project = "foo";
894 var arg_zone = "foo";
895 var arg_filter = "foo";
896 var arg_maxResults = 42;
897 var arg_pageToken = "foo";
898 mock.register(unittest.expectAsync((http.BaseRequest req, json) {
899 var path = (req.url).path;
900 var pathOffset = 0;
901 var index;
902 var subPart;
903 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ als("/"));
904 pathOffset += 1;
905 unittest.expect(path.substring(pathOffset, pathOffset + 19), unittest.eq uals("autoscaler/v1beta2/"));
906 pathOffset += 19;
907 unittest.expect(path.substring(pathOffset, pathOffset + 9), unittest.equ als("projects/"));
908 pathOffset += 9;
909 index = path.indexOf("/zones/", pathOffset);
910 unittest.expect(index >= 0, unittest.isTrue);
911 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index ));
912 pathOffset = index;
913 unittest.expect(subPart, unittest.equals("$arg_project"));
914 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ als("/zones/"));
915 pathOffset += 7;
916 index = path.indexOf("/autoscalers", pathOffset);
917 unittest.expect(index >= 0, unittest.isTrue);
918 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index ));
919 pathOffset = index;
920 unittest.expect(subPart, unittest.equals("$arg_zone"));
921 unittest.expect(path.substring(pathOffset, pathOffset + 12), unittest.eq uals("/autoscalers"));
922 pathOffset += 12;
923
924 var query = (req.url).query;
925 var queryOffset = 0;
926 var queryMap = {};
927 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
928 parseBool(n) {
929 if (n == "true") return true;
930 if (n == "false") return false;
931 if (n == null) return null;
932 throw new core.ArgumentError("Invalid boolean: $n");
933 }
934 if (query.length > 0) {
935 for (var part in query.split("&")) {
936 var keyvalue = part.split("=");
937 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
938 }
939 }
940 unittest.expect(queryMap["filter"].first, unittest.equals(arg_filter));
941 unittest.expect(core.int.parse(queryMap["maxResults"].first), unittest.e quals(arg_maxResults));
942 unittest.expect(queryMap["pageToken"].first, unittest.equals(arg_pageTok en));
943
944
945 var h = {
946 "content-type" : "application/json; charset=utf-8",
947 };
948 var resp = convert.JSON.encode(buildAutoscalerListResponse());
949 return new async.Future.value(stringResponse(200, h, resp));
950 }), true);
951 res.list(arg_project, arg_zone, filter: arg_filter, maxResults: arg_maxRes ults, pageToken: arg_pageToken).then(unittest.expectAsync(((api.AutoscalerListRe sponse response) {
952 checkAutoscalerListResponse(response);
953 })));
954 });
955
956 unittest.test("method--patch", () {
957
958 var mock = new HttpServerMock();
959 api.AutoscalersResourceApi res = new api.AutoscalerApi(mock).autoscalers;
960 var arg_request = buildAutoscaler();
961 var arg_project = "foo";
962 var arg_zone = "foo";
963 var arg_autoscaler = "foo";
964 mock.register(unittest.expectAsync((http.BaseRequest req, json) {
965 var obj = new api.Autoscaler.fromJson(json);
966 checkAutoscaler(obj);
967
968 var path = (req.url).path;
969 var pathOffset = 0;
970 var index;
971 var subPart;
972 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ als("/"));
973 pathOffset += 1;
974 unittest.expect(path.substring(pathOffset, pathOffset + 19), unittest.eq uals("autoscaler/v1beta2/"));
975 pathOffset += 19;
976 unittest.expect(path.substring(pathOffset, pathOffset + 9), unittest.equ als("projects/"));
977 pathOffset += 9;
978 index = path.indexOf("/zones/", pathOffset);
979 unittest.expect(index >= 0, unittest.isTrue);
980 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index ));
981 pathOffset = index;
982 unittest.expect(subPart, unittest.equals("$arg_project"));
983 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ als("/zones/"));
984 pathOffset += 7;
985 index = path.indexOf("/autoscalers/", pathOffset);
986 unittest.expect(index >= 0, unittest.isTrue);
987 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index ));
988 pathOffset = index;
989 unittest.expect(subPart, unittest.equals("$arg_zone"));
990 unittest.expect(path.substring(pathOffset, pathOffset + 13), unittest.eq uals("/autoscalers/"));
991 pathOffset += 13;
992 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset));
993 pathOffset = path.length;
994 unittest.expect(subPart, unittest.equals("$arg_autoscaler"));
995
996 var query = (req.url).query;
997 var queryOffset = 0;
998 var queryMap = {};
999 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
1000 parseBool(n) {
1001 if (n == "true") return true;
1002 if (n == "false") return false;
1003 if (n == null) return null;
1004 throw new core.ArgumentError("Invalid boolean: $n");
1005 }
1006 if (query.length > 0) {
1007 for (var part in query.split("&")) {
1008 var keyvalue = part.split("=");
1009 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
1010 }
1011 }
1012
1013
1014 var h = {
1015 "content-type" : "application/json; charset=utf-8",
1016 };
1017 var resp = convert.JSON.encode(buildOperation());
1018 return new async.Future.value(stringResponse(200, h, resp));
1019 }), true);
1020 res.patch(arg_request, arg_project, arg_zone, arg_autoscaler).then(unittes t.expectAsync(((api.Operation response) {
1021 checkOperation(response);
1022 })));
1023 });
1024
1025 unittest.test("method--update", () {
1026
1027 var mock = new HttpServerMock();
1028 api.AutoscalersResourceApi res = new api.AutoscalerApi(mock).autoscalers;
1029 var arg_request = buildAutoscaler();
1030 var arg_project = "foo";
1031 var arg_zone = "foo";
1032 var arg_autoscaler = "foo";
1033 mock.register(unittest.expectAsync((http.BaseRequest req, json) {
1034 var obj = new api.Autoscaler.fromJson(json);
1035 checkAutoscaler(obj);
1036
1037 var path = (req.url).path;
1038 var pathOffset = 0;
1039 var index;
1040 var subPart;
1041 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ als("/"));
1042 pathOffset += 1;
1043 unittest.expect(path.substring(pathOffset, pathOffset + 19), unittest.eq uals("autoscaler/v1beta2/"));
1044 pathOffset += 19;
1045 unittest.expect(path.substring(pathOffset, pathOffset + 9), unittest.equ als("projects/"));
1046 pathOffset += 9;
1047 index = path.indexOf("/zones/", pathOffset);
1048 unittest.expect(index >= 0, unittest.isTrue);
1049 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index ));
1050 pathOffset = index;
1051 unittest.expect(subPart, unittest.equals("$arg_project"));
1052 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ als("/zones/"));
1053 pathOffset += 7;
1054 index = path.indexOf("/autoscalers/", pathOffset);
1055 unittest.expect(index >= 0, unittest.isTrue);
1056 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index ));
1057 pathOffset = index;
1058 unittest.expect(subPart, unittest.equals("$arg_zone"));
1059 unittest.expect(path.substring(pathOffset, pathOffset + 13), unittest.eq uals("/autoscalers/"));
1060 pathOffset += 13;
1061 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset));
1062 pathOffset = path.length;
1063 unittest.expect(subPart, unittest.equals("$arg_autoscaler"));
1064
1065 var query = (req.url).query;
1066 var queryOffset = 0;
1067 var queryMap = {};
1068 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
1069 parseBool(n) {
1070 if (n == "true") return true;
1071 if (n == "false") return false;
1072 if (n == null) return null;
1073 throw new core.ArgumentError("Invalid boolean: $n");
1074 }
1075 if (query.length > 0) {
1076 for (var part in query.split("&")) {
1077 var keyvalue = part.split("=");
1078 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
1079 }
1080 }
1081
1082
1083 var h = {
1084 "content-type" : "application/json; charset=utf-8",
1085 };
1086 var resp = convert.JSON.encode(buildOperation());
1087 return new async.Future.value(stringResponse(200, h, resp));
1088 }), true);
1089 res.update(arg_request, arg_project, arg_zone, arg_autoscaler).then(unitte st.expectAsync(((api.Operation response) {
1090 checkOperation(response);
1091 })));
1092 });
1093
1094 });
1095
1096
1097 unittest.group("resource-ZoneOperationsResourceApi", () {
1098 unittest.test("method--delete", () {
1099
1100 var mock = new HttpServerMock();
1101 api.ZoneOperationsResourceApi res = new api.AutoscalerApi(mock).zoneOperat ions;
1102 var arg_project = "foo";
1103 var arg_zone = "foo";
1104 var arg_operation = "foo";
1105 mock.register(unittest.expectAsync((http.BaseRequest req, json) {
1106 var path = (req.url).path;
1107 var pathOffset = 0;
1108 var index;
1109 var subPart;
1110 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ als("/"));
1111 pathOffset += 1;
1112
1113 var query = (req.url).query;
1114 var queryOffset = 0;
1115 var queryMap = {};
1116 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
1117 parseBool(n) {
1118 if (n == "true") return true;
1119 if (n == "false") return false;
1120 if (n == null) return null;
1121 throw new core.ArgumentError("Invalid boolean: $n");
1122 }
1123 if (query.length > 0) {
1124 for (var part in query.split("&")) {
1125 var keyvalue = part.split("=");
1126 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
1127 }
1128 }
1129
1130
1131 var h = {
1132 "content-type" : "application/json; charset=utf-8",
1133 };
1134 var resp = "";
1135 return new async.Future.value(stringResponse(200, h, resp));
1136 }), true);
1137 res.delete(arg_project, arg_zone, arg_operation).then(unittest.expectAsync ((_) {}));
1138 });
1139
1140 unittest.test("method--get", () {
1141
1142 var mock = new HttpServerMock();
1143 api.ZoneOperationsResourceApi res = new api.AutoscalerApi(mock).zoneOperat ions;
1144 var arg_project = "foo";
1145 var arg_zone = "foo";
1146 var arg_operation = "foo";
1147 mock.register(unittest.expectAsync((http.BaseRequest req, json) {
1148 var path = (req.url).path;
1149 var pathOffset = 0;
1150 var index;
1151 var subPart;
1152 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ als("/"));
1153 pathOffset += 1;
1154
1155 var query = (req.url).query;
1156 var queryOffset = 0;
1157 var queryMap = {};
1158 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
1159 parseBool(n) {
1160 if (n == "true") return true;
1161 if (n == "false") return false;
1162 if (n == null) return null;
1163 throw new core.ArgumentError("Invalid boolean: $n");
1164 }
1165 if (query.length > 0) {
1166 for (var part in query.split("&")) {
1167 var keyvalue = part.split("=");
1168 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
1169 }
1170 }
1171
1172
1173 var h = {
1174 "content-type" : "application/json; charset=utf-8",
1175 };
1176 var resp = convert.JSON.encode(buildOperation());
1177 return new async.Future.value(stringResponse(200, h, resp));
1178 }), true);
1179 res.get(arg_project, arg_zone, arg_operation).then(unittest.expectAsync((( api.Operation response) {
1180 checkOperation(response);
1181 })));
1182 });
1183
1184 unittest.test("method--list", () {
1185
1186 var mock = new HttpServerMock();
1187 api.ZoneOperationsResourceApi res = new api.AutoscalerApi(mock).zoneOperat ions;
1188 var arg_project = "foo";
1189 var arg_zone = "foo";
1190 var arg_filter = "foo";
1191 var arg_maxResults = 42;
1192 var arg_pageToken = "foo";
1193 mock.register(unittest.expectAsync((http.BaseRequest req, json) {
1194 var path = (req.url).path;
1195 var pathOffset = 0;
1196 var index;
1197 var subPart;
1198 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ als("/"));
1199 pathOffset += 1;
1200
1201 var query = (req.url).query;
1202 var queryOffset = 0;
1203 var queryMap = {};
1204 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
1205 parseBool(n) {
1206 if (n == "true") return true;
1207 if (n == "false") return false;
1208 if (n == null) return null;
1209 throw new core.ArgumentError("Invalid boolean: $n");
1210 }
1211 if (query.length > 0) {
1212 for (var part in query.split("&")) {
1213 var keyvalue = part.split("=");
1214 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
1215 }
1216 }
1217 unittest.expect(queryMap["filter"].first, unittest.equals(arg_filter));
1218 unittest.expect(core.int.parse(queryMap["maxResults"].first), unittest.e quals(arg_maxResults));
1219 unittest.expect(queryMap["pageToken"].first, unittest.equals(arg_pageTok en));
1220
1221
1222 var h = {
1223 "content-type" : "application/json; charset=utf-8",
1224 };
1225 var resp = convert.JSON.encode(buildOperationList());
1226 return new async.Future.value(stringResponse(200, h, resp));
1227 }), true);
1228 res.list(arg_project, arg_zone, filter: arg_filter, maxResults: arg_maxRes ults, pageToken: arg_pageToken).then(unittest.expectAsync(((api.OperationList re sponse) {
1229 checkOperationList(response);
1230 })));
1231 });
1232
1233 });
1234
1235
1236 unittest.group("resource-ZonesResourceApi", () {
1237 unittest.test("method--list", () {
1238
1239 var mock = new HttpServerMock();
1240 api.ZonesResourceApi res = new api.AutoscalerApi(mock).zones;
1241 var arg_filter = "foo";
1242 var arg_maxResults = 42;
1243 var arg_pageToken = "foo";
1244 var arg_project = "foo";
1245 mock.register(unittest.expectAsync((http.BaseRequest req, json) {
1246 var path = (req.url).path;
1247 var pathOffset = 0;
1248 var index;
1249 var subPart;
1250 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ als("/"));
1251 pathOffset += 1;
1252 unittest.expect(path.substring(pathOffset, pathOffset + 19), unittest.eq uals("autoscaler/v1beta2/"));
1253 pathOffset += 19;
1254 unittest.expect(path.substring(pathOffset, pathOffset + 5), unittest.equ als("zones"));
1255 pathOffset += 5;
1256
1257 var query = (req.url).query;
1258 var queryOffset = 0;
1259 var queryMap = {};
1260 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
1261 parseBool(n) {
1262 if (n == "true") return true;
1263 if (n == "false") return false;
1264 if (n == null) return null;
1265 throw new core.ArgumentError("Invalid boolean: $n");
1266 }
1267 if (query.length > 0) {
1268 for (var part in query.split("&")) {
1269 var keyvalue = part.split("=");
1270 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
1271 }
1272 }
1273 unittest.expect(queryMap["filter"].first, unittest.equals(arg_filter));
1274 unittest.expect(core.int.parse(queryMap["maxResults"].first), unittest.e quals(arg_maxResults));
1275 unittest.expect(queryMap["pageToken"].first, unittest.equals(arg_pageTok en));
1276 unittest.expect(queryMap["project"].first, unittest.equals(arg_project)) ;
1277
1278
1279 var h = {
1280 "content-type" : "application/json; charset=utf-8",
1281 };
1282 var resp = convert.JSON.encode(buildZoneList());
1283 return new async.Future.value(stringResponse(200, h, resp));
1284 }), true);
1285 res.list(filter: arg_filter, maxResults: arg_maxResults, pageToken: arg_pa geToken, project: arg_project).then(unittest.expectAsync(((api.ZoneList response ) {
1286 checkZoneList(response);
1287 })));
1288 });
1289
1290 });
1291
1292
1293 }
1294
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698