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

Side by Side Diff: generated/googleapis/test/servicecontrol/v1_test.dart

Issue 2226653002: Api-roll 40: 2016-08-08 (Closed) Base URL: git@github.com:dart-lang/googleapis.git@master
Patch Set: Addressed review comments Created 4 years, 4 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.servicecontrol.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
12 import 'package:googleapis/servicecontrol/v1.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 buildCounterCheckError = 0;
55 buildCheckError() {
56 var o = new api.CheckError();
57 buildCounterCheckError++;
58 if (buildCounterCheckError < 3) {
59 o.code = "foo";
60 o.detail = "foo";
61 }
62 buildCounterCheckError--;
63 return o;
64 }
65
66 checkCheckError(api.CheckError o) {
67 buildCounterCheckError++;
68 if (buildCounterCheckError < 3) {
69 unittest.expect(o.code, unittest.equals('foo'));
70 unittest.expect(o.detail, unittest.equals('foo'));
71 }
72 buildCounterCheckError--;
73 }
74
75 core.int buildCounterCheckRequest = 0;
76 buildCheckRequest() {
77 var o = new api.CheckRequest();
78 buildCounterCheckRequest++;
79 if (buildCounterCheckRequest < 3) {
80 o.operation = buildOperation();
81 }
82 buildCounterCheckRequest--;
83 return o;
84 }
85
86 checkCheckRequest(api.CheckRequest o) {
87 buildCounterCheckRequest++;
88 if (buildCounterCheckRequest < 3) {
89 checkOperation(o.operation);
90 }
91 buildCounterCheckRequest--;
92 }
93
94 buildUnnamed3062() {
95 var o = new core.List<api.CheckError>();
96 o.add(buildCheckError());
97 o.add(buildCheckError());
98 return o;
99 }
100
101 checkUnnamed3062(core.List<api.CheckError> o) {
102 unittest.expect(o, unittest.hasLength(2));
103 checkCheckError(o[0]);
104 checkCheckError(o[1]);
105 }
106
107 core.int buildCounterCheckResponse = 0;
108 buildCheckResponse() {
109 var o = new api.CheckResponse();
110 buildCounterCheckResponse++;
111 if (buildCounterCheckResponse < 3) {
112 o.checkErrors = buildUnnamed3062();
113 o.operationId = "foo";
114 }
115 buildCounterCheckResponse--;
116 return o;
117 }
118
119 checkCheckResponse(api.CheckResponse o) {
120 buildCounterCheckResponse++;
121 if (buildCounterCheckResponse < 3) {
122 checkUnnamed3062(o.checkErrors);
123 unittest.expect(o.operationId, unittest.equals('foo'));
124 }
125 buildCounterCheckResponse--;
126 }
127
128 buildUnnamed3063() {
129 var o = new core.List<core.String>();
130 o.add("foo");
131 o.add("foo");
132 return o;
133 }
134
135 checkUnnamed3063(core.List<core.String> o) {
136 unittest.expect(o, unittest.hasLength(2));
137 unittest.expect(o[0], unittest.equals('foo'));
138 unittest.expect(o[1], unittest.equals('foo'));
139 }
140
141 core.int buildCounterDistribution = 0;
142 buildDistribution() {
143 var o = new api.Distribution();
144 buildCounterDistribution++;
145 if (buildCounterDistribution < 3) {
146 o.bucketCounts = buildUnnamed3063();
147 o.count = "foo";
148 o.explicitBuckets = buildExplicitBuckets();
149 o.exponentialBuckets = buildExponentialBuckets();
150 o.linearBuckets = buildLinearBuckets();
151 o.maximum = 42.0;
152 o.mean = 42.0;
153 o.minimum = 42.0;
154 o.sumOfSquaredDeviation = 42.0;
155 }
156 buildCounterDistribution--;
157 return o;
158 }
159
160 checkDistribution(api.Distribution o) {
161 buildCounterDistribution++;
162 if (buildCounterDistribution < 3) {
163 checkUnnamed3063(o.bucketCounts);
164 unittest.expect(o.count, unittest.equals('foo'));
165 checkExplicitBuckets(o.explicitBuckets);
166 checkExponentialBuckets(o.exponentialBuckets);
167 checkLinearBuckets(o.linearBuckets);
168 unittest.expect(o.maximum, unittest.equals(42.0));
169 unittest.expect(o.mean, unittest.equals(42.0));
170 unittest.expect(o.minimum, unittest.equals(42.0));
171 unittest.expect(o.sumOfSquaredDeviation, unittest.equals(42.0));
172 }
173 buildCounterDistribution--;
174 }
175
176 buildUnnamed3064() {
177 var o = new core.List<core.double>();
178 o.add(42.0);
179 o.add(42.0);
180 return o;
181 }
182
183 checkUnnamed3064(core.List<core.double> o) {
184 unittest.expect(o, unittest.hasLength(2));
185 unittest.expect(o[0], unittest.equals(42.0));
186 unittest.expect(o[1], unittest.equals(42.0));
187 }
188
189 core.int buildCounterExplicitBuckets = 0;
190 buildExplicitBuckets() {
191 var o = new api.ExplicitBuckets();
192 buildCounterExplicitBuckets++;
193 if (buildCounterExplicitBuckets < 3) {
194 o.bounds = buildUnnamed3064();
195 }
196 buildCounterExplicitBuckets--;
197 return o;
198 }
199
200 checkExplicitBuckets(api.ExplicitBuckets o) {
201 buildCounterExplicitBuckets++;
202 if (buildCounterExplicitBuckets < 3) {
203 checkUnnamed3064(o.bounds);
204 }
205 buildCounterExplicitBuckets--;
206 }
207
208 core.int buildCounterExponentialBuckets = 0;
209 buildExponentialBuckets() {
210 var o = new api.ExponentialBuckets();
211 buildCounterExponentialBuckets++;
212 if (buildCounterExponentialBuckets < 3) {
213 o.growthFactor = 42.0;
214 o.numFiniteBuckets = 42;
215 o.scale = 42.0;
216 }
217 buildCounterExponentialBuckets--;
218 return o;
219 }
220
221 checkExponentialBuckets(api.ExponentialBuckets o) {
222 buildCounterExponentialBuckets++;
223 if (buildCounterExponentialBuckets < 3) {
224 unittest.expect(o.growthFactor, unittest.equals(42.0));
225 unittest.expect(o.numFiniteBuckets, unittest.equals(42));
226 unittest.expect(o.scale, unittest.equals(42.0));
227 }
228 buildCounterExponentialBuckets--;
229 }
230
231 core.int buildCounterLinearBuckets = 0;
232 buildLinearBuckets() {
233 var o = new api.LinearBuckets();
234 buildCounterLinearBuckets++;
235 if (buildCounterLinearBuckets < 3) {
236 o.numFiniteBuckets = 42;
237 o.offset = 42.0;
238 o.width = 42.0;
239 }
240 buildCounterLinearBuckets--;
241 return o;
242 }
243
244 checkLinearBuckets(api.LinearBuckets o) {
245 buildCounterLinearBuckets++;
246 if (buildCounterLinearBuckets < 3) {
247 unittest.expect(o.numFiniteBuckets, unittest.equals(42));
248 unittest.expect(o.offset, unittest.equals(42.0));
249 unittest.expect(o.width, unittest.equals(42.0));
250 }
251 buildCounterLinearBuckets--;
252 }
253
254 buildUnnamed3065() {
255 var o = new core.Map<core.String, core.String>();
256 o["x"] = "foo";
257 o["y"] = "foo";
258 return o;
259 }
260
261 checkUnnamed3065(core.Map<core.String, core.String> o) {
262 unittest.expect(o, unittest.hasLength(2));
263 unittest.expect(o["x"], unittest.equals('foo'));
264 unittest.expect(o["y"], unittest.equals('foo'));
265 }
266
267 buildUnnamed3066() {
268 var o = new core.Map<core.String, core.Object>();
269 o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'};
270 o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'};
271 return o;
272 }
273
274 checkUnnamed3066(core.Map<core.String, core.Object> o) {
275 unittest.expect(o, unittest.hasLength(2));
276 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'));
277 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'));
278 }
279
280 buildUnnamed3067() {
281 var o = new core.Map<core.String, core.Object>();
282 o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'};
283 o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'};
284 return o;
285 }
286
287 checkUnnamed3067(core.Map<core.String, core.Object> o) {
288 unittest.expect(o, unittest.hasLength(2));
289 var casted3 = (o["x"]) as core.Map; unittest.expect(casted3, unittest.hasLengt h(3)); unittest.expect(casted3["list"], unittest.equals([1, 2, 3])); unittest.ex pect(casted3["bool"], unittest.equals(true)); unittest.expect(casted3["string"], unittest.equals('foo'));
290 var casted4 = (o["y"]) as core.Map; unittest.expect(casted4, unittest.hasLengt h(3)); unittest.expect(casted4["list"], unittest.equals([1, 2, 3])); unittest.ex pect(casted4["bool"], unittest.equals(true)); unittest.expect(casted4["string"], unittest.equals('foo'));
291 }
292
293 core.int buildCounterLogEntry = 0;
294 buildLogEntry() {
295 var o = new api.LogEntry();
296 buildCounterLogEntry++;
297 if (buildCounterLogEntry < 3) {
298 o.insertId = "foo";
299 o.labels = buildUnnamed3065();
300 o.name = "foo";
301 o.protoPayload = buildUnnamed3066();
302 o.severity = "foo";
303 o.structPayload = buildUnnamed3067();
304 o.textPayload = "foo";
305 o.timestamp = "foo";
306 }
307 buildCounterLogEntry--;
308 return o;
309 }
310
311 checkLogEntry(api.LogEntry o) {
312 buildCounterLogEntry++;
313 if (buildCounterLogEntry < 3) {
314 unittest.expect(o.insertId, unittest.equals('foo'));
315 checkUnnamed3065(o.labels);
316 unittest.expect(o.name, unittest.equals('foo'));
317 checkUnnamed3066(o.protoPayload);
318 unittest.expect(o.severity, unittest.equals('foo'));
319 checkUnnamed3067(o.structPayload);
320 unittest.expect(o.textPayload, unittest.equals('foo'));
321 unittest.expect(o.timestamp, unittest.equals('foo'));
322 }
323 buildCounterLogEntry--;
324 }
325
326 buildUnnamed3068() {
327 var o = new core.Map<core.String, core.String>();
328 o["x"] = "foo";
329 o["y"] = "foo";
330 return o;
331 }
332
333 checkUnnamed3068(core.Map<core.String, core.String> o) {
334 unittest.expect(o, unittest.hasLength(2));
335 unittest.expect(o["x"], unittest.equals('foo'));
336 unittest.expect(o["y"], unittest.equals('foo'));
337 }
338
339 core.int buildCounterMetricValue = 0;
340 buildMetricValue() {
341 var o = new api.MetricValue();
342 buildCounterMetricValue++;
343 if (buildCounterMetricValue < 3) {
344 o.boolValue = true;
345 o.distributionValue = buildDistribution();
346 o.doubleValue = 42.0;
347 o.endTime = "foo";
348 o.int64Value = "foo";
349 o.labels = buildUnnamed3068();
350 o.startTime = "foo";
351 o.stringValue = "foo";
352 }
353 buildCounterMetricValue--;
354 return o;
355 }
356
357 checkMetricValue(api.MetricValue o) {
358 buildCounterMetricValue++;
359 if (buildCounterMetricValue < 3) {
360 unittest.expect(o.boolValue, unittest.isTrue);
361 checkDistribution(o.distributionValue);
362 unittest.expect(o.doubleValue, unittest.equals(42.0));
363 unittest.expect(o.endTime, unittest.equals('foo'));
364 unittest.expect(o.int64Value, unittest.equals('foo'));
365 checkUnnamed3068(o.labels);
366 unittest.expect(o.startTime, unittest.equals('foo'));
367 unittest.expect(o.stringValue, unittest.equals('foo'));
368 }
369 buildCounterMetricValue--;
370 }
371
372 buildUnnamed3069() {
373 var o = new core.List<api.MetricValue>();
374 o.add(buildMetricValue());
375 o.add(buildMetricValue());
376 return o;
377 }
378
379 checkUnnamed3069(core.List<api.MetricValue> o) {
380 unittest.expect(o, unittest.hasLength(2));
381 checkMetricValue(o[0]);
382 checkMetricValue(o[1]);
383 }
384
385 core.int buildCounterMetricValueSet = 0;
386 buildMetricValueSet() {
387 var o = new api.MetricValueSet();
388 buildCounterMetricValueSet++;
389 if (buildCounterMetricValueSet < 3) {
390 o.metricName = "foo";
391 o.metricValues = buildUnnamed3069();
392 }
393 buildCounterMetricValueSet--;
394 return o;
395 }
396
397 checkMetricValueSet(api.MetricValueSet o) {
398 buildCounterMetricValueSet++;
399 if (buildCounterMetricValueSet < 3) {
400 unittest.expect(o.metricName, unittest.equals('foo'));
401 checkUnnamed3069(o.metricValues);
402 }
403 buildCounterMetricValueSet--;
404 }
405
406 buildUnnamed3070() {
407 var o = new core.Map<core.String, core.String>();
408 o["x"] = "foo";
409 o["y"] = "foo";
410 return o;
411 }
412
413 checkUnnamed3070(core.Map<core.String, core.String> o) {
414 unittest.expect(o, unittest.hasLength(2));
415 unittest.expect(o["x"], unittest.equals('foo'));
416 unittest.expect(o["y"], unittest.equals('foo'));
417 }
418
419 buildUnnamed3071() {
420 var o = new core.List<api.LogEntry>();
421 o.add(buildLogEntry());
422 o.add(buildLogEntry());
423 return o;
424 }
425
426 checkUnnamed3071(core.List<api.LogEntry> o) {
427 unittest.expect(o, unittest.hasLength(2));
428 checkLogEntry(o[0]);
429 checkLogEntry(o[1]);
430 }
431
432 buildUnnamed3072() {
433 var o = new core.List<api.MetricValueSet>();
434 o.add(buildMetricValueSet());
435 o.add(buildMetricValueSet());
436 return o;
437 }
438
439 checkUnnamed3072(core.List<api.MetricValueSet> o) {
440 unittest.expect(o, unittest.hasLength(2));
441 checkMetricValueSet(o[0]);
442 checkMetricValueSet(o[1]);
443 }
444
445 core.int buildCounterOperation = 0;
446 buildOperation() {
447 var o = new api.Operation();
448 buildCounterOperation++;
449 if (buildCounterOperation < 3) {
450 o.consumerId = "foo";
451 o.endTime = "foo";
452 o.importance = "foo";
453 o.labels = buildUnnamed3070();
454 o.logEntries = buildUnnamed3071();
455 o.metricValueSets = buildUnnamed3072();
456 o.operationId = "foo";
457 o.operationName = "foo";
458 o.startTime = "foo";
459 }
460 buildCounterOperation--;
461 return o;
462 }
463
464 checkOperation(api.Operation o) {
465 buildCounterOperation++;
466 if (buildCounterOperation < 3) {
467 unittest.expect(o.consumerId, unittest.equals('foo'));
468 unittest.expect(o.endTime, unittest.equals('foo'));
469 unittest.expect(o.importance, unittest.equals('foo'));
470 checkUnnamed3070(o.labels);
471 checkUnnamed3071(o.logEntries);
472 checkUnnamed3072(o.metricValueSets);
473 unittest.expect(o.operationId, unittest.equals('foo'));
474 unittest.expect(o.operationName, unittest.equals('foo'));
475 unittest.expect(o.startTime, unittest.equals('foo'));
476 }
477 buildCounterOperation--;
478 }
479
480 core.int buildCounterReportError = 0;
481 buildReportError() {
482 var o = new api.ReportError();
483 buildCounterReportError++;
484 if (buildCounterReportError < 3) {
485 o.operationId = "foo";
486 o.status = buildStatus();
487 }
488 buildCounterReportError--;
489 return o;
490 }
491
492 checkReportError(api.ReportError o) {
493 buildCounterReportError++;
494 if (buildCounterReportError < 3) {
495 unittest.expect(o.operationId, unittest.equals('foo'));
496 checkStatus(o.status);
497 }
498 buildCounterReportError--;
499 }
500
501 buildUnnamed3073() {
502 var o = new core.List<api.Operation>();
503 o.add(buildOperation());
504 o.add(buildOperation());
505 return o;
506 }
507
508 checkUnnamed3073(core.List<api.Operation> o) {
509 unittest.expect(o, unittest.hasLength(2));
510 checkOperation(o[0]);
511 checkOperation(o[1]);
512 }
513
514 core.int buildCounterReportRequest = 0;
515 buildReportRequest() {
516 var o = new api.ReportRequest();
517 buildCounterReportRequest++;
518 if (buildCounterReportRequest < 3) {
519 o.operations = buildUnnamed3073();
520 }
521 buildCounterReportRequest--;
522 return o;
523 }
524
525 checkReportRequest(api.ReportRequest o) {
526 buildCounterReportRequest++;
527 if (buildCounterReportRequest < 3) {
528 checkUnnamed3073(o.operations);
529 }
530 buildCounterReportRequest--;
531 }
532
533 buildUnnamed3074() {
534 var o = new core.List<api.ReportError>();
535 o.add(buildReportError());
536 o.add(buildReportError());
537 return o;
538 }
539
540 checkUnnamed3074(core.List<api.ReportError> o) {
541 unittest.expect(o, unittest.hasLength(2));
542 checkReportError(o[0]);
543 checkReportError(o[1]);
544 }
545
546 core.int buildCounterReportResponse = 0;
547 buildReportResponse() {
548 var o = new api.ReportResponse();
549 buildCounterReportResponse++;
550 if (buildCounterReportResponse < 3) {
551 o.reportErrors = buildUnnamed3074();
552 }
553 buildCounterReportResponse--;
554 return o;
555 }
556
557 checkReportResponse(api.ReportResponse o) {
558 buildCounterReportResponse++;
559 if (buildCounterReportResponse < 3) {
560 checkUnnamed3074(o.reportErrors);
561 }
562 buildCounterReportResponse--;
563 }
564
565 buildUnnamed3075() {
566 var o = new core.Map<core.String, core.Object>();
567 o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'};
568 o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'};
569 return o;
570 }
571
572 checkUnnamed3075(core.Map<core.String, core.Object> o) {
573 unittest.expect(o, unittest.hasLength(2));
574 var casted5 = (o["x"]) as core.Map; unittest.expect(casted5, unittest.hasLengt h(3)); unittest.expect(casted5["list"], unittest.equals([1, 2, 3])); unittest.ex pect(casted5["bool"], unittest.equals(true)); unittest.expect(casted5["string"], unittest.equals('foo'));
575 var casted6 = (o["y"]) as core.Map; unittest.expect(casted6, unittest.hasLengt h(3)); unittest.expect(casted6["list"], unittest.equals([1, 2, 3])); unittest.ex pect(casted6["bool"], unittest.equals(true)); unittest.expect(casted6["string"], unittest.equals('foo'));
576 }
577
578 buildUnnamed3076() {
579 var o = new core.List<core.Map<core.String, core.Object>>();
580 o.add(buildUnnamed3075());
581 o.add(buildUnnamed3075());
582 return o;
583 }
584
585 checkUnnamed3076(core.List<core.Map<core.String, core.Object>> o) {
586 unittest.expect(o, unittest.hasLength(2));
587 checkUnnamed3075(o[0]);
588 checkUnnamed3075(o[1]);
589 }
590
591 core.int buildCounterStatus = 0;
592 buildStatus() {
593 var o = new api.Status();
594 buildCounterStatus++;
595 if (buildCounterStatus < 3) {
596 o.code = 42;
597 o.details = buildUnnamed3076();
598 o.message = "foo";
599 }
600 buildCounterStatus--;
601 return o;
602 }
603
604 checkStatus(api.Status o) {
605 buildCounterStatus++;
606 if (buildCounterStatus < 3) {
607 unittest.expect(o.code, unittest.equals(42));
608 checkUnnamed3076(o.details);
609 unittest.expect(o.message, unittest.equals('foo'));
610 }
611 buildCounterStatus--;
612 }
613
614
615 main() {
616 unittest.group("obj-schema-CheckError", () {
617 unittest.test("to-json--from-json", () {
618 var o = buildCheckError();
619 var od = new api.CheckError.fromJson(o.toJson());
620 checkCheckError(od);
621 });
622 });
623
624
625 unittest.group("obj-schema-CheckRequest", () {
626 unittest.test("to-json--from-json", () {
627 var o = buildCheckRequest();
628 var od = new api.CheckRequest.fromJson(o.toJson());
629 checkCheckRequest(od);
630 });
631 });
632
633
634 unittest.group("obj-schema-CheckResponse", () {
635 unittest.test("to-json--from-json", () {
636 var o = buildCheckResponse();
637 var od = new api.CheckResponse.fromJson(o.toJson());
638 checkCheckResponse(od);
639 });
640 });
641
642
643 unittest.group("obj-schema-Distribution", () {
644 unittest.test("to-json--from-json", () {
645 var o = buildDistribution();
646 var od = new api.Distribution.fromJson(o.toJson());
647 checkDistribution(od);
648 });
649 });
650
651
652 unittest.group("obj-schema-ExplicitBuckets", () {
653 unittest.test("to-json--from-json", () {
654 var o = buildExplicitBuckets();
655 var od = new api.ExplicitBuckets.fromJson(o.toJson());
656 checkExplicitBuckets(od);
657 });
658 });
659
660
661 unittest.group("obj-schema-ExponentialBuckets", () {
662 unittest.test("to-json--from-json", () {
663 var o = buildExponentialBuckets();
664 var od = new api.ExponentialBuckets.fromJson(o.toJson());
665 checkExponentialBuckets(od);
666 });
667 });
668
669
670 unittest.group("obj-schema-LinearBuckets", () {
671 unittest.test("to-json--from-json", () {
672 var o = buildLinearBuckets();
673 var od = new api.LinearBuckets.fromJson(o.toJson());
674 checkLinearBuckets(od);
675 });
676 });
677
678
679 unittest.group("obj-schema-LogEntry", () {
680 unittest.test("to-json--from-json", () {
681 var o = buildLogEntry();
682 var od = new api.LogEntry.fromJson(o.toJson());
683 checkLogEntry(od);
684 });
685 });
686
687
688 unittest.group("obj-schema-MetricValue", () {
689 unittest.test("to-json--from-json", () {
690 var o = buildMetricValue();
691 var od = new api.MetricValue.fromJson(o.toJson());
692 checkMetricValue(od);
693 });
694 });
695
696
697 unittest.group("obj-schema-MetricValueSet", () {
698 unittest.test("to-json--from-json", () {
699 var o = buildMetricValueSet();
700 var od = new api.MetricValueSet.fromJson(o.toJson());
701 checkMetricValueSet(od);
702 });
703 });
704
705
706 unittest.group("obj-schema-Operation", () {
707 unittest.test("to-json--from-json", () {
708 var o = buildOperation();
709 var od = new api.Operation.fromJson(o.toJson());
710 checkOperation(od);
711 });
712 });
713
714
715 unittest.group("obj-schema-ReportError", () {
716 unittest.test("to-json--from-json", () {
717 var o = buildReportError();
718 var od = new api.ReportError.fromJson(o.toJson());
719 checkReportError(od);
720 });
721 });
722
723
724 unittest.group("obj-schema-ReportRequest", () {
725 unittest.test("to-json--from-json", () {
726 var o = buildReportRequest();
727 var od = new api.ReportRequest.fromJson(o.toJson());
728 checkReportRequest(od);
729 });
730 });
731
732
733 unittest.group("obj-schema-ReportResponse", () {
734 unittest.test("to-json--from-json", () {
735 var o = buildReportResponse();
736 var od = new api.ReportResponse.fromJson(o.toJson());
737 checkReportResponse(od);
738 });
739 });
740
741
742 unittest.group("obj-schema-Status", () {
743 unittest.test("to-json--from-json", () {
744 var o = buildStatus();
745 var od = new api.Status.fromJson(o.toJson());
746 checkStatus(od);
747 });
748 });
749
750
751 unittest.group("resource-ServicesResourceApi", () {
752 unittest.test("method--check", () {
753
754 var mock = new HttpServerMock();
755 api.ServicesResourceApi res = new api.ServicecontrolApi(mock).services;
756 var arg_request = buildCheckRequest();
757 var arg_serviceName = "foo";
758 mock.register(unittest.expectAsync((http.BaseRequest req, json) {
759 var obj = new api.CheckRequest.fromJson(json);
760 checkCheckRequest(obj);
761
762 var path = (req.url).path;
763 var pathOffset = 0;
764 var index;
765 var subPart;
766 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ als("/"));
767 pathOffset += 1;
768 unittest.expect(path.substring(pathOffset, pathOffset + 12), unittest.eq uals("v1/services/"));
769 pathOffset += 12;
770 index = path.indexOf(":check", pathOffset);
771 unittest.expect(index >= 0, unittest.isTrue);
772 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index ));
773 pathOffset = index;
774 unittest.expect(subPart, unittest.equals("$arg_serviceName"));
775 unittest.expect(path.substring(pathOffset, pathOffset + 6), unittest.equ als(":check"));
776 pathOffset += 6;
777
778 var query = (req.url).query;
779 var queryOffset = 0;
780 var queryMap = {};
781 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
782 parseBool(n) {
783 if (n == "true") return true;
784 if (n == "false") return false;
785 if (n == null) return null;
786 throw new core.ArgumentError("Invalid boolean: $n");
787 }
788 if (query.length > 0) {
789 for (var part in query.split("&")) {
790 var keyvalue = part.split("=");
791 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
792 }
793 }
794
795
796 var h = {
797 "content-type" : "application/json; charset=utf-8",
798 };
799 var resp = convert.JSON.encode(buildCheckResponse());
800 return new async.Future.value(stringResponse(200, h, resp));
801 }), true);
802 res.check(arg_request, arg_serviceName).then(unittest.expectAsync(((api.Ch eckResponse response) {
803 checkCheckResponse(response);
804 })));
805 });
806
807 unittest.test("method--report", () {
808
809 var mock = new HttpServerMock();
810 api.ServicesResourceApi res = new api.ServicecontrolApi(mock).services;
811 var arg_request = buildReportRequest();
812 var arg_serviceName = "foo";
813 mock.register(unittest.expectAsync((http.BaseRequest req, json) {
814 var obj = new api.ReportRequest.fromJson(json);
815 checkReportRequest(obj);
816
817 var path = (req.url).path;
818 var pathOffset = 0;
819 var index;
820 var subPart;
821 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ als("/"));
822 pathOffset += 1;
823 unittest.expect(path.substring(pathOffset, pathOffset + 12), unittest.eq uals("v1/services/"));
824 pathOffset += 12;
825 index = path.indexOf(":report", pathOffset);
826 unittest.expect(index >= 0, unittest.isTrue);
827 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index ));
828 pathOffset = index;
829 unittest.expect(subPart, unittest.equals("$arg_serviceName"));
830 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ als(":report"));
831 pathOffset += 7;
832
833 var query = (req.url).query;
834 var queryOffset = 0;
835 var queryMap = {};
836 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
837 parseBool(n) {
838 if (n == "true") return true;
839 if (n == "false") return false;
840 if (n == null) return null;
841 throw new core.ArgumentError("Invalid boolean: $n");
842 }
843 if (query.length > 0) {
844 for (var part in query.split("&")) {
845 var keyvalue = part.split("=");
846 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
847 }
848 }
849
850
851 var h = {
852 "content-type" : "application/json; charset=utf-8",
853 };
854 var resp = convert.JSON.encode(buildReportResponse());
855 return new async.Future.value(stringResponse(200, h, resp));
856 }), true);
857 res.report(arg_request, arg_serviceName).then(unittest.expectAsync(((api.R eportResponse response) {
858 checkReportResponse(response);
859 })));
860 });
861
862 });
863
864
865 }
866
OLDNEW
« no previous file with comments | « generated/googleapis/test/script/v1_test.dart ('k') | generated/googleapis/test/servicemanagement/v1_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698