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

Side by Side Diff: generated/googleapis_beta/test/autoscaler/v1beta2.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_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 import 'package:googleapis_beta/common/common.dart' as common;
12 import 'package:googleapis_beta/src/common_internal.dart' as common_internal;
13 import '../common/common_internal_test.dart' as common_test;
14
15 import 'package:googleapis_beta/autoscaler/v1beta2.dart' as api;
16
17
18
19 core.int buildCounterAutoscaler = 0;
20 buildAutoscaler() {
21 var o = new api.Autoscaler();
22 buildCounterAutoscaler++;
23 if (buildCounterAutoscaler < 3) {
24 o.autoscalingPolicy = buildAutoscalingPolicy();
25 o.creationTimestamp = "foo";
26 o.description = "foo";
27 o.id = "foo";
28 o.name = "foo";
29 o.selfLink = "foo";
30 o.target = "foo";
31 }
32 buildCounterAutoscaler--;
33 return o;
34 }
35
36 checkAutoscaler(api.Autoscaler o) {
37 buildCounterAutoscaler++;
38 if (buildCounterAutoscaler < 3) {
39 checkAutoscalingPolicy(o.autoscalingPolicy);
40 unittest.expect(o.creationTimestamp, unittest.equals('foo'));
41 unittest.expect(o.description, unittest.equals('foo'));
42 unittest.expect(o.id, unittest.equals('foo'));
43 unittest.expect(o.name, unittest.equals('foo'));
44 unittest.expect(o.selfLink, unittest.equals('foo'));
45 unittest.expect(o.target, unittest.equals('foo'));
46 }
47 buildCounterAutoscaler--;
48 }
49
50 buildUnnamed1116() {
51 var o = new core.List<api.Autoscaler>();
52 o.add(buildAutoscaler());
53 o.add(buildAutoscaler());
54 return o;
55 }
56
57 checkUnnamed1116(core.List<api.Autoscaler> o) {
58 unittest.expect(o, unittest.hasLength(2));
59 checkAutoscaler(o[0]);
60 checkAutoscaler(o[1]);
61 }
62
63 core.int buildCounterAutoscalerListResponse = 0;
64 buildAutoscalerListResponse() {
65 var o = new api.AutoscalerListResponse();
66 buildCounterAutoscalerListResponse++;
67 if (buildCounterAutoscalerListResponse < 3) {
68 o.items = buildUnnamed1116();
69 o.nextPageToken = "foo";
70 }
71 buildCounterAutoscalerListResponse--;
72 return o;
73 }
74
75 checkAutoscalerListResponse(api.AutoscalerListResponse o) {
76 buildCounterAutoscalerListResponse++;
77 if (buildCounterAutoscalerListResponse < 3) {
78 checkUnnamed1116(o.items);
79 unittest.expect(o.nextPageToken, unittest.equals('foo'));
80 }
81 buildCounterAutoscalerListResponse--;
82 }
83
84 buildUnnamed1117() {
85 var o = new core.List<api.AutoscalingPolicyCustomMetricUtilization>();
86 o.add(buildAutoscalingPolicyCustomMetricUtilization());
87 o.add(buildAutoscalingPolicyCustomMetricUtilization());
88 return o;
89 }
90
91 checkUnnamed1117(core.List<api.AutoscalingPolicyCustomMetricUtilization> o) {
92 unittest.expect(o, unittest.hasLength(2));
93 checkAutoscalingPolicyCustomMetricUtilization(o[0]);
94 checkAutoscalingPolicyCustomMetricUtilization(o[1]);
95 }
96
97 core.int buildCounterAutoscalingPolicy = 0;
98 buildAutoscalingPolicy() {
99 var o = new api.AutoscalingPolicy();
100 buildCounterAutoscalingPolicy++;
101 if (buildCounterAutoscalingPolicy < 3) {
102 o.coolDownPeriodSec = 42;
103 o.cpuUtilization = buildAutoscalingPolicyCpuUtilization();
104 o.customMetricUtilizations = buildUnnamed1117();
105 o.loadBalancingUtilization = buildAutoscalingPolicyLoadBalancingUtilization( );
106 o.maxNumReplicas = 42;
107 o.minNumReplicas = 42;
108 }
109 buildCounterAutoscalingPolicy--;
110 return o;
111 }
112
113 checkAutoscalingPolicy(api.AutoscalingPolicy o) {
114 buildCounterAutoscalingPolicy++;
115 if (buildCounterAutoscalingPolicy < 3) {
116 unittest.expect(o.coolDownPeriodSec, unittest.equals(42));
117 checkAutoscalingPolicyCpuUtilization(o.cpuUtilization);
118 checkUnnamed1117(o.customMetricUtilizations);
119 checkAutoscalingPolicyLoadBalancingUtilization(o.loadBalancingUtilization);
120 unittest.expect(o.maxNumReplicas, unittest.equals(42));
121 unittest.expect(o.minNumReplicas, unittest.equals(42));
122 }
123 buildCounterAutoscalingPolicy--;
124 }
125
126 core.int buildCounterAutoscalingPolicyCpuUtilization = 0;
127 buildAutoscalingPolicyCpuUtilization() {
128 var o = new api.AutoscalingPolicyCpuUtilization();
129 buildCounterAutoscalingPolicyCpuUtilization++;
130 if (buildCounterAutoscalingPolicyCpuUtilization < 3) {
131 o.utilizationTarget = 42.0;
132 }
133 buildCounterAutoscalingPolicyCpuUtilization--;
134 return o;
135 }
136
137 checkAutoscalingPolicyCpuUtilization(api.AutoscalingPolicyCpuUtilization o) {
138 buildCounterAutoscalingPolicyCpuUtilization++;
139 if (buildCounterAutoscalingPolicyCpuUtilization < 3) {
140 unittest.expect(o.utilizationTarget, unittest.equals(42.0));
141 }
142 buildCounterAutoscalingPolicyCpuUtilization--;
143 }
144
145 core.int buildCounterAutoscalingPolicyCustomMetricUtilization = 0;
146 buildAutoscalingPolicyCustomMetricUtilization() {
147 var o = new api.AutoscalingPolicyCustomMetricUtilization();
148 buildCounterAutoscalingPolicyCustomMetricUtilization++;
149 if (buildCounterAutoscalingPolicyCustomMetricUtilization < 3) {
150 o.metric = "foo";
151 o.utilizationTarget = 42.0;
152 }
153 buildCounterAutoscalingPolicyCustomMetricUtilization--;
154 return o;
155 }
156
157 checkAutoscalingPolicyCustomMetricUtilization(api.AutoscalingPolicyCustomMetricU tilization o) {
158 buildCounterAutoscalingPolicyCustomMetricUtilization++;
159 if (buildCounterAutoscalingPolicyCustomMetricUtilization < 3) {
160 unittest.expect(o.metric, unittest.equals('foo'));
161 unittest.expect(o.utilizationTarget, unittest.equals(42.0));
162 }
163 buildCounterAutoscalingPolicyCustomMetricUtilization--;
164 }
165
166 core.int buildCounterAutoscalingPolicyLoadBalancingUtilization = 0;
167 buildAutoscalingPolicyLoadBalancingUtilization() {
168 var o = new api.AutoscalingPolicyLoadBalancingUtilization();
169 buildCounterAutoscalingPolicyLoadBalancingUtilization++;
170 if (buildCounterAutoscalingPolicyLoadBalancingUtilization < 3) {
171 o.utilizationTarget = 42.0;
172 }
173 buildCounterAutoscalingPolicyLoadBalancingUtilization--;
174 return o;
175 }
176
177 checkAutoscalingPolicyLoadBalancingUtilization(api.AutoscalingPolicyLoadBalancin gUtilization o) {
178 buildCounterAutoscalingPolicyLoadBalancingUtilization++;
179 if (buildCounterAutoscalingPolicyLoadBalancingUtilization < 3) {
180 unittest.expect(o.utilizationTarget, unittest.equals(42.0));
181 }
182 buildCounterAutoscalingPolicyLoadBalancingUtilization--;
183 }
184
185 core.int buildCounterOperationErrorErrors = 0;
186 buildOperationErrorErrors() {
187 var o = new api.OperationErrorErrors();
188 buildCounterOperationErrorErrors++;
189 if (buildCounterOperationErrorErrors < 3) {
190 o.code = "foo";
191 o.location = "foo";
192 o.message = "foo";
193 }
194 buildCounterOperationErrorErrors--;
195 return o;
196 }
197
198 checkOperationErrorErrors(api.OperationErrorErrors o) {
199 buildCounterOperationErrorErrors++;
200 if (buildCounterOperationErrorErrors < 3) {
201 unittest.expect(o.code, unittest.equals('foo'));
202 unittest.expect(o.location, unittest.equals('foo'));
203 unittest.expect(o.message, unittest.equals('foo'));
204 }
205 buildCounterOperationErrorErrors--;
206 }
207
208 buildUnnamed1118() {
209 var o = new core.List<api.OperationErrorErrors>();
210 o.add(buildOperationErrorErrors());
211 o.add(buildOperationErrorErrors());
212 return o;
213 }
214
215 checkUnnamed1118(core.List<api.OperationErrorErrors> o) {
216 unittest.expect(o, unittest.hasLength(2));
217 checkOperationErrorErrors(o[0]);
218 checkOperationErrorErrors(o[1]);
219 }
220
221 core.int buildCounterOperationError = 0;
222 buildOperationError() {
223 var o = new api.OperationError();
224 buildCounterOperationError++;
225 if (buildCounterOperationError < 3) {
226 o.errors = buildUnnamed1118();
227 }
228 buildCounterOperationError--;
229 return o;
230 }
231
232 checkOperationError(api.OperationError o) {
233 buildCounterOperationError++;
234 if (buildCounterOperationError < 3) {
235 checkUnnamed1118(o.errors);
236 }
237 buildCounterOperationError--;
238 }
239
240 core.int buildCounterOperationWarningsData = 0;
241 buildOperationWarningsData() {
242 var o = new api.OperationWarningsData();
243 buildCounterOperationWarningsData++;
244 if (buildCounterOperationWarningsData < 3) {
245 o.key = "foo";
246 o.value = "foo";
247 }
248 buildCounterOperationWarningsData--;
249 return o;
250 }
251
252 checkOperationWarningsData(api.OperationWarningsData o) {
253 buildCounterOperationWarningsData++;
254 if (buildCounterOperationWarningsData < 3) {
255 unittest.expect(o.key, unittest.equals('foo'));
256 unittest.expect(o.value, unittest.equals('foo'));
257 }
258 buildCounterOperationWarningsData--;
259 }
260
261 buildUnnamed1119() {
262 var o = new core.List<api.OperationWarningsData>();
263 o.add(buildOperationWarningsData());
264 o.add(buildOperationWarningsData());
265 return o;
266 }
267
268 checkUnnamed1119(core.List<api.OperationWarningsData> o) {
269 unittest.expect(o, unittest.hasLength(2));
270 checkOperationWarningsData(o[0]);
271 checkOperationWarningsData(o[1]);
272 }
273
274 core.int buildCounterOperationWarnings = 0;
275 buildOperationWarnings() {
276 var o = new api.OperationWarnings();
277 buildCounterOperationWarnings++;
278 if (buildCounterOperationWarnings < 3) {
279 o.code = "foo";
280 o.data = buildUnnamed1119();
281 o.message = "foo";
282 }
283 buildCounterOperationWarnings--;
284 return o;
285 }
286
287 checkOperationWarnings(api.OperationWarnings o) {
288 buildCounterOperationWarnings++;
289 if (buildCounterOperationWarnings < 3) {
290 unittest.expect(o.code, unittest.equals('foo'));
291 checkUnnamed1119(o.data);
292 unittest.expect(o.message, unittest.equals('foo'));
293 }
294 buildCounterOperationWarnings--;
295 }
296
297 buildUnnamed1120() {
298 var o = new core.List<api.OperationWarnings>();
299 o.add(buildOperationWarnings());
300 o.add(buildOperationWarnings());
301 return o;
302 }
303
304 checkUnnamed1120(core.List<api.OperationWarnings> o) {
305 unittest.expect(o, unittest.hasLength(2));
306 checkOperationWarnings(o[0]);
307 checkOperationWarnings(o[1]);
308 }
309
310 core.int buildCounterOperation = 0;
311 buildOperation() {
312 var o = new api.Operation();
313 buildCounterOperation++;
314 if (buildCounterOperation < 3) {
315 o.clientOperationId = "foo";
316 o.creationTimestamp = "foo";
317 o.endTime = "foo";
318 o.error = buildOperationError();
319 o.httpErrorMessage = "foo";
320 o.httpErrorStatusCode = 42;
321 o.id = "foo";
322 o.insertTime = "foo";
323 o.kind = "foo";
324 o.name = "foo";
325 o.operationType = "foo";
326 o.progress = 42;
327 o.region = "foo";
328 o.selfLink = "foo";
329 o.startTime = "foo";
330 o.status = "foo";
331 o.statusMessage = "foo";
332 o.targetId = "foo";
333 o.targetLink = "foo";
334 o.user = "foo";
335 o.warnings = buildUnnamed1120();
336 o.zone = "foo";
337 }
338 buildCounterOperation--;
339 return o;
340 }
341
342 checkOperation(api.Operation o) {
343 buildCounterOperation++;
344 if (buildCounterOperation < 3) {
345 unittest.expect(o.clientOperationId, unittest.equals('foo'));
346 unittest.expect(o.creationTimestamp, unittest.equals('foo'));
347 unittest.expect(o.endTime, unittest.equals('foo'));
348 checkOperationError(o.error);
349 unittest.expect(o.httpErrorMessage, unittest.equals('foo'));
350 unittest.expect(o.httpErrorStatusCode, unittest.equals(42));
351 unittest.expect(o.id, unittest.equals('foo'));
352 unittest.expect(o.insertTime, unittest.equals('foo'));
353 unittest.expect(o.kind, unittest.equals('foo'));
354 unittest.expect(o.name, unittest.equals('foo'));
355 unittest.expect(o.operationType, unittest.equals('foo'));
356 unittest.expect(o.progress, unittest.equals(42));
357 unittest.expect(o.region, unittest.equals('foo'));
358 unittest.expect(o.selfLink, unittest.equals('foo'));
359 unittest.expect(o.startTime, unittest.equals('foo'));
360 unittest.expect(o.status, unittest.equals('foo'));
361 unittest.expect(o.statusMessage, unittest.equals('foo'));
362 unittest.expect(o.targetId, unittest.equals('foo'));
363 unittest.expect(o.targetLink, unittest.equals('foo'));
364 unittest.expect(o.user, unittest.equals('foo'));
365 checkUnnamed1120(o.warnings);
366 unittest.expect(o.zone, unittest.equals('foo'));
367 }
368 buildCounterOperation--;
369 }
370
371 buildUnnamed1121() {
372 var o = new core.List<api.Operation>();
373 o.add(buildOperation());
374 o.add(buildOperation());
375 return o;
376 }
377
378 checkUnnamed1121(core.List<api.Operation> o) {
379 unittest.expect(o, unittest.hasLength(2));
380 checkOperation(o[0]);
381 checkOperation(o[1]);
382 }
383
384 core.int buildCounterOperationList = 0;
385 buildOperationList() {
386 var o = new api.OperationList();
387 buildCounterOperationList++;
388 if (buildCounterOperationList < 3) {
389 o.id = "foo";
390 o.items = buildUnnamed1121();
391 o.kind = "foo";
392 o.nextPageToken = "foo";
393 o.selfLink = "foo";
394 }
395 buildCounterOperationList--;
396 return o;
397 }
398
399 checkOperationList(api.OperationList o) {
400 buildCounterOperationList++;
401 if (buildCounterOperationList < 3) {
402 unittest.expect(o.id, unittest.equals('foo'));
403 checkUnnamed1121(o.items);
404 unittest.expect(o.kind, unittest.equals('foo'));
405 unittest.expect(o.nextPageToken, unittest.equals('foo'));
406 unittest.expect(o.selfLink, unittest.equals('foo'));
407 }
408 buildCounterOperationList--;
409 }
410
411
412 main() {
413 unittest.group("obj-schema-Autoscaler", () {
414 unittest.test("to-json--from-json", () {
415 var o = buildAutoscaler();
416 var od = new api.Autoscaler.fromJson(o.toJson());
417 checkAutoscaler(od);
418 });
419 });
420
421
422 unittest.group("obj-schema-AutoscalerListResponse", () {
423 unittest.test("to-json--from-json", () {
424 var o = buildAutoscalerListResponse();
425 var od = new api.AutoscalerListResponse.fromJson(o.toJson());
426 checkAutoscalerListResponse(od);
427 });
428 });
429
430
431 unittest.group("obj-schema-AutoscalingPolicy", () {
432 unittest.test("to-json--from-json", () {
433 var o = buildAutoscalingPolicy();
434 var od = new api.AutoscalingPolicy.fromJson(o.toJson());
435 checkAutoscalingPolicy(od);
436 });
437 });
438
439
440 unittest.group("obj-schema-AutoscalingPolicyCpuUtilization", () {
441 unittest.test("to-json--from-json", () {
442 var o = buildAutoscalingPolicyCpuUtilization();
443 var od = new api.AutoscalingPolicyCpuUtilization.fromJson(o.toJson());
444 checkAutoscalingPolicyCpuUtilization(od);
445 });
446 });
447
448
449 unittest.group("obj-schema-AutoscalingPolicyCustomMetricUtilization", () {
450 unittest.test("to-json--from-json", () {
451 var o = buildAutoscalingPolicyCustomMetricUtilization();
452 var od = new api.AutoscalingPolicyCustomMetricUtilization.fromJson(o.toJso n());
453 checkAutoscalingPolicyCustomMetricUtilization(od);
454 });
455 });
456
457
458 unittest.group("obj-schema-AutoscalingPolicyLoadBalancingUtilization", () {
459 unittest.test("to-json--from-json", () {
460 var o = buildAutoscalingPolicyLoadBalancingUtilization();
461 var od = new api.AutoscalingPolicyLoadBalancingUtilization.fromJson(o.toJs on());
462 checkAutoscalingPolicyLoadBalancingUtilization(od);
463 });
464 });
465
466
467 unittest.group("obj-schema-OperationErrorErrors", () {
468 unittest.test("to-json--from-json", () {
469 var o = buildOperationErrorErrors();
470 var od = new api.OperationErrorErrors.fromJson(o.toJson());
471 checkOperationErrorErrors(od);
472 });
473 });
474
475
476 unittest.group("obj-schema-OperationError", () {
477 unittest.test("to-json--from-json", () {
478 var o = buildOperationError();
479 var od = new api.OperationError.fromJson(o.toJson());
480 checkOperationError(od);
481 });
482 });
483
484
485 unittest.group("obj-schema-OperationWarningsData", () {
486 unittest.test("to-json--from-json", () {
487 var o = buildOperationWarningsData();
488 var od = new api.OperationWarningsData.fromJson(o.toJson());
489 checkOperationWarningsData(od);
490 });
491 });
492
493
494 unittest.group("obj-schema-OperationWarnings", () {
495 unittest.test("to-json--from-json", () {
496 var o = buildOperationWarnings();
497 var od = new api.OperationWarnings.fromJson(o.toJson());
498 checkOperationWarnings(od);
499 });
500 });
501
502
503 unittest.group("obj-schema-Operation", () {
504 unittest.test("to-json--from-json", () {
505 var o = buildOperation();
506 var od = new api.Operation.fromJson(o.toJson());
507 checkOperation(od);
508 });
509 });
510
511
512 unittest.group("obj-schema-OperationList", () {
513 unittest.test("to-json--from-json", () {
514 var o = buildOperationList();
515 var od = new api.OperationList.fromJson(o.toJson());
516 checkOperationList(od);
517 });
518 });
519
520
521 unittest.group("resource-AutoscalersResourceApi", () {
522 unittest.test("method--delete", () {
523
524 var mock = new common_test.HttpServerMock();
525 api.AutoscalersResourceApi res = new api.AutoscalerApi(mock).autoscalers;
526 var arg_project = "foo";
527 var arg_zone = "foo";
528 var arg_autoscaler = "foo";
529 mock.register(unittest.expectAsync((http.BaseRequest req, json) {
530 var path = (req.url).path;
531 var pathOffset = 0;
532 var index;
533 var subPart;
534 unittest.expect(path.substring(pathOffset, pathOffset + 20), unittest.eq uals("/autoscaler/v1beta2/"));
535 pathOffset += 20;
536 unittest.expect(path.substring(pathOffset, pathOffset + 9), unittest.equ als("projects/"));
537 pathOffset += 9;
538 index = path.indexOf("/zones/", pathOffset);
539 unittest.expect(index >= 0, unittest.isTrue);
540 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index ));
541 pathOffset = index;
542 unittest.expect(subPart, unittest.equals("$arg_project"));
543 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ als("/zones/"));
544 pathOffset += 7;
545 index = path.indexOf("/autoscalers/", pathOffset);
546 unittest.expect(index >= 0, unittest.isTrue);
547 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index ));
548 pathOffset = index;
549 unittest.expect(subPart, unittest.equals("$arg_zone"));
550 unittest.expect(path.substring(pathOffset, pathOffset + 13), unittest.eq uals("/autoscalers/"));
551 pathOffset += 13;
552 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset));
553 pathOffset = path.length;
554 unittest.expect(subPart, unittest.equals("$arg_autoscaler"));
555
556 var query = (req.url).query;
557 var queryOffset = 0;
558 var queryMap = {};
559 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
560 parseBool(n) {
561 if (n == "true") return true;
562 if (n == "false") return false;
563 if (n == null) return null;
564 throw new core.ArgumentError("Invalid boolean: $n");
565 }
566 if (query.length > 0) {
567 for (var part in query.split("&")) {
568 var keyvalue = part.split("=");
569 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
570 }
571 }
572
573
574 var h = {
575 "content-type" : "application/json; charset=utf-8",
576 };
577 var resp = convert.JSON.encode(buildOperation());
578 return new async.Future.value(common_test.stringResponse(200, h, resp));
579 }), true);
580 res.delete(arg_project, arg_zone, arg_autoscaler).then(unittest.expectAsyn c(((api.Operation response) {
581 checkOperation(response);
582 })));
583 });
584
585 unittest.test("method--get", () {
586
587 var mock = new common_test.HttpServerMock();
588 api.AutoscalersResourceApi res = new api.AutoscalerApi(mock).autoscalers;
589 var arg_project = "foo";
590 var arg_zone = "foo";
591 var arg_autoscaler = "foo";
592 mock.register(unittest.expectAsync((http.BaseRequest req, json) {
593 var path = (req.url).path;
594 var pathOffset = 0;
595 var index;
596 var subPart;
597 unittest.expect(path.substring(pathOffset, pathOffset + 20), unittest.eq uals("/autoscaler/v1beta2/"));
598 pathOffset += 20;
599 unittest.expect(path.substring(pathOffset, pathOffset + 9), unittest.equ als("projects/"));
600 pathOffset += 9;
601 index = path.indexOf("/zones/", pathOffset);
602 unittest.expect(index >= 0, unittest.isTrue);
603 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index ));
604 pathOffset = index;
605 unittest.expect(subPart, unittest.equals("$arg_project"));
606 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ als("/zones/"));
607 pathOffset += 7;
608 index = path.indexOf("/autoscalers/", pathOffset);
609 unittest.expect(index >= 0, unittest.isTrue);
610 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index ));
611 pathOffset = index;
612 unittest.expect(subPart, unittest.equals("$arg_zone"));
613 unittest.expect(path.substring(pathOffset, pathOffset + 13), unittest.eq uals("/autoscalers/"));
614 pathOffset += 13;
615 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset));
616 pathOffset = path.length;
617 unittest.expect(subPart, unittest.equals("$arg_autoscaler"));
618
619 var query = (req.url).query;
620 var queryOffset = 0;
621 var queryMap = {};
622 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
623 parseBool(n) {
624 if (n == "true") return true;
625 if (n == "false") return false;
626 if (n == null) return null;
627 throw new core.ArgumentError("Invalid boolean: $n");
628 }
629 if (query.length > 0) {
630 for (var part in query.split("&")) {
631 var keyvalue = part.split("=");
632 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
633 }
634 }
635
636
637 var h = {
638 "content-type" : "application/json; charset=utf-8",
639 };
640 var resp = convert.JSON.encode(buildAutoscaler());
641 return new async.Future.value(common_test.stringResponse(200, h, resp));
642 }), true);
643 res.get(arg_project, arg_zone, arg_autoscaler).then(unittest.expectAsync(( (api.Autoscaler response) {
644 checkAutoscaler(response);
645 })));
646 });
647
648 unittest.test("method--insert", () {
649
650 var mock = new common_test.HttpServerMock();
651 api.AutoscalersResourceApi res = new api.AutoscalerApi(mock).autoscalers;
652 var arg_request = buildAutoscaler();
653 var arg_project = "foo";
654 var arg_zone = "foo";
655 mock.register(unittest.expectAsync((http.BaseRequest req, json) {
656 var obj = new api.Autoscaler.fromJson(json);
657 checkAutoscaler(obj);
658
659 var path = (req.url).path;
660 var pathOffset = 0;
661 var index;
662 var subPart;
663 unittest.expect(path.substring(pathOffset, pathOffset + 20), unittest.eq uals("/autoscaler/v1beta2/"));
664 pathOffset += 20;
665 unittest.expect(path.substring(pathOffset, pathOffset + 9), unittest.equ als("projects/"));
666 pathOffset += 9;
667 index = path.indexOf("/zones/", pathOffset);
668 unittest.expect(index >= 0, unittest.isTrue);
669 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index ));
670 pathOffset = index;
671 unittest.expect(subPart, unittest.equals("$arg_project"));
672 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ als("/zones/"));
673 pathOffset += 7;
674 index = path.indexOf("/autoscalers", pathOffset);
675 unittest.expect(index >= 0, unittest.isTrue);
676 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index ));
677 pathOffset = index;
678 unittest.expect(subPart, unittest.equals("$arg_zone"));
679 unittest.expect(path.substring(pathOffset, pathOffset + 12), unittest.eq uals("/autoscalers"));
680 pathOffset += 12;
681
682 var query = (req.url).query;
683 var queryOffset = 0;
684 var queryMap = {};
685 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
686 parseBool(n) {
687 if (n == "true") return true;
688 if (n == "false") return false;
689 if (n == null) return null;
690 throw new core.ArgumentError("Invalid boolean: $n");
691 }
692 if (query.length > 0) {
693 for (var part in query.split("&")) {
694 var keyvalue = part.split("=");
695 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
696 }
697 }
698
699
700 var h = {
701 "content-type" : "application/json; charset=utf-8",
702 };
703 var resp = convert.JSON.encode(buildOperation());
704 return new async.Future.value(common_test.stringResponse(200, h, resp));
705 }), true);
706 res.insert(arg_request, arg_project, arg_zone).then(unittest.expectAsync(( (api.Operation response) {
707 checkOperation(response);
708 })));
709 });
710
711 unittest.test("method--list", () {
712
713 var mock = new common_test.HttpServerMock();
714 api.AutoscalersResourceApi res = new api.AutoscalerApi(mock).autoscalers;
715 var arg_project = "foo";
716 var arg_zone = "foo";
717 var arg_filter = "foo";
718 var arg_maxResults = 42;
719 var arg_pageToken = "foo";
720 mock.register(unittest.expectAsync((http.BaseRequest req, json) {
721 var path = (req.url).path;
722 var pathOffset = 0;
723 var index;
724 var subPart;
725 unittest.expect(path.substring(pathOffset, pathOffset + 20), unittest.eq uals("/autoscaler/v1beta2/"));
726 pathOffset += 20;
727 unittest.expect(path.substring(pathOffset, pathOffset + 9), unittest.equ als("projects/"));
728 pathOffset += 9;
729 index = path.indexOf("/zones/", pathOffset);
730 unittest.expect(index >= 0, unittest.isTrue);
731 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index ));
732 pathOffset = index;
733 unittest.expect(subPart, unittest.equals("$arg_project"));
734 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ als("/zones/"));
735 pathOffset += 7;
736 index = path.indexOf("/autoscalers", pathOffset);
737 unittest.expect(index >= 0, unittest.isTrue);
738 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index ));
739 pathOffset = index;
740 unittest.expect(subPart, unittest.equals("$arg_zone"));
741 unittest.expect(path.substring(pathOffset, pathOffset + 12), unittest.eq uals("/autoscalers"));
742 pathOffset += 12;
743
744 var query = (req.url).query;
745 var queryOffset = 0;
746 var queryMap = {};
747 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
748 parseBool(n) {
749 if (n == "true") return true;
750 if (n == "false") return false;
751 if (n == null) return null;
752 throw new core.ArgumentError("Invalid boolean: $n");
753 }
754 if (query.length > 0) {
755 for (var part in query.split("&")) {
756 var keyvalue = part.split("=");
757 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
758 }
759 }
760 unittest.expect(queryMap["filter"].first, unittest.equals(arg_filter));
761 unittest.expect(core.int.parse(queryMap["maxResults"].first), unittest.e quals(arg_maxResults));
762 unittest.expect(queryMap["pageToken"].first, unittest.equals(arg_pageTok en));
763
764
765 var h = {
766 "content-type" : "application/json; charset=utf-8",
767 };
768 var resp = convert.JSON.encode(buildAutoscalerListResponse());
769 return new async.Future.value(common_test.stringResponse(200, h, resp));
770 }), true);
771 res.list(arg_project, arg_zone, filter: arg_filter, maxResults: arg_maxRes ults, pageToken: arg_pageToken).then(unittest.expectAsync(((api.AutoscalerListRe sponse response) {
772 checkAutoscalerListResponse(response);
773 })));
774 });
775
776 unittest.test("method--patch", () {
777
778 var mock = new common_test.HttpServerMock();
779 api.AutoscalersResourceApi res = new api.AutoscalerApi(mock).autoscalers;
780 var arg_request = buildAutoscaler();
781 var arg_project = "foo";
782 var arg_zone = "foo";
783 var arg_autoscaler = "foo";
784 mock.register(unittest.expectAsync((http.BaseRequest req, json) {
785 var obj = new api.Autoscaler.fromJson(json);
786 checkAutoscaler(obj);
787
788 var path = (req.url).path;
789 var pathOffset = 0;
790 var index;
791 var subPart;
792 unittest.expect(path.substring(pathOffset, pathOffset + 20), unittest.eq uals("/autoscaler/v1beta2/"));
793 pathOffset += 20;
794 unittest.expect(path.substring(pathOffset, pathOffset + 9), unittest.equ als("projects/"));
795 pathOffset += 9;
796 index = path.indexOf("/zones/", pathOffset);
797 unittest.expect(index >= 0, unittest.isTrue);
798 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index ));
799 pathOffset = index;
800 unittest.expect(subPart, unittest.equals("$arg_project"));
801 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ als("/zones/"));
802 pathOffset += 7;
803 index = path.indexOf("/autoscalers/", pathOffset);
804 unittest.expect(index >= 0, unittest.isTrue);
805 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index ));
806 pathOffset = index;
807 unittest.expect(subPart, unittest.equals("$arg_zone"));
808 unittest.expect(path.substring(pathOffset, pathOffset + 13), unittest.eq uals("/autoscalers/"));
809 pathOffset += 13;
810 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset));
811 pathOffset = path.length;
812 unittest.expect(subPart, unittest.equals("$arg_autoscaler"));
813
814 var query = (req.url).query;
815 var queryOffset = 0;
816 var queryMap = {};
817 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
818 parseBool(n) {
819 if (n == "true") return true;
820 if (n == "false") return false;
821 if (n == null) return null;
822 throw new core.ArgumentError("Invalid boolean: $n");
823 }
824 if (query.length > 0) {
825 for (var part in query.split("&")) {
826 var keyvalue = part.split("=");
827 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
828 }
829 }
830
831
832 var h = {
833 "content-type" : "application/json; charset=utf-8",
834 };
835 var resp = convert.JSON.encode(buildOperation());
836 return new async.Future.value(common_test.stringResponse(200, h, resp));
837 }), true);
838 res.patch(arg_request, arg_project, arg_zone, arg_autoscaler).then(unittes t.expectAsync(((api.Operation response) {
839 checkOperation(response);
840 })));
841 });
842
843 unittest.test("method--update", () {
844
845 var mock = new common_test.HttpServerMock();
846 api.AutoscalersResourceApi res = new api.AutoscalerApi(mock).autoscalers;
847 var arg_request = buildAutoscaler();
848 var arg_project = "foo";
849 var arg_zone = "foo";
850 var arg_autoscaler = "foo";
851 mock.register(unittest.expectAsync((http.BaseRequest req, json) {
852 var obj = new api.Autoscaler.fromJson(json);
853 checkAutoscaler(obj);
854
855 var path = (req.url).path;
856 var pathOffset = 0;
857 var index;
858 var subPart;
859 unittest.expect(path.substring(pathOffset, pathOffset + 20), unittest.eq uals("/autoscaler/v1beta2/"));
860 pathOffset += 20;
861 unittest.expect(path.substring(pathOffset, pathOffset + 9), unittest.equ als("projects/"));
862 pathOffset += 9;
863 index = path.indexOf("/zones/", pathOffset);
864 unittest.expect(index >= 0, unittest.isTrue);
865 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index ));
866 pathOffset = index;
867 unittest.expect(subPart, unittest.equals("$arg_project"));
868 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ als("/zones/"));
869 pathOffset += 7;
870 index = path.indexOf("/autoscalers/", pathOffset);
871 unittest.expect(index >= 0, unittest.isTrue);
872 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index ));
873 pathOffset = index;
874 unittest.expect(subPart, unittest.equals("$arg_zone"));
875 unittest.expect(path.substring(pathOffset, pathOffset + 13), unittest.eq uals("/autoscalers/"));
876 pathOffset += 13;
877 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset));
878 pathOffset = path.length;
879 unittest.expect(subPart, unittest.equals("$arg_autoscaler"));
880
881 var query = (req.url).query;
882 var queryOffset = 0;
883 var queryMap = {};
884 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
885 parseBool(n) {
886 if (n == "true") return true;
887 if (n == "false") return false;
888 if (n == null) return null;
889 throw new core.ArgumentError("Invalid boolean: $n");
890 }
891 if (query.length > 0) {
892 for (var part in query.split("&")) {
893 var keyvalue = part.split("=");
894 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
895 }
896 }
897
898
899 var h = {
900 "content-type" : "application/json; charset=utf-8",
901 };
902 var resp = convert.JSON.encode(buildOperation());
903 return new async.Future.value(common_test.stringResponse(200, h, resp));
904 }), true);
905 res.update(arg_request, arg_project, arg_zone, arg_autoscaler).then(unitte st.expectAsync(((api.Operation response) {
906 checkOperation(response);
907 })));
908 });
909
910 });
911
912
913 unittest.group("resource-ZoneOperationsResourceApi", () {
914 unittest.test("method--delete", () {
915
916 var mock = new common_test.HttpServerMock();
917 api.ZoneOperationsResourceApi res = new api.AutoscalerApi(mock).zoneOperat ions;
918 var arg_project = "foo";
919 var arg_zone = "foo";
920 var arg_operation = "foo";
921 mock.register(unittest.expectAsync((http.BaseRequest req, json) {
922 var path = (req.url).path;
923 var pathOffset = 0;
924 var index;
925 var subPart;
926 unittest.expect(path.substring(pathOffset, pathOffset + 20), unittest.eq uals("/autoscaler/v1beta2/"));
927 pathOffset += 20;
928 index = path.indexOf("/zones/", pathOffset);
929 unittest.expect(index >= 0, unittest.isTrue);
930 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index ));
931 pathOffset = index;
932 unittest.expect(subPart, unittest.equals("$arg_project"));
933 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ als("/zones/"));
934 pathOffset += 7;
935 index = path.indexOf("/operations/", pathOffset);
936 unittest.expect(index >= 0, unittest.isTrue);
937 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index ));
938 pathOffset = index;
939 unittest.expect(subPart, unittest.equals("$arg_zone"));
940 unittest.expect(path.substring(pathOffset, pathOffset + 12), unittest.eq uals("/operations/"));
941 pathOffset += 12;
942 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset));
943 pathOffset = path.length;
944 unittest.expect(subPart, unittest.equals("$arg_operation"));
945
946 var query = (req.url).query;
947 var queryOffset = 0;
948 var queryMap = {};
949 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
950 parseBool(n) {
951 if (n == "true") return true;
952 if (n == "false") return false;
953 if (n == null) return null;
954 throw new core.ArgumentError("Invalid boolean: $n");
955 }
956 if (query.length > 0) {
957 for (var part in query.split("&")) {
958 var keyvalue = part.split("=");
959 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
960 }
961 }
962
963
964 var h = {
965 "content-type" : "application/json; charset=utf-8",
966 };
967 var resp = "";
968 return new async.Future.value(common_test.stringResponse(200, h, resp));
969 }), true);
970 res.delete(arg_project, arg_zone, arg_operation).then(unittest.expectAsync ((_) {}));
971 });
972
973 unittest.test("method--get", () {
974
975 var mock = new common_test.HttpServerMock();
976 api.ZoneOperationsResourceApi res = new api.AutoscalerApi(mock).zoneOperat ions;
977 var arg_project = "foo";
978 var arg_zone = "foo";
979 var arg_operation = "foo";
980 mock.register(unittest.expectAsync((http.BaseRequest req, json) {
981 var path = (req.url).path;
982 var pathOffset = 0;
983 var index;
984 var subPart;
985 unittest.expect(path.substring(pathOffset, pathOffset + 20), unittest.eq uals("/autoscaler/v1beta2/"));
986 pathOffset += 20;
987 index = path.indexOf("/zones/", pathOffset);
988 unittest.expect(index >= 0, unittest.isTrue);
989 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index ));
990 pathOffset = index;
991 unittest.expect(subPart, unittest.equals("$arg_project"));
992 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ als("/zones/"));
993 pathOffset += 7;
994 index = path.indexOf("/operations/", pathOffset);
995 unittest.expect(index >= 0, unittest.isTrue);
996 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index ));
997 pathOffset = index;
998 unittest.expect(subPart, unittest.equals("$arg_zone"));
999 unittest.expect(path.substring(pathOffset, pathOffset + 12), unittest.eq uals("/operations/"));
1000 pathOffset += 12;
1001 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset));
1002 pathOffset = path.length;
1003 unittest.expect(subPart, unittest.equals("$arg_operation"));
1004
1005 var query = (req.url).query;
1006 var queryOffset = 0;
1007 var queryMap = {};
1008 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
1009 parseBool(n) {
1010 if (n == "true") return true;
1011 if (n == "false") return false;
1012 if (n == null) return null;
1013 throw new core.ArgumentError("Invalid boolean: $n");
1014 }
1015 if (query.length > 0) {
1016 for (var part in query.split("&")) {
1017 var keyvalue = part.split("=");
1018 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
1019 }
1020 }
1021
1022
1023 var h = {
1024 "content-type" : "application/json; charset=utf-8",
1025 };
1026 var resp = convert.JSON.encode(buildOperation());
1027 return new async.Future.value(common_test.stringResponse(200, h, resp));
1028 }), true);
1029 res.get(arg_project, arg_zone, arg_operation).then(unittest.expectAsync((( api.Operation response) {
1030 checkOperation(response);
1031 })));
1032 });
1033
1034 unittest.test("method--list", () {
1035
1036 var mock = new common_test.HttpServerMock();
1037 api.ZoneOperationsResourceApi res = new api.AutoscalerApi(mock).zoneOperat ions;
1038 var arg_project = "foo";
1039 var arg_zone = "foo";
1040 var arg_filter = "foo";
1041 var arg_maxResults = 42;
1042 var arg_pageToken = "foo";
1043 mock.register(unittest.expectAsync((http.BaseRequest req, json) {
1044 var path = (req.url).path;
1045 var pathOffset = 0;
1046 var index;
1047 var subPart;
1048 unittest.expect(path.substring(pathOffset, pathOffset + 20), unittest.eq uals("/autoscaler/v1beta2/"));
1049 pathOffset += 20;
1050 index = path.indexOf("/zones/", pathOffset);
1051 unittest.expect(index >= 0, unittest.isTrue);
1052 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index ));
1053 pathOffset = index;
1054 unittest.expect(subPart, unittest.equals("$arg_project"));
1055 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ als("/zones/"));
1056 pathOffset += 7;
1057 index = path.indexOf("/operations", pathOffset);
1058 unittest.expect(index >= 0, unittest.isTrue);
1059 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index ));
1060 pathOffset = index;
1061 unittest.expect(subPart, unittest.equals("$arg_zone"));
1062 unittest.expect(path.substring(pathOffset, pathOffset + 11), unittest.eq uals("/operations"));
1063 pathOffset += 11;
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 unittest.expect(queryMap["filter"].first, unittest.equals(arg_filter));
1082 unittest.expect(core.int.parse(queryMap["maxResults"].first), unittest.e quals(arg_maxResults));
1083 unittest.expect(queryMap["pageToken"].first, unittest.equals(arg_pageTok en));
1084
1085
1086 var h = {
1087 "content-type" : "application/json; charset=utf-8",
1088 };
1089 var resp = convert.JSON.encode(buildOperationList());
1090 return new async.Future.value(common_test.stringResponse(200, h, resp));
1091 }), true);
1092 res.list(arg_project, arg_zone, filter: arg_filter, maxResults: arg_maxRes ults, pageToken: arg_pageToken).then(unittest.expectAsync(((api.OperationList re sponse) {
1093 checkOperationList(response);
1094 })));
1095 });
1096
1097 });
1098
1099
1100 }
1101
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698