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

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

Issue 3006323002: Api-Roll 54: 2017-09-11 (Closed)
Patch Set: use 2.0.0-dev.infinity sdk constraint in pubspecs Created 3 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
1 library googleapis.customsearch.v1.test; 1 library googleapis.customsearch.v1.test;
2 2
3 import "dart:core" as core; 3 import "dart:core" as core;
4 import "dart:collection" as collection;
5 import "dart:async" as async; 4 import "dart:async" as async;
6 import "dart:convert" as convert; 5 import "dart:convert" as convert;
7 6
8 import 'package:http/http.dart' as http; 7 import 'package:http/http.dart' as http;
9 import 'package:http/testing.dart' as http_testing;
10 import 'package:test/test.dart' as unittest; 8 import 'package:test/test.dart' as unittest;
11 9
12 import 'package:googleapis/customsearch/v1.dart' as api; 10 import 'package:googleapis/customsearch/v1.dart' as api;
13 11
14 class HttpServerMock extends http.BaseClient { 12 class HttpServerMock extends http.BaseClient {
15 core.Function _callback; 13 core.Function _callback;
16 core.bool _expectJson; 14 core.bool _expectJson;
17 15
18 void register(core.Function callback, core.bool expectJson) { 16 void register(core.Function callback, core.bool expectJson) {
19 _callback = callback; 17 _callback = callback;
20 _expectJson = expectJson; 18 _expectJson = expectJson;
21 } 19 }
22 20
23 async.Future<http.StreamedResponse> send(http.BaseRequest request) { 21 async.Future<http.StreamedResponse> send(http.BaseRequest request) {
24 if (_expectJson) { 22 if (_expectJson) {
25 return request.finalize() 23 return request
24 .finalize()
26 .transform(convert.UTF8.decoder) 25 .transform(convert.UTF8.decoder)
27 .join('') 26 .join('')
28 .then((core.String jsonString) { 27 .then((core.String jsonString) {
29 if (jsonString.isEmpty) { 28 if (jsonString.isEmpty) {
30 return _callback(request, null); 29 return _callback(request, null);
31 } else { 30 } else {
32 return _callback(request, convert.JSON.decode(jsonString)); 31 return _callback(request, convert.JSON.decode(jsonString));
33 } 32 }
34 }); 33 });
35 } else { 34 } else {
36 var stream = request.finalize(); 35 var stream = request.finalize();
37 if (stream == null) { 36 if (stream == null) {
38 return _callback(request, []); 37 return _callback(request, []);
39 } else { 38 } else {
40 return stream.toBytes().then((data) { 39 return stream.toBytes().then((data) {
41 return _callback(request, data); 40 return _callback(request, data);
42 }); 41 });
43 } 42 }
44 } 43 }
45 } 44 }
46 } 45 }
47 46
48 http.StreamedResponse stringResponse( 47 http.StreamedResponse stringResponse(core.int status,
49 core.int status, core.Map<core.String, core.String> headers, core.String bod y) { 48 core.Map<core.String, core.String> headers, core.String body) {
50 var stream = new async.Stream.fromIterable([convert.UTF8.encode(body)]); 49 var stream = new async.Stream.fromIterable([convert.UTF8.encode(body)]);
51 return new http.StreamedResponse(stream, status, headers: headers); 50 return new http.StreamedResponse(stream, status, headers: headers);
52 } 51 }
53 52
54 core.int buildCounterContextFacets = 0; 53 core.int buildCounterContextFacets = 0;
55 buildContextFacets() { 54 buildContextFacets() {
56 var o = new api.ContextFacets(); 55 var o = new api.ContextFacets();
57 buildCounterContextFacets++; 56 buildCounterContextFacets++;
58 if (buildCounterContextFacets < 3) { 57 if (buildCounterContextFacets < 3) {
59 o.anchor = "foo"; 58 o.anchor = "foo";
60 o.label = "foo"; 59 o.label = "foo";
61 o.labelWithOp = "foo"; 60 o.labelWithOp = "foo";
62 } 61 }
63 buildCounterContextFacets--; 62 buildCounterContextFacets--;
64 return o; 63 return o;
65 } 64 }
66 65
67 checkContextFacets(api.ContextFacets o) { 66 checkContextFacets(api.ContextFacets o) {
68 buildCounterContextFacets++; 67 buildCounterContextFacets++;
69 if (buildCounterContextFacets < 3) { 68 if (buildCounterContextFacets < 3) {
70 unittest.expect(o.anchor, unittest.equals('foo')); 69 unittest.expect(o.anchor, unittest.equals('foo'));
71 unittest.expect(o.label, unittest.equals('foo')); 70 unittest.expect(o.label, unittest.equals('foo'));
72 unittest.expect(o.labelWithOp, unittest.equals('foo')); 71 unittest.expect(o.labelWithOp, unittest.equals('foo'));
73 } 72 }
74 buildCounterContextFacets--; 73 buildCounterContextFacets--;
75 } 74 }
76 75
77 buildUnnamed299() { 76 buildUnnamed298() {
78 var o = new core.List<api.ContextFacets>(); 77 var o = new core.List<api.ContextFacets>();
79 o.add(buildContextFacets()); 78 o.add(buildContextFacets());
80 o.add(buildContextFacets()); 79 o.add(buildContextFacets());
81 return o; 80 return o;
82 } 81 }
83 82
84 checkUnnamed299(core.List<api.ContextFacets> o) { 83 checkUnnamed298(core.List<api.ContextFacets> o) {
85 unittest.expect(o, unittest.hasLength(2)); 84 unittest.expect(o, unittest.hasLength(2));
86 checkContextFacets(o[0]); 85 checkContextFacets(o[0]);
87 checkContextFacets(o[1]); 86 checkContextFacets(o[1]);
88 } 87 }
89 88
90 buildUnnamed300() { 89 buildUnnamed299() {
91 var o = new core.List<core.List<api.ContextFacets>>(); 90 var o = new core.List<core.List<api.ContextFacets>>();
92 o.add(buildUnnamed299()); 91 o.add(buildUnnamed298());
93 o.add(buildUnnamed299()); 92 o.add(buildUnnamed298());
94 return o; 93 return o;
95 } 94 }
96 95
97 checkUnnamed300(core.List<core.List<api.ContextFacets>> o) { 96 checkUnnamed299(core.List<core.List<api.ContextFacets>> o) {
98 unittest.expect(o, unittest.hasLength(2)); 97 unittest.expect(o, unittest.hasLength(2));
99 checkUnnamed299(o[0]); 98 checkUnnamed298(o[0]);
100 checkUnnamed299(o[1]); 99 checkUnnamed298(o[1]);
101 } 100 }
102 101
103 core.int buildCounterContext = 0; 102 core.int buildCounterContext = 0;
104 buildContext() { 103 buildContext() {
105 var o = new api.Context(); 104 var o = new api.Context();
106 buildCounterContext++; 105 buildCounterContext++;
107 if (buildCounterContext < 3) { 106 if (buildCounterContext < 3) {
108 o.facets = buildUnnamed300(); 107 o.facets = buildUnnamed299();
109 o.title = "foo"; 108 o.title = "foo";
110 } 109 }
111 buildCounterContext--; 110 buildCounterContext--;
112 return o; 111 return o;
113 } 112 }
114 113
115 checkContext(api.Context o) { 114 checkContext(api.Context o) {
116 buildCounterContext++; 115 buildCounterContext++;
117 if (buildCounterContext < 3) { 116 if (buildCounterContext < 3) {
118 checkUnnamed300(o.facets); 117 checkUnnamed299(o.facets);
119 unittest.expect(o.title, unittest.equals('foo')); 118 unittest.expect(o.title, unittest.equals('foo'));
120 } 119 }
121 buildCounterContext--; 120 buildCounterContext--;
122 } 121 }
123 122
124 core.int buildCounterPromotionBodyLines = 0; 123 core.int buildCounterPromotionBodyLines = 0;
125 buildPromotionBodyLines() { 124 buildPromotionBodyLines() {
126 var o = new api.PromotionBodyLines(); 125 var o = new api.PromotionBodyLines();
127 buildCounterPromotionBodyLines++; 126 buildCounterPromotionBodyLines++;
128 if (buildCounterPromotionBodyLines < 3) { 127 if (buildCounterPromotionBodyLines < 3) {
(...skipping 10 matching lines...) Expand all
139 buildCounterPromotionBodyLines++; 138 buildCounterPromotionBodyLines++;
140 if (buildCounterPromotionBodyLines < 3) { 139 if (buildCounterPromotionBodyLines < 3) {
141 unittest.expect(o.htmlTitle, unittest.equals('foo')); 140 unittest.expect(o.htmlTitle, unittest.equals('foo'));
142 unittest.expect(o.link, unittest.equals('foo')); 141 unittest.expect(o.link, unittest.equals('foo'));
143 unittest.expect(o.title, unittest.equals('foo')); 142 unittest.expect(o.title, unittest.equals('foo'));
144 unittest.expect(o.url, unittest.equals('foo')); 143 unittest.expect(o.url, unittest.equals('foo'));
145 } 144 }
146 buildCounterPromotionBodyLines--; 145 buildCounterPromotionBodyLines--;
147 } 146 }
148 147
149 buildUnnamed301() { 148 buildUnnamed300() {
150 var o = new core.List<api.PromotionBodyLines>(); 149 var o = new core.List<api.PromotionBodyLines>();
151 o.add(buildPromotionBodyLines()); 150 o.add(buildPromotionBodyLines());
152 o.add(buildPromotionBodyLines()); 151 o.add(buildPromotionBodyLines());
153 return o; 152 return o;
154 } 153 }
155 154
156 checkUnnamed301(core.List<api.PromotionBodyLines> o) { 155 checkUnnamed300(core.List<api.PromotionBodyLines> o) {
157 unittest.expect(o, unittest.hasLength(2)); 156 unittest.expect(o, unittest.hasLength(2));
158 checkPromotionBodyLines(o[0]); 157 checkPromotionBodyLines(o[0]);
159 checkPromotionBodyLines(o[1]); 158 checkPromotionBodyLines(o[1]);
160 } 159 }
161 160
162 core.int buildCounterPromotionImage = 0; 161 core.int buildCounterPromotionImage = 0;
163 buildPromotionImage() { 162 buildPromotionImage() {
164 var o = new api.PromotionImage(); 163 var o = new api.PromotionImage();
165 buildCounterPromotionImage++; 164 buildCounterPromotionImage++;
166 if (buildCounterPromotionImage < 3) { 165 if (buildCounterPromotionImage < 3) {
(...skipping 13 matching lines...) Expand all
180 unittest.expect(o.width, unittest.equals(42)); 179 unittest.expect(o.width, unittest.equals(42));
181 } 180 }
182 buildCounterPromotionImage--; 181 buildCounterPromotionImage--;
183 } 182 }
184 183
185 core.int buildCounterPromotion = 0; 184 core.int buildCounterPromotion = 0;
186 buildPromotion() { 185 buildPromotion() {
187 var o = new api.Promotion(); 186 var o = new api.Promotion();
188 buildCounterPromotion++; 187 buildCounterPromotion++;
189 if (buildCounterPromotion < 3) { 188 if (buildCounterPromotion < 3) {
190 o.bodyLines = buildUnnamed301(); 189 o.bodyLines = buildUnnamed300();
191 o.displayLink = "foo"; 190 o.displayLink = "foo";
192 o.htmlTitle = "foo"; 191 o.htmlTitle = "foo";
193 o.image = buildPromotionImage(); 192 o.image = buildPromotionImage();
194 o.link = "foo"; 193 o.link = "foo";
195 o.title = "foo"; 194 o.title = "foo";
196 } 195 }
197 buildCounterPromotion--; 196 buildCounterPromotion--;
198 return o; 197 return o;
199 } 198 }
200 199
201 checkPromotion(api.Promotion o) { 200 checkPromotion(api.Promotion o) {
202 buildCounterPromotion++; 201 buildCounterPromotion++;
203 if (buildCounterPromotion < 3) { 202 if (buildCounterPromotion < 3) {
204 checkUnnamed301(o.bodyLines); 203 checkUnnamed300(o.bodyLines);
205 unittest.expect(o.displayLink, unittest.equals('foo')); 204 unittest.expect(o.displayLink, unittest.equals('foo'));
206 unittest.expect(o.htmlTitle, unittest.equals('foo')); 205 unittest.expect(o.htmlTitle, unittest.equals('foo'));
207 checkPromotionImage(o.image); 206 checkPromotionImage(o.image);
208 unittest.expect(o.link, unittest.equals('foo')); 207 unittest.expect(o.link, unittest.equals('foo'));
209 unittest.expect(o.title, unittest.equals('foo')); 208 unittest.expect(o.title, unittest.equals('foo'));
210 } 209 }
211 buildCounterPromotion--; 210 buildCounterPromotion--;
212 } 211 }
213 212
214 core.int buildCounterQuery = 0; 213 core.int buildCounterQuery = 0;
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 checkResultLabels(api.ResultLabels o) { 346 checkResultLabels(api.ResultLabels o) {
348 buildCounterResultLabels++; 347 buildCounterResultLabels++;
349 if (buildCounterResultLabels < 3) { 348 if (buildCounterResultLabels < 3) {
350 unittest.expect(o.displayName, unittest.equals('foo')); 349 unittest.expect(o.displayName, unittest.equals('foo'));
351 unittest.expect(o.labelWithOp, unittest.equals('foo')); 350 unittest.expect(o.labelWithOp, unittest.equals('foo'));
352 unittest.expect(o.name, unittest.equals('foo')); 351 unittest.expect(o.name, unittest.equals('foo'));
353 } 352 }
354 buildCounterResultLabels--; 353 buildCounterResultLabels--;
355 } 354 }
356 355
357 buildUnnamed302() { 356 buildUnnamed301() {
358 var o = new core.List<api.ResultLabels>(); 357 var o = new core.List<api.ResultLabels>();
359 o.add(buildResultLabels()); 358 o.add(buildResultLabels());
360 o.add(buildResultLabels()); 359 o.add(buildResultLabels());
361 return o; 360 return o;
362 } 361 }
363 362
364 checkUnnamed302(core.List<api.ResultLabels> o) { 363 checkUnnamed301(core.List<api.ResultLabels> o) {
365 unittest.expect(o, unittest.hasLength(2)); 364 unittest.expect(o, unittest.hasLength(2));
366 checkResultLabels(o[0]); 365 checkResultLabels(o[0]);
367 checkResultLabels(o[1]); 366 checkResultLabels(o[1]);
368 } 367 }
369 368
370 buildUnnamed303() { 369 buildUnnamed302() {
371 var o = new core.Map<core.String, core.Object>(); 370 var o = new core.Map<core.String, core.Object>();
372 o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; 371 o["x"] = {
373 o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; 372 'list': [1, 2, 3],
373 'bool': true,
374 'string': 'foo'
375 };
376 o["y"] = {
377 'list': [1, 2, 3],
378 'bool': true,
379 'string': 'foo'
380 };
374 return o; 381 return o;
375 } 382 }
376 383
377 checkUnnamed303(core.Map<core.String, core.Object> o) { 384 checkUnnamed302(core.Map<core.String, core.Object> o) {
378 unittest.expect(o, unittest.hasLength(2)); 385 unittest.expect(o, unittest.hasLength(2));
379 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')); 386 var casted1 = (o["x"]) as core.Map;
380 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')); 387 unittest.expect(casted1, unittest.hasLength(3));
388 unittest.expect(casted1["list"], unittest.equals([1, 2, 3]));
389 unittest.expect(casted1["bool"], unittest.equals(true));
390 unittest.expect(casted1["string"], unittest.equals('foo'));
391 var casted2 = (o["y"]) as core.Map;
392 unittest.expect(casted2, unittest.hasLength(3));
393 unittest.expect(casted2["list"], unittest.equals([1, 2, 3]));
394 unittest.expect(casted2["bool"], unittest.equals(true));
395 unittest.expect(casted2["string"], unittest.equals('foo'));
396 }
397
398 buildUnnamed303() {
399 var o = new core.List<core.Map<core.String, core.Object>>();
400 o.add(buildUnnamed302());
401 o.add(buildUnnamed302());
402 return o;
403 }
404
405 checkUnnamed303(core.List<core.Map<core.String, core.Object>> o) {
406 unittest.expect(o, unittest.hasLength(2));
407 checkUnnamed302(o[0]);
408 checkUnnamed302(o[1]);
381 } 409 }
382 410
383 buildUnnamed304() { 411 buildUnnamed304() {
384 var o = new core.List<core.Map<core.String, core.Object>>(); 412 var o = new core
385 o.add(buildUnnamed303()); 413 .Map<core.String, core.List<core.Map<core.String, core.Object>>>();
386 o.add(buildUnnamed303()); 414 o["x"] = buildUnnamed303();
415 o["y"] = buildUnnamed303();
387 return o; 416 return o;
388 } 417 }
389 418
390 checkUnnamed304(core.List<core.Map<core.String, core.Object>> o) { 419 checkUnnamed304(
420 core.Map<core.String, core.List<core.Map<core.String, core.Object>>> o) {
391 unittest.expect(o, unittest.hasLength(2)); 421 unittest.expect(o, unittest.hasLength(2));
392 checkUnnamed303(o[0]); 422 checkUnnamed303(o["x"]);
393 checkUnnamed303(o[1]); 423 checkUnnamed303(o["y"]);
394 }
395
396 buildUnnamed305() {
397 var o = new core.Map<core.String, core.List<core.Map<core.String, core.Object> >>();
398 o["x"] = buildUnnamed304();
399 o["y"] = buildUnnamed304();
400 return o;
401 }
402
403 checkUnnamed305(core.Map<core.String, core.List<core.Map<core.String, core.Objec t>>> o) {
404 unittest.expect(o, unittest.hasLength(2));
405 checkUnnamed304(o["x"]);
406 checkUnnamed304(o["y"]);
407 } 424 }
408 425
409 core.int buildCounterResult = 0; 426 core.int buildCounterResult = 0;
410 buildResult() { 427 buildResult() {
411 var o = new api.Result(); 428 var o = new api.Result();
412 buildCounterResult++; 429 buildCounterResult++;
413 if (buildCounterResult < 3) { 430 if (buildCounterResult < 3) {
414 o.cacheId = "foo"; 431 o.cacheId = "foo";
415 o.displayLink = "foo"; 432 o.displayLink = "foo";
416 o.fileFormat = "foo"; 433 o.fileFormat = "foo";
417 o.formattedUrl = "foo"; 434 o.formattedUrl = "foo";
418 o.htmlFormattedUrl = "foo"; 435 o.htmlFormattedUrl = "foo";
419 o.htmlSnippet = "foo"; 436 o.htmlSnippet = "foo";
420 o.htmlTitle = "foo"; 437 o.htmlTitle = "foo";
421 o.image = buildResultImage(); 438 o.image = buildResultImage();
422 o.kind = "foo"; 439 o.kind = "foo";
423 o.labels = buildUnnamed302(); 440 o.labels = buildUnnamed301();
424 o.link = "foo"; 441 o.link = "foo";
425 o.mime = "foo"; 442 o.mime = "foo";
426 o.pagemap = buildUnnamed305(); 443 o.pagemap = buildUnnamed304();
427 o.snippet = "foo"; 444 o.snippet = "foo";
428 o.title = "foo"; 445 o.title = "foo";
429 } 446 }
430 buildCounterResult--; 447 buildCounterResult--;
431 return o; 448 return o;
432 } 449 }
433 450
434 checkResult(api.Result o) { 451 checkResult(api.Result o) {
435 buildCounterResult++; 452 buildCounterResult++;
436 if (buildCounterResult < 3) { 453 if (buildCounterResult < 3) {
437 unittest.expect(o.cacheId, unittest.equals('foo')); 454 unittest.expect(o.cacheId, unittest.equals('foo'));
438 unittest.expect(o.displayLink, unittest.equals('foo')); 455 unittest.expect(o.displayLink, unittest.equals('foo'));
439 unittest.expect(o.fileFormat, unittest.equals('foo')); 456 unittest.expect(o.fileFormat, unittest.equals('foo'));
440 unittest.expect(o.formattedUrl, unittest.equals('foo')); 457 unittest.expect(o.formattedUrl, unittest.equals('foo'));
441 unittest.expect(o.htmlFormattedUrl, unittest.equals('foo')); 458 unittest.expect(o.htmlFormattedUrl, unittest.equals('foo'));
442 unittest.expect(o.htmlSnippet, unittest.equals('foo')); 459 unittest.expect(o.htmlSnippet, unittest.equals('foo'));
443 unittest.expect(o.htmlTitle, unittest.equals('foo')); 460 unittest.expect(o.htmlTitle, unittest.equals('foo'));
444 checkResultImage(o.image); 461 checkResultImage(o.image);
445 unittest.expect(o.kind, unittest.equals('foo')); 462 unittest.expect(o.kind, unittest.equals('foo'));
446 checkUnnamed302(o.labels); 463 checkUnnamed301(o.labels);
447 unittest.expect(o.link, unittest.equals('foo')); 464 unittest.expect(o.link, unittest.equals('foo'));
448 unittest.expect(o.mime, unittest.equals('foo')); 465 unittest.expect(o.mime, unittest.equals('foo'));
449 checkUnnamed305(o.pagemap); 466 checkUnnamed304(o.pagemap);
450 unittest.expect(o.snippet, unittest.equals('foo')); 467 unittest.expect(o.snippet, unittest.equals('foo'));
451 unittest.expect(o.title, unittest.equals('foo')); 468 unittest.expect(o.title, unittest.equals('foo'));
452 } 469 }
453 buildCounterResult--; 470 buildCounterResult--;
454 } 471 }
455 472
456 buildUnnamed306() { 473 buildUnnamed305() {
457 var o = new core.List<api.Result>(); 474 var o = new core.List<api.Result>();
458 o.add(buildResult()); 475 o.add(buildResult());
459 o.add(buildResult()); 476 o.add(buildResult());
460 return o; 477 return o;
461 } 478 }
462 479
463 checkUnnamed306(core.List<api.Result> o) { 480 checkUnnamed305(core.List<api.Result> o) {
464 unittest.expect(o, unittest.hasLength(2)); 481 unittest.expect(o, unittest.hasLength(2));
465 checkResult(o[0]); 482 checkResult(o[0]);
466 checkResult(o[1]); 483 checkResult(o[1]);
467 } 484 }
468 485
469 buildUnnamed307() { 486 buildUnnamed306() {
470 var o = new core.List<api.Promotion>(); 487 var o = new core.List<api.Promotion>();
471 o.add(buildPromotion()); 488 o.add(buildPromotion());
472 o.add(buildPromotion()); 489 o.add(buildPromotion());
473 return o; 490 return o;
474 } 491 }
475 492
476 checkUnnamed307(core.List<api.Promotion> o) { 493 checkUnnamed306(core.List<api.Promotion> o) {
477 unittest.expect(o, unittest.hasLength(2)); 494 unittest.expect(o, unittest.hasLength(2));
478 checkPromotion(o[0]); 495 checkPromotion(o[0]);
479 checkPromotion(o[1]); 496 checkPromotion(o[1]);
480 } 497 }
481 498
482 buildUnnamed308() { 499 buildUnnamed307() {
483 var o = new core.List<api.Query>(); 500 var o = new core.List<api.Query>();
484 o.add(buildQuery()); 501 o.add(buildQuery());
485 o.add(buildQuery()); 502 o.add(buildQuery());
486 return o; 503 return o;
487 } 504 }
488 505
489 checkUnnamed308(core.List<api.Query> o) { 506 checkUnnamed307(core.List<api.Query> o) {
490 unittest.expect(o, unittest.hasLength(2)); 507 unittest.expect(o, unittest.hasLength(2));
491 checkQuery(o[0]); 508 checkQuery(o[0]);
492 checkQuery(o[1]); 509 checkQuery(o[1]);
493 } 510 }
494 511
495 buildUnnamed309() { 512 buildUnnamed308() {
496 var o = new core.Map<core.String, core.List<api.Query>>(); 513 var o = new core.Map<core.String, core.List<api.Query>>();
497 o["x"] = buildUnnamed308(); 514 o["x"] = buildUnnamed307();
498 o["y"] = buildUnnamed308(); 515 o["y"] = buildUnnamed307();
499 return o; 516 return o;
500 } 517 }
501 518
502 checkUnnamed309(core.Map<core.String, core.List<api.Query>> o) { 519 checkUnnamed308(core.Map<core.String, core.List<api.Query>> o) {
503 unittest.expect(o, unittest.hasLength(2)); 520 unittest.expect(o, unittest.hasLength(2));
504 checkUnnamed308(o["x"]); 521 checkUnnamed307(o["x"]);
505 checkUnnamed308(o["y"]); 522 checkUnnamed307(o["y"]);
506 } 523 }
507 524
508 core.int buildCounterSearchSearchInformation = 0; 525 core.int buildCounterSearchSearchInformation = 0;
509 buildSearchSearchInformation() { 526 buildSearchSearchInformation() {
510 var o = new api.SearchSearchInformation(); 527 var o = new api.SearchSearchInformation();
511 buildCounterSearchSearchInformation++; 528 buildCounterSearchSearchInformation++;
512 if (buildCounterSearchSearchInformation < 3) { 529 if (buildCounterSearchSearchInformation < 3) {
513 o.formattedSearchTime = "foo"; 530 o.formattedSearchTime = "foo";
514 o.formattedTotalResults = "foo"; 531 o.formattedTotalResults = "foo";
515 o.searchTime = 42.0; 532 o.searchTime = 42.0;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 } 588 }
572 buildCounterSearchUrl--; 589 buildCounterSearchUrl--;
573 } 590 }
574 591
575 core.int buildCounterSearch = 0; 592 core.int buildCounterSearch = 0;
576 buildSearch() { 593 buildSearch() {
577 var o = new api.Search(); 594 var o = new api.Search();
578 buildCounterSearch++; 595 buildCounterSearch++;
579 if (buildCounterSearch < 3) { 596 if (buildCounterSearch < 3) {
580 o.context = buildContext(); 597 o.context = buildContext();
581 o.items = buildUnnamed306(); 598 o.items = buildUnnamed305();
582 o.kind = "foo"; 599 o.kind = "foo";
583 o.promotions = buildUnnamed307(); 600 o.promotions = buildUnnamed306();
584 o.queries = buildUnnamed309(); 601 o.queries = buildUnnamed308();
585 o.searchInformation = buildSearchSearchInformation(); 602 o.searchInformation = buildSearchSearchInformation();
586 o.spelling = buildSearchSpelling(); 603 o.spelling = buildSearchSpelling();
587 o.url = buildSearchUrl(); 604 o.url = buildSearchUrl();
588 } 605 }
589 buildCounterSearch--; 606 buildCounterSearch--;
590 return o; 607 return o;
591 } 608 }
592 609
593 checkSearch(api.Search o) { 610 checkSearch(api.Search o) {
594 buildCounterSearch++; 611 buildCounterSearch++;
595 if (buildCounterSearch < 3) { 612 if (buildCounterSearch < 3) {
596 checkContext(o.context); 613 checkContext(o.context);
597 checkUnnamed306(o.items); 614 checkUnnamed305(o.items);
598 unittest.expect(o.kind, unittest.equals('foo')); 615 unittest.expect(o.kind, unittest.equals('foo'));
599 checkUnnamed307(o.promotions); 616 checkUnnamed306(o.promotions);
600 checkUnnamed309(o.queries); 617 checkUnnamed308(o.queries);
601 checkSearchSearchInformation(o.searchInformation); 618 checkSearchSearchInformation(o.searchInformation);
602 checkSearchSpelling(o.spelling); 619 checkSearchSpelling(o.spelling);
603 checkSearchUrl(o.url); 620 checkSearchUrl(o.url);
604 } 621 }
605 buildCounterSearch--; 622 buildCounterSearch--;
606 } 623 }
607 624
608
609 main() { 625 main() {
610 unittest.group("obj-schema-ContextFacets", () { 626 unittest.group("obj-schema-ContextFacets", () {
611 unittest.test("to-json--from-json", () { 627 unittest.test("to-json--from-json", () {
612 var o = buildContextFacets(); 628 var o = buildContextFacets();
613 var od = new api.ContextFacets.fromJson(o.toJson()); 629 var od = new api.ContextFacets.fromJson(o.toJson());
614 checkContextFacets(od); 630 checkContextFacets(od);
615 }); 631 });
616 }); 632 });
617 633
618
619 unittest.group("obj-schema-Context", () { 634 unittest.group("obj-schema-Context", () {
620 unittest.test("to-json--from-json", () { 635 unittest.test("to-json--from-json", () {
621 var o = buildContext(); 636 var o = buildContext();
622 var od = new api.Context.fromJson(o.toJson()); 637 var od = new api.Context.fromJson(o.toJson());
623 checkContext(od); 638 checkContext(od);
624 }); 639 });
625 }); 640 });
626 641
627
628 unittest.group("obj-schema-PromotionBodyLines", () { 642 unittest.group("obj-schema-PromotionBodyLines", () {
629 unittest.test("to-json--from-json", () { 643 unittest.test("to-json--from-json", () {
630 var o = buildPromotionBodyLines(); 644 var o = buildPromotionBodyLines();
631 var od = new api.PromotionBodyLines.fromJson(o.toJson()); 645 var od = new api.PromotionBodyLines.fromJson(o.toJson());
632 checkPromotionBodyLines(od); 646 checkPromotionBodyLines(od);
633 }); 647 });
634 }); 648 });
635 649
636
637 unittest.group("obj-schema-PromotionImage", () { 650 unittest.group("obj-schema-PromotionImage", () {
638 unittest.test("to-json--from-json", () { 651 unittest.test("to-json--from-json", () {
639 var o = buildPromotionImage(); 652 var o = buildPromotionImage();
640 var od = new api.PromotionImage.fromJson(o.toJson()); 653 var od = new api.PromotionImage.fromJson(o.toJson());
641 checkPromotionImage(od); 654 checkPromotionImage(od);
642 }); 655 });
643 }); 656 });
644 657
645
646 unittest.group("obj-schema-Promotion", () { 658 unittest.group("obj-schema-Promotion", () {
647 unittest.test("to-json--from-json", () { 659 unittest.test("to-json--from-json", () {
648 var o = buildPromotion(); 660 var o = buildPromotion();
649 var od = new api.Promotion.fromJson(o.toJson()); 661 var od = new api.Promotion.fromJson(o.toJson());
650 checkPromotion(od); 662 checkPromotion(od);
651 }); 663 });
652 }); 664 });
653 665
654
655 unittest.group("obj-schema-Query", () { 666 unittest.group("obj-schema-Query", () {
656 unittest.test("to-json--from-json", () { 667 unittest.test("to-json--from-json", () {
657 var o = buildQuery(); 668 var o = buildQuery();
658 var od = new api.Query.fromJson(o.toJson()); 669 var od = new api.Query.fromJson(o.toJson());
659 checkQuery(od); 670 checkQuery(od);
660 }); 671 });
661 }); 672 });
662 673
663
664 unittest.group("obj-schema-ResultImage", () { 674 unittest.group("obj-schema-ResultImage", () {
665 unittest.test("to-json--from-json", () { 675 unittest.test("to-json--from-json", () {
666 var o = buildResultImage(); 676 var o = buildResultImage();
667 var od = new api.ResultImage.fromJson(o.toJson()); 677 var od = new api.ResultImage.fromJson(o.toJson());
668 checkResultImage(od); 678 checkResultImage(od);
669 }); 679 });
670 }); 680 });
671 681
672
673 unittest.group("obj-schema-ResultLabels", () { 682 unittest.group("obj-schema-ResultLabels", () {
674 unittest.test("to-json--from-json", () { 683 unittest.test("to-json--from-json", () {
675 var o = buildResultLabels(); 684 var o = buildResultLabels();
676 var od = new api.ResultLabels.fromJson(o.toJson()); 685 var od = new api.ResultLabels.fromJson(o.toJson());
677 checkResultLabels(od); 686 checkResultLabels(od);
678 }); 687 });
679 }); 688 });
680 689
681
682 unittest.group("obj-schema-Result", () { 690 unittest.group("obj-schema-Result", () {
683 unittest.test("to-json--from-json", () { 691 unittest.test("to-json--from-json", () {
684 var o = buildResult(); 692 var o = buildResult();
685 var od = new api.Result.fromJson(o.toJson()); 693 var od = new api.Result.fromJson(o.toJson());
686 checkResult(od); 694 checkResult(od);
687 }); 695 });
688 }); 696 });
689 697
690
691 unittest.group("obj-schema-SearchSearchInformation", () { 698 unittest.group("obj-schema-SearchSearchInformation", () {
692 unittest.test("to-json--from-json", () { 699 unittest.test("to-json--from-json", () {
693 var o = buildSearchSearchInformation(); 700 var o = buildSearchSearchInformation();
694 var od = new api.SearchSearchInformation.fromJson(o.toJson()); 701 var od = new api.SearchSearchInformation.fromJson(o.toJson());
695 checkSearchSearchInformation(od); 702 checkSearchSearchInformation(od);
696 }); 703 });
697 }); 704 });
698 705
699
700 unittest.group("obj-schema-SearchSpelling", () { 706 unittest.group("obj-schema-SearchSpelling", () {
701 unittest.test("to-json--from-json", () { 707 unittest.test("to-json--from-json", () {
702 var o = buildSearchSpelling(); 708 var o = buildSearchSpelling();
703 var od = new api.SearchSpelling.fromJson(o.toJson()); 709 var od = new api.SearchSpelling.fromJson(o.toJson());
704 checkSearchSpelling(od); 710 checkSearchSpelling(od);
705 }); 711 });
706 }); 712 });
707 713
708
709 unittest.group("obj-schema-SearchUrl", () { 714 unittest.group("obj-schema-SearchUrl", () {
710 unittest.test("to-json--from-json", () { 715 unittest.test("to-json--from-json", () {
711 var o = buildSearchUrl(); 716 var o = buildSearchUrl();
712 var od = new api.SearchUrl.fromJson(o.toJson()); 717 var od = new api.SearchUrl.fromJson(o.toJson());
713 checkSearchUrl(od); 718 checkSearchUrl(od);
714 }); 719 });
715 }); 720 });
716 721
717
718 unittest.group("obj-schema-Search", () { 722 unittest.group("obj-schema-Search", () {
719 unittest.test("to-json--from-json", () { 723 unittest.test("to-json--from-json", () {
720 var o = buildSearch(); 724 var o = buildSearch();
721 var od = new api.Search.fromJson(o.toJson()); 725 var od = new api.Search.fromJson(o.toJson());
722 checkSearch(od); 726 checkSearch(od);
723 }); 727 });
724 }); 728 });
725 729
726
727 unittest.group("resource-CseResourceApi", () { 730 unittest.group("resource-CseResourceApi", () {
728 unittest.test("method--list", () { 731 unittest.test("method--list", () {
729
730 var mock = new HttpServerMock(); 732 var mock = new HttpServerMock();
731 api.CseResourceApi res = new api.CustomsearchApi(mock).cse; 733 api.CseResourceApi res = new api.CustomsearchApi(mock).cse;
732 var arg_q = "foo"; 734 var arg_q = "foo";
733 var arg_c2coff = "foo"; 735 var arg_c2coff = "foo";
734 var arg_cr = "foo"; 736 var arg_cr = "foo";
735 var arg_cx = "foo"; 737 var arg_cx = "foo";
736 var arg_dateRestrict = "foo"; 738 var arg_dateRestrict = "foo";
737 var arg_exactTerms = "foo"; 739 var arg_exactTerms = "foo";
738 var arg_excludeTerms = "foo"; 740 var arg_excludeTerms = "foo";
739 var arg_fileType = "foo"; 741 var arg_fileType = "foo";
(...skipping 18 matching lines...) Expand all
758 var arg_searchType = "foo"; 760 var arg_searchType = "foo";
759 var arg_siteSearch = "foo"; 761 var arg_siteSearch = "foo";
760 var arg_siteSearchFilter = "foo"; 762 var arg_siteSearchFilter = "foo";
761 var arg_sort = "foo"; 763 var arg_sort = "foo";
762 var arg_start = 42; 764 var arg_start = 42;
763 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { 765 mock.register(unittest.expectAsync2((http.BaseRequest req, json) {
764 var path = (req.url).path; 766 var path = (req.url).path;
765 var pathOffset = 0; 767 var pathOffset = 0;
766 var index; 768 var index;
767 var subPart; 769 var subPart;
768 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ als("/")); 770 unittest.expect(
771 path.substring(pathOffset, pathOffset + 1), unittest.equals("/"));
769 pathOffset += 1; 772 pathOffset += 1;
770 unittest.expect(path.substring(pathOffset, pathOffset + 13), unittest.eq uals("customsearch/")); 773 unittest.expect(path.substring(pathOffset, pathOffset + 13),
774 unittest.equals("customsearch/"));
771 pathOffset += 13; 775 pathOffset += 13;
772 unittest.expect(path.substring(pathOffset, pathOffset + 2), unittest.equ als("v1")); 776 unittest.expect(
777 path.substring(pathOffset, pathOffset + 2), unittest.equals("v1"));
773 pathOffset += 2; 778 pathOffset += 2;
774 779
775 var query = (req.url).query; 780 var query = (req.url).query;
776 var queryOffset = 0; 781 var queryOffset = 0;
777 var queryMap = {}; 782 var queryMap = {};
778 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); 783 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
779 parseBool(n) { 784 parseBool(n) {
780 if (n == "true") return true; 785 if (n == "true") return true;
781 if (n == "false") return false; 786 if (n == "false") return false;
782 if (n == null) return null; 787 if (n == null) return null;
783 throw new core.ArgumentError("Invalid boolean: $n"); 788 throw new core.ArgumentError("Invalid boolean: $n");
784 } 789 }
790
785 if (query.length > 0) { 791 if (query.length > 0) {
786 for (var part in query.split("&")) { 792 for (var part in query.split("&")) {
787 var keyvalue = part.split("="); 793 var keyvalue = part.split("=");
788 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1])); 794 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]),
795 core.Uri.decodeQueryComponent(keyvalue[1]));
789 } 796 }
790 } 797 }
791 unittest.expect(queryMap["q"].first, unittest.equals(arg_q)); 798 unittest.expect(queryMap["q"].first, unittest.equals(arg_q));
792 unittest.expect(queryMap["c2coff"].first, unittest.equals(arg_c2coff)); 799 unittest.expect(queryMap["c2coff"].first, unittest.equals(arg_c2coff));
793 unittest.expect(queryMap["cr"].first, unittest.equals(arg_cr)); 800 unittest.expect(queryMap["cr"].first, unittest.equals(arg_cr));
794 unittest.expect(queryMap["cx"].first, unittest.equals(arg_cx)); 801 unittest.expect(queryMap["cx"].first, unittest.equals(arg_cx));
795 unittest.expect(queryMap["dateRestrict"].first, unittest.equals(arg_date Restrict)); 802 unittest.expect(
796 unittest.expect(queryMap["exactTerms"].first, unittest.equals(arg_exactT erms)); 803 queryMap["dateRestrict"].first, unittest.equals(arg_dateRestrict));
797 unittest.expect(queryMap["excludeTerms"].first, unittest.equals(arg_excl udeTerms)); 804 unittest.expect(
798 unittest.expect(queryMap["fileType"].first, unittest.equals(arg_fileType )); 805 queryMap["exactTerms"].first, unittest.equals(arg_exactTerms));
806 unittest.expect(
807 queryMap["excludeTerms"].first, unittest.equals(arg_excludeTerms));
808 unittest.expect(
809 queryMap["fileType"].first, unittest.equals(arg_fileType));
799 unittest.expect(queryMap["filter"].first, unittest.equals(arg_filter)); 810 unittest.expect(queryMap["filter"].first, unittest.equals(arg_filter));
800 unittest.expect(queryMap["gl"].first, unittest.equals(arg_gl)); 811 unittest.expect(queryMap["gl"].first, unittest.equals(arg_gl));
801 unittest.expect(queryMap["googlehost"].first, unittest.equals(arg_google host)); 812 unittest.expect(
802 unittest.expect(queryMap["highRange"].first, unittest.equals(arg_highRan ge)); 813 queryMap["googlehost"].first, unittest.equals(arg_googlehost));
814 unittest.expect(
815 queryMap["highRange"].first, unittest.equals(arg_highRange));
803 unittest.expect(queryMap["hl"].first, unittest.equals(arg_hl)); 816 unittest.expect(queryMap["hl"].first, unittest.equals(arg_hl));
804 unittest.expect(queryMap["hq"].first, unittest.equals(arg_hq)); 817 unittest.expect(queryMap["hq"].first, unittest.equals(arg_hq));
805 unittest.expect(queryMap["imgColorType"].first, unittest.equals(arg_imgC olorType)); 818 unittest.expect(
806 unittest.expect(queryMap["imgDominantColor"].first, unittest.equals(arg_ imgDominantColor)); 819 queryMap["imgColorType"].first, unittest.equals(arg_imgColorType));
807 unittest.expect(queryMap["imgSize"].first, unittest.equals(arg_imgSize)) ; 820 unittest.expect(queryMap["imgDominantColor"].first,
808 unittest.expect(queryMap["imgType"].first, unittest.equals(arg_imgType)) ; 821 unittest.equals(arg_imgDominantColor));
809 unittest.expect(queryMap["linkSite"].first, unittest.equals(arg_linkSite )); 822 unittest.expect(
810 unittest.expect(queryMap["lowRange"].first, unittest.equals(arg_lowRange )); 823 queryMap["imgSize"].first, unittest.equals(arg_imgSize));
824 unittest.expect(
825 queryMap["imgType"].first, unittest.equals(arg_imgType));
826 unittest.expect(
827 queryMap["linkSite"].first, unittest.equals(arg_linkSite));
828 unittest.expect(
829 queryMap["lowRange"].first, unittest.equals(arg_lowRange));
811 unittest.expect(queryMap["lr"].first, unittest.equals(arg_lr)); 830 unittest.expect(queryMap["lr"].first, unittest.equals(arg_lr));
812 unittest.expect(core.int.parse(queryMap["num"].first), unittest.equals(a rg_num)); 831 unittest.expect(
813 unittest.expect(queryMap["orTerms"].first, unittest.equals(arg_orTerms)) ; 832 core.int.parse(queryMap["num"].first), unittest.equals(arg_num));
814 unittest.expect(queryMap["relatedSite"].first, unittest.equals(arg_relat edSite)); 833 unittest.expect(
834 queryMap["orTerms"].first, unittest.equals(arg_orTerms));
835 unittest.expect(
836 queryMap["relatedSite"].first, unittest.equals(arg_relatedSite));
815 unittest.expect(queryMap["rights"].first, unittest.equals(arg_rights)); 837 unittest.expect(queryMap["rights"].first, unittest.equals(arg_rights));
816 unittest.expect(queryMap["safe"].first, unittest.equals(arg_safe)); 838 unittest.expect(queryMap["safe"].first, unittest.equals(arg_safe));
817 unittest.expect(queryMap["searchType"].first, unittest.equals(arg_search Type)); 839 unittest.expect(
818 unittest.expect(queryMap["siteSearch"].first, unittest.equals(arg_siteSe arch)); 840 queryMap["searchType"].first, unittest.equals(arg_searchType));
819 unittest.expect(queryMap["siteSearchFilter"].first, unittest.equals(arg_ siteSearchFilter)); 841 unittest.expect(
842 queryMap["siteSearch"].first, unittest.equals(arg_siteSearch));
843 unittest.expect(queryMap["siteSearchFilter"].first,
844 unittest.equals(arg_siteSearchFilter));
820 unittest.expect(queryMap["sort"].first, unittest.equals(arg_sort)); 845 unittest.expect(queryMap["sort"].first, unittest.equals(arg_sort));
821 unittest.expect(core.int.parse(queryMap["start"].first), unittest.equals (arg_start)); 846 unittest.expect(core.int.parse(queryMap["start"].first),
822 847 unittest.equals(arg_start));
823 848
824 var h = { 849 var h = {
825 "content-type" : "application/json; charset=utf-8", 850 "content-type": "application/json; charset=utf-8",
826 }; 851 };
827 var resp = convert.JSON.encode(buildSearch()); 852 var resp = convert.JSON.encode(buildSearch());
828 return new async.Future.value(stringResponse(200, h, resp)); 853 return new async.Future.value(stringResponse(200, h, resp));
829 }), true); 854 }), true);
830 res.list(arg_q, c2coff: arg_c2coff, cr: arg_cr, cx: arg_cx, dateRestrict: arg_dateRestrict, exactTerms: arg_exactTerms, excludeTerms: arg_excludeTerms, fi leType: arg_fileType, filter: arg_filter, gl: arg_gl, googlehost: arg_googlehost , highRange: arg_highRange, hl: arg_hl, hq: arg_hq, imgColorType: arg_imgColorTy pe, imgDominantColor: arg_imgDominantColor, imgSize: arg_imgSize, imgType: arg_i mgType, linkSite: arg_linkSite, lowRange: arg_lowRange, lr: arg_lr, num: arg_num , orTerms: arg_orTerms, relatedSite: arg_relatedSite, rights: arg_rights, safe: arg_safe, searchType: arg_searchType, siteSearch: arg_siteSearch, siteSearchFilt er: arg_siteSearchFilter, sort: arg_sort, start: arg_start).then(unittest.expect Async1(((api.Search response) { 855 res
856 .list(arg_q,
857 c2coff: arg_c2coff,
858 cr: arg_cr,
859 cx: arg_cx,
860 dateRestrict: arg_dateRestrict,
861 exactTerms: arg_exactTerms,
862 excludeTerms: arg_excludeTerms,
863 fileType: arg_fileType,
864 filter: arg_filter,
865 gl: arg_gl,
866 googlehost: arg_googlehost,
867 highRange: arg_highRange,
868 hl: arg_hl,
869 hq: arg_hq,
870 imgColorType: arg_imgColorType,
871 imgDominantColor: arg_imgDominantColor,
872 imgSize: arg_imgSize,
873 imgType: arg_imgType,
874 linkSite: arg_linkSite,
875 lowRange: arg_lowRange,
876 lr: arg_lr,
877 num: arg_num,
878 orTerms: arg_orTerms,
879 relatedSite: arg_relatedSite,
880 rights: arg_rights,
881 safe: arg_safe,
882 searchType: arg_searchType,
883 siteSearch: arg_siteSearch,
884 siteSearchFilter: arg_siteSearchFilter,
885 sort: arg_sort,
886 start: arg_start)
887 .then(unittest.expectAsync1(((api.Search response) {
831 checkSearch(response); 888 checkSearch(response);
832 }))); 889 })));
833 }); 890 });
834
835 }); 891 });
836
837
838 } 892 }
839
OLDNEW
« no previous file with comments | « generated/googleapis/test/container/v1_test.dart ('k') | generated/googleapis/test/dataproc/v1_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698