| OLD | NEW |
| (Empty) | |
| 1 library googleapis_beta.language.v1beta1.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_beta/language/v1beta1.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 buildUnnamed4023() { |
| 76 var o = new core.List<api.Entity>(); |
| 77 o.add(buildEntity()); |
| 78 o.add(buildEntity()); |
| 79 return o; |
| 80 } |
| 81 |
| 82 checkUnnamed4023(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 = buildUnnamed4023(); |
| 94 o.language = "foo"; |
| 95 } |
| 96 buildCounterAnalyzeEntitiesResponse--; |
| 97 return o; |
| 98 } |
| 99 |
| 100 checkAnalyzeEntitiesResponse(api.AnalyzeEntitiesResponse o) { |
| 101 buildCounterAnalyzeEntitiesResponse++; |
| 102 if (buildCounterAnalyzeEntitiesResponse < 3) { |
| 103 checkUnnamed4023(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 } |
| 116 buildCounterAnalyzeSentimentRequest--; |
| 117 return o; |
| 118 } |
| 119 |
| 120 checkAnalyzeSentimentRequest(api.AnalyzeSentimentRequest o) { |
| 121 buildCounterAnalyzeSentimentRequest++; |
| 122 if (buildCounterAnalyzeSentimentRequest < 3) { |
| 123 checkDocument(o.document); |
| 124 } |
| 125 buildCounterAnalyzeSentimentRequest--; |
| 126 } |
| 127 |
| 128 core.int buildCounterAnalyzeSentimentResponse = 0; |
| 129 buildAnalyzeSentimentResponse() { |
| 130 var o = new api.AnalyzeSentimentResponse(); |
| 131 buildCounterAnalyzeSentimentResponse++; |
| 132 if (buildCounterAnalyzeSentimentResponse < 3) { |
| 133 o.documentSentiment = buildSentiment(); |
| 134 o.language = "foo"; |
| 135 } |
| 136 buildCounterAnalyzeSentimentResponse--; |
| 137 return o; |
| 138 } |
| 139 |
| 140 checkAnalyzeSentimentResponse(api.AnalyzeSentimentResponse o) { |
| 141 buildCounterAnalyzeSentimentResponse++; |
| 142 if (buildCounterAnalyzeSentimentResponse < 3) { |
| 143 checkSentiment(o.documentSentiment); |
| 144 unittest.expect(o.language, unittest.equals('foo')); |
| 145 } |
| 146 buildCounterAnalyzeSentimentResponse--; |
| 147 } |
| 148 |
| 149 core.int buildCounterAnnotateTextRequest = 0; |
| 150 buildAnnotateTextRequest() { |
| 151 var o = new api.AnnotateTextRequest(); |
| 152 buildCounterAnnotateTextRequest++; |
| 153 if (buildCounterAnnotateTextRequest < 3) { |
| 154 o.document = buildDocument(); |
| 155 o.encodingType = "foo"; |
| 156 o.features = buildFeatures(); |
| 157 } |
| 158 buildCounterAnnotateTextRequest--; |
| 159 return o; |
| 160 } |
| 161 |
| 162 checkAnnotateTextRequest(api.AnnotateTextRequest o) { |
| 163 buildCounterAnnotateTextRequest++; |
| 164 if (buildCounterAnnotateTextRequest < 3) { |
| 165 checkDocument(o.document); |
| 166 unittest.expect(o.encodingType, unittest.equals('foo')); |
| 167 checkFeatures(o.features); |
| 168 } |
| 169 buildCounterAnnotateTextRequest--; |
| 170 } |
| 171 |
| 172 buildUnnamed4024() { |
| 173 var o = new core.List<api.Entity>(); |
| 174 o.add(buildEntity()); |
| 175 o.add(buildEntity()); |
| 176 return o; |
| 177 } |
| 178 |
| 179 checkUnnamed4024(core.List<api.Entity> o) { |
| 180 unittest.expect(o, unittest.hasLength(2)); |
| 181 checkEntity(o[0]); |
| 182 checkEntity(o[1]); |
| 183 } |
| 184 |
| 185 buildUnnamed4025() { |
| 186 var o = new core.List<api.Sentence>(); |
| 187 o.add(buildSentence()); |
| 188 o.add(buildSentence()); |
| 189 return o; |
| 190 } |
| 191 |
| 192 checkUnnamed4025(core.List<api.Sentence> o) { |
| 193 unittest.expect(o, unittest.hasLength(2)); |
| 194 checkSentence(o[0]); |
| 195 checkSentence(o[1]); |
| 196 } |
| 197 |
| 198 buildUnnamed4026() { |
| 199 var o = new core.List<api.Token>(); |
| 200 o.add(buildToken()); |
| 201 o.add(buildToken()); |
| 202 return o; |
| 203 } |
| 204 |
| 205 checkUnnamed4026(core.List<api.Token> o) { |
| 206 unittest.expect(o, unittest.hasLength(2)); |
| 207 checkToken(o[0]); |
| 208 checkToken(o[1]); |
| 209 } |
| 210 |
| 211 core.int buildCounterAnnotateTextResponse = 0; |
| 212 buildAnnotateTextResponse() { |
| 213 var o = new api.AnnotateTextResponse(); |
| 214 buildCounterAnnotateTextResponse++; |
| 215 if (buildCounterAnnotateTextResponse < 3) { |
| 216 o.documentSentiment = buildSentiment(); |
| 217 o.entities = buildUnnamed4024(); |
| 218 o.language = "foo"; |
| 219 o.sentences = buildUnnamed4025(); |
| 220 o.tokens = buildUnnamed4026(); |
| 221 } |
| 222 buildCounterAnnotateTextResponse--; |
| 223 return o; |
| 224 } |
| 225 |
| 226 checkAnnotateTextResponse(api.AnnotateTextResponse o) { |
| 227 buildCounterAnnotateTextResponse++; |
| 228 if (buildCounterAnnotateTextResponse < 3) { |
| 229 checkSentiment(o.documentSentiment); |
| 230 checkUnnamed4024(o.entities); |
| 231 unittest.expect(o.language, unittest.equals('foo')); |
| 232 checkUnnamed4025(o.sentences); |
| 233 checkUnnamed4026(o.tokens); |
| 234 } |
| 235 buildCounterAnnotateTextResponse--; |
| 236 } |
| 237 |
| 238 core.int buildCounterDependencyEdge = 0; |
| 239 buildDependencyEdge() { |
| 240 var o = new api.DependencyEdge(); |
| 241 buildCounterDependencyEdge++; |
| 242 if (buildCounterDependencyEdge < 3) { |
| 243 o.headTokenIndex = 42; |
| 244 o.label = "foo"; |
| 245 } |
| 246 buildCounterDependencyEdge--; |
| 247 return o; |
| 248 } |
| 249 |
| 250 checkDependencyEdge(api.DependencyEdge o) { |
| 251 buildCounterDependencyEdge++; |
| 252 if (buildCounterDependencyEdge < 3) { |
| 253 unittest.expect(o.headTokenIndex, unittest.equals(42)); |
| 254 unittest.expect(o.label, unittest.equals('foo')); |
| 255 } |
| 256 buildCounterDependencyEdge--; |
| 257 } |
| 258 |
| 259 core.int buildCounterDocument = 0; |
| 260 buildDocument() { |
| 261 var o = new api.Document(); |
| 262 buildCounterDocument++; |
| 263 if (buildCounterDocument < 3) { |
| 264 o.content = "foo"; |
| 265 o.gcsContentUri = "foo"; |
| 266 o.language = "foo"; |
| 267 o.type = "foo"; |
| 268 } |
| 269 buildCounterDocument--; |
| 270 return o; |
| 271 } |
| 272 |
| 273 checkDocument(api.Document o) { |
| 274 buildCounterDocument++; |
| 275 if (buildCounterDocument < 3) { |
| 276 unittest.expect(o.content, unittest.equals('foo')); |
| 277 unittest.expect(o.gcsContentUri, unittest.equals('foo')); |
| 278 unittest.expect(o.language, unittest.equals('foo')); |
| 279 unittest.expect(o.type, unittest.equals('foo')); |
| 280 } |
| 281 buildCounterDocument--; |
| 282 } |
| 283 |
| 284 buildUnnamed4027() { |
| 285 var o = new core.List<api.EntityMention>(); |
| 286 o.add(buildEntityMention()); |
| 287 o.add(buildEntityMention()); |
| 288 return o; |
| 289 } |
| 290 |
| 291 checkUnnamed4027(core.List<api.EntityMention> o) { |
| 292 unittest.expect(o, unittest.hasLength(2)); |
| 293 checkEntityMention(o[0]); |
| 294 checkEntityMention(o[1]); |
| 295 } |
| 296 |
| 297 buildUnnamed4028() { |
| 298 var o = new core.Map<core.String, core.String>(); |
| 299 o["x"] = "foo"; |
| 300 o["y"] = "foo"; |
| 301 return o; |
| 302 } |
| 303 |
| 304 checkUnnamed4028(core.Map<core.String, core.String> o) { |
| 305 unittest.expect(o, unittest.hasLength(2)); |
| 306 unittest.expect(o["x"], unittest.equals('foo')); |
| 307 unittest.expect(o["y"], unittest.equals('foo')); |
| 308 } |
| 309 |
| 310 core.int buildCounterEntity = 0; |
| 311 buildEntity() { |
| 312 var o = new api.Entity(); |
| 313 buildCounterEntity++; |
| 314 if (buildCounterEntity < 3) { |
| 315 o.mentions = buildUnnamed4027(); |
| 316 o.metadata = buildUnnamed4028(); |
| 317 o.name = "foo"; |
| 318 o.salience = 42.0; |
| 319 o.type = "foo"; |
| 320 } |
| 321 buildCounterEntity--; |
| 322 return o; |
| 323 } |
| 324 |
| 325 checkEntity(api.Entity o) { |
| 326 buildCounterEntity++; |
| 327 if (buildCounterEntity < 3) { |
| 328 checkUnnamed4027(o.mentions); |
| 329 checkUnnamed4028(o.metadata); |
| 330 unittest.expect(o.name, unittest.equals('foo')); |
| 331 unittest.expect(o.salience, unittest.equals(42.0)); |
| 332 unittest.expect(o.type, unittest.equals('foo')); |
| 333 } |
| 334 buildCounterEntity--; |
| 335 } |
| 336 |
| 337 core.int buildCounterEntityMention = 0; |
| 338 buildEntityMention() { |
| 339 var o = new api.EntityMention(); |
| 340 buildCounterEntityMention++; |
| 341 if (buildCounterEntityMention < 3) { |
| 342 o.text = buildTextSpan(); |
| 343 } |
| 344 buildCounterEntityMention--; |
| 345 return o; |
| 346 } |
| 347 |
| 348 checkEntityMention(api.EntityMention o) { |
| 349 buildCounterEntityMention++; |
| 350 if (buildCounterEntityMention < 3) { |
| 351 checkTextSpan(o.text); |
| 352 } |
| 353 buildCounterEntityMention--; |
| 354 } |
| 355 |
| 356 core.int buildCounterFeatures = 0; |
| 357 buildFeatures() { |
| 358 var o = new api.Features(); |
| 359 buildCounterFeatures++; |
| 360 if (buildCounterFeatures < 3) { |
| 361 o.extractDocumentSentiment = true; |
| 362 o.extractEntities = true; |
| 363 o.extractSyntax = true; |
| 364 } |
| 365 buildCounterFeatures--; |
| 366 return o; |
| 367 } |
| 368 |
| 369 checkFeatures(api.Features o) { |
| 370 buildCounterFeatures++; |
| 371 if (buildCounterFeatures < 3) { |
| 372 unittest.expect(o.extractDocumentSentiment, unittest.isTrue); |
| 373 unittest.expect(o.extractEntities, unittest.isTrue); |
| 374 unittest.expect(o.extractSyntax, unittest.isTrue); |
| 375 } |
| 376 buildCounterFeatures--; |
| 377 } |
| 378 |
| 379 core.int buildCounterPartOfSpeech = 0; |
| 380 buildPartOfSpeech() { |
| 381 var o = new api.PartOfSpeech(); |
| 382 buildCounterPartOfSpeech++; |
| 383 if (buildCounterPartOfSpeech < 3) { |
| 384 o.tag = "foo"; |
| 385 } |
| 386 buildCounterPartOfSpeech--; |
| 387 return o; |
| 388 } |
| 389 |
| 390 checkPartOfSpeech(api.PartOfSpeech o) { |
| 391 buildCounterPartOfSpeech++; |
| 392 if (buildCounterPartOfSpeech < 3) { |
| 393 unittest.expect(o.tag, unittest.equals('foo')); |
| 394 } |
| 395 buildCounterPartOfSpeech--; |
| 396 } |
| 397 |
| 398 core.int buildCounterSentence = 0; |
| 399 buildSentence() { |
| 400 var o = new api.Sentence(); |
| 401 buildCounterSentence++; |
| 402 if (buildCounterSentence < 3) { |
| 403 o.text = buildTextSpan(); |
| 404 } |
| 405 buildCounterSentence--; |
| 406 return o; |
| 407 } |
| 408 |
| 409 checkSentence(api.Sentence o) { |
| 410 buildCounterSentence++; |
| 411 if (buildCounterSentence < 3) { |
| 412 checkTextSpan(o.text); |
| 413 } |
| 414 buildCounterSentence--; |
| 415 } |
| 416 |
| 417 core.int buildCounterSentiment = 0; |
| 418 buildSentiment() { |
| 419 var o = new api.Sentiment(); |
| 420 buildCounterSentiment++; |
| 421 if (buildCounterSentiment < 3) { |
| 422 o.magnitude = 42.0; |
| 423 o.polarity = 42.0; |
| 424 } |
| 425 buildCounterSentiment--; |
| 426 return o; |
| 427 } |
| 428 |
| 429 checkSentiment(api.Sentiment o) { |
| 430 buildCounterSentiment++; |
| 431 if (buildCounterSentiment < 3) { |
| 432 unittest.expect(o.magnitude, unittest.equals(42.0)); |
| 433 unittest.expect(o.polarity, unittest.equals(42.0)); |
| 434 } |
| 435 buildCounterSentiment--; |
| 436 } |
| 437 |
| 438 buildUnnamed4029() { |
| 439 var o = new core.Map<core.String, core.Object>(); |
| 440 o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; |
| 441 o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; |
| 442 return o; |
| 443 } |
| 444 |
| 445 checkUnnamed4029(core.Map<core.String, core.Object> o) { |
| 446 unittest.expect(o, unittest.hasLength(2)); |
| 447 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')); |
| 448 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')); |
| 449 } |
| 450 |
| 451 buildUnnamed4030() { |
| 452 var o = new core.List<core.Map<core.String, core.Object>>(); |
| 453 o.add(buildUnnamed4029()); |
| 454 o.add(buildUnnamed4029()); |
| 455 return o; |
| 456 } |
| 457 |
| 458 checkUnnamed4030(core.List<core.Map<core.String, core.Object>> o) { |
| 459 unittest.expect(o, unittest.hasLength(2)); |
| 460 checkUnnamed4029(o[0]); |
| 461 checkUnnamed4029(o[1]); |
| 462 } |
| 463 |
| 464 core.int buildCounterStatus = 0; |
| 465 buildStatus() { |
| 466 var o = new api.Status(); |
| 467 buildCounterStatus++; |
| 468 if (buildCounterStatus < 3) { |
| 469 o.code = 42; |
| 470 o.details = buildUnnamed4030(); |
| 471 o.message = "foo"; |
| 472 } |
| 473 buildCounterStatus--; |
| 474 return o; |
| 475 } |
| 476 |
| 477 checkStatus(api.Status o) { |
| 478 buildCounterStatus++; |
| 479 if (buildCounterStatus < 3) { |
| 480 unittest.expect(o.code, unittest.equals(42)); |
| 481 checkUnnamed4030(o.details); |
| 482 unittest.expect(o.message, unittest.equals('foo')); |
| 483 } |
| 484 buildCounterStatus--; |
| 485 } |
| 486 |
| 487 core.int buildCounterTextSpan = 0; |
| 488 buildTextSpan() { |
| 489 var o = new api.TextSpan(); |
| 490 buildCounterTextSpan++; |
| 491 if (buildCounterTextSpan < 3) { |
| 492 o.beginOffset = 42; |
| 493 o.content = "foo"; |
| 494 } |
| 495 buildCounterTextSpan--; |
| 496 return o; |
| 497 } |
| 498 |
| 499 checkTextSpan(api.TextSpan o) { |
| 500 buildCounterTextSpan++; |
| 501 if (buildCounterTextSpan < 3) { |
| 502 unittest.expect(o.beginOffset, unittest.equals(42)); |
| 503 unittest.expect(o.content, unittest.equals('foo')); |
| 504 } |
| 505 buildCounterTextSpan--; |
| 506 } |
| 507 |
| 508 core.int buildCounterToken = 0; |
| 509 buildToken() { |
| 510 var o = new api.Token(); |
| 511 buildCounterToken++; |
| 512 if (buildCounterToken < 3) { |
| 513 o.dependencyEdge = buildDependencyEdge(); |
| 514 o.lemma = "foo"; |
| 515 o.partOfSpeech = buildPartOfSpeech(); |
| 516 o.text = buildTextSpan(); |
| 517 } |
| 518 buildCounterToken--; |
| 519 return o; |
| 520 } |
| 521 |
| 522 checkToken(api.Token o) { |
| 523 buildCounterToken++; |
| 524 if (buildCounterToken < 3) { |
| 525 checkDependencyEdge(o.dependencyEdge); |
| 526 unittest.expect(o.lemma, unittest.equals('foo')); |
| 527 checkPartOfSpeech(o.partOfSpeech); |
| 528 checkTextSpan(o.text); |
| 529 } |
| 530 buildCounterToken--; |
| 531 } |
| 532 |
| 533 |
| 534 main() { |
| 535 unittest.group("obj-schema-AnalyzeEntitiesRequest", () { |
| 536 unittest.test("to-json--from-json", () { |
| 537 var o = buildAnalyzeEntitiesRequest(); |
| 538 var od = new api.AnalyzeEntitiesRequest.fromJson(o.toJson()); |
| 539 checkAnalyzeEntitiesRequest(od); |
| 540 }); |
| 541 }); |
| 542 |
| 543 |
| 544 unittest.group("obj-schema-AnalyzeEntitiesResponse", () { |
| 545 unittest.test("to-json--from-json", () { |
| 546 var o = buildAnalyzeEntitiesResponse(); |
| 547 var od = new api.AnalyzeEntitiesResponse.fromJson(o.toJson()); |
| 548 checkAnalyzeEntitiesResponse(od); |
| 549 }); |
| 550 }); |
| 551 |
| 552 |
| 553 unittest.group("obj-schema-AnalyzeSentimentRequest", () { |
| 554 unittest.test("to-json--from-json", () { |
| 555 var o = buildAnalyzeSentimentRequest(); |
| 556 var od = new api.AnalyzeSentimentRequest.fromJson(o.toJson()); |
| 557 checkAnalyzeSentimentRequest(od); |
| 558 }); |
| 559 }); |
| 560 |
| 561 |
| 562 unittest.group("obj-schema-AnalyzeSentimentResponse", () { |
| 563 unittest.test("to-json--from-json", () { |
| 564 var o = buildAnalyzeSentimentResponse(); |
| 565 var od = new api.AnalyzeSentimentResponse.fromJson(o.toJson()); |
| 566 checkAnalyzeSentimentResponse(od); |
| 567 }); |
| 568 }); |
| 569 |
| 570 |
| 571 unittest.group("obj-schema-AnnotateTextRequest", () { |
| 572 unittest.test("to-json--from-json", () { |
| 573 var o = buildAnnotateTextRequest(); |
| 574 var od = new api.AnnotateTextRequest.fromJson(o.toJson()); |
| 575 checkAnnotateTextRequest(od); |
| 576 }); |
| 577 }); |
| 578 |
| 579 |
| 580 unittest.group("obj-schema-AnnotateTextResponse", () { |
| 581 unittest.test("to-json--from-json", () { |
| 582 var o = buildAnnotateTextResponse(); |
| 583 var od = new api.AnnotateTextResponse.fromJson(o.toJson()); |
| 584 checkAnnotateTextResponse(od); |
| 585 }); |
| 586 }); |
| 587 |
| 588 |
| 589 unittest.group("obj-schema-DependencyEdge", () { |
| 590 unittest.test("to-json--from-json", () { |
| 591 var o = buildDependencyEdge(); |
| 592 var od = new api.DependencyEdge.fromJson(o.toJson()); |
| 593 checkDependencyEdge(od); |
| 594 }); |
| 595 }); |
| 596 |
| 597 |
| 598 unittest.group("obj-schema-Document", () { |
| 599 unittest.test("to-json--from-json", () { |
| 600 var o = buildDocument(); |
| 601 var od = new api.Document.fromJson(o.toJson()); |
| 602 checkDocument(od); |
| 603 }); |
| 604 }); |
| 605 |
| 606 |
| 607 unittest.group("obj-schema-Entity", () { |
| 608 unittest.test("to-json--from-json", () { |
| 609 var o = buildEntity(); |
| 610 var od = new api.Entity.fromJson(o.toJson()); |
| 611 checkEntity(od); |
| 612 }); |
| 613 }); |
| 614 |
| 615 |
| 616 unittest.group("obj-schema-EntityMention", () { |
| 617 unittest.test("to-json--from-json", () { |
| 618 var o = buildEntityMention(); |
| 619 var od = new api.EntityMention.fromJson(o.toJson()); |
| 620 checkEntityMention(od); |
| 621 }); |
| 622 }); |
| 623 |
| 624 |
| 625 unittest.group("obj-schema-Features", () { |
| 626 unittest.test("to-json--from-json", () { |
| 627 var o = buildFeatures(); |
| 628 var od = new api.Features.fromJson(o.toJson()); |
| 629 checkFeatures(od); |
| 630 }); |
| 631 }); |
| 632 |
| 633 |
| 634 unittest.group("obj-schema-PartOfSpeech", () { |
| 635 unittest.test("to-json--from-json", () { |
| 636 var o = buildPartOfSpeech(); |
| 637 var od = new api.PartOfSpeech.fromJson(o.toJson()); |
| 638 checkPartOfSpeech(od); |
| 639 }); |
| 640 }); |
| 641 |
| 642 |
| 643 unittest.group("obj-schema-Sentence", () { |
| 644 unittest.test("to-json--from-json", () { |
| 645 var o = buildSentence(); |
| 646 var od = new api.Sentence.fromJson(o.toJson()); |
| 647 checkSentence(od); |
| 648 }); |
| 649 }); |
| 650 |
| 651 |
| 652 unittest.group("obj-schema-Sentiment", () { |
| 653 unittest.test("to-json--from-json", () { |
| 654 var o = buildSentiment(); |
| 655 var od = new api.Sentiment.fromJson(o.toJson()); |
| 656 checkSentiment(od); |
| 657 }); |
| 658 }); |
| 659 |
| 660 |
| 661 unittest.group("obj-schema-Status", () { |
| 662 unittest.test("to-json--from-json", () { |
| 663 var o = buildStatus(); |
| 664 var od = new api.Status.fromJson(o.toJson()); |
| 665 checkStatus(od); |
| 666 }); |
| 667 }); |
| 668 |
| 669 |
| 670 unittest.group("obj-schema-TextSpan", () { |
| 671 unittest.test("to-json--from-json", () { |
| 672 var o = buildTextSpan(); |
| 673 var od = new api.TextSpan.fromJson(o.toJson()); |
| 674 checkTextSpan(od); |
| 675 }); |
| 676 }); |
| 677 |
| 678 |
| 679 unittest.group("obj-schema-Token", () { |
| 680 unittest.test("to-json--from-json", () { |
| 681 var o = buildToken(); |
| 682 var od = new api.Token.fromJson(o.toJson()); |
| 683 checkToken(od); |
| 684 }); |
| 685 }); |
| 686 |
| 687 |
| 688 unittest.group("resource-DocumentsResourceApi", () { |
| 689 unittest.test("method--analyzeEntities", () { |
| 690 |
| 691 var mock = new HttpServerMock(); |
| 692 api.DocumentsResourceApi res = new api.LanguageApi(mock).documents; |
| 693 var arg_request = buildAnalyzeEntitiesRequest(); |
| 694 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| 695 var obj = new api.AnalyzeEntitiesRequest.fromJson(json); |
| 696 checkAnalyzeEntitiesRequest(obj); |
| 697 |
| 698 var path = (req.url).path; |
| 699 var pathOffset = 0; |
| 700 var index; |
| 701 var subPart; |
| 702 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
| 703 pathOffset += 1; |
| 704 unittest.expect(path.substring(pathOffset, pathOffset + 33), unittest.eq
uals("v1beta1/documents:analyzeEntities")); |
| 705 pathOffset += 33; |
| 706 |
| 707 var query = (req.url).query; |
| 708 var queryOffset = 0; |
| 709 var queryMap = {}; |
| 710 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 711 parseBool(n) { |
| 712 if (n == "true") return true; |
| 713 if (n == "false") return false; |
| 714 if (n == null) return null; |
| 715 throw new core.ArgumentError("Invalid boolean: $n"); |
| 716 } |
| 717 if (query.length > 0) { |
| 718 for (var part in query.split("&")) { |
| 719 var keyvalue = part.split("="); |
| 720 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
| 721 } |
| 722 } |
| 723 |
| 724 |
| 725 var h = { |
| 726 "content-type" : "application/json; charset=utf-8", |
| 727 }; |
| 728 var resp = convert.JSON.encode(buildAnalyzeEntitiesResponse()); |
| 729 return new async.Future.value(stringResponse(200, h, resp)); |
| 730 }), true); |
| 731 res.analyzeEntities(arg_request).then(unittest.expectAsync(((api.AnalyzeEn
titiesResponse response) { |
| 732 checkAnalyzeEntitiesResponse(response); |
| 733 }))); |
| 734 }); |
| 735 |
| 736 unittest.test("method--analyzeSentiment", () { |
| 737 |
| 738 var mock = new HttpServerMock(); |
| 739 api.DocumentsResourceApi res = new api.LanguageApi(mock).documents; |
| 740 var arg_request = buildAnalyzeSentimentRequest(); |
| 741 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| 742 var obj = new api.AnalyzeSentimentRequest.fromJson(json); |
| 743 checkAnalyzeSentimentRequest(obj); |
| 744 |
| 745 var path = (req.url).path; |
| 746 var pathOffset = 0; |
| 747 var index; |
| 748 var subPart; |
| 749 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
| 750 pathOffset += 1; |
| 751 unittest.expect(path.substring(pathOffset, pathOffset + 34), unittest.eq
uals("v1beta1/documents:analyzeSentiment")); |
| 752 pathOffset += 34; |
| 753 |
| 754 var query = (req.url).query; |
| 755 var queryOffset = 0; |
| 756 var queryMap = {}; |
| 757 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 758 parseBool(n) { |
| 759 if (n == "true") return true; |
| 760 if (n == "false") return false; |
| 761 if (n == null) return null; |
| 762 throw new core.ArgumentError("Invalid boolean: $n"); |
| 763 } |
| 764 if (query.length > 0) { |
| 765 for (var part in query.split("&")) { |
| 766 var keyvalue = part.split("="); |
| 767 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
| 768 } |
| 769 } |
| 770 |
| 771 |
| 772 var h = { |
| 773 "content-type" : "application/json; charset=utf-8", |
| 774 }; |
| 775 var resp = convert.JSON.encode(buildAnalyzeSentimentResponse()); |
| 776 return new async.Future.value(stringResponse(200, h, resp)); |
| 777 }), true); |
| 778 res.analyzeSentiment(arg_request).then(unittest.expectAsync(((api.AnalyzeS
entimentResponse response) { |
| 779 checkAnalyzeSentimentResponse(response); |
| 780 }))); |
| 781 }); |
| 782 |
| 783 unittest.test("method--annotateText", () { |
| 784 |
| 785 var mock = new HttpServerMock(); |
| 786 api.DocumentsResourceApi res = new api.LanguageApi(mock).documents; |
| 787 var arg_request = buildAnnotateTextRequest(); |
| 788 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| 789 var obj = new api.AnnotateTextRequest.fromJson(json); |
| 790 checkAnnotateTextRequest(obj); |
| 791 |
| 792 var path = (req.url).path; |
| 793 var pathOffset = 0; |
| 794 var index; |
| 795 var subPart; |
| 796 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
| 797 pathOffset += 1; |
| 798 unittest.expect(path.substring(pathOffset, pathOffset + 30), unittest.eq
uals("v1beta1/documents:annotateText")); |
| 799 pathOffset += 30; |
| 800 |
| 801 var query = (req.url).query; |
| 802 var queryOffset = 0; |
| 803 var queryMap = {}; |
| 804 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 805 parseBool(n) { |
| 806 if (n == "true") return true; |
| 807 if (n == "false") return false; |
| 808 if (n == null) return null; |
| 809 throw new core.ArgumentError("Invalid boolean: $n"); |
| 810 } |
| 811 if (query.length > 0) { |
| 812 for (var part in query.split("&")) { |
| 813 var keyvalue = part.split("="); |
| 814 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
| 815 } |
| 816 } |
| 817 |
| 818 |
| 819 var h = { |
| 820 "content-type" : "application/json; charset=utf-8", |
| 821 }; |
| 822 var resp = convert.JSON.encode(buildAnnotateTextResponse()); |
| 823 return new async.Future.value(stringResponse(200, h, resp)); |
| 824 }), true); |
| 825 res.annotateText(arg_request).then(unittest.expectAsync(((api.AnnotateText
Response response) { |
| 826 checkAnnotateTextResponse(response); |
| 827 }))); |
| 828 }); |
| 829 |
| 830 }); |
| 831 |
| 832 |
| 833 } |
| 834 |
| OLD | NEW |