| OLD | NEW |
| 1 library googleapis.translate.v2.test; | 1 library googleapis.translate.v2.test; |
| 2 | 2 |
| 3 import "dart:core" as core; | 3 import "dart:core" as core; |
| 4 import "dart:collection" as collection; | 4 import "dart:collection" as collection; |
| 5 import "dart:async" as async; | 5 import "dart:async" as async; |
| 6 import "dart:convert" as convert; | 6 import "dart:convert" as convert; |
| 7 | 7 |
| 8 import 'package:http/http.dart' as http; | 8 import 'package:http/http.dart' as http; |
| 9 import 'package:http/testing.dart' as http_testing; | 9 import 'package:http/testing.dart' as http_testing; |
| 10 import 'package:unittest/unittest.dart' as unittest; | 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 | 11 |
| 15 import 'package:googleapis/translate/v2.dart' as api; | 12 import 'package:googleapis/translate/v2.dart' as api; |
| 16 | 13 |
| 14 class HttpServerMock extends http.BaseClient { |
| 15 core.Function _callback; |
| 16 core.bool _expectJson; |
| 17 | 17 |
| 18 void register(core.Function callback, core.bool expectJson) { |
| 19 _callback = callback; |
| 20 _expectJson = expectJson; |
| 21 } |
| 18 | 22 |
| 19 buildUnnamed736() { | 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 buildUnnamed1387() { |
| 20 var o = new core.List<api.DetectionsResource>(); | 55 var o = new core.List<api.DetectionsResource>(); |
| 21 o.add(buildDetectionsResource()); | 56 o.add(buildDetectionsResource()); |
| 22 o.add(buildDetectionsResource()); | 57 o.add(buildDetectionsResource()); |
| 23 return o; | 58 return o; |
| 24 } | 59 } |
| 25 | 60 |
| 26 checkUnnamed736(core.List<api.DetectionsResource> o) { | 61 checkUnnamed1387(core.List<api.DetectionsResource> o) { |
| 27 unittest.expect(o, unittest.hasLength(2)); | 62 unittest.expect(o, unittest.hasLength(2)); |
| 28 checkDetectionsResource(o[0]); | 63 checkDetectionsResource(o[0]); |
| 29 checkDetectionsResource(o[1]); | 64 checkDetectionsResource(o[1]); |
| 30 } | 65 } |
| 31 | 66 |
| 32 core.int buildCounterDetectionsListResponse = 0; | 67 core.int buildCounterDetectionsListResponse = 0; |
| 33 buildDetectionsListResponse() { | 68 buildDetectionsListResponse() { |
| 34 var o = new api.DetectionsListResponse(); | 69 var o = new api.DetectionsListResponse(); |
| 35 buildCounterDetectionsListResponse++; | 70 buildCounterDetectionsListResponse++; |
| 36 if (buildCounterDetectionsListResponse < 3) { | 71 if (buildCounterDetectionsListResponse < 3) { |
| 37 o.detections = buildUnnamed736(); | 72 o.detections = buildUnnamed1387(); |
| 38 } | 73 } |
| 39 buildCounterDetectionsListResponse--; | 74 buildCounterDetectionsListResponse--; |
| 40 return o; | 75 return o; |
| 41 } | 76 } |
| 42 | 77 |
| 43 checkDetectionsListResponse(api.DetectionsListResponse o) { | 78 checkDetectionsListResponse(api.DetectionsListResponse o) { |
| 44 buildCounterDetectionsListResponse++; | 79 buildCounterDetectionsListResponse++; |
| 45 if (buildCounterDetectionsListResponse < 3) { | 80 if (buildCounterDetectionsListResponse < 3) { |
| 46 checkUnnamed736(o.detections); | 81 checkUnnamed1387(o.detections); |
| 47 } | 82 } |
| 48 buildCounterDetectionsListResponse--; | 83 buildCounterDetectionsListResponse--; |
| 49 } | 84 } |
| 50 | 85 |
| 51 core.int buildCounterDetectionsResourceElement = 0; | 86 core.int buildCounterDetectionsResourceElement = 0; |
| 52 buildDetectionsResourceElement() { | 87 buildDetectionsResourceElement() { |
| 53 var o = new api.DetectionsResourceElement(); | 88 var o = new api.DetectionsResourceElement(); |
| 54 buildCounterDetectionsResourceElement++; | 89 buildCounterDetectionsResourceElement++; |
| 55 if (buildCounterDetectionsResourceElement < 3) { | 90 if (buildCounterDetectionsResourceElement < 3) { |
| 56 o.confidence = 42.0; | 91 o.confidence = 42.0; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 77 o.add(buildDetectionsResourceElement()); | 112 o.add(buildDetectionsResourceElement()); |
| 78 return o; | 113 return o; |
| 79 } | 114 } |
| 80 | 115 |
| 81 checkDetectionsResource(api.DetectionsResource o) { | 116 checkDetectionsResource(api.DetectionsResource o) { |
| 82 unittest.expect(o, unittest.hasLength(2)); | 117 unittest.expect(o, unittest.hasLength(2)); |
| 83 checkDetectionsResourceElement(o[0]); | 118 checkDetectionsResourceElement(o[0]); |
| 84 checkDetectionsResourceElement(o[1]); | 119 checkDetectionsResourceElement(o[1]); |
| 85 } | 120 } |
| 86 | 121 |
| 87 buildUnnamed737() { | 122 buildUnnamed1388() { |
| 88 var o = new core.List<api.LanguagesResource>(); | 123 var o = new core.List<api.LanguagesResource>(); |
| 89 o.add(buildLanguagesResource()); | 124 o.add(buildLanguagesResource()); |
| 90 o.add(buildLanguagesResource()); | 125 o.add(buildLanguagesResource()); |
| 91 return o; | 126 return o; |
| 92 } | 127 } |
| 93 | 128 |
| 94 checkUnnamed737(core.List<api.LanguagesResource> o) { | 129 checkUnnamed1388(core.List<api.LanguagesResource> o) { |
| 95 unittest.expect(o, unittest.hasLength(2)); | 130 unittest.expect(o, unittest.hasLength(2)); |
| 96 checkLanguagesResource(o[0]); | 131 checkLanguagesResource(o[0]); |
| 97 checkLanguagesResource(o[1]); | 132 checkLanguagesResource(o[1]); |
| 98 } | 133 } |
| 99 | 134 |
| 100 core.int buildCounterLanguagesListResponse = 0; | 135 core.int buildCounterLanguagesListResponse = 0; |
| 101 buildLanguagesListResponse() { | 136 buildLanguagesListResponse() { |
| 102 var o = new api.LanguagesListResponse(); | 137 var o = new api.LanguagesListResponse(); |
| 103 buildCounterLanguagesListResponse++; | 138 buildCounterLanguagesListResponse++; |
| 104 if (buildCounterLanguagesListResponse < 3) { | 139 if (buildCounterLanguagesListResponse < 3) { |
| 105 o.languages = buildUnnamed737(); | 140 o.languages = buildUnnamed1388(); |
| 106 } | 141 } |
| 107 buildCounterLanguagesListResponse--; | 142 buildCounterLanguagesListResponse--; |
| 108 return o; | 143 return o; |
| 109 } | 144 } |
| 110 | 145 |
| 111 checkLanguagesListResponse(api.LanguagesListResponse o) { | 146 checkLanguagesListResponse(api.LanguagesListResponse o) { |
| 112 buildCounterLanguagesListResponse++; | 147 buildCounterLanguagesListResponse++; |
| 113 if (buildCounterLanguagesListResponse < 3) { | 148 if (buildCounterLanguagesListResponse < 3) { |
| 114 checkUnnamed737(o.languages); | 149 checkUnnamed1388(o.languages); |
| 115 } | 150 } |
| 116 buildCounterLanguagesListResponse--; | 151 buildCounterLanguagesListResponse--; |
| 117 } | 152 } |
| 118 | 153 |
| 119 core.int buildCounterLanguagesResource = 0; | 154 core.int buildCounterLanguagesResource = 0; |
| 120 buildLanguagesResource() { | 155 buildLanguagesResource() { |
| 121 var o = new api.LanguagesResource(); | 156 var o = new api.LanguagesResource(); |
| 122 buildCounterLanguagesResource++; | 157 buildCounterLanguagesResource++; |
| 123 if (buildCounterLanguagesResource < 3) { | 158 if (buildCounterLanguagesResource < 3) { |
| 124 o.language = "foo"; | 159 o.language = "foo"; |
| 125 o.name = "foo"; | 160 o.name = "foo"; |
| 126 } | 161 } |
| 127 buildCounterLanguagesResource--; | 162 buildCounterLanguagesResource--; |
| 128 return o; | 163 return o; |
| 129 } | 164 } |
| 130 | 165 |
| 131 checkLanguagesResource(api.LanguagesResource o) { | 166 checkLanguagesResource(api.LanguagesResource o) { |
| 132 buildCounterLanguagesResource++; | 167 buildCounterLanguagesResource++; |
| 133 if (buildCounterLanguagesResource < 3) { | 168 if (buildCounterLanguagesResource < 3) { |
| 134 unittest.expect(o.language, unittest.equals('foo')); | 169 unittest.expect(o.language, unittest.equals('foo')); |
| 135 unittest.expect(o.name, unittest.equals('foo')); | 170 unittest.expect(o.name, unittest.equals('foo')); |
| 136 } | 171 } |
| 137 buildCounterLanguagesResource--; | 172 buildCounterLanguagesResource--; |
| 138 } | 173 } |
| 139 | 174 |
| 140 buildUnnamed738() { | 175 buildUnnamed1389() { |
| 141 var o = new core.List<api.TranslationsResource>(); | 176 var o = new core.List<api.TranslationsResource>(); |
| 142 o.add(buildTranslationsResource()); | 177 o.add(buildTranslationsResource()); |
| 143 o.add(buildTranslationsResource()); | 178 o.add(buildTranslationsResource()); |
| 144 return o; | 179 return o; |
| 145 } | 180 } |
| 146 | 181 |
| 147 checkUnnamed738(core.List<api.TranslationsResource> o) { | 182 checkUnnamed1389(core.List<api.TranslationsResource> o) { |
| 148 unittest.expect(o, unittest.hasLength(2)); | 183 unittest.expect(o, unittest.hasLength(2)); |
| 149 checkTranslationsResource(o[0]); | 184 checkTranslationsResource(o[0]); |
| 150 checkTranslationsResource(o[1]); | 185 checkTranslationsResource(o[1]); |
| 151 } | 186 } |
| 152 | 187 |
| 153 core.int buildCounterTranslationsListResponse = 0; | 188 core.int buildCounterTranslationsListResponse = 0; |
| 154 buildTranslationsListResponse() { | 189 buildTranslationsListResponse() { |
| 155 var o = new api.TranslationsListResponse(); | 190 var o = new api.TranslationsListResponse(); |
| 156 buildCounterTranslationsListResponse++; | 191 buildCounterTranslationsListResponse++; |
| 157 if (buildCounterTranslationsListResponse < 3) { | 192 if (buildCounterTranslationsListResponse < 3) { |
| 158 o.translations = buildUnnamed738(); | 193 o.translations = buildUnnamed1389(); |
| 159 } | 194 } |
| 160 buildCounterTranslationsListResponse--; | 195 buildCounterTranslationsListResponse--; |
| 161 return o; | 196 return o; |
| 162 } | 197 } |
| 163 | 198 |
| 164 checkTranslationsListResponse(api.TranslationsListResponse o) { | 199 checkTranslationsListResponse(api.TranslationsListResponse o) { |
| 165 buildCounterTranslationsListResponse++; | 200 buildCounterTranslationsListResponse++; |
| 166 if (buildCounterTranslationsListResponse < 3) { | 201 if (buildCounterTranslationsListResponse < 3) { |
| 167 checkUnnamed738(o.translations); | 202 checkUnnamed1389(o.translations); |
| 168 } | 203 } |
| 169 buildCounterTranslationsListResponse--; | 204 buildCounterTranslationsListResponse--; |
| 170 } | 205 } |
| 171 | 206 |
| 172 core.int buildCounterTranslationsResource = 0; | 207 core.int buildCounterTranslationsResource = 0; |
| 173 buildTranslationsResource() { | 208 buildTranslationsResource() { |
| 174 var o = new api.TranslationsResource(); | 209 var o = new api.TranslationsResource(); |
| 175 buildCounterTranslationsResource++; | 210 buildCounterTranslationsResource++; |
| 176 if (buildCounterTranslationsResource < 3) { | 211 if (buildCounterTranslationsResource < 3) { |
| 177 o.detectedSourceLanguage = "foo"; | 212 o.detectedSourceLanguage = "foo"; |
| 178 o.translatedText = "foo"; | 213 o.translatedText = "foo"; |
| 179 } | 214 } |
| 180 buildCounterTranslationsResource--; | 215 buildCounterTranslationsResource--; |
| 181 return o; | 216 return o; |
| 182 } | 217 } |
| 183 | 218 |
| 184 checkTranslationsResource(api.TranslationsResource o) { | 219 checkTranslationsResource(api.TranslationsResource o) { |
| 185 buildCounterTranslationsResource++; | 220 buildCounterTranslationsResource++; |
| 186 if (buildCounterTranslationsResource < 3) { | 221 if (buildCounterTranslationsResource < 3) { |
| 187 unittest.expect(o.detectedSourceLanguage, unittest.equals('foo')); | 222 unittest.expect(o.detectedSourceLanguage, unittest.equals('foo')); |
| 188 unittest.expect(o.translatedText, unittest.equals('foo')); | 223 unittest.expect(o.translatedText, unittest.equals('foo')); |
| 189 } | 224 } |
| 190 buildCounterTranslationsResource--; | 225 buildCounterTranslationsResource--; |
| 191 } | 226 } |
| 192 | 227 |
| 193 buildUnnamed739() { | 228 buildUnnamed1390() { |
| 194 var o = new core.List<core.String>(); | 229 var o = new core.List<core.String>(); |
| 195 o.add("foo"); | 230 o.add("foo"); |
| 196 o.add("foo"); | 231 o.add("foo"); |
| 197 return o; | 232 return o; |
| 198 } | 233 } |
| 199 | 234 |
| 200 checkUnnamed739(core.List<core.String> o) { | 235 checkUnnamed1390(core.List<core.String> o) { |
| 201 unittest.expect(o, unittest.hasLength(2)); | 236 unittest.expect(o, unittest.hasLength(2)); |
| 202 unittest.expect(o[0], unittest.equals('foo')); | 237 unittest.expect(o[0], unittest.equals('foo')); |
| 203 unittest.expect(o[1], unittest.equals('foo')); | 238 unittest.expect(o[1], unittest.equals('foo')); |
| 204 } | 239 } |
| 205 | 240 |
| 206 buildUnnamed740() { | 241 buildUnnamed1391() { |
| 207 var o = new core.List<core.String>(); | 242 var o = new core.List<core.String>(); |
| 208 o.add("foo"); | 243 o.add("foo"); |
| 209 o.add("foo"); | 244 o.add("foo"); |
| 210 return o; | 245 return o; |
| 211 } | 246 } |
| 212 | 247 |
| 213 checkUnnamed740(core.List<core.String> o) { | 248 checkUnnamed1391(core.List<core.String> o) { |
| 214 unittest.expect(o, unittest.hasLength(2)); | 249 unittest.expect(o, unittest.hasLength(2)); |
| 215 unittest.expect(o[0], unittest.equals('foo')); | 250 unittest.expect(o[0], unittest.equals('foo')); |
| 216 unittest.expect(o[1], unittest.equals('foo')); | 251 unittest.expect(o[1], unittest.equals('foo')); |
| 217 } | 252 } |
| 218 | 253 |
| 219 buildUnnamed741() { | 254 buildUnnamed1392() { |
| 220 var o = new core.List<core.String>(); | 255 var o = new core.List<core.String>(); |
| 221 o.add("foo"); | 256 o.add("foo"); |
| 222 o.add("foo"); | 257 o.add("foo"); |
| 223 return o; | 258 return o; |
| 224 } | 259 } |
| 225 | 260 |
| 226 checkUnnamed741(core.List<core.String> o) { | 261 checkUnnamed1392(core.List<core.String> o) { |
| 227 unittest.expect(o, unittest.hasLength(2)); | 262 unittest.expect(o, unittest.hasLength(2)); |
| 228 unittest.expect(o[0], unittest.equals('foo')); | 263 unittest.expect(o[0], unittest.equals('foo')); |
| 229 unittest.expect(o[1], unittest.equals('foo')); | 264 unittest.expect(o[1], unittest.equals('foo')); |
| 230 } | 265 } |
| 231 | 266 |
| 232 | 267 |
| 233 main() { | 268 main() { |
| 234 unittest.group("obj-schema-DetectionsListResponse", () { | 269 unittest.group("obj-schema-DetectionsListResponse", () { |
| 235 unittest.test("to-json--from-json", () { | 270 unittest.test("to-json--from-json", () { |
| 236 var o = buildDetectionsListResponse(); | 271 var o = buildDetectionsListResponse(); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 var o = buildTranslationsResource(); | 325 var o = buildTranslationsResource(); |
| 291 var od = new api.TranslationsResource.fromJson(o.toJson()); | 326 var od = new api.TranslationsResource.fromJson(o.toJson()); |
| 292 checkTranslationsResource(od); | 327 checkTranslationsResource(od); |
| 293 }); | 328 }); |
| 294 }); | 329 }); |
| 295 | 330 |
| 296 | 331 |
| 297 unittest.group("resource-DetectionsResourceApi", () { | 332 unittest.group("resource-DetectionsResourceApi", () { |
| 298 unittest.test("method--list", () { | 333 unittest.test("method--list", () { |
| 299 | 334 |
| 300 var mock = new common_test.HttpServerMock(); | 335 var mock = new HttpServerMock(); |
| 301 api.DetectionsResourceApi res = new api.TranslateApi(mock).detections; | 336 api.DetectionsResourceApi res = new api.TranslateApi(mock).detections; |
| 302 var arg_q = buildUnnamed739(); | 337 var arg_q = buildUnnamed1390(); |
| 303 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | 338 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| 304 var path = (req.url).path; | 339 var path = (req.url).path; |
| 305 var pathOffset = 0; | 340 var pathOffset = 0; |
| 306 var index; | 341 var index; |
| 307 var subPart; | 342 var subPart; |
| 308 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 343 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
| 309 pathOffset += 1; | 344 pathOffset += 1; |
| 310 unittest.expect(path.substring(pathOffset, pathOffset + 19), unittest.eq
uals("language/translate/")); | 345 unittest.expect(path.substring(pathOffset, pathOffset + 19), unittest.eq
uals("language/translate/")); |
| 311 pathOffset += 19; | 346 pathOffset += 19; |
| 312 unittest.expect(path.substring(pathOffset, pathOffset + 9), unittest.equ
als("v2/detect")); | 347 unittest.expect(path.substring(pathOffset, pathOffset + 9), unittest.equ
als("v2/detect")); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 328 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 363 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
| 329 } | 364 } |
| 330 } | 365 } |
| 331 unittest.expect(queryMap["q"], unittest.equals(arg_q)); | 366 unittest.expect(queryMap["q"], unittest.equals(arg_q)); |
| 332 | 367 |
| 333 | 368 |
| 334 var h = { | 369 var h = { |
| 335 "content-type" : "application/json; charset=utf-8", | 370 "content-type" : "application/json; charset=utf-8", |
| 336 }; | 371 }; |
| 337 var resp = convert.JSON.encode(buildDetectionsListResponse()); | 372 var resp = convert.JSON.encode(buildDetectionsListResponse()); |
| 338 return new async.Future.value(common_test.stringResponse(200, h, resp)); | 373 return new async.Future.value(stringResponse(200, h, resp)); |
| 339 }), true); | 374 }), true); |
| 340 res.list(arg_q).then(unittest.expectAsync(((api.DetectionsListResponse res
ponse) { | 375 res.list(arg_q).then(unittest.expectAsync(((api.DetectionsListResponse res
ponse) { |
| 341 checkDetectionsListResponse(response); | 376 checkDetectionsListResponse(response); |
| 342 }))); | 377 }))); |
| 343 }); | 378 }); |
| 344 | 379 |
| 345 }); | 380 }); |
| 346 | 381 |
| 347 | 382 |
| 348 unittest.group("resource-LanguagesResourceApi", () { | 383 unittest.group("resource-LanguagesResourceApi", () { |
| 349 unittest.test("method--list", () { | 384 unittest.test("method--list", () { |
| 350 | 385 |
| 351 var mock = new common_test.HttpServerMock(); | 386 var mock = new HttpServerMock(); |
| 352 api.LanguagesResourceApi res = new api.TranslateApi(mock).languages; | 387 api.LanguagesResourceApi res = new api.TranslateApi(mock).languages; |
| 353 var arg_target = "foo"; | 388 var arg_target = "foo"; |
| 354 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | 389 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| 355 var path = (req.url).path; | 390 var path = (req.url).path; |
| 356 var pathOffset = 0; | 391 var pathOffset = 0; |
| 357 var index; | 392 var index; |
| 358 var subPart; | 393 var subPart; |
| 359 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 394 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
| 360 pathOffset += 1; | 395 pathOffset += 1; |
| 361 unittest.expect(path.substring(pathOffset, pathOffset + 19), unittest.eq
uals("language/translate/")); | 396 unittest.expect(path.substring(pathOffset, pathOffset + 19), unittest.eq
uals("language/translate/")); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 379 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 414 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
| 380 } | 415 } |
| 381 } | 416 } |
| 382 unittest.expect(queryMap["target"].first, unittest.equals(arg_target)); | 417 unittest.expect(queryMap["target"].first, unittest.equals(arg_target)); |
| 383 | 418 |
| 384 | 419 |
| 385 var h = { | 420 var h = { |
| 386 "content-type" : "application/json; charset=utf-8", | 421 "content-type" : "application/json; charset=utf-8", |
| 387 }; | 422 }; |
| 388 var resp = convert.JSON.encode(buildLanguagesListResponse()); | 423 var resp = convert.JSON.encode(buildLanguagesListResponse()); |
| 389 return new async.Future.value(common_test.stringResponse(200, h, resp)); | 424 return new async.Future.value(stringResponse(200, h, resp)); |
| 390 }), true); | 425 }), true); |
| 391 res.list(target: arg_target).then(unittest.expectAsync(((api.LanguagesList
Response response) { | 426 res.list(target: arg_target).then(unittest.expectAsync(((api.LanguagesList
Response response) { |
| 392 checkLanguagesListResponse(response); | 427 checkLanguagesListResponse(response); |
| 393 }))); | 428 }))); |
| 394 }); | 429 }); |
| 395 | 430 |
| 396 }); | 431 }); |
| 397 | 432 |
| 398 | 433 |
| 399 unittest.group("resource-TranslationsResourceApi", () { | 434 unittest.group("resource-TranslationsResourceApi", () { |
| 400 unittest.test("method--list", () { | 435 unittest.test("method--list", () { |
| 401 | 436 |
| 402 var mock = new common_test.HttpServerMock(); | 437 var mock = new HttpServerMock(); |
| 403 api.TranslationsResourceApi res = new api.TranslateApi(mock).translations; | 438 api.TranslationsResourceApi res = new api.TranslateApi(mock).translations; |
| 404 var arg_q = buildUnnamed740(); | 439 var arg_q = buildUnnamed1391(); |
| 405 var arg_target = "foo"; | 440 var arg_target = "foo"; |
| 406 var arg_cid = buildUnnamed741(); | 441 var arg_cid = buildUnnamed1392(); |
| 407 var arg_format = "foo"; | 442 var arg_format = "foo"; |
| 408 var arg_source = "foo"; | 443 var arg_source = "foo"; |
| 409 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | 444 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| 410 var path = (req.url).path; | 445 var path = (req.url).path; |
| 411 var pathOffset = 0; | 446 var pathOffset = 0; |
| 412 var index; | 447 var index; |
| 413 var subPart; | 448 var subPart; |
| 414 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 449 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
| 415 pathOffset += 1; | 450 pathOffset += 1; |
| 416 unittest.expect(path.substring(pathOffset, pathOffset + 19), unittest.eq
uals("language/translate/")); | 451 unittest.expect(path.substring(pathOffset, pathOffset + 19), unittest.eq
uals("language/translate/")); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 438 unittest.expect(queryMap["target"].first, unittest.equals(arg_target)); | 473 unittest.expect(queryMap["target"].first, unittest.equals(arg_target)); |
| 439 unittest.expect(queryMap["cid"], unittest.equals(arg_cid)); | 474 unittest.expect(queryMap["cid"], unittest.equals(arg_cid)); |
| 440 unittest.expect(queryMap["format"].first, unittest.equals(arg_format)); | 475 unittest.expect(queryMap["format"].first, unittest.equals(arg_format)); |
| 441 unittest.expect(queryMap["source"].first, unittest.equals(arg_source)); | 476 unittest.expect(queryMap["source"].first, unittest.equals(arg_source)); |
| 442 | 477 |
| 443 | 478 |
| 444 var h = { | 479 var h = { |
| 445 "content-type" : "application/json; charset=utf-8", | 480 "content-type" : "application/json; charset=utf-8", |
| 446 }; | 481 }; |
| 447 var resp = convert.JSON.encode(buildTranslationsListResponse()); | 482 var resp = convert.JSON.encode(buildTranslationsListResponse()); |
| 448 return new async.Future.value(common_test.stringResponse(200, h, resp)); | 483 return new async.Future.value(stringResponse(200, h, resp)); |
| 449 }), true); | 484 }), true); |
| 450 res.list(arg_q, arg_target, cid: arg_cid, format: arg_format, source: arg_
source).then(unittest.expectAsync(((api.TranslationsListResponse response) { | 485 res.list(arg_q, arg_target, cid: arg_cid, format: arg_format, source: arg_
source).then(unittest.expectAsync(((api.TranslationsListResponse response) { |
| 451 checkTranslationsListResponse(response); | 486 checkTranslationsListResponse(response); |
| 452 }))); | 487 }))); |
| 453 }); | 488 }); |
| 454 | 489 |
| 455 }); | 490 }); |
| 456 | 491 |
| 457 | 492 |
| 458 } | 493 } |
| 459 | 494 |
| OLD | NEW |