OLD | NEW |
1 library googleapis_beta.speech.v1beta1.test; | 1 library googleapis_beta.speech.v1beta1.test; |
2 | 2 |
3 import "dart:core" as core; | 3 import "dart:core" as core; |
4 import "dart:collection" as collection; | |
5 import "dart:async" as async; | 4 import "dart:async" as async; |
6 import "dart:convert" as convert; | 5 import "dart:convert" as convert; |
7 | 6 |
8 import 'package:http/http.dart' as http; | 7 import 'package:http/http.dart' as http; |
9 import 'package:http/testing.dart' as http_testing; | |
10 import 'package:test/test.dart' as unittest; | 8 import 'package:test/test.dart' as unittest; |
11 | 9 |
12 import 'package:googleapis_beta/speech/v1beta1.dart' as api; | 10 import 'package:googleapis_beta/speech/v1beta1.dart' as api; |
13 | 11 |
14 class HttpServerMock extends http.BaseClient { | 12 class HttpServerMock extends http.BaseClient { |
15 core.Function _callback; | 13 core.Function _callback; |
16 core.bool _expectJson; | 14 core.bool _expectJson; |
17 | 15 |
18 void register(core.Function callback, core.bool expectJson) { | 16 void register(core.Function callback, core.bool expectJson) { |
19 _callback = callback; | 17 _callback = callback; |
20 _expectJson = expectJson; | 18 _expectJson = expectJson; |
21 } | 19 } |
22 | 20 |
23 async.Future<http.StreamedResponse> send(http.BaseRequest request) { | 21 async.Future<http.StreamedResponse> send(http.BaseRequest request) { |
24 if (_expectJson) { | 22 if (_expectJson) { |
25 return request.finalize() | 23 return request |
| 24 .finalize() |
26 .transform(convert.UTF8.decoder) | 25 .transform(convert.UTF8.decoder) |
27 .join('') | 26 .join('') |
28 .then((core.String jsonString) { | 27 .then((core.String jsonString) { |
29 if (jsonString.isEmpty) { | 28 if (jsonString.isEmpty) { |
30 return _callback(request, null); | 29 return _callback(request, null); |
31 } else { | 30 } else { |
32 return _callback(request, convert.JSON.decode(jsonString)); | 31 return _callback(request, convert.JSON.decode(jsonString)); |
33 } | 32 } |
34 }); | 33 }); |
35 } else { | 34 } else { |
36 var stream = request.finalize(); | 35 var stream = request.finalize(); |
37 if (stream == null) { | 36 if (stream == null) { |
38 return _callback(request, []); | 37 return _callback(request, []); |
39 } else { | 38 } else { |
40 return stream.toBytes().then((data) { | 39 return stream.toBytes().then((data) { |
41 return _callback(request, data); | 40 return _callback(request, data); |
42 }); | 41 }); |
43 } | 42 } |
44 } | 43 } |
45 } | 44 } |
46 } | 45 } |
47 | 46 |
48 http.StreamedResponse stringResponse( | 47 http.StreamedResponse stringResponse(core.int status, |
49 core.int status, core.Map<core.String, core.String> headers, core.String bod
y) { | 48 core.Map<core.String, core.String> headers, core.String body) { |
50 var stream = new async.Stream.fromIterable([convert.UTF8.encode(body)]); | 49 var stream = new async.Stream.fromIterable([convert.UTF8.encode(body)]); |
51 return new http.StreamedResponse(stream, status, headers: headers); | 50 return new http.StreamedResponse(stream, status, headers: headers); |
52 } | 51 } |
53 | 52 |
54 core.int buildCounterAsyncRecognizeRequest = 0; | 53 core.int buildCounterAsyncRecognizeRequest = 0; |
55 buildAsyncRecognizeRequest() { | 54 buildAsyncRecognizeRequest() { |
56 var o = new api.AsyncRecognizeRequest(); | 55 var o = new api.AsyncRecognizeRequest(); |
57 buildCounterAsyncRecognizeRequest++; | 56 buildCounterAsyncRecognizeRequest++; |
58 if (buildCounterAsyncRecognizeRequest < 3) { | 57 if (buildCounterAsyncRecognizeRequest < 3) { |
59 o.audio = buildRecognitionAudio(); | 58 o.audio = buildRecognitionAudio(); |
60 o.config = buildRecognitionConfig(); | 59 o.config = buildRecognitionConfig(); |
61 } | 60 } |
62 buildCounterAsyncRecognizeRequest--; | 61 buildCounterAsyncRecognizeRequest--; |
63 return o; | 62 return o; |
64 } | 63 } |
65 | 64 |
66 checkAsyncRecognizeRequest(api.AsyncRecognizeRequest o) { | 65 checkAsyncRecognizeRequest(api.AsyncRecognizeRequest o) { |
67 buildCounterAsyncRecognizeRequest++; | 66 buildCounterAsyncRecognizeRequest++; |
68 if (buildCounterAsyncRecognizeRequest < 3) { | 67 if (buildCounterAsyncRecognizeRequest < 3) { |
69 checkRecognitionAudio(o.audio); | 68 checkRecognitionAudio(o.audio); |
70 checkRecognitionConfig(o.config); | 69 checkRecognitionConfig(o.config); |
71 } | 70 } |
72 buildCounterAsyncRecognizeRequest--; | 71 buildCounterAsyncRecognizeRequest--; |
73 } | 72 } |
74 | 73 |
75 core.int buildCounterEmpty = 0; | 74 core.int buildCounterEmpty = 0; |
76 buildEmpty() { | 75 buildEmpty() { |
77 var o = new api.Empty(); | 76 var o = new api.Empty(); |
78 buildCounterEmpty++; | 77 buildCounterEmpty++; |
79 if (buildCounterEmpty < 3) { | 78 if (buildCounterEmpty < 3) {} |
80 } | |
81 buildCounterEmpty--; | 79 buildCounterEmpty--; |
82 return o; | 80 return o; |
83 } | 81 } |
84 | 82 |
85 checkEmpty(api.Empty o) { | 83 checkEmpty(api.Empty o) { |
86 buildCounterEmpty++; | 84 buildCounterEmpty++; |
87 if (buildCounterEmpty < 3) { | 85 if (buildCounterEmpty < 3) {} |
88 } | |
89 buildCounterEmpty--; | 86 buildCounterEmpty--; |
90 } | 87 } |
91 | 88 |
92 buildUnnamed3416() { | 89 buildUnnamed3421() { |
93 var o = new core.List<api.Operation>(); | 90 var o = new core.List<api.Operation>(); |
94 o.add(buildOperation()); | 91 o.add(buildOperation()); |
95 o.add(buildOperation()); | 92 o.add(buildOperation()); |
96 return o; | 93 return o; |
97 } | 94 } |
98 | 95 |
99 checkUnnamed3416(core.List<api.Operation> o) { | 96 checkUnnamed3421(core.List<api.Operation> o) { |
100 unittest.expect(o, unittest.hasLength(2)); | 97 unittest.expect(o, unittest.hasLength(2)); |
101 checkOperation(o[0]); | 98 checkOperation(o[0]); |
102 checkOperation(o[1]); | 99 checkOperation(o[1]); |
103 } | 100 } |
104 | 101 |
105 core.int buildCounterListOperationsResponse = 0; | 102 core.int buildCounterListOperationsResponse = 0; |
106 buildListOperationsResponse() { | 103 buildListOperationsResponse() { |
107 var o = new api.ListOperationsResponse(); | 104 var o = new api.ListOperationsResponse(); |
108 buildCounterListOperationsResponse++; | 105 buildCounterListOperationsResponse++; |
109 if (buildCounterListOperationsResponse < 3) { | 106 if (buildCounterListOperationsResponse < 3) { |
110 o.nextPageToken = "foo"; | 107 o.nextPageToken = "foo"; |
111 o.operations = buildUnnamed3416(); | 108 o.operations = buildUnnamed3421(); |
112 } | 109 } |
113 buildCounterListOperationsResponse--; | 110 buildCounterListOperationsResponse--; |
114 return o; | 111 return o; |
115 } | 112 } |
116 | 113 |
117 checkListOperationsResponse(api.ListOperationsResponse o) { | 114 checkListOperationsResponse(api.ListOperationsResponse o) { |
118 buildCounterListOperationsResponse++; | 115 buildCounterListOperationsResponse++; |
119 if (buildCounterListOperationsResponse < 3) { | 116 if (buildCounterListOperationsResponse < 3) { |
120 unittest.expect(o.nextPageToken, unittest.equals('foo')); | 117 unittest.expect(o.nextPageToken, unittest.equals('foo')); |
121 checkUnnamed3416(o.operations); | 118 checkUnnamed3421(o.operations); |
122 } | 119 } |
123 buildCounterListOperationsResponse--; | 120 buildCounterListOperationsResponse--; |
124 } | 121 } |
125 | 122 |
126 buildUnnamed3417() { | 123 buildUnnamed3422() { |
127 var o = new core.Map<core.String, core.Object>(); | 124 var o = new core.Map<core.String, core.Object>(); |
128 o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; | 125 o["x"] = { |
129 o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; | 126 'list': [1, 2, 3], |
| 127 'bool': true, |
| 128 'string': 'foo' |
| 129 }; |
| 130 o["y"] = { |
| 131 'list': [1, 2, 3], |
| 132 'bool': true, |
| 133 'string': 'foo' |
| 134 }; |
130 return o; | 135 return o; |
131 } | 136 } |
132 | 137 |
133 checkUnnamed3417(core.Map<core.String, core.Object> o) { | 138 checkUnnamed3422(core.Map<core.String, core.Object> o) { |
134 unittest.expect(o, unittest.hasLength(2)); | 139 unittest.expect(o, unittest.hasLength(2)); |
135 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')); | 140 var casted1 = (o["x"]) as core.Map; |
136 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')); | 141 unittest.expect(casted1, unittest.hasLength(3)); |
| 142 unittest.expect(casted1["list"], unittest.equals([1, 2, 3])); |
| 143 unittest.expect(casted1["bool"], unittest.equals(true)); |
| 144 unittest.expect(casted1["string"], unittest.equals('foo')); |
| 145 var casted2 = (o["y"]) as core.Map; |
| 146 unittest.expect(casted2, unittest.hasLength(3)); |
| 147 unittest.expect(casted2["list"], unittest.equals([1, 2, 3])); |
| 148 unittest.expect(casted2["bool"], unittest.equals(true)); |
| 149 unittest.expect(casted2["string"], unittest.equals('foo')); |
137 } | 150 } |
138 | 151 |
139 buildUnnamed3418() { | 152 buildUnnamed3423() { |
140 var o = new core.Map<core.String, core.Object>(); | 153 var o = new core.Map<core.String, core.Object>(); |
141 o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; | 154 o["x"] = { |
142 o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; | 155 'list': [1, 2, 3], |
| 156 'bool': true, |
| 157 'string': 'foo' |
| 158 }; |
| 159 o["y"] = { |
| 160 'list': [1, 2, 3], |
| 161 'bool': true, |
| 162 'string': 'foo' |
| 163 }; |
143 return o; | 164 return o; |
144 } | 165 } |
145 | 166 |
146 checkUnnamed3418(core.Map<core.String, core.Object> o) { | 167 checkUnnamed3423(core.Map<core.String, core.Object> o) { |
147 unittest.expect(o, unittest.hasLength(2)); | 168 unittest.expect(o, unittest.hasLength(2)); |
148 var casted3 = (o["x"]) as core.Map; unittest.expect(casted3, unittest.hasLengt
h(3)); unittest.expect(casted3["list"], unittest.equals([1, 2, 3])); unittest.ex
pect(casted3["bool"], unittest.equals(true)); unittest.expect(casted3["string"],
unittest.equals('foo')); | 169 var casted3 = (o["x"]) as core.Map; |
149 var casted4 = (o["y"]) as core.Map; unittest.expect(casted4, unittest.hasLengt
h(3)); unittest.expect(casted4["list"], unittest.equals([1, 2, 3])); unittest.ex
pect(casted4["bool"], unittest.equals(true)); unittest.expect(casted4["string"],
unittest.equals('foo')); | 170 unittest.expect(casted3, unittest.hasLength(3)); |
| 171 unittest.expect(casted3["list"], unittest.equals([1, 2, 3])); |
| 172 unittest.expect(casted3["bool"], unittest.equals(true)); |
| 173 unittest.expect(casted3["string"], unittest.equals('foo')); |
| 174 var casted4 = (o["y"]) as core.Map; |
| 175 unittest.expect(casted4, unittest.hasLength(3)); |
| 176 unittest.expect(casted4["list"], unittest.equals([1, 2, 3])); |
| 177 unittest.expect(casted4["bool"], unittest.equals(true)); |
| 178 unittest.expect(casted4["string"], unittest.equals('foo')); |
150 } | 179 } |
151 | 180 |
152 core.int buildCounterOperation = 0; | 181 core.int buildCounterOperation = 0; |
153 buildOperation() { | 182 buildOperation() { |
154 var o = new api.Operation(); | 183 var o = new api.Operation(); |
155 buildCounterOperation++; | 184 buildCounterOperation++; |
156 if (buildCounterOperation < 3) { | 185 if (buildCounterOperation < 3) { |
157 o.done = true; | 186 o.done = true; |
158 o.error = buildStatus(); | 187 o.error = buildStatus(); |
159 o.metadata = buildUnnamed3417(); | 188 o.metadata = buildUnnamed3422(); |
160 o.name = "foo"; | 189 o.name = "foo"; |
161 o.response = buildUnnamed3418(); | 190 o.response = buildUnnamed3423(); |
162 } | 191 } |
163 buildCounterOperation--; | 192 buildCounterOperation--; |
164 return o; | 193 return o; |
165 } | 194 } |
166 | 195 |
167 checkOperation(api.Operation o) { | 196 checkOperation(api.Operation o) { |
168 buildCounterOperation++; | 197 buildCounterOperation++; |
169 if (buildCounterOperation < 3) { | 198 if (buildCounterOperation < 3) { |
170 unittest.expect(o.done, unittest.isTrue); | 199 unittest.expect(o.done, unittest.isTrue); |
171 checkStatus(o.error); | 200 checkStatus(o.error); |
172 checkUnnamed3417(o.metadata); | 201 checkUnnamed3422(o.metadata); |
173 unittest.expect(o.name, unittest.equals('foo')); | 202 unittest.expect(o.name, unittest.equals('foo')); |
174 checkUnnamed3418(o.response); | 203 checkUnnamed3423(o.response); |
175 } | 204 } |
176 buildCounterOperation--; | 205 buildCounterOperation--; |
177 } | 206 } |
178 | 207 |
179 core.int buildCounterRecognitionAudio = 0; | 208 core.int buildCounterRecognitionAudio = 0; |
180 buildRecognitionAudio() { | 209 buildRecognitionAudio() { |
181 var o = new api.RecognitionAudio(); | 210 var o = new api.RecognitionAudio(); |
182 buildCounterRecognitionAudio++; | 211 buildCounterRecognitionAudio++; |
183 if (buildCounterRecognitionAudio < 3) { | 212 if (buildCounterRecognitionAudio < 3) { |
184 o.content = "foo"; | 213 o.content = "foo"; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 unittest.expect(o.encoding, unittest.equals('foo')); | 248 unittest.expect(o.encoding, unittest.equals('foo')); |
220 unittest.expect(o.languageCode, unittest.equals('foo')); | 249 unittest.expect(o.languageCode, unittest.equals('foo')); |
221 unittest.expect(o.maxAlternatives, unittest.equals(42)); | 250 unittest.expect(o.maxAlternatives, unittest.equals(42)); |
222 unittest.expect(o.profanityFilter, unittest.isTrue); | 251 unittest.expect(o.profanityFilter, unittest.isTrue); |
223 unittest.expect(o.sampleRate, unittest.equals(42)); | 252 unittest.expect(o.sampleRate, unittest.equals(42)); |
224 checkSpeechContext(o.speechContext); | 253 checkSpeechContext(o.speechContext); |
225 } | 254 } |
226 buildCounterRecognitionConfig--; | 255 buildCounterRecognitionConfig--; |
227 } | 256 } |
228 | 257 |
229 buildUnnamed3419() { | 258 buildUnnamed3424() { |
230 var o = new core.List<core.String>(); | 259 var o = new core.List<core.String>(); |
231 o.add("foo"); | 260 o.add("foo"); |
232 o.add("foo"); | 261 o.add("foo"); |
233 return o; | 262 return o; |
234 } | 263 } |
235 | 264 |
236 checkUnnamed3419(core.List<core.String> o) { | 265 checkUnnamed3424(core.List<core.String> o) { |
237 unittest.expect(o, unittest.hasLength(2)); | 266 unittest.expect(o, unittest.hasLength(2)); |
238 unittest.expect(o[0], unittest.equals('foo')); | 267 unittest.expect(o[0], unittest.equals('foo')); |
239 unittest.expect(o[1], unittest.equals('foo')); | 268 unittest.expect(o[1], unittest.equals('foo')); |
240 } | 269 } |
241 | 270 |
242 core.int buildCounterSpeechContext = 0; | 271 core.int buildCounterSpeechContext = 0; |
243 buildSpeechContext() { | 272 buildSpeechContext() { |
244 var o = new api.SpeechContext(); | 273 var o = new api.SpeechContext(); |
245 buildCounterSpeechContext++; | 274 buildCounterSpeechContext++; |
246 if (buildCounterSpeechContext < 3) { | 275 if (buildCounterSpeechContext < 3) { |
247 o.phrases = buildUnnamed3419(); | 276 o.phrases = buildUnnamed3424(); |
248 } | 277 } |
249 buildCounterSpeechContext--; | 278 buildCounterSpeechContext--; |
250 return o; | 279 return o; |
251 } | 280 } |
252 | 281 |
253 checkSpeechContext(api.SpeechContext o) { | 282 checkSpeechContext(api.SpeechContext o) { |
254 buildCounterSpeechContext++; | 283 buildCounterSpeechContext++; |
255 if (buildCounterSpeechContext < 3) { | 284 if (buildCounterSpeechContext < 3) { |
256 checkUnnamed3419(o.phrases); | 285 checkUnnamed3424(o.phrases); |
257 } | 286 } |
258 buildCounterSpeechContext--; | 287 buildCounterSpeechContext--; |
259 } | 288 } |
260 | 289 |
261 core.int buildCounterSpeechRecognitionAlternative = 0; | 290 core.int buildCounterSpeechRecognitionAlternative = 0; |
262 buildSpeechRecognitionAlternative() { | 291 buildSpeechRecognitionAlternative() { |
263 var o = new api.SpeechRecognitionAlternative(); | 292 var o = new api.SpeechRecognitionAlternative(); |
264 buildCounterSpeechRecognitionAlternative++; | 293 buildCounterSpeechRecognitionAlternative++; |
265 if (buildCounterSpeechRecognitionAlternative < 3) { | 294 if (buildCounterSpeechRecognitionAlternative < 3) { |
266 o.confidence = 42.0; | 295 o.confidence = 42.0; |
267 o.transcript = "foo"; | 296 o.transcript = "foo"; |
268 } | 297 } |
269 buildCounterSpeechRecognitionAlternative--; | 298 buildCounterSpeechRecognitionAlternative--; |
270 return o; | 299 return o; |
271 } | 300 } |
272 | 301 |
273 checkSpeechRecognitionAlternative(api.SpeechRecognitionAlternative o) { | 302 checkSpeechRecognitionAlternative(api.SpeechRecognitionAlternative o) { |
274 buildCounterSpeechRecognitionAlternative++; | 303 buildCounterSpeechRecognitionAlternative++; |
275 if (buildCounterSpeechRecognitionAlternative < 3) { | 304 if (buildCounterSpeechRecognitionAlternative < 3) { |
276 unittest.expect(o.confidence, unittest.equals(42.0)); | 305 unittest.expect(o.confidence, unittest.equals(42.0)); |
277 unittest.expect(o.transcript, unittest.equals('foo')); | 306 unittest.expect(o.transcript, unittest.equals('foo')); |
278 } | 307 } |
279 buildCounterSpeechRecognitionAlternative--; | 308 buildCounterSpeechRecognitionAlternative--; |
280 } | 309 } |
281 | 310 |
282 buildUnnamed3420() { | 311 buildUnnamed3425() { |
283 var o = new core.List<api.SpeechRecognitionAlternative>(); | 312 var o = new core.List<api.SpeechRecognitionAlternative>(); |
284 o.add(buildSpeechRecognitionAlternative()); | 313 o.add(buildSpeechRecognitionAlternative()); |
285 o.add(buildSpeechRecognitionAlternative()); | 314 o.add(buildSpeechRecognitionAlternative()); |
286 return o; | 315 return o; |
287 } | 316 } |
288 | 317 |
289 checkUnnamed3420(core.List<api.SpeechRecognitionAlternative> o) { | 318 checkUnnamed3425(core.List<api.SpeechRecognitionAlternative> o) { |
290 unittest.expect(o, unittest.hasLength(2)); | 319 unittest.expect(o, unittest.hasLength(2)); |
291 checkSpeechRecognitionAlternative(o[0]); | 320 checkSpeechRecognitionAlternative(o[0]); |
292 checkSpeechRecognitionAlternative(o[1]); | 321 checkSpeechRecognitionAlternative(o[1]); |
293 } | 322 } |
294 | 323 |
295 core.int buildCounterSpeechRecognitionResult = 0; | 324 core.int buildCounterSpeechRecognitionResult = 0; |
296 buildSpeechRecognitionResult() { | 325 buildSpeechRecognitionResult() { |
297 var o = new api.SpeechRecognitionResult(); | 326 var o = new api.SpeechRecognitionResult(); |
298 buildCounterSpeechRecognitionResult++; | 327 buildCounterSpeechRecognitionResult++; |
299 if (buildCounterSpeechRecognitionResult < 3) { | 328 if (buildCounterSpeechRecognitionResult < 3) { |
300 o.alternatives = buildUnnamed3420(); | 329 o.alternatives = buildUnnamed3425(); |
301 } | 330 } |
302 buildCounterSpeechRecognitionResult--; | 331 buildCounterSpeechRecognitionResult--; |
303 return o; | 332 return o; |
304 } | 333 } |
305 | 334 |
306 checkSpeechRecognitionResult(api.SpeechRecognitionResult o) { | 335 checkSpeechRecognitionResult(api.SpeechRecognitionResult o) { |
307 buildCounterSpeechRecognitionResult++; | 336 buildCounterSpeechRecognitionResult++; |
308 if (buildCounterSpeechRecognitionResult < 3) { | 337 if (buildCounterSpeechRecognitionResult < 3) { |
309 checkUnnamed3420(o.alternatives); | 338 checkUnnamed3425(o.alternatives); |
310 } | 339 } |
311 buildCounterSpeechRecognitionResult--; | 340 buildCounterSpeechRecognitionResult--; |
312 } | 341 } |
313 | 342 |
314 buildUnnamed3421() { | 343 buildUnnamed3426() { |
315 var o = new core.Map<core.String, core.Object>(); | 344 var o = new core.Map<core.String, core.Object>(); |
316 o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; | 345 o["x"] = { |
317 o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; | 346 'list': [1, 2, 3], |
| 347 'bool': true, |
| 348 'string': 'foo' |
| 349 }; |
| 350 o["y"] = { |
| 351 'list': [1, 2, 3], |
| 352 'bool': true, |
| 353 'string': 'foo' |
| 354 }; |
318 return o; | 355 return o; |
319 } | 356 } |
320 | 357 |
321 checkUnnamed3421(core.Map<core.String, core.Object> o) { | 358 checkUnnamed3426(core.Map<core.String, core.Object> o) { |
322 unittest.expect(o, unittest.hasLength(2)); | 359 unittest.expect(o, unittest.hasLength(2)); |
323 var casted5 = (o["x"]) as core.Map; unittest.expect(casted5, unittest.hasLengt
h(3)); unittest.expect(casted5["list"], unittest.equals([1, 2, 3])); unittest.ex
pect(casted5["bool"], unittest.equals(true)); unittest.expect(casted5["string"],
unittest.equals('foo')); | 360 var casted5 = (o["x"]) as core.Map; |
324 var casted6 = (o["y"]) as core.Map; unittest.expect(casted6, unittest.hasLengt
h(3)); unittest.expect(casted6["list"], unittest.equals([1, 2, 3])); unittest.ex
pect(casted6["bool"], unittest.equals(true)); unittest.expect(casted6["string"],
unittest.equals('foo')); | 361 unittest.expect(casted5, unittest.hasLength(3)); |
| 362 unittest.expect(casted5["list"], unittest.equals([1, 2, 3])); |
| 363 unittest.expect(casted5["bool"], unittest.equals(true)); |
| 364 unittest.expect(casted5["string"], unittest.equals('foo')); |
| 365 var casted6 = (o["y"]) as core.Map; |
| 366 unittest.expect(casted6, unittest.hasLength(3)); |
| 367 unittest.expect(casted6["list"], unittest.equals([1, 2, 3])); |
| 368 unittest.expect(casted6["bool"], unittest.equals(true)); |
| 369 unittest.expect(casted6["string"], unittest.equals('foo')); |
325 } | 370 } |
326 | 371 |
327 buildUnnamed3422() { | 372 buildUnnamed3427() { |
328 var o = new core.List<core.Map<core.String, core.Object>>(); | 373 var o = new core.List<core.Map<core.String, core.Object>>(); |
329 o.add(buildUnnamed3421()); | 374 o.add(buildUnnamed3426()); |
330 o.add(buildUnnamed3421()); | 375 o.add(buildUnnamed3426()); |
331 return o; | 376 return o; |
332 } | 377 } |
333 | 378 |
334 checkUnnamed3422(core.List<core.Map<core.String, core.Object>> o) { | 379 checkUnnamed3427(core.List<core.Map<core.String, core.Object>> o) { |
335 unittest.expect(o, unittest.hasLength(2)); | 380 unittest.expect(o, unittest.hasLength(2)); |
336 checkUnnamed3421(o[0]); | 381 checkUnnamed3426(o[0]); |
337 checkUnnamed3421(o[1]); | 382 checkUnnamed3426(o[1]); |
338 } | 383 } |
339 | 384 |
340 core.int buildCounterStatus = 0; | 385 core.int buildCounterStatus = 0; |
341 buildStatus() { | 386 buildStatus() { |
342 var o = new api.Status(); | 387 var o = new api.Status(); |
343 buildCounterStatus++; | 388 buildCounterStatus++; |
344 if (buildCounterStatus < 3) { | 389 if (buildCounterStatus < 3) { |
345 o.code = 42; | 390 o.code = 42; |
346 o.details = buildUnnamed3422(); | 391 o.details = buildUnnamed3427(); |
347 o.message = "foo"; | 392 o.message = "foo"; |
348 } | 393 } |
349 buildCounterStatus--; | 394 buildCounterStatus--; |
350 return o; | 395 return o; |
351 } | 396 } |
352 | 397 |
353 checkStatus(api.Status o) { | 398 checkStatus(api.Status o) { |
354 buildCounterStatus++; | 399 buildCounterStatus++; |
355 if (buildCounterStatus < 3) { | 400 if (buildCounterStatus < 3) { |
356 unittest.expect(o.code, unittest.equals(42)); | 401 unittest.expect(o.code, unittest.equals(42)); |
357 checkUnnamed3422(o.details); | 402 checkUnnamed3427(o.details); |
358 unittest.expect(o.message, unittest.equals('foo')); | 403 unittest.expect(o.message, unittest.equals('foo')); |
359 } | 404 } |
360 buildCounterStatus--; | 405 buildCounterStatus--; |
361 } | 406 } |
362 | 407 |
363 core.int buildCounterSyncRecognizeRequest = 0; | 408 core.int buildCounterSyncRecognizeRequest = 0; |
364 buildSyncRecognizeRequest() { | 409 buildSyncRecognizeRequest() { |
365 var o = new api.SyncRecognizeRequest(); | 410 var o = new api.SyncRecognizeRequest(); |
366 buildCounterSyncRecognizeRequest++; | 411 buildCounterSyncRecognizeRequest++; |
367 if (buildCounterSyncRecognizeRequest < 3) { | 412 if (buildCounterSyncRecognizeRequest < 3) { |
368 o.audio = buildRecognitionAudio(); | 413 o.audio = buildRecognitionAudio(); |
369 o.config = buildRecognitionConfig(); | 414 o.config = buildRecognitionConfig(); |
370 } | 415 } |
371 buildCounterSyncRecognizeRequest--; | 416 buildCounterSyncRecognizeRequest--; |
372 return o; | 417 return o; |
373 } | 418 } |
374 | 419 |
375 checkSyncRecognizeRequest(api.SyncRecognizeRequest o) { | 420 checkSyncRecognizeRequest(api.SyncRecognizeRequest o) { |
376 buildCounterSyncRecognizeRequest++; | 421 buildCounterSyncRecognizeRequest++; |
377 if (buildCounterSyncRecognizeRequest < 3) { | 422 if (buildCounterSyncRecognizeRequest < 3) { |
378 checkRecognitionAudio(o.audio); | 423 checkRecognitionAudio(o.audio); |
379 checkRecognitionConfig(o.config); | 424 checkRecognitionConfig(o.config); |
380 } | 425 } |
381 buildCounterSyncRecognizeRequest--; | 426 buildCounterSyncRecognizeRequest--; |
382 } | 427 } |
383 | 428 |
384 buildUnnamed3423() { | 429 buildUnnamed3428() { |
385 var o = new core.List<api.SpeechRecognitionResult>(); | 430 var o = new core.List<api.SpeechRecognitionResult>(); |
386 o.add(buildSpeechRecognitionResult()); | 431 o.add(buildSpeechRecognitionResult()); |
387 o.add(buildSpeechRecognitionResult()); | 432 o.add(buildSpeechRecognitionResult()); |
388 return o; | 433 return o; |
389 } | 434 } |
390 | 435 |
391 checkUnnamed3423(core.List<api.SpeechRecognitionResult> o) { | 436 checkUnnamed3428(core.List<api.SpeechRecognitionResult> o) { |
392 unittest.expect(o, unittest.hasLength(2)); | 437 unittest.expect(o, unittest.hasLength(2)); |
393 checkSpeechRecognitionResult(o[0]); | 438 checkSpeechRecognitionResult(o[0]); |
394 checkSpeechRecognitionResult(o[1]); | 439 checkSpeechRecognitionResult(o[1]); |
395 } | 440 } |
396 | 441 |
397 core.int buildCounterSyncRecognizeResponse = 0; | 442 core.int buildCounterSyncRecognizeResponse = 0; |
398 buildSyncRecognizeResponse() { | 443 buildSyncRecognizeResponse() { |
399 var o = new api.SyncRecognizeResponse(); | 444 var o = new api.SyncRecognizeResponse(); |
400 buildCounterSyncRecognizeResponse++; | 445 buildCounterSyncRecognizeResponse++; |
401 if (buildCounterSyncRecognizeResponse < 3) { | 446 if (buildCounterSyncRecognizeResponse < 3) { |
402 o.results = buildUnnamed3423(); | 447 o.results = buildUnnamed3428(); |
403 } | 448 } |
404 buildCounterSyncRecognizeResponse--; | 449 buildCounterSyncRecognizeResponse--; |
405 return o; | 450 return o; |
406 } | 451 } |
407 | 452 |
408 checkSyncRecognizeResponse(api.SyncRecognizeResponse o) { | 453 checkSyncRecognizeResponse(api.SyncRecognizeResponse o) { |
409 buildCounterSyncRecognizeResponse++; | 454 buildCounterSyncRecognizeResponse++; |
410 if (buildCounterSyncRecognizeResponse < 3) { | 455 if (buildCounterSyncRecognizeResponse < 3) { |
411 checkUnnamed3423(o.results); | 456 checkUnnamed3428(o.results); |
412 } | 457 } |
413 buildCounterSyncRecognizeResponse--; | 458 buildCounterSyncRecognizeResponse--; |
414 } | 459 } |
415 | 460 |
416 | |
417 main() { | 461 main() { |
418 unittest.group("obj-schema-AsyncRecognizeRequest", () { | 462 unittest.group("obj-schema-AsyncRecognizeRequest", () { |
419 unittest.test("to-json--from-json", () { | 463 unittest.test("to-json--from-json", () { |
420 var o = buildAsyncRecognizeRequest(); | 464 var o = buildAsyncRecognizeRequest(); |
421 var od = new api.AsyncRecognizeRequest.fromJson(o.toJson()); | 465 var od = new api.AsyncRecognizeRequest.fromJson(o.toJson()); |
422 checkAsyncRecognizeRequest(od); | 466 checkAsyncRecognizeRequest(od); |
423 }); | 467 }); |
424 }); | 468 }); |
425 | 469 |
426 | |
427 unittest.group("obj-schema-Empty", () { | 470 unittest.group("obj-schema-Empty", () { |
428 unittest.test("to-json--from-json", () { | 471 unittest.test("to-json--from-json", () { |
429 var o = buildEmpty(); | 472 var o = buildEmpty(); |
430 var od = new api.Empty.fromJson(o.toJson()); | 473 var od = new api.Empty.fromJson(o.toJson()); |
431 checkEmpty(od); | 474 checkEmpty(od); |
432 }); | 475 }); |
433 }); | 476 }); |
434 | 477 |
435 | |
436 unittest.group("obj-schema-ListOperationsResponse", () { | 478 unittest.group("obj-schema-ListOperationsResponse", () { |
437 unittest.test("to-json--from-json", () { | 479 unittest.test("to-json--from-json", () { |
438 var o = buildListOperationsResponse(); | 480 var o = buildListOperationsResponse(); |
439 var od = new api.ListOperationsResponse.fromJson(o.toJson()); | 481 var od = new api.ListOperationsResponse.fromJson(o.toJson()); |
440 checkListOperationsResponse(od); | 482 checkListOperationsResponse(od); |
441 }); | 483 }); |
442 }); | 484 }); |
443 | 485 |
444 | |
445 unittest.group("obj-schema-Operation", () { | 486 unittest.group("obj-schema-Operation", () { |
446 unittest.test("to-json--from-json", () { | 487 unittest.test("to-json--from-json", () { |
447 var o = buildOperation(); | 488 var o = buildOperation(); |
448 var od = new api.Operation.fromJson(o.toJson()); | 489 var od = new api.Operation.fromJson(o.toJson()); |
449 checkOperation(od); | 490 checkOperation(od); |
450 }); | 491 }); |
451 }); | 492 }); |
452 | 493 |
453 | |
454 unittest.group("obj-schema-RecognitionAudio", () { | 494 unittest.group("obj-schema-RecognitionAudio", () { |
455 unittest.test("to-json--from-json", () { | 495 unittest.test("to-json--from-json", () { |
456 var o = buildRecognitionAudio(); | 496 var o = buildRecognitionAudio(); |
457 var od = new api.RecognitionAudio.fromJson(o.toJson()); | 497 var od = new api.RecognitionAudio.fromJson(o.toJson()); |
458 checkRecognitionAudio(od); | 498 checkRecognitionAudio(od); |
459 }); | 499 }); |
460 }); | 500 }); |
461 | 501 |
462 | |
463 unittest.group("obj-schema-RecognitionConfig", () { | 502 unittest.group("obj-schema-RecognitionConfig", () { |
464 unittest.test("to-json--from-json", () { | 503 unittest.test("to-json--from-json", () { |
465 var o = buildRecognitionConfig(); | 504 var o = buildRecognitionConfig(); |
466 var od = new api.RecognitionConfig.fromJson(o.toJson()); | 505 var od = new api.RecognitionConfig.fromJson(o.toJson()); |
467 checkRecognitionConfig(od); | 506 checkRecognitionConfig(od); |
468 }); | 507 }); |
469 }); | 508 }); |
470 | 509 |
471 | |
472 unittest.group("obj-schema-SpeechContext", () { | 510 unittest.group("obj-schema-SpeechContext", () { |
473 unittest.test("to-json--from-json", () { | 511 unittest.test("to-json--from-json", () { |
474 var o = buildSpeechContext(); | 512 var o = buildSpeechContext(); |
475 var od = new api.SpeechContext.fromJson(o.toJson()); | 513 var od = new api.SpeechContext.fromJson(o.toJson()); |
476 checkSpeechContext(od); | 514 checkSpeechContext(od); |
477 }); | 515 }); |
478 }); | 516 }); |
479 | 517 |
480 | |
481 unittest.group("obj-schema-SpeechRecognitionAlternative", () { | 518 unittest.group("obj-schema-SpeechRecognitionAlternative", () { |
482 unittest.test("to-json--from-json", () { | 519 unittest.test("to-json--from-json", () { |
483 var o = buildSpeechRecognitionAlternative(); | 520 var o = buildSpeechRecognitionAlternative(); |
484 var od = new api.SpeechRecognitionAlternative.fromJson(o.toJson()); | 521 var od = new api.SpeechRecognitionAlternative.fromJson(o.toJson()); |
485 checkSpeechRecognitionAlternative(od); | 522 checkSpeechRecognitionAlternative(od); |
486 }); | 523 }); |
487 }); | 524 }); |
488 | 525 |
489 | |
490 unittest.group("obj-schema-SpeechRecognitionResult", () { | 526 unittest.group("obj-schema-SpeechRecognitionResult", () { |
491 unittest.test("to-json--from-json", () { | 527 unittest.test("to-json--from-json", () { |
492 var o = buildSpeechRecognitionResult(); | 528 var o = buildSpeechRecognitionResult(); |
493 var od = new api.SpeechRecognitionResult.fromJson(o.toJson()); | 529 var od = new api.SpeechRecognitionResult.fromJson(o.toJson()); |
494 checkSpeechRecognitionResult(od); | 530 checkSpeechRecognitionResult(od); |
495 }); | 531 }); |
496 }); | 532 }); |
497 | 533 |
498 | |
499 unittest.group("obj-schema-Status", () { | 534 unittest.group("obj-schema-Status", () { |
500 unittest.test("to-json--from-json", () { | 535 unittest.test("to-json--from-json", () { |
501 var o = buildStatus(); | 536 var o = buildStatus(); |
502 var od = new api.Status.fromJson(o.toJson()); | 537 var od = new api.Status.fromJson(o.toJson()); |
503 checkStatus(od); | 538 checkStatus(od); |
504 }); | 539 }); |
505 }); | 540 }); |
506 | 541 |
507 | |
508 unittest.group("obj-schema-SyncRecognizeRequest", () { | 542 unittest.group("obj-schema-SyncRecognizeRequest", () { |
509 unittest.test("to-json--from-json", () { | 543 unittest.test("to-json--from-json", () { |
510 var o = buildSyncRecognizeRequest(); | 544 var o = buildSyncRecognizeRequest(); |
511 var od = new api.SyncRecognizeRequest.fromJson(o.toJson()); | 545 var od = new api.SyncRecognizeRequest.fromJson(o.toJson()); |
512 checkSyncRecognizeRequest(od); | 546 checkSyncRecognizeRequest(od); |
513 }); | 547 }); |
514 }); | 548 }); |
515 | 549 |
516 | |
517 unittest.group("obj-schema-SyncRecognizeResponse", () { | 550 unittest.group("obj-schema-SyncRecognizeResponse", () { |
518 unittest.test("to-json--from-json", () { | 551 unittest.test("to-json--from-json", () { |
519 var o = buildSyncRecognizeResponse(); | 552 var o = buildSyncRecognizeResponse(); |
520 var od = new api.SyncRecognizeResponse.fromJson(o.toJson()); | 553 var od = new api.SyncRecognizeResponse.fromJson(o.toJson()); |
521 checkSyncRecognizeResponse(od); | 554 checkSyncRecognizeResponse(od); |
522 }); | 555 }); |
523 }); | 556 }); |
524 | 557 |
525 | |
526 unittest.group("resource-OperationsResourceApi", () { | 558 unittest.group("resource-OperationsResourceApi", () { |
527 unittest.test("method--cancel", () { | 559 unittest.test("method--cancel", () { |
528 | |
529 var mock = new HttpServerMock(); | 560 var mock = new HttpServerMock(); |
530 api.OperationsResourceApi res = new api.SpeechApi(mock).operations; | 561 api.OperationsResourceApi res = new api.SpeechApi(mock).operations; |
531 var arg_name = "foo"; | 562 var arg_name = "foo"; |
532 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 563 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
533 var path = (req.url).path; | 564 var path = (req.url).path; |
534 var pathOffset = 0; | 565 var pathOffset = 0; |
535 var index; | 566 var index; |
536 var subPart; | 567 var subPart; |
537 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 568 unittest.expect( |
| 569 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
538 pathOffset += 1; | 570 pathOffset += 1; |
539 unittest.expect(path.substring(pathOffset, pathOffset + 19), unittest.eq
uals("v1beta1/operations/")); | 571 unittest.expect(path.substring(pathOffset, pathOffset + 19), |
| 572 unittest.equals("v1beta1/operations/")); |
540 pathOffset += 19; | 573 pathOffset += 19; |
541 // NOTE: We cannot test reserved expansions due to the inability to reve
rse the operation; | 574 // NOTE: We cannot test reserved expansions due to the inability to reve
rse the operation; |
542 | 575 |
543 var query = (req.url).query; | 576 var query = (req.url).query; |
544 var queryOffset = 0; | 577 var queryOffset = 0; |
545 var queryMap = {}; | 578 var queryMap = {}; |
546 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 579 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
547 parseBool(n) { | 580 parseBool(n) { |
548 if (n == "true") return true; | 581 if (n == "true") return true; |
549 if (n == "false") return false; | 582 if (n == "false") return false; |
550 if (n == null) return null; | 583 if (n == null) return null; |
551 throw new core.ArgumentError("Invalid boolean: $n"); | 584 throw new core.ArgumentError("Invalid boolean: $n"); |
552 } | 585 } |
| 586 |
553 if (query.length > 0) { | 587 if (query.length > 0) { |
554 for (var part in query.split("&")) { | 588 for (var part in query.split("&")) { |
555 var keyvalue = part.split("="); | 589 var keyvalue = part.split("="); |
556 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 590 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 591 core.Uri.decodeQueryComponent(keyvalue[1])); |
557 } | 592 } |
558 } | 593 } |
559 | 594 |
560 | |
561 var h = { | 595 var h = { |
562 "content-type" : "application/json; charset=utf-8", | 596 "content-type": "application/json; charset=utf-8", |
563 }; | 597 }; |
564 var resp = convert.JSON.encode(buildEmpty()); | 598 var resp = convert.JSON.encode(buildEmpty()); |
565 return new async.Future.value(stringResponse(200, h, resp)); | 599 return new async.Future.value(stringResponse(200, h, resp)); |
566 }), true); | 600 }), true); |
567 res.cancel(arg_name).then(unittest.expectAsync1(((api.Empty response) { | 601 res.cancel(arg_name).then(unittest.expectAsync1(((api.Empty response) { |
568 checkEmpty(response); | 602 checkEmpty(response); |
569 }))); | 603 }))); |
570 }); | 604 }); |
571 | 605 |
572 unittest.test("method--delete", () { | 606 unittest.test("method--delete", () { |
573 | |
574 var mock = new HttpServerMock(); | 607 var mock = new HttpServerMock(); |
575 api.OperationsResourceApi res = new api.SpeechApi(mock).operations; | 608 api.OperationsResourceApi res = new api.SpeechApi(mock).operations; |
576 var arg_name = "foo"; | 609 var arg_name = "foo"; |
577 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 610 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
578 var path = (req.url).path; | 611 var path = (req.url).path; |
579 var pathOffset = 0; | 612 var pathOffset = 0; |
580 var index; | 613 var index; |
581 var subPart; | 614 var subPart; |
582 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 615 unittest.expect( |
| 616 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
583 pathOffset += 1; | 617 pathOffset += 1; |
584 unittest.expect(path.substring(pathOffset, pathOffset + 19), unittest.eq
uals("v1beta1/operations/")); | 618 unittest.expect(path.substring(pathOffset, pathOffset + 19), |
| 619 unittest.equals("v1beta1/operations/")); |
585 pathOffset += 19; | 620 pathOffset += 19; |
586 // NOTE: We cannot test reserved expansions due to the inability to reve
rse the operation; | 621 // NOTE: We cannot test reserved expansions due to the inability to reve
rse the operation; |
587 | 622 |
588 var query = (req.url).query; | 623 var query = (req.url).query; |
589 var queryOffset = 0; | 624 var queryOffset = 0; |
590 var queryMap = {}; | 625 var queryMap = {}; |
591 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 626 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
592 parseBool(n) { | 627 parseBool(n) { |
593 if (n == "true") return true; | 628 if (n == "true") return true; |
594 if (n == "false") return false; | 629 if (n == "false") return false; |
595 if (n == null) return null; | 630 if (n == null) return null; |
596 throw new core.ArgumentError("Invalid boolean: $n"); | 631 throw new core.ArgumentError("Invalid boolean: $n"); |
597 } | 632 } |
| 633 |
598 if (query.length > 0) { | 634 if (query.length > 0) { |
599 for (var part in query.split("&")) { | 635 for (var part in query.split("&")) { |
600 var keyvalue = part.split("="); | 636 var keyvalue = part.split("="); |
601 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 637 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 638 core.Uri.decodeQueryComponent(keyvalue[1])); |
602 } | 639 } |
603 } | 640 } |
604 | 641 |
605 | |
606 var h = { | 642 var h = { |
607 "content-type" : "application/json; charset=utf-8", | 643 "content-type": "application/json; charset=utf-8", |
608 }; | 644 }; |
609 var resp = convert.JSON.encode(buildEmpty()); | 645 var resp = convert.JSON.encode(buildEmpty()); |
610 return new async.Future.value(stringResponse(200, h, resp)); | 646 return new async.Future.value(stringResponse(200, h, resp)); |
611 }), true); | 647 }), true); |
612 res.delete(arg_name).then(unittest.expectAsync1(((api.Empty response) { | 648 res.delete(arg_name).then(unittest.expectAsync1(((api.Empty response) { |
613 checkEmpty(response); | 649 checkEmpty(response); |
614 }))); | 650 }))); |
615 }); | 651 }); |
616 | 652 |
617 unittest.test("method--get", () { | 653 unittest.test("method--get", () { |
618 | |
619 var mock = new HttpServerMock(); | 654 var mock = new HttpServerMock(); |
620 api.OperationsResourceApi res = new api.SpeechApi(mock).operations; | 655 api.OperationsResourceApi res = new api.SpeechApi(mock).operations; |
621 var arg_name = "foo"; | 656 var arg_name = "foo"; |
622 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 657 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
623 var path = (req.url).path; | 658 var path = (req.url).path; |
624 var pathOffset = 0; | 659 var pathOffset = 0; |
625 var index; | 660 var index; |
626 var subPart; | 661 var subPart; |
627 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 662 unittest.expect( |
| 663 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
628 pathOffset += 1; | 664 pathOffset += 1; |
629 unittest.expect(path.substring(pathOffset, pathOffset + 19), unittest.eq
uals("v1beta1/operations/")); | 665 unittest.expect(path.substring(pathOffset, pathOffset + 19), |
| 666 unittest.equals("v1beta1/operations/")); |
630 pathOffset += 19; | 667 pathOffset += 19; |
631 // NOTE: We cannot test reserved expansions due to the inability to reve
rse the operation; | 668 // NOTE: We cannot test reserved expansions due to the inability to reve
rse the operation; |
632 | 669 |
633 var query = (req.url).query; | 670 var query = (req.url).query; |
634 var queryOffset = 0; | 671 var queryOffset = 0; |
635 var queryMap = {}; | 672 var queryMap = {}; |
636 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 673 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
637 parseBool(n) { | 674 parseBool(n) { |
638 if (n == "true") return true; | 675 if (n == "true") return true; |
639 if (n == "false") return false; | 676 if (n == "false") return false; |
640 if (n == null) return null; | 677 if (n == null) return null; |
641 throw new core.ArgumentError("Invalid boolean: $n"); | 678 throw new core.ArgumentError("Invalid boolean: $n"); |
642 } | 679 } |
| 680 |
643 if (query.length > 0) { | 681 if (query.length > 0) { |
644 for (var part in query.split("&")) { | 682 for (var part in query.split("&")) { |
645 var keyvalue = part.split("="); | 683 var keyvalue = part.split("="); |
646 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 684 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 685 core.Uri.decodeQueryComponent(keyvalue[1])); |
647 } | 686 } |
648 } | 687 } |
649 | 688 |
650 | |
651 var h = { | 689 var h = { |
652 "content-type" : "application/json; charset=utf-8", | 690 "content-type": "application/json; charset=utf-8", |
653 }; | 691 }; |
654 var resp = convert.JSON.encode(buildOperation()); | 692 var resp = convert.JSON.encode(buildOperation()); |
655 return new async.Future.value(stringResponse(200, h, resp)); | 693 return new async.Future.value(stringResponse(200, h, resp)); |
656 }), true); | 694 }), true); |
657 res.get(arg_name).then(unittest.expectAsync1(((api.Operation response) { | 695 res.get(arg_name).then(unittest.expectAsync1(((api.Operation response) { |
658 checkOperation(response); | 696 checkOperation(response); |
659 }))); | 697 }))); |
660 }); | 698 }); |
661 | 699 |
662 unittest.test("method--list", () { | 700 unittest.test("method--list", () { |
663 | |
664 var mock = new HttpServerMock(); | 701 var mock = new HttpServerMock(); |
665 api.OperationsResourceApi res = new api.SpeechApi(mock).operations; | 702 api.OperationsResourceApi res = new api.SpeechApi(mock).operations; |
| 703 var arg_filter = "foo"; |
666 var arg_pageToken = "foo"; | 704 var arg_pageToken = "foo"; |
667 var arg_name = "foo"; | 705 var arg_name = "foo"; |
668 var arg_pageSize = 42; | 706 var arg_pageSize = 42; |
669 var arg_filter = "foo"; | |
670 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 707 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
671 var path = (req.url).path; | 708 var path = (req.url).path; |
672 var pathOffset = 0; | 709 var pathOffset = 0; |
673 var index; | 710 var index; |
674 var subPart; | 711 var subPart; |
675 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 712 unittest.expect( |
| 713 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
676 pathOffset += 1; | 714 pathOffset += 1; |
677 unittest.expect(path.substring(pathOffset, pathOffset + 18), unittest.eq
uals("v1beta1/operations")); | 715 unittest.expect(path.substring(pathOffset, pathOffset + 18), |
| 716 unittest.equals("v1beta1/operations")); |
678 pathOffset += 18; | 717 pathOffset += 18; |
679 | 718 |
680 var query = (req.url).query; | 719 var query = (req.url).query; |
681 var queryOffset = 0; | 720 var queryOffset = 0; |
682 var queryMap = {}; | 721 var queryMap = {}; |
683 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 722 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
684 parseBool(n) { | 723 parseBool(n) { |
685 if (n == "true") return true; | 724 if (n == "true") return true; |
686 if (n == "false") return false; | 725 if (n == "false") return false; |
687 if (n == null) return null; | 726 if (n == null) return null; |
688 throw new core.ArgumentError("Invalid boolean: $n"); | 727 throw new core.ArgumentError("Invalid boolean: $n"); |
689 } | 728 } |
| 729 |
690 if (query.length > 0) { | 730 if (query.length > 0) { |
691 for (var part in query.split("&")) { | 731 for (var part in query.split("&")) { |
692 var keyvalue = part.split("="); | 732 var keyvalue = part.split("="); |
693 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 733 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 734 core.Uri.decodeQueryComponent(keyvalue[1])); |
694 } | 735 } |
695 } | 736 } |
696 unittest.expect(queryMap["pageToken"].first, unittest.equals(arg_pageTok
en)); | 737 unittest.expect(queryMap["filter"].first, unittest.equals(arg_filter)); |
| 738 unittest.expect( |
| 739 queryMap["pageToken"].first, unittest.equals(arg_pageToken)); |
697 unittest.expect(queryMap["name"].first, unittest.equals(arg_name)); | 740 unittest.expect(queryMap["name"].first, unittest.equals(arg_name)); |
698 unittest.expect(core.int.parse(queryMap["pageSize"].first), unittest.equ
als(arg_pageSize)); | 741 unittest.expect(core.int.parse(queryMap["pageSize"].first), |
699 unittest.expect(queryMap["filter"].first, unittest.equals(arg_filter)); | 742 unittest.equals(arg_pageSize)); |
700 | |
701 | 743 |
702 var h = { | 744 var h = { |
703 "content-type" : "application/json; charset=utf-8", | 745 "content-type": "application/json; charset=utf-8", |
704 }; | 746 }; |
705 var resp = convert.JSON.encode(buildListOperationsResponse()); | 747 var resp = convert.JSON.encode(buildListOperationsResponse()); |
706 return new async.Future.value(stringResponse(200, h, resp)); | 748 return new async.Future.value(stringResponse(200, h, resp)); |
707 }), true); | 749 }), true); |
708 res.list(pageToken: arg_pageToken, name: arg_name, pageSize: arg_pageSize,
filter: arg_filter).then(unittest.expectAsync1(((api.ListOperationsResponse res
ponse) { | 750 res |
| 751 .list( |
| 752 filter: arg_filter, |
| 753 pageToken: arg_pageToken, |
| 754 name: arg_name, |
| 755 pageSize: arg_pageSize) |
| 756 .then(unittest.expectAsync1(((api.ListOperationsResponse response) { |
709 checkListOperationsResponse(response); | 757 checkListOperationsResponse(response); |
710 }))); | 758 }))); |
711 }); | 759 }); |
712 | |
713 }); | 760 }); |
714 | 761 |
715 | |
716 unittest.group("resource-SpeechResourceApi", () { | 762 unittest.group("resource-SpeechResourceApi", () { |
717 unittest.test("method--asyncrecognize", () { | 763 unittest.test("method--asyncrecognize", () { |
718 | |
719 var mock = new HttpServerMock(); | 764 var mock = new HttpServerMock(); |
720 api.SpeechResourceApi res = new api.SpeechApi(mock).speech; | 765 api.SpeechResourceApi res = new api.SpeechApi(mock).speech; |
721 var arg_request = buildAsyncRecognizeRequest(); | 766 var arg_request = buildAsyncRecognizeRequest(); |
722 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 767 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
723 var obj = new api.AsyncRecognizeRequest.fromJson(json); | 768 var obj = new api.AsyncRecognizeRequest.fromJson(json); |
724 checkAsyncRecognizeRequest(obj); | 769 checkAsyncRecognizeRequest(obj); |
725 | 770 |
726 var path = (req.url).path; | 771 var path = (req.url).path; |
727 var pathOffset = 0; | 772 var pathOffset = 0; |
728 var index; | 773 var index; |
729 var subPart; | 774 var subPart; |
730 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 775 unittest.expect( |
| 776 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
731 pathOffset += 1; | 777 pathOffset += 1; |
732 unittest.expect(path.substring(pathOffset, pathOffset + 29), unittest.eq
uals("v1beta1/speech:asyncrecognize")); | 778 unittest.expect(path.substring(pathOffset, pathOffset + 29), |
| 779 unittest.equals("v1beta1/speech:asyncrecognize")); |
733 pathOffset += 29; | 780 pathOffset += 29; |
734 | 781 |
735 var query = (req.url).query; | 782 var query = (req.url).query; |
736 var queryOffset = 0; | 783 var queryOffset = 0; |
737 var queryMap = {}; | 784 var queryMap = {}; |
738 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 785 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
739 parseBool(n) { | 786 parseBool(n) { |
740 if (n == "true") return true; | 787 if (n == "true") return true; |
741 if (n == "false") return false; | 788 if (n == "false") return false; |
742 if (n == null) return null; | 789 if (n == null) return null; |
743 throw new core.ArgumentError("Invalid boolean: $n"); | 790 throw new core.ArgumentError("Invalid boolean: $n"); |
744 } | 791 } |
| 792 |
745 if (query.length > 0) { | 793 if (query.length > 0) { |
746 for (var part in query.split("&")) { | 794 for (var part in query.split("&")) { |
747 var keyvalue = part.split("="); | 795 var keyvalue = part.split("="); |
748 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 796 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 797 core.Uri.decodeQueryComponent(keyvalue[1])); |
749 } | 798 } |
750 } | 799 } |
751 | 800 |
752 | |
753 var h = { | 801 var h = { |
754 "content-type" : "application/json; charset=utf-8", | 802 "content-type": "application/json; charset=utf-8", |
755 }; | 803 }; |
756 var resp = convert.JSON.encode(buildOperation()); | 804 var resp = convert.JSON.encode(buildOperation()); |
757 return new async.Future.value(stringResponse(200, h, resp)); | 805 return new async.Future.value(stringResponse(200, h, resp)); |
758 }), true); | 806 }), true); |
759 res.asyncrecognize(arg_request).then(unittest.expectAsync1(((api.Operation
response) { | 807 res |
| 808 .asyncrecognize(arg_request) |
| 809 .then(unittest.expectAsync1(((api.Operation response) { |
760 checkOperation(response); | 810 checkOperation(response); |
761 }))); | 811 }))); |
762 }); | 812 }); |
763 | 813 |
764 unittest.test("method--syncrecognize", () { | 814 unittest.test("method--syncrecognize", () { |
765 | |
766 var mock = new HttpServerMock(); | 815 var mock = new HttpServerMock(); |
767 api.SpeechResourceApi res = new api.SpeechApi(mock).speech; | 816 api.SpeechResourceApi res = new api.SpeechApi(mock).speech; |
768 var arg_request = buildSyncRecognizeRequest(); | 817 var arg_request = buildSyncRecognizeRequest(); |
769 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 818 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
770 var obj = new api.SyncRecognizeRequest.fromJson(json); | 819 var obj = new api.SyncRecognizeRequest.fromJson(json); |
771 checkSyncRecognizeRequest(obj); | 820 checkSyncRecognizeRequest(obj); |
772 | 821 |
773 var path = (req.url).path; | 822 var path = (req.url).path; |
774 var pathOffset = 0; | 823 var pathOffset = 0; |
775 var index; | 824 var index; |
776 var subPart; | 825 var subPart; |
777 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 826 unittest.expect( |
| 827 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
778 pathOffset += 1; | 828 pathOffset += 1; |
779 unittest.expect(path.substring(pathOffset, pathOffset + 28), unittest.eq
uals("v1beta1/speech:syncrecognize")); | 829 unittest.expect(path.substring(pathOffset, pathOffset + 28), |
| 830 unittest.equals("v1beta1/speech:syncrecognize")); |
780 pathOffset += 28; | 831 pathOffset += 28; |
781 | 832 |
782 var query = (req.url).query; | 833 var query = (req.url).query; |
783 var queryOffset = 0; | 834 var queryOffset = 0; |
784 var queryMap = {}; | 835 var queryMap = {}; |
785 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 836 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
786 parseBool(n) { | 837 parseBool(n) { |
787 if (n == "true") return true; | 838 if (n == "true") return true; |
788 if (n == "false") return false; | 839 if (n == "false") return false; |
789 if (n == null) return null; | 840 if (n == null) return null; |
790 throw new core.ArgumentError("Invalid boolean: $n"); | 841 throw new core.ArgumentError("Invalid boolean: $n"); |
791 } | 842 } |
| 843 |
792 if (query.length > 0) { | 844 if (query.length > 0) { |
793 for (var part in query.split("&")) { | 845 for (var part in query.split("&")) { |
794 var keyvalue = part.split("="); | 846 var keyvalue = part.split("="); |
795 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 847 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 848 core.Uri.decodeQueryComponent(keyvalue[1])); |
796 } | 849 } |
797 } | 850 } |
798 | 851 |
799 | |
800 var h = { | 852 var h = { |
801 "content-type" : "application/json; charset=utf-8", | 853 "content-type": "application/json; charset=utf-8", |
802 }; | 854 }; |
803 var resp = convert.JSON.encode(buildSyncRecognizeResponse()); | 855 var resp = convert.JSON.encode(buildSyncRecognizeResponse()); |
804 return new async.Future.value(stringResponse(200, h, resp)); | 856 return new async.Future.value(stringResponse(200, h, resp)); |
805 }), true); | 857 }), true); |
806 res.syncrecognize(arg_request).then(unittest.expectAsync1(((api.SyncRecogn
izeResponse response) { | 858 res |
| 859 .syncrecognize(arg_request) |
| 860 .then(unittest.expectAsync1(((api.SyncRecognizeResponse response) { |
807 checkSyncRecognizeResponse(response); | 861 checkSyncRecognizeResponse(response); |
808 }))); | 862 }))); |
809 }); | 863 }); |
810 | |
811 }); | 864 }); |
812 | |
813 | |
814 } | 865 } |
815 | |
OLD | NEW |