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

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

Issue 2571553005: Api-roll 43: 2016-12-13 (Closed)
Patch Set: Created 4 years 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.language.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/language/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 buildCounterAnalyzeEntitiesRequest = 0;
55 buildAnalyzeEntitiesRequest() {
56 var o = new api.AnalyzeEntitiesRequest();
57 buildCounterAnalyzeEntitiesRequest++;
58 if (buildCounterAnalyzeEntitiesRequest < 3) {
59 o.document = buildDocument();
60 o.encodingType = "foo";
61 }
62 buildCounterAnalyzeEntitiesRequest--;
63 return o;
64 }
65
66 checkAnalyzeEntitiesRequest(api.AnalyzeEntitiesRequest o) {
67 buildCounterAnalyzeEntitiesRequest++;
68 if (buildCounterAnalyzeEntitiesRequest < 3) {
69 checkDocument(o.document);
70 unittest.expect(o.encodingType, unittest.equals('foo'));
71 }
72 buildCounterAnalyzeEntitiesRequest--;
73 }
74
75 buildUnnamed738() {
76 var o = new core.List<api.Entity>();
77 o.add(buildEntity());
78 o.add(buildEntity());
79 return o;
80 }
81
82 checkUnnamed738(core.List<api.Entity> o) {
83 unittest.expect(o, unittest.hasLength(2));
84 checkEntity(o[0]);
85 checkEntity(o[1]);
86 }
87
88 core.int buildCounterAnalyzeEntitiesResponse = 0;
89 buildAnalyzeEntitiesResponse() {
90 var o = new api.AnalyzeEntitiesResponse();
91 buildCounterAnalyzeEntitiesResponse++;
92 if (buildCounterAnalyzeEntitiesResponse < 3) {
93 o.entities = buildUnnamed738();
94 o.language = "foo";
95 }
96 buildCounterAnalyzeEntitiesResponse--;
97 return o;
98 }
99
100 checkAnalyzeEntitiesResponse(api.AnalyzeEntitiesResponse o) {
101 buildCounterAnalyzeEntitiesResponse++;
102 if (buildCounterAnalyzeEntitiesResponse < 3) {
103 checkUnnamed738(o.entities);
104 unittest.expect(o.language, unittest.equals('foo'));
105 }
106 buildCounterAnalyzeEntitiesResponse--;
107 }
108
109 core.int buildCounterAnalyzeSentimentRequest = 0;
110 buildAnalyzeSentimentRequest() {
111 var o = new api.AnalyzeSentimentRequest();
112 buildCounterAnalyzeSentimentRequest++;
113 if (buildCounterAnalyzeSentimentRequest < 3) {
114 o.document = buildDocument();
115 o.encodingType = "foo";
116 }
117 buildCounterAnalyzeSentimentRequest--;
118 return o;
119 }
120
121 checkAnalyzeSentimentRequest(api.AnalyzeSentimentRequest o) {
122 buildCounterAnalyzeSentimentRequest++;
123 if (buildCounterAnalyzeSentimentRequest < 3) {
124 checkDocument(o.document);
125 unittest.expect(o.encodingType, unittest.equals('foo'));
126 }
127 buildCounterAnalyzeSentimentRequest--;
128 }
129
130 buildUnnamed739() {
131 var o = new core.List<api.Sentence>();
132 o.add(buildSentence());
133 o.add(buildSentence());
134 return o;
135 }
136
137 checkUnnamed739(core.List<api.Sentence> o) {
138 unittest.expect(o, unittest.hasLength(2));
139 checkSentence(o[0]);
140 checkSentence(o[1]);
141 }
142
143 core.int buildCounterAnalyzeSentimentResponse = 0;
144 buildAnalyzeSentimentResponse() {
145 var o = new api.AnalyzeSentimentResponse();
146 buildCounterAnalyzeSentimentResponse++;
147 if (buildCounterAnalyzeSentimentResponse < 3) {
148 o.documentSentiment = buildSentiment();
149 o.language = "foo";
150 o.sentences = buildUnnamed739();
151 }
152 buildCounterAnalyzeSentimentResponse--;
153 return o;
154 }
155
156 checkAnalyzeSentimentResponse(api.AnalyzeSentimentResponse o) {
157 buildCounterAnalyzeSentimentResponse++;
158 if (buildCounterAnalyzeSentimentResponse < 3) {
159 checkSentiment(o.documentSentiment);
160 unittest.expect(o.language, unittest.equals('foo'));
161 checkUnnamed739(o.sentences);
162 }
163 buildCounterAnalyzeSentimentResponse--;
164 }
165
166 core.int buildCounterAnalyzeSyntaxRequest = 0;
167 buildAnalyzeSyntaxRequest() {
168 var o = new api.AnalyzeSyntaxRequest();
169 buildCounterAnalyzeSyntaxRequest++;
170 if (buildCounterAnalyzeSyntaxRequest < 3) {
171 o.document = buildDocument();
172 o.encodingType = "foo";
173 }
174 buildCounterAnalyzeSyntaxRequest--;
175 return o;
176 }
177
178 checkAnalyzeSyntaxRequest(api.AnalyzeSyntaxRequest o) {
179 buildCounterAnalyzeSyntaxRequest++;
180 if (buildCounterAnalyzeSyntaxRequest < 3) {
181 checkDocument(o.document);
182 unittest.expect(o.encodingType, unittest.equals('foo'));
183 }
184 buildCounterAnalyzeSyntaxRequest--;
185 }
186
187 buildUnnamed740() {
188 var o = new core.List<api.Sentence>();
189 o.add(buildSentence());
190 o.add(buildSentence());
191 return o;
192 }
193
194 checkUnnamed740(core.List<api.Sentence> o) {
195 unittest.expect(o, unittest.hasLength(2));
196 checkSentence(o[0]);
197 checkSentence(o[1]);
198 }
199
200 buildUnnamed741() {
201 var o = new core.List<api.Token>();
202 o.add(buildToken());
203 o.add(buildToken());
204 return o;
205 }
206
207 checkUnnamed741(core.List<api.Token> o) {
208 unittest.expect(o, unittest.hasLength(2));
209 checkToken(o[0]);
210 checkToken(o[1]);
211 }
212
213 core.int buildCounterAnalyzeSyntaxResponse = 0;
214 buildAnalyzeSyntaxResponse() {
215 var o = new api.AnalyzeSyntaxResponse();
216 buildCounterAnalyzeSyntaxResponse++;
217 if (buildCounterAnalyzeSyntaxResponse < 3) {
218 o.language = "foo";
219 o.sentences = buildUnnamed740();
220 o.tokens = buildUnnamed741();
221 }
222 buildCounterAnalyzeSyntaxResponse--;
223 return o;
224 }
225
226 checkAnalyzeSyntaxResponse(api.AnalyzeSyntaxResponse o) {
227 buildCounterAnalyzeSyntaxResponse++;
228 if (buildCounterAnalyzeSyntaxResponse < 3) {
229 unittest.expect(o.language, unittest.equals('foo'));
230 checkUnnamed740(o.sentences);
231 checkUnnamed741(o.tokens);
232 }
233 buildCounterAnalyzeSyntaxResponse--;
234 }
235
236 core.int buildCounterAnnotateTextRequest = 0;
237 buildAnnotateTextRequest() {
238 var o = new api.AnnotateTextRequest();
239 buildCounterAnnotateTextRequest++;
240 if (buildCounterAnnotateTextRequest < 3) {
241 o.document = buildDocument();
242 o.encodingType = "foo";
243 o.features = buildFeatures();
244 }
245 buildCounterAnnotateTextRequest--;
246 return o;
247 }
248
249 checkAnnotateTextRequest(api.AnnotateTextRequest o) {
250 buildCounterAnnotateTextRequest++;
251 if (buildCounterAnnotateTextRequest < 3) {
252 checkDocument(o.document);
253 unittest.expect(o.encodingType, unittest.equals('foo'));
254 checkFeatures(o.features);
255 }
256 buildCounterAnnotateTextRequest--;
257 }
258
259 buildUnnamed742() {
260 var o = new core.List<api.Entity>();
261 o.add(buildEntity());
262 o.add(buildEntity());
263 return o;
264 }
265
266 checkUnnamed742(core.List<api.Entity> o) {
267 unittest.expect(o, unittest.hasLength(2));
268 checkEntity(o[0]);
269 checkEntity(o[1]);
270 }
271
272 buildUnnamed743() {
273 var o = new core.List<api.Sentence>();
274 o.add(buildSentence());
275 o.add(buildSentence());
276 return o;
277 }
278
279 checkUnnamed743(core.List<api.Sentence> o) {
280 unittest.expect(o, unittest.hasLength(2));
281 checkSentence(o[0]);
282 checkSentence(o[1]);
283 }
284
285 buildUnnamed744() {
286 var o = new core.List<api.Token>();
287 o.add(buildToken());
288 o.add(buildToken());
289 return o;
290 }
291
292 checkUnnamed744(core.List<api.Token> o) {
293 unittest.expect(o, unittest.hasLength(2));
294 checkToken(o[0]);
295 checkToken(o[1]);
296 }
297
298 core.int buildCounterAnnotateTextResponse = 0;
299 buildAnnotateTextResponse() {
300 var o = new api.AnnotateTextResponse();
301 buildCounterAnnotateTextResponse++;
302 if (buildCounterAnnotateTextResponse < 3) {
303 o.documentSentiment = buildSentiment();
304 o.entities = buildUnnamed742();
305 o.language = "foo";
306 o.sentences = buildUnnamed743();
307 o.tokens = buildUnnamed744();
308 }
309 buildCounterAnnotateTextResponse--;
310 return o;
311 }
312
313 checkAnnotateTextResponse(api.AnnotateTextResponse o) {
314 buildCounterAnnotateTextResponse++;
315 if (buildCounterAnnotateTextResponse < 3) {
316 checkSentiment(o.documentSentiment);
317 checkUnnamed742(o.entities);
318 unittest.expect(o.language, unittest.equals('foo'));
319 checkUnnamed743(o.sentences);
320 checkUnnamed744(o.tokens);
321 }
322 buildCounterAnnotateTextResponse--;
323 }
324
325 core.int buildCounterDependencyEdge = 0;
326 buildDependencyEdge() {
327 var o = new api.DependencyEdge();
328 buildCounterDependencyEdge++;
329 if (buildCounterDependencyEdge < 3) {
330 o.headTokenIndex = 42;
331 o.label = "foo";
332 }
333 buildCounterDependencyEdge--;
334 return o;
335 }
336
337 checkDependencyEdge(api.DependencyEdge o) {
338 buildCounterDependencyEdge++;
339 if (buildCounterDependencyEdge < 3) {
340 unittest.expect(o.headTokenIndex, unittest.equals(42));
341 unittest.expect(o.label, unittest.equals('foo'));
342 }
343 buildCounterDependencyEdge--;
344 }
345
346 core.int buildCounterDocument = 0;
347 buildDocument() {
348 var o = new api.Document();
349 buildCounterDocument++;
350 if (buildCounterDocument < 3) {
351 o.content = "foo";
352 o.gcsContentUri = "foo";
353 o.language = "foo";
354 o.type = "foo";
355 }
356 buildCounterDocument--;
357 return o;
358 }
359
360 checkDocument(api.Document o) {
361 buildCounterDocument++;
362 if (buildCounterDocument < 3) {
363 unittest.expect(o.content, unittest.equals('foo'));
364 unittest.expect(o.gcsContentUri, unittest.equals('foo'));
365 unittest.expect(o.language, unittest.equals('foo'));
366 unittest.expect(o.type, unittest.equals('foo'));
367 }
368 buildCounterDocument--;
369 }
370
371 buildUnnamed745() {
372 var o = new core.List<api.EntityMention>();
373 o.add(buildEntityMention());
374 o.add(buildEntityMention());
375 return o;
376 }
377
378 checkUnnamed745(core.List<api.EntityMention> o) {
379 unittest.expect(o, unittest.hasLength(2));
380 checkEntityMention(o[0]);
381 checkEntityMention(o[1]);
382 }
383
384 buildUnnamed746() {
385 var o = new core.Map<core.String, core.String>();
386 o["x"] = "foo";
387 o["y"] = "foo";
388 return o;
389 }
390
391 checkUnnamed746(core.Map<core.String, core.String> o) {
392 unittest.expect(o, unittest.hasLength(2));
393 unittest.expect(o["x"], unittest.equals('foo'));
394 unittest.expect(o["y"], unittest.equals('foo'));
395 }
396
397 core.int buildCounterEntity = 0;
398 buildEntity() {
399 var o = new api.Entity();
400 buildCounterEntity++;
401 if (buildCounterEntity < 3) {
402 o.mentions = buildUnnamed745();
403 o.metadata = buildUnnamed746();
404 o.name = "foo";
405 o.salience = 42.0;
406 o.type = "foo";
407 }
408 buildCounterEntity--;
409 return o;
410 }
411
412 checkEntity(api.Entity o) {
413 buildCounterEntity++;
414 if (buildCounterEntity < 3) {
415 checkUnnamed745(o.mentions);
416 checkUnnamed746(o.metadata);
417 unittest.expect(o.name, unittest.equals('foo'));
418 unittest.expect(o.salience, unittest.equals(42.0));
419 unittest.expect(o.type, unittest.equals('foo'));
420 }
421 buildCounterEntity--;
422 }
423
424 core.int buildCounterEntityMention = 0;
425 buildEntityMention() {
426 var o = new api.EntityMention();
427 buildCounterEntityMention++;
428 if (buildCounterEntityMention < 3) {
429 o.text = buildTextSpan();
430 o.type = "foo";
431 }
432 buildCounterEntityMention--;
433 return o;
434 }
435
436 checkEntityMention(api.EntityMention o) {
437 buildCounterEntityMention++;
438 if (buildCounterEntityMention < 3) {
439 checkTextSpan(o.text);
440 unittest.expect(o.type, unittest.equals('foo'));
441 }
442 buildCounterEntityMention--;
443 }
444
445 core.int buildCounterFeatures = 0;
446 buildFeatures() {
447 var o = new api.Features();
448 buildCounterFeatures++;
449 if (buildCounterFeatures < 3) {
450 o.extractDocumentSentiment = true;
451 o.extractEntities = true;
452 o.extractSyntax = true;
453 }
454 buildCounterFeatures--;
455 return o;
456 }
457
458 checkFeatures(api.Features o) {
459 buildCounterFeatures++;
460 if (buildCounterFeatures < 3) {
461 unittest.expect(o.extractDocumentSentiment, unittest.isTrue);
462 unittest.expect(o.extractEntities, unittest.isTrue);
463 unittest.expect(o.extractSyntax, unittest.isTrue);
464 }
465 buildCounterFeatures--;
466 }
467
468 core.int buildCounterPartOfSpeech = 0;
469 buildPartOfSpeech() {
470 var o = new api.PartOfSpeech();
471 buildCounterPartOfSpeech++;
472 if (buildCounterPartOfSpeech < 3) {
473 o.aspect = "foo";
474 o.case_ = "foo";
475 o.form = "foo";
476 o.gender = "foo";
477 o.mood = "foo";
478 o.number = "foo";
479 o.person = "foo";
480 o.proper = "foo";
481 o.reciprocity = "foo";
482 o.tag = "foo";
483 o.tense = "foo";
484 o.voice = "foo";
485 }
486 buildCounterPartOfSpeech--;
487 return o;
488 }
489
490 checkPartOfSpeech(api.PartOfSpeech o) {
491 buildCounterPartOfSpeech++;
492 if (buildCounterPartOfSpeech < 3) {
493 unittest.expect(o.aspect, unittest.equals('foo'));
494 unittest.expect(o.case_, unittest.equals('foo'));
495 unittest.expect(o.form, unittest.equals('foo'));
496 unittest.expect(o.gender, unittest.equals('foo'));
497 unittest.expect(o.mood, unittest.equals('foo'));
498 unittest.expect(o.number, unittest.equals('foo'));
499 unittest.expect(o.person, unittest.equals('foo'));
500 unittest.expect(o.proper, unittest.equals('foo'));
501 unittest.expect(o.reciprocity, unittest.equals('foo'));
502 unittest.expect(o.tag, unittest.equals('foo'));
503 unittest.expect(o.tense, unittest.equals('foo'));
504 unittest.expect(o.voice, unittest.equals('foo'));
505 }
506 buildCounterPartOfSpeech--;
507 }
508
509 core.int buildCounterSentence = 0;
510 buildSentence() {
511 var o = new api.Sentence();
512 buildCounterSentence++;
513 if (buildCounterSentence < 3) {
514 o.sentiment = buildSentiment();
515 o.text = buildTextSpan();
516 }
517 buildCounterSentence--;
518 return o;
519 }
520
521 checkSentence(api.Sentence o) {
522 buildCounterSentence++;
523 if (buildCounterSentence < 3) {
524 checkSentiment(o.sentiment);
525 checkTextSpan(o.text);
526 }
527 buildCounterSentence--;
528 }
529
530 core.int buildCounterSentiment = 0;
531 buildSentiment() {
532 var o = new api.Sentiment();
533 buildCounterSentiment++;
534 if (buildCounterSentiment < 3) {
535 o.magnitude = 42.0;
536 o.score = 42.0;
537 }
538 buildCounterSentiment--;
539 return o;
540 }
541
542 checkSentiment(api.Sentiment o) {
543 buildCounterSentiment++;
544 if (buildCounterSentiment < 3) {
545 unittest.expect(o.magnitude, unittest.equals(42.0));
546 unittest.expect(o.score, unittest.equals(42.0));
547 }
548 buildCounterSentiment--;
549 }
550
551 buildUnnamed747() {
552 var o = new core.Map<core.String, core.Object>();
553 o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'};
554 o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'};
555 return o;
556 }
557
558 checkUnnamed747(core.Map<core.String, core.Object> o) {
559 unittest.expect(o, unittest.hasLength(2));
560 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'));
561 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'));
562 }
563
564 buildUnnamed748() {
565 var o = new core.List<core.Map<core.String, core.Object>>();
566 o.add(buildUnnamed747());
567 o.add(buildUnnamed747());
568 return o;
569 }
570
571 checkUnnamed748(core.List<core.Map<core.String, core.Object>> o) {
572 unittest.expect(o, unittest.hasLength(2));
573 checkUnnamed747(o[0]);
574 checkUnnamed747(o[1]);
575 }
576
577 core.int buildCounterStatus = 0;
578 buildStatus() {
579 var o = new api.Status();
580 buildCounterStatus++;
581 if (buildCounterStatus < 3) {
582 o.code = 42;
583 o.details = buildUnnamed748();
584 o.message = "foo";
585 }
586 buildCounterStatus--;
587 return o;
588 }
589
590 checkStatus(api.Status o) {
591 buildCounterStatus++;
592 if (buildCounterStatus < 3) {
593 unittest.expect(o.code, unittest.equals(42));
594 checkUnnamed748(o.details);
595 unittest.expect(o.message, unittest.equals('foo'));
596 }
597 buildCounterStatus--;
598 }
599
600 core.int buildCounterTextSpan = 0;
601 buildTextSpan() {
602 var o = new api.TextSpan();
603 buildCounterTextSpan++;
604 if (buildCounterTextSpan < 3) {
605 o.beginOffset = 42;
606 o.content = "foo";
607 }
608 buildCounterTextSpan--;
609 return o;
610 }
611
612 checkTextSpan(api.TextSpan o) {
613 buildCounterTextSpan++;
614 if (buildCounterTextSpan < 3) {
615 unittest.expect(o.beginOffset, unittest.equals(42));
616 unittest.expect(o.content, unittest.equals('foo'));
617 }
618 buildCounterTextSpan--;
619 }
620
621 core.int buildCounterToken = 0;
622 buildToken() {
623 var o = new api.Token();
624 buildCounterToken++;
625 if (buildCounterToken < 3) {
626 o.dependencyEdge = buildDependencyEdge();
627 o.lemma = "foo";
628 o.partOfSpeech = buildPartOfSpeech();
629 o.text = buildTextSpan();
630 }
631 buildCounterToken--;
632 return o;
633 }
634
635 checkToken(api.Token o) {
636 buildCounterToken++;
637 if (buildCounterToken < 3) {
638 checkDependencyEdge(o.dependencyEdge);
639 unittest.expect(o.lemma, unittest.equals('foo'));
640 checkPartOfSpeech(o.partOfSpeech);
641 checkTextSpan(o.text);
642 }
643 buildCounterToken--;
644 }
645
646
647 main() {
648 unittest.group("obj-schema-AnalyzeEntitiesRequest", () {
649 unittest.test("to-json--from-json", () {
650 var o = buildAnalyzeEntitiesRequest();
651 var od = new api.AnalyzeEntitiesRequest.fromJson(o.toJson());
652 checkAnalyzeEntitiesRequest(od);
653 });
654 });
655
656
657 unittest.group("obj-schema-AnalyzeEntitiesResponse", () {
658 unittest.test("to-json--from-json", () {
659 var o = buildAnalyzeEntitiesResponse();
660 var od = new api.AnalyzeEntitiesResponse.fromJson(o.toJson());
661 checkAnalyzeEntitiesResponse(od);
662 });
663 });
664
665
666 unittest.group("obj-schema-AnalyzeSentimentRequest", () {
667 unittest.test("to-json--from-json", () {
668 var o = buildAnalyzeSentimentRequest();
669 var od = new api.AnalyzeSentimentRequest.fromJson(o.toJson());
670 checkAnalyzeSentimentRequest(od);
671 });
672 });
673
674
675 unittest.group("obj-schema-AnalyzeSentimentResponse", () {
676 unittest.test("to-json--from-json", () {
677 var o = buildAnalyzeSentimentResponse();
678 var od = new api.AnalyzeSentimentResponse.fromJson(o.toJson());
679 checkAnalyzeSentimentResponse(od);
680 });
681 });
682
683
684 unittest.group("obj-schema-AnalyzeSyntaxRequest", () {
685 unittest.test("to-json--from-json", () {
686 var o = buildAnalyzeSyntaxRequest();
687 var od = new api.AnalyzeSyntaxRequest.fromJson(o.toJson());
688 checkAnalyzeSyntaxRequest(od);
689 });
690 });
691
692
693 unittest.group("obj-schema-AnalyzeSyntaxResponse", () {
694 unittest.test("to-json--from-json", () {
695 var o = buildAnalyzeSyntaxResponse();
696 var od = new api.AnalyzeSyntaxResponse.fromJson(o.toJson());
697 checkAnalyzeSyntaxResponse(od);
698 });
699 });
700
701
702 unittest.group("obj-schema-AnnotateTextRequest", () {
703 unittest.test("to-json--from-json", () {
704 var o = buildAnnotateTextRequest();
705 var od = new api.AnnotateTextRequest.fromJson(o.toJson());
706 checkAnnotateTextRequest(od);
707 });
708 });
709
710
711 unittest.group("obj-schema-AnnotateTextResponse", () {
712 unittest.test("to-json--from-json", () {
713 var o = buildAnnotateTextResponse();
714 var od = new api.AnnotateTextResponse.fromJson(o.toJson());
715 checkAnnotateTextResponse(od);
716 });
717 });
718
719
720 unittest.group("obj-schema-DependencyEdge", () {
721 unittest.test("to-json--from-json", () {
722 var o = buildDependencyEdge();
723 var od = new api.DependencyEdge.fromJson(o.toJson());
724 checkDependencyEdge(od);
725 });
726 });
727
728
729 unittest.group("obj-schema-Document", () {
730 unittest.test("to-json--from-json", () {
731 var o = buildDocument();
732 var od = new api.Document.fromJson(o.toJson());
733 checkDocument(od);
734 });
735 });
736
737
738 unittest.group("obj-schema-Entity", () {
739 unittest.test("to-json--from-json", () {
740 var o = buildEntity();
741 var od = new api.Entity.fromJson(o.toJson());
742 checkEntity(od);
743 });
744 });
745
746
747 unittest.group("obj-schema-EntityMention", () {
748 unittest.test("to-json--from-json", () {
749 var o = buildEntityMention();
750 var od = new api.EntityMention.fromJson(o.toJson());
751 checkEntityMention(od);
752 });
753 });
754
755
756 unittest.group("obj-schema-Features", () {
757 unittest.test("to-json--from-json", () {
758 var o = buildFeatures();
759 var od = new api.Features.fromJson(o.toJson());
760 checkFeatures(od);
761 });
762 });
763
764
765 unittest.group("obj-schema-PartOfSpeech", () {
766 unittest.test("to-json--from-json", () {
767 var o = buildPartOfSpeech();
768 var od = new api.PartOfSpeech.fromJson(o.toJson());
769 checkPartOfSpeech(od);
770 });
771 });
772
773
774 unittest.group("obj-schema-Sentence", () {
775 unittest.test("to-json--from-json", () {
776 var o = buildSentence();
777 var od = new api.Sentence.fromJson(o.toJson());
778 checkSentence(od);
779 });
780 });
781
782
783 unittest.group("obj-schema-Sentiment", () {
784 unittest.test("to-json--from-json", () {
785 var o = buildSentiment();
786 var od = new api.Sentiment.fromJson(o.toJson());
787 checkSentiment(od);
788 });
789 });
790
791
792 unittest.group("obj-schema-Status", () {
793 unittest.test("to-json--from-json", () {
794 var o = buildStatus();
795 var od = new api.Status.fromJson(o.toJson());
796 checkStatus(od);
797 });
798 });
799
800
801 unittest.group("obj-schema-TextSpan", () {
802 unittest.test("to-json--from-json", () {
803 var o = buildTextSpan();
804 var od = new api.TextSpan.fromJson(o.toJson());
805 checkTextSpan(od);
806 });
807 });
808
809
810 unittest.group("obj-schema-Token", () {
811 unittest.test("to-json--from-json", () {
812 var o = buildToken();
813 var od = new api.Token.fromJson(o.toJson());
814 checkToken(od);
815 });
816 });
817
818
819 unittest.group("resource-DocumentsResourceApi", () {
820 unittest.test("method--analyzeEntities", () {
821
822 var mock = new HttpServerMock();
823 api.DocumentsResourceApi res = new api.LanguageApi(mock).documents;
824 var arg_request = buildAnalyzeEntitiesRequest();
825 mock.register(unittest.expectAsync((http.BaseRequest req, json) {
826 var obj = new api.AnalyzeEntitiesRequest.fromJson(json);
827 checkAnalyzeEntitiesRequest(obj);
828
829 var path = (req.url).path;
830 var pathOffset = 0;
831 var index;
832 var subPart;
833 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ als("/"));
834 pathOffset += 1;
835 unittest.expect(path.substring(pathOffset, pathOffset + 28), unittest.eq uals("v1/documents:analyzeEntities"));
836 pathOffset += 28;
837
838 var query = (req.url).query;
839 var queryOffset = 0;
840 var queryMap = {};
841 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
842 parseBool(n) {
843 if (n == "true") return true;
844 if (n == "false") return false;
845 if (n == null) return null;
846 throw new core.ArgumentError("Invalid boolean: $n");
847 }
848 if (query.length > 0) {
849 for (var part in query.split("&")) {
850 var keyvalue = part.split("=");
851 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
852 }
853 }
854
855
856 var h = {
857 "content-type" : "application/json; charset=utf-8",
858 };
859 var resp = convert.JSON.encode(buildAnalyzeEntitiesResponse());
860 return new async.Future.value(stringResponse(200, h, resp));
861 }), true);
862 res.analyzeEntities(arg_request).then(unittest.expectAsync(((api.AnalyzeEn titiesResponse response) {
863 checkAnalyzeEntitiesResponse(response);
864 })));
865 });
866
867 unittest.test("method--analyzeSentiment", () {
868
869 var mock = new HttpServerMock();
870 api.DocumentsResourceApi res = new api.LanguageApi(mock).documents;
871 var arg_request = buildAnalyzeSentimentRequest();
872 mock.register(unittest.expectAsync((http.BaseRequest req, json) {
873 var obj = new api.AnalyzeSentimentRequest.fromJson(json);
874 checkAnalyzeSentimentRequest(obj);
875
876 var path = (req.url).path;
877 var pathOffset = 0;
878 var index;
879 var subPart;
880 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ als("/"));
881 pathOffset += 1;
882 unittest.expect(path.substring(pathOffset, pathOffset + 29), unittest.eq uals("v1/documents:analyzeSentiment"));
883 pathOffset += 29;
884
885 var query = (req.url).query;
886 var queryOffset = 0;
887 var queryMap = {};
888 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
889 parseBool(n) {
890 if (n == "true") return true;
891 if (n == "false") return false;
892 if (n == null) return null;
893 throw new core.ArgumentError("Invalid boolean: $n");
894 }
895 if (query.length > 0) {
896 for (var part in query.split("&")) {
897 var keyvalue = part.split("=");
898 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
899 }
900 }
901
902
903 var h = {
904 "content-type" : "application/json; charset=utf-8",
905 };
906 var resp = convert.JSON.encode(buildAnalyzeSentimentResponse());
907 return new async.Future.value(stringResponse(200, h, resp));
908 }), true);
909 res.analyzeSentiment(arg_request).then(unittest.expectAsync(((api.AnalyzeS entimentResponse response) {
910 checkAnalyzeSentimentResponse(response);
911 })));
912 });
913
914 unittest.test("method--analyzeSyntax", () {
915
916 var mock = new HttpServerMock();
917 api.DocumentsResourceApi res = new api.LanguageApi(mock).documents;
918 var arg_request = buildAnalyzeSyntaxRequest();
919 mock.register(unittest.expectAsync((http.BaseRequest req, json) {
920 var obj = new api.AnalyzeSyntaxRequest.fromJson(json);
921 checkAnalyzeSyntaxRequest(obj);
922
923 var path = (req.url).path;
924 var pathOffset = 0;
925 var index;
926 var subPart;
927 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ als("/"));
928 pathOffset += 1;
929 unittest.expect(path.substring(pathOffset, pathOffset + 26), unittest.eq uals("v1/documents:analyzeSyntax"));
930 pathOffset += 26;
931
932 var query = (req.url).query;
933 var queryOffset = 0;
934 var queryMap = {};
935 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
936 parseBool(n) {
937 if (n == "true") return true;
938 if (n == "false") return false;
939 if (n == null) return null;
940 throw new core.ArgumentError("Invalid boolean: $n");
941 }
942 if (query.length > 0) {
943 for (var part in query.split("&")) {
944 var keyvalue = part.split("=");
945 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
946 }
947 }
948
949
950 var h = {
951 "content-type" : "application/json; charset=utf-8",
952 };
953 var resp = convert.JSON.encode(buildAnalyzeSyntaxResponse());
954 return new async.Future.value(stringResponse(200, h, resp));
955 }), true);
956 res.analyzeSyntax(arg_request).then(unittest.expectAsync(((api.AnalyzeSynt axResponse response) {
957 checkAnalyzeSyntaxResponse(response);
958 })));
959 });
960
961 unittest.test("method--annotateText", () {
962
963 var mock = new HttpServerMock();
964 api.DocumentsResourceApi res = new api.LanguageApi(mock).documents;
965 var arg_request = buildAnnotateTextRequest();
966 mock.register(unittest.expectAsync((http.BaseRequest req, json) {
967 var obj = new api.AnnotateTextRequest.fromJson(json);
968 checkAnnotateTextRequest(obj);
969
970 var path = (req.url).path;
971 var pathOffset = 0;
972 var index;
973 var subPart;
974 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ als("/"));
975 pathOffset += 1;
976 unittest.expect(path.substring(pathOffset, pathOffset + 25), unittest.eq uals("v1/documents:annotateText"));
977 pathOffset += 25;
978
979 var query = (req.url).query;
980 var queryOffset = 0;
981 var queryMap = {};
982 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
983 parseBool(n) {
984 if (n == "true") return true;
985 if (n == "false") return false;
986 if (n == null) return null;
987 throw new core.ArgumentError("Invalid boolean: $n");
988 }
989 if (query.length > 0) {
990 for (var part in query.split("&")) {
991 var keyvalue = part.split("=");
992 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
993 }
994 }
995
996
997 var h = {
998 "content-type" : "application/json; charset=utf-8",
999 };
1000 var resp = convert.JSON.encode(buildAnnotateTextResponse());
1001 return new async.Future.value(stringResponse(200, h, resp));
1002 }), true);
1003 res.annotateText(arg_request).then(unittest.expectAsync(((api.AnnotateText Response response) {
1004 checkAnnotateTextResponse(response);
1005 })));
1006 });
1007
1008 });
1009
1010
1011 }
1012
OLDNEW
« no previous file with comments | « generated/googleapis/test/kgsearch/v1_test.dart ('k') | generated/googleapis/test/licensing/v1_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698