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; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 } | 44 } |
45 } | 45 } |
46 } | 46 } |
47 | 47 |
48 http.StreamedResponse stringResponse( | 48 http.StreamedResponse stringResponse( |
49 core.int status, core.Map headers, core.String body) { | 49 core.int status, core.Map headers, core.String body) { |
50 var stream = new async.Stream.fromIterable([convert.UTF8.encode(body)]); | 50 var stream = new async.Stream.fromIterable([convert.UTF8.encode(body)]); |
51 return new http.StreamedResponse(stream, status, headers: headers); | 51 return new http.StreamedResponse(stream, status, headers: headers); |
52 } | 52 } |
53 | 53 |
54 buildUnnamed637() { | 54 buildUnnamed644() { |
55 var o = new core.List<api.DetectionsResource>(); | 55 var o = new core.List<api.DetectionsResource>(); |
56 o.add(buildDetectionsResource()); | 56 o.add(buildDetectionsResource()); |
57 o.add(buildDetectionsResource()); | 57 o.add(buildDetectionsResource()); |
58 return o; | 58 return o; |
59 } | 59 } |
60 | 60 |
61 checkUnnamed637(core.List<api.DetectionsResource> o) { | 61 checkUnnamed644(core.List<api.DetectionsResource> o) { |
62 unittest.expect(o, unittest.hasLength(2)); | 62 unittest.expect(o, unittest.hasLength(2)); |
63 checkDetectionsResource(o[0]); | 63 checkDetectionsResource(o[0]); |
64 checkDetectionsResource(o[1]); | 64 checkDetectionsResource(o[1]); |
65 } | 65 } |
66 | 66 |
67 core.int buildCounterDetectionsListResponse = 0; | 67 core.int buildCounterDetectionsListResponse = 0; |
68 buildDetectionsListResponse() { | 68 buildDetectionsListResponse() { |
69 var o = new api.DetectionsListResponse(); | 69 var o = new api.DetectionsListResponse(); |
70 buildCounterDetectionsListResponse++; | 70 buildCounterDetectionsListResponse++; |
71 if (buildCounterDetectionsListResponse < 3) { | 71 if (buildCounterDetectionsListResponse < 3) { |
72 o.detections = buildUnnamed637(); | 72 o.detections = buildUnnamed644(); |
73 } | 73 } |
74 buildCounterDetectionsListResponse--; | 74 buildCounterDetectionsListResponse--; |
75 return o; | 75 return o; |
76 } | 76 } |
77 | 77 |
78 checkDetectionsListResponse(api.DetectionsListResponse o) { | 78 checkDetectionsListResponse(api.DetectionsListResponse o) { |
79 buildCounterDetectionsListResponse++; | 79 buildCounterDetectionsListResponse++; |
80 if (buildCounterDetectionsListResponse < 3) { | 80 if (buildCounterDetectionsListResponse < 3) { |
81 checkUnnamed637(o.detections); | 81 checkUnnamed644(o.detections); |
82 } | 82 } |
83 buildCounterDetectionsListResponse--; | 83 buildCounterDetectionsListResponse--; |
84 } | 84 } |
85 | 85 |
86 core.int buildCounterDetectionsResourceElement = 0; | 86 core.int buildCounterDetectionsResourceElement = 0; |
87 buildDetectionsResourceElement() { | 87 buildDetectionsResourceElement() { |
88 var o = new api.DetectionsResourceElement(); | 88 var o = new api.DetectionsResourceElement(); |
89 buildCounterDetectionsResourceElement++; | 89 buildCounterDetectionsResourceElement++; |
90 if (buildCounterDetectionsResourceElement < 3) { | 90 if (buildCounterDetectionsResourceElement < 3) { |
91 o.confidence = 42.0; | 91 o.confidence = 42.0; |
(...skipping 20 matching lines...) Expand all Loading... |
112 o.add(buildDetectionsResourceElement()); | 112 o.add(buildDetectionsResourceElement()); |
113 return o; | 113 return o; |
114 } | 114 } |
115 | 115 |
116 checkDetectionsResource(api.DetectionsResource o) { | 116 checkDetectionsResource(api.DetectionsResource o) { |
117 unittest.expect(o, unittest.hasLength(2)); | 117 unittest.expect(o, unittest.hasLength(2)); |
118 checkDetectionsResourceElement(o[0]); | 118 checkDetectionsResourceElement(o[0]); |
119 checkDetectionsResourceElement(o[1]); | 119 checkDetectionsResourceElement(o[1]); |
120 } | 120 } |
121 | 121 |
122 buildUnnamed638() { | 122 buildUnnamed645() { |
123 var o = new core.List<api.LanguagesResource>(); | 123 var o = new core.List<api.LanguagesResource>(); |
124 o.add(buildLanguagesResource()); | 124 o.add(buildLanguagesResource()); |
125 o.add(buildLanguagesResource()); | 125 o.add(buildLanguagesResource()); |
126 return o; | 126 return o; |
127 } | 127 } |
128 | 128 |
129 checkUnnamed638(core.List<api.LanguagesResource> o) { | 129 checkUnnamed645(core.List<api.LanguagesResource> o) { |
130 unittest.expect(o, unittest.hasLength(2)); | 130 unittest.expect(o, unittest.hasLength(2)); |
131 checkLanguagesResource(o[0]); | 131 checkLanguagesResource(o[0]); |
132 checkLanguagesResource(o[1]); | 132 checkLanguagesResource(o[1]); |
133 } | 133 } |
134 | 134 |
135 core.int buildCounterLanguagesListResponse = 0; | 135 core.int buildCounterLanguagesListResponse = 0; |
136 buildLanguagesListResponse() { | 136 buildLanguagesListResponse() { |
137 var o = new api.LanguagesListResponse(); | 137 var o = new api.LanguagesListResponse(); |
138 buildCounterLanguagesListResponse++; | 138 buildCounterLanguagesListResponse++; |
139 if (buildCounterLanguagesListResponse < 3) { | 139 if (buildCounterLanguagesListResponse < 3) { |
140 o.languages = buildUnnamed638(); | 140 o.languages = buildUnnamed645(); |
141 } | 141 } |
142 buildCounterLanguagesListResponse--; | 142 buildCounterLanguagesListResponse--; |
143 return o; | 143 return o; |
144 } | 144 } |
145 | 145 |
146 checkLanguagesListResponse(api.LanguagesListResponse o) { | 146 checkLanguagesListResponse(api.LanguagesListResponse o) { |
147 buildCounterLanguagesListResponse++; | 147 buildCounterLanguagesListResponse++; |
148 if (buildCounterLanguagesListResponse < 3) { | 148 if (buildCounterLanguagesListResponse < 3) { |
149 checkUnnamed638(o.languages); | 149 checkUnnamed645(o.languages); |
150 } | 150 } |
151 buildCounterLanguagesListResponse--; | 151 buildCounterLanguagesListResponse--; |
152 } | 152 } |
153 | 153 |
154 core.int buildCounterLanguagesResource = 0; | 154 core.int buildCounterLanguagesResource = 0; |
155 buildLanguagesResource() { | 155 buildLanguagesResource() { |
156 var o = new api.LanguagesResource(); | 156 var o = new api.LanguagesResource(); |
157 buildCounterLanguagesResource++; | 157 buildCounterLanguagesResource++; |
158 if (buildCounterLanguagesResource < 3) { | 158 if (buildCounterLanguagesResource < 3) { |
159 o.language = "foo"; | 159 o.language = "foo"; |
160 o.name = "foo"; | 160 o.name = "foo"; |
161 } | 161 } |
162 buildCounterLanguagesResource--; | 162 buildCounterLanguagesResource--; |
163 return o; | 163 return o; |
164 } | 164 } |
165 | 165 |
166 checkLanguagesResource(api.LanguagesResource o) { | 166 checkLanguagesResource(api.LanguagesResource o) { |
167 buildCounterLanguagesResource++; | 167 buildCounterLanguagesResource++; |
168 if (buildCounterLanguagesResource < 3) { | 168 if (buildCounterLanguagesResource < 3) { |
169 unittest.expect(o.language, unittest.equals('foo')); | 169 unittest.expect(o.language, unittest.equals('foo')); |
170 unittest.expect(o.name, unittest.equals('foo')); | 170 unittest.expect(o.name, unittest.equals('foo')); |
171 } | 171 } |
172 buildCounterLanguagesResource--; | 172 buildCounterLanguagesResource--; |
173 } | 173 } |
174 | 174 |
175 buildUnnamed639() { | 175 buildUnnamed646() { |
176 var o = new core.List<api.TranslationsResource>(); | 176 var o = new core.List<api.TranslationsResource>(); |
177 o.add(buildTranslationsResource()); | 177 o.add(buildTranslationsResource()); |
178 o.add(buildTranslationsResource()); | 178 o.add(buildTranslationsResource()); |
179 return o; | 179 return o; |
180 } | 180 } |
181 | 181 |
182 checkUnnamed639(core.List<api.TranslationsResource> o) { | 182 checkUnnamed646(core.List<api.TranslationsResource> o) { |
183 unittest.expect(o, unittest.hasLength(2)); | 183 unittest.expect(o, unittest.hasLength(2)); |
184 checkTranslationsResource(o[0]); | 184 checkTranslationsResource(o[0]); |
185 checkTranslationsResource(o[1]); | 185 checkTranslationsResource(o[1]); |
186 } | 186 } |
187 | 187 |
188 core.int buildCounterTranslationsListResponse = 0; | 188 core.int buildCounterTranslationsListResponse = 0; |
189 buildTranslationsListResponse() { | 189 buildTranslationsListResponse() { |
190 var o = new api.TranslationsListResponse(); | 190 var o = new api.TranslationsListResponse(); |
191 buildCounterTranslationsListResponse++; | 191 buildCounterTranslationsListResponse++; |
192 if (buildCounterTranslationsListResponse < 3) { | 192 if (buildCounterTranslationsListResponse < 3) { |
193 o.translations = buildUnnamed639(); | 193 o.translations = buildUnnamed646(); |
194 } | 194 } |
195 buildCounterTranslationsListResponse--; | 195 buildCounterTranslationsListResponse--; |
196 return o; | 196 return o; |
197 } | 197 } |
198 | 198 |
199 checkTranslationsListResponse(api.TranslationsListResponse o) { | 199 checkTranslationsListResponse(api.TranslationsListResponse o) { |
200 buildCounterTranslationsListResponse++; | 200 buildCounterTranslationsListResponse++; |
201 if (buildCounterTranslationsListResponse < 3) { | 201 if (buildCounterTranslationsListResponse < 3) { |
202 checkUnnamed639(o.translations); | 202 checkUnnamed646(o.translations); |
203 } | 203 } |
204 buildCounterTranslationsListResponse--; | 204 buildCounterTranslationsListResponse--; |
205 } | 205 } |
206 | 206 |
207 core.int buildCounterTranslationsResource = 0; | 207 core.int buildCounterTranslationsResource = 0; |
208 buildTranslationsResource() { | 208 buildTranslationsResource() { |
209 var o = new api.TranslationsResource(); | 209 var o = new api.TranslationsResource(); |
210 buildCounterTranslationsResource++; | 210 buildCounterTranslationsResource++; |
211 if (buildCounterTranslationsResource < 3) { | 211 if (buildCounterTranslationsResource < 3) { |
212 o.detectedSourceLanguage = "foo"; | 212 o.detectedSourceLanguage = "foo"; |
213 o.translatedText = "foo"; | 213 o.translatedText = "foo"; |
214 } | 214 } |
215 buildCounterTranslationsResource--; | 215 buildCounterTranslationsResource--; |
216 return o; | 216 return o; |
217 } | 217 } |
218 | 218 |
219 checkTranslationsResource(api.TranslationsResource o) { | 219 checkTranslationsResource(api.TranslationsResource o) { |
220 buildCounterTranslationsResource++; | 220 buildCounterTranslationsResource++; |
221 if (buildCounterTranslationsResource < 3) { | 221 if (buildCounterTranslationsResource < 3) { |
222 unittest.expect(o.detectedSourceLanguage, unittest.equals('foo')); | 222 unittest.expect(o.detectedSourceLanguage, unittest.equals('foo')); |
223 unittest.expect(o.translatedText, unittest.equals('foo')); | 223 unittest.expect(o.translatedText, unittest.equals('foo')); |
224 } | 224 } |
225 buildCounterTranslationsResource--; | 225 buildCounterTranslationsResource--; |
226 } | 226 } |
227 | 227 |
228 buildUnnamed640() { | 228 buildUnnamed647() { |
229 var o = new core.List<core.String>(); | 229 var o = new core.List<core.String>(); |
230 o.add("foo"); | 230 o.add("foo"); |
231 o.add("foo"); | 231 o.add("foo"); |
232 return o; | 232 return o; |
233 } | 233 } |
234 | 234 |
235 checkUnnamed640(core.List<core.String> o) { | 235 checkUnnamed647(core.List<core.String> o) { |
236 unittest.expect(o, unittest.hasLength(2)); | 236 unittest.expect(o, unittest.hasLength(2)); |
237 unittest.expect(o[0], unittest.equals('foo')); | 237 unittest.expect(o[0], unittest.equals('foo')); |
238 unittest.expect(o[1], unittest.equals('foo')); | 238 unittest.expect(o[1], unittest.equals('foo')); |
239 } | 239 } |
240 | 240 |
241 buildUnnamed641() { | 241 buildUnnamed648() { |
242 var o = new core.List<core.String>(); | 242 var o = new core.List<core.String>(); |
243 o.add("foo"); | 243 o.add("foo"); |
244 o.add("foo"); | 244 o.add("foo"); |
245 return o; | 245 return o; |
246 } | 246 } |
247 | 247 |
248 checkUnnamed641(core.List<core.String> o) { | 248 checkUnnamed648(core.List<core.String> o) { |
249 unittest.expect(o, unittest.hasLength(2)); | 249 unittest.expect(o, unittest.hasLength(2)); |
250 unittest.expect(o[0], unittest.equals('foo')); | 250 unittest.expect(o[0], unittest.equals('foo')); |
251 unittest.expect(o[1], unittest.equals('foo')); | 251 unittest.expect(o[1], unittest.equals('foo')); |
252 } | 252 } |
253 | 253 |
254 buildUnnamed642() { | 254 buildUnnamed649() { |
255 var o = new core.List<core.String>(); | 255 var o = new core.List<core.String>(); |
256 o.add("foo"); | 256 o.add("foo"); |
257 o.add("foo"); | 257 o.add("foo"); |
258 return o; | 258 return o; |
259 } | 259 } |
260 | 260 |
261 checkUnnamed642(core.List<core.String> o) { | 261 checkUnnamed649(core.List<core.String> o) { |
262 unittest.expect(o, unittest.hasLength(2)); | 262 unittest.expect(o, unittest.hasLength(2)); |
263 unittest.expect(o[0], unittest.equals('foo')); | 263 unittest.expect(o[0], unittest.equals('foo')); |
264 unittest.expect(o[1], unittest.equals('foo')); | 264 unittest.expect(o[1], unittest.equals('foo')); |
265 } | 265 } |
266 | 266 |
267 | 267 |
268 main() { | 268 main() { |
269 unittest.group("obj-schema-DetectionsListResponse", () { | 269 unittest.group("obj-schema-DetectionsListResponse", () { |
270 unittest.test("to-json--from-json", () { | 270 unittest.test("to-json--from-json", () { |
271 var o = buildDetectionsListResponse(); | 271 var o = buildDetectionsListResponse(); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 checkTranslationsResource(od); | 327 checkTranslationsResource(od); |
328 }); | 328 }); |
329 }); | 329 }); |
330 | 330 |
331 | 331 |
332 unittest.group("resource-DetectionsResourceApi", () { | 332 unittest.group("resource-DetectionsResourceApi", () { |
333 unittest.test("method--list", () { | 333 unittest.test("method--list", () { |
334 | 334 |
335 var mock = new HttpServerMock(); | 335 var mock = new HttpServerMock(); |
336 api.DetectionsResourceApi res = new api.TranslateApi(mock).detections; | 336 api.DetectionsResourceApi res = new api.TranslateApi(mock).detections; |
337 var arg_q = buildUnnamed640(); | 337 var arg_q = buildUnnamed647(); |
338 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | 338 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
339 var path = (req.url).path; | 339 var path = (req.url).path; |
340 var pathOffset = 0; | 340 var pathOffset = 0; |
341 var index; | 341 var index; |
342 var subPart; | 342 var subPart; |
343 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 343 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
344 pathOffset += 1; | 344 pathOffset += 1; |
345 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/")); |
346 pathOffset += 19; | 346 pathOffset += 19; |
347 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 }); | 429 }); |
430 | 430 |
431 }); | 431 }); |
432 | 432 |
433 | 433 |
434 unittest.group("resource-TranslationsResourceApi", () { | 434 unittest.group("resource-TranslationsResourceApi", () { |
435 unittest.test("method--list", () { | 435 unittest.test("method--list", () { |
436 | 436 |
437 var mock = new HttpServerMock(); | 437 var mock = new HttpServerMock(); |
438 api.TranslationsResourceApi res = new api.TranslateApi(mock).translations; | 438 api.TranslationsResourceApi res = new api.TranslateApi(mock).translations; |
439 var arg_q = buildUnnamed641(); | 439 var arg_q = buildUnnamed648(); |
440 var arg_target = "foo"; | 440 var arg_target = "foo"; |
441 var arg_cid = buildUnnamed642(); | 441 var arg_cid = buildUnnamed649(); |
442 var arg_format = "foo"; | 442 var arg_format = "foo"; |
443 var arg_source = "foo"; | 443 var arg_source = "foo"; |
444 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | 444 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
445 var path = (req.url).path; | 445 var path = (req.url).path; |
446 var pathOffset = 0; | 446 var pathOffset = 0; |
447 var index; | 447 var index; |
448 var subPart; | 448 var subPart; |
449 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 449 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
450 pathOffset += 1; | 450 pathOffset += 1; |
451 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 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) { |
486 checkTranslationsListResponse(response); | 486 checkTranslationsListResponse(response); |
487 }))); | 487 }))); |
488 }); | 488 }); |
489 | 489 |
490 }); | 490 }); |
491 | 491 |
492 | 492 |
493 } | 493 } |
494 | 494 |
OLD | NEW |