OLD | NEW |
| (Empty) |
1 library googleapis.customsearch.v1.test; | |
2 | |
3 import "dart:core" as core; | |
4 import "dart:collection" as collection; | |
5 import "dart:async" as async; | |
6 import "dart:convert" as convert; | |
7 | |
8 import 'package:http/http.dart' as http; | |
9 import 'package:http/testing.dart' as http_testing; | |
10 import 'package:unittest/unittest.dart' as unittest; | |
11 import 'package:googleapis/common/common.dart' as common; | |
12 import 'package:googleapis/src/common_internal.dart' as common_internal; | |
13 import '../common/common_internal_test.dart' as common_test; | |
14 | |
15 import 'package:googleapis/customsearch/v1.dart' as api; | |
16 | |
17 | |
18 | |
19 core.int buildCounterContextFacets = 0; | |
20 buildContextFacets() { | |
21 var o = new api.ContextFacets(); | |
22 buildCounterContextFacets++; | |
23 if (buildCounterContextFacets < 3) { | |
24 o.anchor = "foo"; | |
25 o.label = "foo"; | |
26 o.labelWithOp = "foo"; | |
27 } | |
28 buildCounterContextFacets--; | |
29 return o; | |
30 } | |
31 | |
32 checkContextFacets(api.ContextFacets o) { | |
33 buildCounterContextFacets++; | |
34 if (buildCounterContextFacets < 3) { | |
35 unittest.expect(o.anchor, unittest.equals('foo')); | |
36 unittest.expect(o.label, unittest.equals('foo')); | |
37 unittest.expect(o.labelWithOp, unittest.equals('foo')); | |
38 } | |
39 buildCounterContextFacets--; | |
40 } | |
41 | |
42 buildUnnamed288() { | |
43 var o = new core.List<api.ContextFacets>(); | |
44 o.add(buildContextFacets()); | |
45 o.add(buildContextFacets()); | |
46 return o; | |
47 } | |
48 | |
49 checkUnnamed288(core.List<api.ContextFacets> o) { | |
50 unittest.expect(o, unittest.hasLength(2)); | |
51 checkContextFacets(o[0]); | |
52 checkContextFacets(o[1]); | |
53 } | |
54 | |
55 buildUnnamed289() { | |
56 var o = new core.List<core.List<api.ContextFacets>>(); | |
57 o.add(buildUnnamed288()); | |
58 o.add(buildUnnamed288()); | |
59 return o; | |
60 } | |
61 | |
62 checkUnnamed289(core.List<core.List<api.ContextFacets>> o) { | |
63 unittest.expect(o, unittest.hasLength(2)); | |
64 checkUnnamed288(o[0]); | |
65 checkUnnamed288(o[1]); | |
66 } | |
67 | |
68 core.int buildCounterContext = 0; | |
69 buildContext() { | |
70 var o = new api.Context(); | |
71 buildCounterContext++; | |
72 if (buildCounterContext < 3) { | |
73 o.facets = buildUnnamed289(); | |
74 o.title = "foo"; | |
75 } | |
76 buildCounterContext--; | |
77 return o; | |
78 } | |
79 | |
80 checkContext(api.Context o) { | |
81 buildCounterContext++; | |
82 if (buildCounterContext < 3) { | |
83 checkUnnamed289(o.facets); | |
84 unittest.expect(o.title, unittest.equals('foo')); | |
85 } | |
86 buildCounterContext--; | |
87 } | |
88 | |
89 core.int buildCounterPromotionBodyLines = 0; | |
90 buildPromotionBodyLines() { | |
91 var o = new api.PromotionBodyLines(); | |
92 buildCounterPromotionBodyLines++; | |
93 if (buildCounterPromotionBodyLines < 3) { | |
94 o.htmlTitle = "foo"; | |
95 o.link = "foo"; | |
96 o.title = "foo"; | |
97 o.url = "foo"; | |
98 } | |
99 buildCounterPromotionBodyLines--; | |
100 return o; | |
101 } | |
102 | |
103 checkPromotionBodyLines(api.PromotionBodyLines o) { | |
104 buildCounterPromotionBodyLines++; | |
105 if (buildCounterPromotionBodyLines < 3) { | |
106 unittest.expect(o.htmlTitle, unittest.equals('foo')); | |
107 unittest.expect(o.link, unittest.equals('foo')); | |
108 unittest.expect(o.title, unittest.equals('foo')); | |
109 unittest.expect(o.url, unittest.equals('foo')); | |
110 } | |
111 buildCounterPromotionBodyLines--; | |
112 } | |
113 | |
114 buildUnnamed290() { | |
115 var o = new core.List<api.PromotionBodyLines>(); | |
116 o.add(buildPromotionBodyLines()); | |
117 o.add(buildPromotionBodyLines()); | |
118 return o; | |
119 } | |
120 | |
121 checkUnnamed290(core.List<api.PromotionBodyLines> o) { | |
122 unittest.expect(o, unittest.hasLength(2)); | |
123 checkPromotionBodyLines(o[0]); | |
124 checkPromotionBodyLines(o[1]); | |
125 } | |
126 | |
127 core.int buildCounterPromotionImage = 0; | |
128 buildPromotionImage() { | |
129 var o = new api.PromotionImage(); | |
130 buildCounterPromotionImage++; | |
131 if (buildCounterPromotionImage < 3) { | |
132 o.height = 42; | |
133 o.source = "foo"; | |
134 o.width = 42; | |
135 } | |
136 buildCounterPromotionImage--; | |
137 return o; | |
138 } | |
139 | |
140 checkPromotionImage(api.PromotionImage o) { | |
141 buildCounterPromotionImage++; | |
142 if (buildCounterPromotionImage < 3) { | |
143 unittest.expect(o.height, unittest.equals(42)); | |
144 unittest.expect(o.source, unittest.equals('foo')); | |
145 unittest.expect(o.width, unittest.equals(42)); | |
146 } | |
147 buildCounterPromotionImage--; | |
148 } | |
149 | |
150 core.int buildCounterPromotion = 0; | |
151 buildPromotion() { | |
152 var o = new api.Promotion(); | |
153 buildCounterPromotion++; | |
154 if (buildCounterPromotion < 3) { | |
155 o.bodyLines = buildUnnamed290(); | |
156 o.displayLink = "foo"; | |
157 o.htmlTitle = "foo"; | |
158 o.image = buildPromotionImage(); | |
159 o.link = "foo"; | |
160 o.title = "foo"; | |
161 } | |
162 buildCounterPromotion--; | |
163 return o; | |
164 } | |
165 | |
166 checkPromotion(api.Promotion o) { | |
167 buildCounterPromotion++; | |
168 if (buildCounterPromotion < 3) { | |
169 checkUnnamed290(o.bodyLines); | |
170 unittest.expect(o.displayLink, unittest.equals('foo')); | |
171 unittest.expect(o.htmlTitle, unittest.equals('foo')); | |
172 checkPromotionImage(o.image); | |
173 unittest.expect(o.link, unittest.equals('foo')); | |
174 unittest.expect(o.title, unittest.equals('foo')); | |
175 } | |
176 buildCounterPromotion--; | |
177 } | |
178 | |
179 core.int buildCounterQuery = 0; | |
180 buildQuery() { | |
181 var o = new api.Query(); | |
182 buildCounterQuery++; | |
183 if (buildCounterQuery < 3) { | |
184 o.count = 42; | |
185 o.cr = "foo"; | |
186 o.cref = "foo"; | |
187 o.cx = "foo"; | |
188 o.dateRestrict = "foo"; | |
189 o.disableCnTwTranslation = "foo"; | |
190 o.exactTerms = "foo"; | |
191 o.excludeTerms = "foo"; | |
192 o.fileType = "foo"; | |
193 o.filter = "foo"; | |
194 o.gl = "foo"; | |
195 o.googleHost = "foo"; | |
196 o.highRange = "foo"; | |
197 o.hl = "foo"; | |
198 o.hq = "foo"; | |
199 o.imgColorType = "foo"; | |
200 o.imgDominantColor = "foo"; | |
201 o.imgSize = "foo"; | |
202 o.imgType = "foo"; | |
203 o.inputEncoding = "foo"; | |
204 o.language = "foo"; | |
205 o.linkSite = "foo"; | |
206 o.lowRange = "foo"; | |
207 o.orTerms = "foo"; | |
208 o.outputEncoding = "foo"; | |
209 o.relatedSite = "foo"; | |
210 o.rights = "foo"; | |
211 o.safe = "foo"; | |
212 o.searchTerms = "foo"; | |
213 o.searchType = "foo"; | |
214 o.siteSearch = "foo"; | |
215 o.siteSearchFilter = "foo"; | |
216 o.sort = "foo"; | |
217 o.startIndex = 42; | |
218 o.startPage = 42; | |
219 o.title = "foo"; | |
220 o.totalResults = "foo"; | |
221 } | |
222 buildCounterQuery--; | |
223 return o; | |
224 } | |
225 | |
226 checkQuery(api.Query o) { | |
227 buildCounterQuery++; | |
228 if (buildCounterQuery < 3) { | |
229 unittest.expect(o.count, unittest.equals(42)); | |
230 unittest.expect(o.cr, unittest.equals('foo')); | |
231 unittest.expect(o.cref, unittest.equals('foo')); | |
232 unittest.expect(o.cx, unittest.equals('foo')); | |
233 unittest.expect(o.dateRestrict, unittest.equals('foo')); | |
234 unittest.expect(o.disableCnTwTranslation, unittest.equals('foo')); | |
235 unittest.expect(o.exactTerms, unittest.equals('foo')); | |
236 unittest.expect(o.excludeTerms, unittest.equals('foo')); | |
237 unittest.expect(o.fileType, unittest.equals('foo')); | |
238 unittest.expect(o.filter, unittest.equals('foo')); | |
239 unittest.expect(o.gl, unittest.equals('foo')); | |
240 unittest.expect(o.googleHost, unittest.equals('foo')); | |
241 unittest.expect(o.highRange, unittest.equals('foo')); | |
242 unittest.expect(o.hl, unittest.equals('foo')); | |
243 unittest.expect(o.hq, unittest.equals('foo')); | |
244 unittest.expect(o.imgColorType, unittest.equals('foo')); | |
245 unittest.expect(o.imgDominantColor, unittest.equals('foo')); | |
246 unittest.expect(o.imgSize, unittest.equals('foo')); | |
247 unittest.expect(o.imgType, unittest.equals('foo')); | |
248 unittest.expect(o.inputEncoding, unittest.equals('foo')); | |
249 unittest.expect(o.language, unittest.equals('foo')); | |
250 unittest.expect(o.linkSite, unittest.equals('foo')); | |
251 unittest.expect(o.lowRange, unittest.equals('foo')); | |
252 unittest.expect(o.orTerms, unittest.equals('foo')); | |
253 unittest.expect(o.outputEncoding, unittest.equals('foo')); | |
254 unittest.expect(o.relatedSite, unittest.equals('foo')); | |
255 unittest.expect(o.rights, unittest.equals('foo')); | |
256 unittest.expect(o.safe, unittest.equals('foo')); | |
257 unittest.expect(o.searchTerms, unittest.equals('foo')); | |
258 unittest.expect(o.searchType, unittest.equals('foo')); | |
259 unittest.expect(o.siteSearch, unittest.equals('foo')); | |
260 unittest.expect(o.siteSearchFilter, unittest.equals('foo')); | |
261 unittest.expect(o.sort, unittest.equals('foo')); | |
262 unittest.expect(o.startIndex, unittest.equals(42)); | |
263 unittest.expect(o.startPage, unittest.equals(42)); | |
264 unittest.expect(o.title, unittest.equals('foo')); | |
265 unittest.expect(o.totalResults, unittest.equals('foo')); | |
266 } | |
267 buildCounterQuery--; | |
268 } | |
269 | |
270 core.int buildCounterResultImage = 0; | |
271 buildResultImage() { | |
272 var o = new api.ResultImage(); | |
273 buildCounterResultImage++; | |
274 if (buildCounterResultImage < 3) { | |
275 o.byteSize = 42; | |
276 o.contextLink = "foo"; | |
277 o.height = 42; | |
278 o.thumbnailHeight = 42; | |
279 o.thumbnailLink = "foo"; | |
280 o.thumbnailWidth = 42; | |
281 o.width = 42; | |
282 } | |
283 buildCounterResultImage--; | |
284 return o; | |
285 } | |
286 | |
287 checkResultImage(api.ResultImage o) { | |
288 buildCounterResultImage++; | |
289 if (buildCounterResultImage < 3) { | |
290 unittest.expect(o.byteSize, unittest.equals(42)); | |
291 unittest.expect(o.contextLink, unittest.equals('foo')); | |
292 unittest.expect(o.height, unittest.equals(42)); | |
293 unittest.expect(o.thumbnailHeight, unittest.equals(42)); | |
294 unittest.expect(o.thumbnailLink, unittest.equals('foo')); | |
295 unittest.expect(o.thumbnailWidth, unittest.equals(42)); | |
296 unittest.expect(o.width, unittest.equals(42)); | |
297 } | |
298 buildCounterResultImage--; | |
299 } | |
300 | |
301 core.int buildCounterResultLabels = 0; | |
302 buildResultLabels() { | |
303 var o = new api.ResultLabels(); | |
304 buildCounterResultLabels++; | |
305 if (buildCounterResultLabels < 3) { | |
306 o.displayName = "foo"; | |
307 o.labelWithOp = "foo"; | |
308 o.name = "foo"; | |
309 } | |
310 buildCounterResultLabels--; | |
311 return o; | |
312 } | |
313 | |
314 checkResultLabels(api.ResultLabels o) { | |
315 buildCounterResultLabels++; | |
316 if (buildCounterResultLabels < 3) { | |
317 unittest.expect(o.displayName, unittest.equals('foo')); | |
318 unittest.expect(o.labelWithOp, unittest.equals('foo')); | |
319 unittest.expect(o.name, unittest.equals('foo')); | |
320 } | |
321 buildCounterResultLabels--; | |
322 } | |
323 | |
324 buildUnnamed291() { | |
325 var o = new core.List<api.ResultLabels>(); | |
326 o.add(buildResultLabels()); | |
327 o.add(buildResultLabels()); | |
328 return o; | |
329 } | |
330 | |
331 checkUnnamed291(core.List<api.ResultLabels> o) { | |
332 unittest.expect(o, unittest.hasLength(2)); | |
333 checkResultLabels(o[0]); | |
334 checkResultLabels(o[1]); | |
335 } | |
336 | |
337 buildUnnamed292() { | |
338 var o = new core.Map<core.String, core.Object>(); | |
339 o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; | |
340 o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; | |
341 return o; | |
342 } | |
343 | |
344 checkUnnamed292(core.Map<core.String, core.Object> o) { | |
345 unittest.expect(o, unittest.hasLength(2)); | |
346 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')); | |
347 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')); | |
348 } | |
349 | |
350 buildUnnamed293() { | |
351 var o = new core.List<core.Map<core.String, core.Object>>(); | |
352 o.add(buildUnnamed292()); | |
353 o.add(buildUnnamed292()); | |
354 return o; | |
355 } | |
356 | |
357 checkUnnamed293(core.List<core.Map<core.String, core.Object>> o) { | |
358 unittest.expect(o, unittest.hasLength(2)); | |
359 checkUnnamed292(o[0]); | |
360 checkUnnamed292(o[1]); | |
361 } | |
362 | |
363 buildUnnamed294() { | |
364 var o = new core.Map<core.String, core.List<core.Map<core.String, core.Object>
>>(); | |
365 o["x"] = buildUnnamed293(); | |
366 o["y"] = buildUnnamed293(); | |
367 return o; | |
368 } | |
369 | |
370 checkUnnamed294(core.Map<core.String, core.List<core.Map<core.String, core.Objec
t>>> o) { | |
371 unittest.expect(o, unittest.hasLength(2)); | |
372 checkUnnamed293(o["x"]); | |
373 checkUnnamed293(o["y"]); | |
374 } | |
375 | |
376 core.int buildCounterResult = 0; | |
377 buildResult() { | |
378 var o = new api.Result(); | |
379 buildCounterResult++; | |
380 if (buildCounterResult < 3) { | |
381 o.cacheId = "foo"; | |
382 o.displayLink = "foo"; | |
383 o.fileFormat = "foo"; | |
384 o.formattedUrl = "foo"; | |
385 o.htmlFormattedUrl = "foo"; | |
386 o.htmlSnippet = "foo"; | |
387 o.htmlTitle = "foo"; | |
388 o.image = buildResultImage(); | |
389 o.kind = "foo"; | |
390 o.labels = buildUnnamed291(); | |
391 o.link = "foo"; | |
392 o.mime = "foo"; | |
393 o.pagemap = buildUnnamed294(); | |
394 o.snippet = "foo"; | |
395 o.title = "foo"; | |
396 } | |
397 buildCounterResult--; | |
398 return o; | |
399 } | |
400 | |
401 checkResult(api.Result o) { | |
402 buildCounterResult++; | |
403 if (buildCounterResult < 3) { | |
404 unittest.expect(o.cacheId, unittest.equals('foo')); | |
405 unittest.expect(o.displayLink, unittest.equals('foo')); | |
406 unittest.expect(o.fileFormat, unittest.equals('foo')); | |
407 unittest.expect(o.formattedUrl, unittest.equals('foo')); | |
408 unittest.expect(o.htmlFormattedUrl, unittest.equals('foo')); | |
409 unittest.expect(o.htmlSnippet, unittest.equals('foo')); | |
410 unittest.expect(o.htmlTitle, unittest.equals('foo')); | |
411 checkResultImage(o.image); | |
412 unittest.expect(o.kind, unittest.equals('foo')); | |
413 checkUnnamed291(o.labels); | |
414 unittest.expect(o.link, unittest.equals('foo')); | |
415 unittest.expect(o.mime, unittest.equals('foo')); | |
416 checkUnnamed294(o.pagemap); | |
417 unittest.expect(o.snippet, unittest.equals('foo')); | |
418 unittest.expect(o.title, unittest.equals('foo')); | |
419 } | |
420 buildCounterResult--; | |
421 } | |
422 | |
423 buildUnnamed295() { | |
424 var o = new core.List<api.Result>(); | |
425 o.add(buildResult()); | |
426 o.add(buildResult()); | |
427 return o; | |
428 } | |
429 | |
430 checkUnnamed295(core.List<api.Result> o) { | |
431 unittest.expect(o, unittest.hasLength(2)); | |
432 checkResult(o[0]); | |
433 checkResult(o[1]); | |
434 } | |
435 | |
436 buildUnnamed296() { | |
437 var o = new core.List<api.Promotion>(); | |
438 o.add(buildPromotion()); | |
439 o.add(buildPromotion()); | |
440 return o; | |
441 } | |
442 | |
443 checkUnnamed296(core.List<api.Promotion> o) { | |
444 unittest.expect(o, unittest.hasLength(2)); | |
445 checkPromotion(o[0]); | |
446 checkPromotion(o[1]); | |
447 } | |
448 | |
449 buildUnnamed297() { | |
450 var o = new core.List<api.Query>(); | |
451 o.add(buildQuery()); | |
452 o.add(buildQuery()); | |
453 return o; | |
454 } | |
455 | |
456 checkUnnamed297(core.List<api.Query> o) { | |
457 unittest.expect(o, unittest.hasLength(2)); | |
458 checkQuery(o[0]); | |
459 checkQuery(o[1]); | |
460 } | |
461 | |
462 buildUnnamed298() { | |
463 var o = new core.Map<core.String, core.List<api.Query>>(); | |
464 o["x"] = buildUnnamed297(); | |
465 o["y"] = buildUnnamed297(); | |
466 return o; | |
467 } | |
468 | |
469 checkUnnamed298(core.Map<core.String, core.List<api.Query>> o) { | |
470 unittest.expect(o, unittest.hasLength(2)); | |
471 checkUnnamed297(o["x"]); | |
472 checkUnnamed297(o["y"]); | |
473 } | |
474 | |
475 core.int buildCounterSearchSearchInformation = 0; | |
476 buildSearchSearchInformation() { | |
477 var o = new api.SearchSearchInformation(); | |
478 buildCounterSearchSearchInformation++; | |
479 if (buildCounterSearchSearchInformation < 3) { | |
480 o.formattedSearchTime = "foo"; | |
481 o.formattedTotalResults = "foo"; | |
482 o.searchTime = 42.0; | |
483 o.totalResults = "foo"; | |
484 } | |
485 buildCounterSearchSearchInformation--; | |
486 return o; | |
487 } | |
488 | |
489 checkSearchSearchInformation(api.SearchSearchInformation o) { | |
490 buildCounterSearchSearchInformation++; | |
491 if (buildCounterSearchSearchInformation < 3) { | |
492 unittest.expect(o.formattedSearchTime, unittest.equals('foo')); | |
493 unittest.expect(o.formattedTotalResults, unittest.equals('foo')); | |
494 unittest.expect(o.searchTime, unittest.equals(42.0)); | |
495 unittest.expect(o.totalResults, unittest.equals('foo')); | |
496 } | |
497 buildCounterSearchSearchInformation--; | |
498 } | |
499 | |
500 core.int buildCounterSearchSpelling = 0; | |
501 buildSearchSpelling() { | |
502 var o = new api.SearchSpelling(); | |
503 buildCounterSearchSpelling++; | |
504 if (buildCounterSearchSpelling < 3) { | |
505 o.correctedQuery = "foo"; | |
506 o.htmlCorrectedQuery = "foo"; | |
507 } | |
508 buildCounterSearchSpelling--; | |
509 return o; | |
510 } | |
511 | |
512 checkSearchSpelling(api.SearchSpelling o) { | |
513 buildCounterSearchSpelling++; | |
514 if (buildCounterSearchSpelling < 3) { | |
515 unittest.expect(o.correctedQuery, unittest.equals('foo')); | |
516 unittest.expect(o.htmlCorrectedQuery, unittest.equals('foo')); | |
517 } | |
518 buildCounterSearchSpelling--; | |
519 } | |
520 | |
521 core.int buildCounterSearchUrl = 0; | |
522 buildSearchUrl() { | |
523 var o = new api.SearchUrl(); | |
524 buildCounterSearchUrl++; | |
525 if (buildCounterSearchUrl < 3) { | |
526 o.template = "foo"; | |
527 o.type = "foo"; | |
528 } | |
529 buildCounterSearchUrl--; | |
530 return o; | |
531 } | |
532 | |
533 checkSearchUrl(api.SearchUrl o) { | |
534 buildCounterSearchUrl++; | |
535 if (buildCounterSearchUrl < 3) { | |
536 unittest.expect(o.template, unittest.equals('foo')); | |
537 unittest.expect(o.type, unittest.equals('foo')); | |
538 } | |
539 buildCounterSearchUrl--; | |
540 } | |
541 | |
542 core.int buildCounterSearch = 0; | |
543 buildSearch() { | |
544 var o = new api.Search(); | |
545 buildCounterSearch++; | |
546 if (buildCounterSearch < 3) { | |
547 o.context = buildContext(); | |
548 o.items = buildUnnamed295(); | |
549 o.kind = "foo"; | |
550 o.promotions = buildUnnamed296(); | |
551 o.queries = buildUnnamed298(); | |
552 o.searchInformation = buildSearchSearchInformation(); | |
553 o.spelling = buildSearchSpelling(); | |
554 o.url = buildSearchUrl(); | |
555 } | |
556 buildCounterSearch--; | |
557 return o; | |
558 } | |
559 | |
560 checkSearch(api.Search o) { | |
561 buildCounterSearch++; | |
562 if (buildCounterSearch < 3) { | |
563 checkContext(o.context); | |
564 checkUnnamed295(o.items); | |
565 unittest.expect(o.kind, unittest.equals('foo')); | |
566 checkUnnamed296(o.promotions); | |
567 checkUnnamed298(o.queries); | |
568 checkSearchSearchInformation(o.searchInformation); | |
569 checkSearchSpelling(o.spelling); | |
570 checkSearchUrl(o.url); | |
571 } | |
572 buildCounterSearch--; | |
573 } | |
574 | |
575 | |
576 main() { | |
577 unittest.group("obj-schema-ContextFacets", () { | |
578 unittest.test("to-json--from-json", () { | |
579 var o = buildContextFacets(); | |
580 var od = new api.ContextFacets.fromJson(o.toJson()); | |
581 checkContextFacets(od); | |
582 }); | |
583 }); | |
584 | |
585 | |
586 unittest.group("obj-schema-Context", () { | |
587 unittest.test("to-json--from-json", () { | |
588 var o = buildContext(); | |
589 var od = new api.Context.fromJson(o.toJson()); | |
590 checkContext(od); | |
591 }); | |
592 }); | |
593 | |
594 | |
595 unittest.group("obj-schema-PromotionBodyLines", () { | |
596 unittest.test("to-json--from-json", () { | |
597 var o = buildPromotionBodyLines(); | |
598 var od = new api.PromotionBodyLines.fromJson(o.toJson()); | |
599 checkPromotionBodyLines(od); | |
600 }); | |
601 }); | |
602 | |
603 | |
604 unittest.group("obj-schema-PromotionImage", () { | |
605 unittest.test("to-json--from-json", () { | |
606 var o = buildPromotionImage(); | |
607 var od = new api.PromotionImage.fromJson(o.toJson()); | |
608 checkPromotionImage(od); | |
609 }); | |
610 }); | |
611 | |
612 | |
613 unittest.group("obj-schema-Promotion", () { | |
614 unittest.test("to-json--from-json", () { | |
615 var o = buildPromotion(); | |
616 var od = new api.Promotion.fromJson(o.toJson()); | |
617 checkPromotion(od); | |
618 }); | |
619 }); | |
620 | |
621 | |
622 unittest.group("obj-schema-Query", () { | |
623 unittest.test("to-json--from-json", () { | |
624 var o = buildQuery(); | |
625 var od = new api.Query.fromJson(o.toJson()); | |
626 checkQuery(od); | |
627 }); | |
628 }); | |
629 | |
630 | |
631 unittest.group("obj-schema-ResultImage", () { | |
632 unittest.test("to-json--from-json", () { | |
633 var o = buildResultImage(); | |
634 var od = new api.ResultImage.fromJson(o.toJson()); | |
635 checkResultImage(od); | |
636 }); | |
637 }); | |
638 | |
639 | |
640 unittest.group("obj-schema-ResultLabels", () { | |
641 unittest.test("to-json--from-json", () { | |
642 var o = buildResultLabels(); | |
643 var od = new api.ResultLabels.fromJson(o.toJson()); | |
644 checkResultLabels(od); | |
645 }); | |
646 }); | |
647 | |
648 | |
649 unittest.group("obj-schema-Result", () { | |
650 unittest.test("to-json--from-json", () { | |
651 var o = buildResult(); | |
652 var od = new api.Result.fromJson(o.toJson()); | |
653 checkResult(od); | |
654 }); | |
655 }); | |
656 | |
657 | |
658 unittest.group("obj-schema-SearchSearchInformation", () { | |
659 unittest.test("to-json--from-json", () { | |
660 var o = buildSearchSearchInformation(); | |
661 var od = new api.SearchSearchInformation.fromJson(o.toJson()); | |
662 checkSearchSearchInformation(od); | |
663 }); | |
664 }); | |
665 | |
666 | |
667 unittest.group("obj-schema-SearchSpelling", () { | |
668 unittest.test("to-json--from-json", () { | |
669 var o = buildSearchSpelling(); | |
670 var od = new api.SearchSpelling.fromJson(o.toJson()); | |
671 checkSearchSpelling(od); | |
672 }); | |
673 }); | |
674 | |
675 | |
676 unittest.group("obj-schema-SearchUrl", () { | |
677 unittest.test("to-json--from-json", () { | |
678 var o = buildSearchUrl(); | |
679 var od = new api.SearchUrl.fromJson(o.toJson()); | |
680 checkSearchUrl(od); | |
681 }); | |
682 }); | |
683 | |
684 | |
685 unittest.group("obj-schema-Search", () { | |
686 unittest.test("to-json--from-json", () { | |
687 var o = buildSearch(); | |
688 var od = new api.Search.fromJson(o.toJson()); | |
689 checkSearch(od); | |
690 }); | |
691 }); | |
692 | |
693 | |
694 unittest.group("resource-CseResourceApi", () { | |
695 unittest.test("method--list", () { | |
696 | |
697 var mock = new common_test.HttpServerMock(); | |
698 api.CseResourceApi res = new api.CustomsearchApi(mock).cse; | |
699 var arg_q = "foo"; | |
700 var arg_c2coff = "foo"; | |
701 var arg_cr = "foo"; | |
702 var arg_cref = "foo"; | |
703 var arg_cx = "foo"; | |
704 var arg_dateRestrict = "foo"; | |
705 var arg_exactTerms = "foo"; | |
706 var arg_excludeTerms = "foo"; | |
707 var arg_fileType = "foo"; | |
708 var arg_filter = "foo"; | |
709 var arg_gl = "foo"; | |
710 var arg_googlehost = "foo"; | |
711 var arg_highRange = "foo"; | |
712 var arg_hl = "foo"; | |
713 var arg_hq = "foo"; | |
714 var arg_imgColorType = "foo"; | |
715 var arg_imgDominantColor = "foo"; | |
716 var arg_imgSize = "foo"; | |
717 var arg_imgType = "foo"; | |
718 var arg_linkSite = "foo"; | |
719 var arg_lowRange = "foo"; | |
720 var arg_lr = "foo"; | |
721 var arg_num = 42; | |
722 var arg_orTerms = "foo"; | |
723 var arg_relatedSite = "foo"; | |
724 var arg_rights = "foo"; | |
725 var arg_safe = "foo"; | |
726 var arg_searchType = "foo"; | |
727 var arg_siteSearch = "foo"; | |
728 var arg_siteSearchFilter = "foo"; | |
729 var arg_sort = "foo"; | |
730 var arg_start = 42; | |
731 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
732 var path = (req.url).path; | |
733 var pathOffset = 0; | |
734 var index; | |
735 var subPart; | |
736 unittest.expect(path.substring(pathOffset, pathOffset + 14), unittest.eq
uals("/customsearch/")); | |
737 pathOffset += 14; | |
738 unittest.expect(path.substring(pathOffset, pathOffset + 2), unittest.equ
als("v1")); | |
739 pathOffset += 2; | |
740 | |
741 var query = (req.url).query; | |
742 var queryOffset = 0; | |
743 var queryMap = {}; | |
744 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
745 parseBool(n) { | |
746 if (n == "true") return true; | |
747 if (n == "false") return false; | |
748 if (n == null) return null; | |
749 throw new core.ArgumentError("Invalid boolean: $n"); | |
750 } | |
751 if (query.length > 0) { | |
752 for (var part in query.split("&")) { | |
753 var keyvalue = part.split("="); | |
754 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
755 } | |
756 } | |
757 unittest.expect(queryMap["q"].first, unittest.equals(arg_q)); | |
758 unittest.expect(queryMap["c2coff"].first, unittest.equals(arg_c2coff)); | |
759 unittest.expect(queryMap["cr"].first, unittest.equals(arg_cr)); | |
760 unittest.expect(queryMap["cref"].first, unittest.equals(arg_cref)); | |
761 unittest.expect(queryMap["cx"].first, unittest.equals(arg_cx)); | |
762 unittest.expect(queryMap["dateRestrict"].first, unittest.equals(arg_date
Restrict)); | |
763 unittest.expect(queryMap["exactTerms"].first, unittest.equals(arg_exactT
erms)); | |
764 unittest.expect(queryMap["excludeTerms"].first, unittest.equals(arg_excl
udeTerms)); | |
765 unittest.expect(queryMap["fileType"].first, unittest.equals(arg_fileType
)); | |
766 unittest.expect(queryMap["filter"].first, unittest.equals(arg_filter)); | |
767 unittest.expect(queryMap["gl"].first, unittest.equals(arg_gl)); | |
768 unittest.expect(queryMap["googlehost"].first, unittest.equals(arg_google
host)); | |
769 unittest.expect(queryMap["highRange"].first, unittest.equals(arg_highRan
ge)); | |
770 unittest.expect(queryMap["hl"].first, unittest.equals(arg_hl)); | |
771 unittest.expect(queryMap["hq"].first, unittest.equals(arg_hq)); | |
772 unittest.expect(queryMap["imgColorType"].first, unittest.equals(arg_imgC
olorType)); | |
773 unittest.expect(queryMap["imgDominantColor"].first, unittest.equals(arg_
imgDominantColor)); | |
774 unittest.expect(queryMap["imgSize"].first, unittest.equals(arg_imgSize))
; | |
775 unittest.expect(queryMap["imgType"].first, unittest.equals(arg_imgType))
; | |
776 unittest.expect(queryMap["linkSite"].first, unittest.equals(arg_linkSite
)); | |
777 unittest.expect(queryMap["lowRange"].first, unittest.equals(arg_lowRange
)); | |
778 unittest.expect(queryMap["lr"].first, unittest.equals(arg_lr)); | |
779 unittest.expect(core.int.parse(queryMap["num"].first), unittest.equals(a
rg_num)); | |
780 unittest.expect(queryMap["orTerms"].first, unittest.equals(arg_orTerms))
; | |
781 unittest.expect(queryMap["relatedSite"].first, unittest.equals(arg_relat
edSite)); | |
782 unittest.expect(queryMap["rights"].first, unittest.equals(arg_rights)); | |
783 unittest.expect(queryMap["safe"].first, unittest.equals(arg_safe)); | |
784 unittest.expect(queryMap["searchType"].first, unittest.equals(arg_search
Type)); | |
785 unittest.expect(queryMap["siteSearch"].first, unittest.equals(arg_siteSe
arch)); | |
786 unittest.expect(queryMap["siteSearchFilter"].first, unittest.equals(arg_
siteSearchFilter)); | |
787 unittest.expect(queryMap["sort"].first, unittest.equals(arg_sort)); | |
788 unittest.expect(core.int.parse(queryMap["start"].first), unittest.equals
(arg_start)); | |
789 | |
790 | |
791 var h = { | |
792 "content-type" : "application/json; charset=utf-8", | |
793 }; | |
794 var resp = convert.JSON.encode(buildSearch()); | |
795 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
796 }), true); | |
797 res.list(arg_q, c2coff: arg_c2coff, cr: arg_cr, cref: arg_cref, cx: arg_cx
, dateRestrict: arg_dateRestrict, exactTerms: arg_exactTerms, excludeTerms: arg_
excludeTerms, fileType: arg_fileType, filter: arg_filter, gl: arg_gl, googlehost
: arg_googlehost, highRange: arg_highRange, hl: arg_hl, hq: arg_hq, imgColorType
: arg_imgColorType, imgDominantColor: arg_imgDominantColor, imgSize: arg_imgSize
, imgType: arg_imgType, linkSite: arg_linkSite, lowRange: arg_lowRange, lr: arg_
lr, num: arg_num, orTerms: arg_orTerms, relatedSite: arg_relatedSite, rights: ar
g_rights, safe: arg_safe, searchType: arg_searchType, siteSearch: arg_siteSearch
, siteSearchFilter: arg_siteSearchFilter, sort: arg_sort, start: arg_start).then
(unittest.expectAsync(((api.Search response) { | |
798 checkSearch(response); | |
799 }))); | |
800 }); | |
801 | |
802 }); | |
803 | |
804 | |
805 } | |
806 | |
OLD | NEW |