| OLD | NEW |
| 1 library googleapis.speech.v1.test; | 1 library googleapis.speech.v1.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/speech/v1.dart' as api; | 10 import 'package:googleapis/speech/v1.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 buildCounterCancelOperationRequest = 0; | 53 core.int buildCounterCancelOperationRequest = 0; |
| 55 buildCancelOperationRequest() { | 54 buildCancelOperationRequest() { |
| 56 var o = new api.CancelOperationRequest(); | 55 var o = new api.CancelOperationRequest(); |
| 57 buildCounterCancelOperationRequest++; | 56 buildCounterCancelOperationRequest++; |
| 58 if (buildCounterCancelOperationRequest < 3) { | 57 if (buildCounterCancelOperationRequest < 3) {} |
| 59 } | |
| 60 buildCounterCancelOperationRequest--; | 58 buildCounterCancelOperationRequest--; |
| 61 return o; | 59 return o; |
| 62 } | 60 } |
| 63 | 61 |
| 64 checkCancelOperationRequest(api.CancelOperationRequest o) { | 62 checkCancelOperationRequest(api.CancelOperationRequest o) { |
| 65 buildCounterCancelOperationRequest++; | 63 buildCounterCancelOperationRequest++; |
| 66 if (buildCounterCancelOperationRequest < 3) { | 64 if (buildCounterCancelOperationRequest < 3) {} |
| 67 } | |
| 68 buildCounterCancelOperationRequest--; | 65 buildCounterCancelOperationRequest--; |
| 69 } | 66 } |
| 70 | 67 |
| 71 core.int buildCounterEmpty = 0; | 68 core.int buildCounterEmpty = 0; |
| 72 buildEmpty() { | 69 buildEmpty() { |
| 73 var o = new api.Empty(); | 70 var o = new api.Empty(); |
| 74 buildCounterEmpty++; | 71 buildCounterEmpty++; |
| 75 if (buildCounterEmpty < 3) { | 72 if (buildCounterEmpty < 3) {} |
| 76 } | |
| 77 buildCounterEmpty--; | 73 buildCounterEmpty--; |
| 78 return o; | 74 return o; |
| 79 } | 75 } |
| 80 | 76 |
| 81 checkEmpty(api.Empty o) { | 77 checkEmpty(api.Empty o) { |
| 82 buildCounterEmpty++; | 78 buildCounterEmpty++; |
| 83 if (buildCounterEmpty < 3) { | 79 if (buildCounterEmpty < 3) {} |
| 84 } | |
| 85 buildCounterEmpty--; | 80 buildCounterEmpty--; |
| 86 } | 81 } |
| 87 | 82 |
| 88 buildUnnamed2707() { | 83 buildUnnamed2700() { |
| 89 var o = new core.List<api.Operation>(); | 84 var o = new core.List<api.Operation>(); |
| 90 o.add(buildOperation()); | 85 o.add(buildOperation()); |
| 91 o.add(buildOperation()); | 86 o.add(buildOperation()); |
| 92 return o; | 87 return o; |
| 93 } | 88 } |
| 94 | 89 |
| 95 checkUnnamed2707(core.List<api.Operation> o) { | 90 checkUnnamed2700(core.List<api.Operation> o) { |
| 96 unittest.expect(o, unittest.hasLength(2)); | 91 unittest.expect(o, unittest.hasLength(2)); |
| 97 checkOperation(o[0]); | 92 checkOperation(o[0]); |
| 98 checkOperation(o[1]); | 93 checkOperation(o[1]); |
| 99 } | 94 } |
| 100 | 95 |
| 101 core.int buildCounterListOperationsResponse = 0; | 96 core.int buildCounterListOperationsResponse = 0; |
| 102 buildListOperationsResponse() { | 97 buildListOperationsResponse() { |
| 103 var o = new api.ListOperationsResponse(); | 98 var o = new api.ListOperationsResponse(); |
| 104 buildCounterListOperationsResponse++; | 99 buildCounterListOperationsResponse++; |
| 105 if (buildCounterListOperationsResponse < 3) { | 100 if (buildCounterListOperationsResponse < 3) { |
| 106 o.nextPageToken = "foo"; | 101 o.nextPageToken = "foo"; |
| 107 o.operations = buildUnnamed2707(); | 102 o.operations = buildUnnamed2700(); |
| 108 } | 103 } |
| 109 buildCounterListOperationsResponse--; | 104 buildCounterListOperationsResponse--; |
| 110 return o; | 105 return o; |
| 111 } | 106 } |
| 112 | 107 |
| 113 checkListOperationsResponse(api.ListOperationsResponse o) { | 108 checkListOperationsResponse(api.ListOperationsResponse o) { |
| 114 buildCounterListOperationsResponse++; | 109 buildCounterListOperationsResponse++; |
| 115 if (buildCounterListOperationsResponse < 3) { | 110 if (buildCounterListOperationsResponse < 3) { |
| 116 unittest.expect(o.nextPageToken, unittest.equals('foo')); | 111 unittest.expect(o.nextPageToken, unittest.equals('foo')); |
| 117 checkUnnamed2707(o.operations); | 112 checkUnnamed2700(o.operations); |
| 118 } | 113 } |
| 119 buildCounterListOperationsResponse--; | 114 buildCounterListOperationsResponse--; |
| 120 } | 115 } |
| 121 | 116 |
| 122 core.int buildCounterLongRunningRecognizeRequest = 0; | 117 core.int buildCounterLongRunningRecognizeRequest = 0; |
| 123 buildLongRunningRecognizeRequest() { | 118 buildLongRunningRecognizeRequest() { |
| 124 var o = new api.LongRunningRecognizeRequest(); | 119 var o = new api.LongRunningRecognizeRequest(); |
| 125 buildCounterLongRunningRecognizeRequest++; | 120 buildCounterLongRunningRecognizeRequest++; |
| 126 if (buildCounterLongRunningRecognizeRequest < 3) { | 121 if (buildCounterLongRunningRecognizeRequest < 3) { |
| 127 o.audio = buildRecognitionAudio(); | 122 o.audio = buildRecognitionAudio(); |
| 128 o.config = buildRecognitionConfig(); | 123 o.config = buildRecognitionConfig(); |
| 129 } | 124 } |
| 130 buildCounterLongRunningRecognizeRequest--; | 125 buildCounterLongRunningRecognizeRequest--; |
| 131 return o; | 126 return o; |
| 132 } | 127 } |
| 133 | 128 |
| 134 checkLongRunningRecognizeRequest(api.LongRunningRecognizeRequest o) { | 129 checkLongRunningRecognizeRequest(api.LongRunningRecognizeRequest o) { |
| 135 buildCounterLongRunningRecognizeRequest++; | 130 buildCounterLongRunningRecognizeRequest++; |
| 136 if (buildCounterLongRunningRecognizeRequest < 3) { | 131 if (buildCounterLongRunningRecognizeRequest < 3) { |
| 137 checkRecognitionAudio(o.audio); | 132 checkRecognitionAudio(o.audio); |
| 138 checkRecognitionConfig(o.config); | 133 checkRecognitionConfig(o.config); |
| 139 } | 134 } |
| 140 buildCounterLongRunningRecognizeRequest--; | 135 buildCounterLongRunningRecognizeRequest--; |
| 141 } | 136 } |
| 142 | 137 |
| 143 buildUnnamed2708() { | 138 buildUnnamed2701() { |
| 144 var o = new core.Map<core.String, core.Object>(); | 139 var o = new core.Map<core.String, core.Object>(); |
| 145 o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; | 140 o["x"] = { |
| 146 o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; | 141 'list': [1, 2, 3], |
| 142 'bool': true, |
| 143 'string': 'foo' |
| 144 }; |
| 145 o["y"] = { |
| 146 'list': [1, 2, 3], |
| 147 'bool': true, |
| 148 'string': 'foo' |
| 149 }; |
| 147 return o; | 150 return o; |
| 148 } | 151 } |
| 149 | 152 |
| 150 checkUnnamed2708(core.Map<core.String, core.Object> o) { | 153 checkUnnamed2701(core.Map<core.String, core.Object> o) { |
| 151 unittest.expect(o, unittest.hasLength(2)); | 154 unittest.expect(o, unittest.hasLength(2)); |
| 152 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')); | 155 var casted1 = (o["x"]) as core.Map; |
| 153 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')); | 156 unittest.expect(casted1, unittest.hasLength(3)); |
| 157 unittest.expect(casted1["list"], unittest.equals([1, 2, 3])); |
| 158 unittest.expect(casted1["bool"], unittest.equals(true)); |
| 159 unittest.expect(casted1["string"], unittest.equals('foo')); |
| 160 var casted2 = (o["y"]) as core.Map; |
| 161 unittest.expect(casted2, unittest.hasLength(3)); |
| 162 unittest.expect(casted2["list"], unittest.equals([1, 2, 3])); |
| 163 unittest.expect(casted2["bool"], unittest.equals(true)); |
| 164 unittest.expect(casted2["string"], unittest.equals('foo')); |
| 154 } | 165 } |
| 155 | 166 |
| 156 buildUnnamed2709() { | 167 buildUnnamed2702() { |
| 157 var o = new core.Map<core.String, core.Object>(); | 168 var o = new core.Map<core.String, core.Object>(); |
| 158 o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; | 169 o["x"] = { |
| 159 o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; | 170 'list': [1, 2, 3], |
| 171 'bool': true, |
| 172 'string': 'foo' |
| 173 }; |
| 174 o["y"] = { |
| 175 'list': [1, 2, 3], |
| 176 'bool': true, |
| 177 'string': 'foo' |
| 178 }; |
| 160 return o; | 179 return o; |
| 161 } | 180 } |
| 162 | 181 |
| 163 checkUnnamed2709(core.Map<core.String, core.Object> o) { | 182 checkUnnamed2702(core.Map<core.String, core.Object> o) { |
| 164 unittest.expect(o, unittest.hasLength(2)); | 183 unittest.expect(o, unittest.hasLength(2)); |
| 165 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')); | 184 var casted3 = (o["x"]) as core.Map; |
| 166 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')); | 185 unittest.expect(casted3, unittest.hasLength(3)); |
| 186 unittest.expect(casted3["list"], unittest.equals([1, 2, 3])); |
| 187 unittest.expect(casted3["bool"], unittest.equals(true)); |
| 188 unittest.expect(casted3["string"], unittest.equals('foo')); |
| 189 var casted4 = (o["y"]) as core.Map; |
| 190 unittest.expect(casted4, unittest.hasLength(3)); |
| 191 unittest.expect(casted4["list"], unittest.equals([1, 2, 3])); |
| 192 unittest.expect(casted4["bool"], unittest.equals(true)); |
| 193 unittest.expect(casted4["string"], unittest.equals('foo')); |
| 167 } | 194 } |
| 168 | 195 |
| 169 core.int buildCounterOperation = 0; | 196 core.int buildCounterOperation = 0; |
| 170 buildOperation() { | 197 buildOperation() { |
| 171 var o = new api.Operation(); | 198 var o = new api.Operation(); |
| 172 buildCounterOperation++; | 199 buildCounterOperation++; |
| 173 if (buildCounterOperation < 3) { | 200 if (buildCounterOperation < 3) { |
| 174 o.done = true; | 201 o.done = true; |
| 175 o.error = buildStatus(); | 202 o.error = buildStatus(); |
| 176 o.metadata = buildUnnamed2708(); | 203 o.metadata = buildUnnamed2701(); |
| 177 o.name = "foo"; | 204 o.name = "foo"; |
| 178 o.response = buildUnnamed2709(); | 205 o.response = buildUnnamed2702(); |
| 179 } | 206 } |
| 180 buildCounterOperation--; | 207 buildCounterOperation--; |
| 181 return o; | 208 return o; |
| 182 } | 209 } |
| 183 | 210 |
| 184 checkOperation(api.Operation o) { | 211 checkOperation(api.Operation o) { |
| 185 buildCounterOperation++; | 212 buildCounterOperation++; |
| 186 if (buildCounterOperation < 3) { | 213 if (buildCounterOperation < 3) { |
| 187 unittest.expect(o.done, unittest.isTrue); | 214 unittest.expect(o.done, unittest.isTrue); |
| 188 checkStatus(o.error); | 215 checkStatus(o.error); |
| 189 checkUnnamed2708(o.metadata); | 216 checkUnnamed2701(o.metadata); |
| 190 unittest.expect(o.name, unittest.equals('foo')); | 217 unittest.expect(o.name, unittest.equals('foo')); |
| 191 checkUnnamed2709(o.response); | 218 checkUnnamed2702(o.response); |
| 192 } | 219 } |
| 193 buildCounterOperation--; | 220 buildCounterOperation--; |
| 194 } | 221 } |
| 195 | 222 |
| 196 core.int buildCounterRecognitionAudio = 0; | 223 core.int buildCounterRecognitionAudio = 0; |
| 197 buildRecognitionAudio() { | 224 buildRecognitionAudio() { |
| 198 var o = new api.RecognitionAudio(); | 225 var o = new api.RecognitionAudio(); |
| 199 buildCounterRecognitionAudio++; | 226 buildCounterRecognitionAudio++; |
| 200 if (buildCounterRecognitionAudio < 3) { | 227 if (buildCounterRecognitionAudio < 3) { |
| 201 o.content = "foo"; | 228 o.content = "foo"; |
| 202 o.uri = "foo"; | 229 o.uri = "foo"; |
| 203 } | 230 } |
| 204 buildCounterRecognitionAudio--; | 231 buildCounterRecognitionAudio--; |
| 205 return o; | 232 return o; |
| 206 } | 233 } |
| 207 | 234 |
| 208 checkRecognitionAudio(api.RecognitionAudio o) { | 235 checkRecognitionAudio(api.RecognitionAudio o) { |
| 209 buildCounterRecognitionAudio++; | 236 buildCounterRecognitionAudio++; |
| 210 if (buildCounterRecognitionAudio < 3) { | 237 if (buildCounterRecognitionAudio < 3) { |
| 211 unittest.expect(o.content, unittest.equals('foo')); | 238 unittest.expect(o.content, unittest.equals('foo')); |
| 212 unittest.expect(o.uri, unittest.equals('foo')); | 239 unittest.expect(o.uri, unittest.equals('foo')); |
| 213 } | 240 } |
| 214 buildCounterRecognitionAudio--; | 241 buildCounterRecognitionAudio--; |
| 215 } | 242 } |
| 216 | 243 |
| 217 buildUnnamed2710() { | 244 buildUnnamed2703() { |
| 218 var o = new core.List<api.SpeechContext>(); | 245 var o = new core.List<api.SpeechContext>(); |
| 219 o.add(buildSpeechContext()); | 246 o.add(buildSpeechContext()); |
| 220 o.add(buildSpeechContext()); | 247 o.add(buildSpeechContext()); |
| 221 return o; | 248 return o; |
| 222 } | 249 } |
| 223 | 250 |
| 224 checkUnnamed2710(core.List<api.SpeechContext> o) { | 251 checkUnnamed2703(core.List<api.SpeechContext> o) { |
| 225 unittest.expect(o, unittest.hasLength(2)); | 252 unittest.expect(o, unittest.hasLength(2)); |
| 226 checkSpeechContext(o[0]); | 253 checkSpeechContext(o[0]); |
| 227 checkSpeechContext(o[1]); | 254 checkSpeechContext(o[1]); |
| 228 } | 255 } |
| 229 | 256 |
| 230 core.int buildCounterRecognitionConfig = 0; | 257 core.int buildCounterRecognitionConfig = 0; |
| 231 buildRecognitionConfig() { | 258 buildRecognitionConfig() { |
| 232 var o = new api.RecognitionConfig(); | 259 var o = new api.RecognitionConfig(); |
| 233 buildCounterRecognitionConfig++; | 260 buildCounterRecognitionConfig++; |
| 234 if (buildCounterRecognitionConfig < 3) { | 261 if (buildCounterRecognitionConfig < 3) { |
| 235 o.enableWordTimeOffsets = true; | 262 o.enableWordTimeOffsets = true; |
| 236 o.encoding = "foo"; | 263 o.encoding = "foo"; |
| 237 o.languageCode = "foo"; | 264 o.languageCode = "foo"; |
| 238 o.maxAlternatives = 42; | 265 o.maxAlternatives = 42; |
| 239 o.profanityFilter = true; | 266 o.profanityFilter = true; |
| 240 o.sampleRateHertz = 42; | 267 o.sampleRateHertz = 42; |
| 241 o.speechContexts = buildUnnamed2710(); | 268 o.speechContexts = buildUnnamed2703(); |
| 242 } | 269 } |
| 243 buildCounterRecognitionConfig--; | 270 buildCounterRecognitionConfig--; |
| 244 return o; | 271 return o; |
| 245 } | 272 } |
| 246 | 273 |
| 247 checkRecognitionConfig(api.RecognitionConfig o) { | 274 checkRecognitionConfig(api.RecognitionConfig o) { |
| 248 buildCounterRecognitionConfig++; | 275 buildCounterRecognitionConfig++; |
| 249 if (buildCounterRecognitionConfig < 3) { | 276 if (buildCounterRecognitionConfig < 3) { |
| 250 unittest.expect(o.enableWordTimeOffsets, unittest.isTrue); | 277 unittest.expect(o.enableWordTimeOffsets, unittest.isTrue); |
| 251 unittest.expect(o.encoding, unittest.equals('foo')); | 278 unittest.expect(o.encoding, unittest.equals('foo')); |
| 252 unittest.expect(o.languageCode, unittest.equals('foo')); | 279 unittest.expect(o.languageCode, unittest.equals('foo')); |
| 253 unittest.expect(o.maxAlternatives, unittest.equals(42)); | 280 unittest.expect(o.maxAlternatives, unittest.equals(42)); |
| 254 unittest.expect(o.profanityFilter, unittest.isTrue); | 281 unittest.expect(o.profanityFilter, unittest.isTrue); |
| 255 unittest.expect(o.sampleRateHertz, unittest.equals(42)); | 282 unittest.expect(o.sampleRateHertz, unittest.equals(42)); |
| 256 checkUnnamed2710(o.speechContexts); | 283 checkUnnamed2703(o.speechContexts); |
| 257 } | 284 } |
| 258 buildCounterRecognitionConfig--; | 285 buildCounterRecognitionConfig--; |
| 259 } | 286 } |
| 260 | 287 |
| 261 core.int buildCounterRecognizeRequest = 0; | 288 core.int buildCounterRecognizeRequest = 0; |
| 262 buildRecognizeRequest() { | 289 buildRecognizeRequest() { |
| 263 var o = new api.RecognizeRequest(); | 290 var o = new api.RecognizeRequest(); |
| 264 buildCounterRecognizeRequest++; | 291 buildCounterRecognizeRequest++; |
| 265 if (buildCounterRecognizeRequest < 3) { | 292 if (buildCounterRecognizeRequest < 3) { |
| 266 o.audio = buildRecognitionAudio(); | 293 o.audio = buildRecognitionAudio(); |
| 267 o.config = buildRecognitionConfig(); | 294 o.config = buildRecognitionConfig(); |
| 268 } | 295 } |
| 269 buildCounterRecognizeRequest--; | 296 buildCounterRecognizeRequest--; |
| 270 return o; | 297 return o; |
| 271 } | 298 } |
| 272 | 299 |
| 273 checkRecognizeRequest(api.RecognizeRequest o) { | 300 checkRecognizeRequest(api.RecognizeRequest o) { |
| 274 buildCounterRecognizeRequest++; | 301 buildCounterRecognizeRequest++; |
| 275 if (buildCounterRecognizeRequest < 3) { | 302 if (buildCounterRecognizeRequest < 3) { |
| 276 checkRecognitionAudio(o.audio); | 303 checkRecognitionAudio(o.audio); |
| 277 checkRecognitionConfig(o.config); | 304 checkRecognitionConfig(o.config); |
| 278 } | 305 } |
| 279 buildCounterRecognizeRequest--; | 306 buildCounterRecognizeRequest--; |
| 280 } | 307 } |
| 281 | 308 |
| 282 buildUnnamed2711() { | 309 buildUnnamed2704() { |
| 283 var o = new core.List<api.SpeechRecognitionResult>(); | 310 var o = new core.List<api.SpeechRecognitionResult>(); |
| 284 o.add(buildSpeechRecognitionResult()); | 311 o.add(buildSpeechRecognitionResult()); |
| 285 o.add(buildSpeechRecognitionResult()); | 312 o.add(buildSpeechRecognitionResult()); |
| 286 return o; | 313 return o; |
| 287 } | 314 } |
| 288 | 315 |
| 289 checkUnnamed2711(core.List<api.SpeechRecognitionResult> o) { | 316 checkUnnamed2704(core.List<api.SpeechRecognitionResult> o) { |
| 290 unittest.expect(o, unittest.hasLength(2)); | 317 unittest.expect(o, unittest.hasLength(2)); |
| 291 checkSpeechRecognitionResult(o[0]); | 318 checkSpeechRecognitionResult(o[0]); |
| 292 checkSpeechRecognitionResult(o[1]); | 319 checkSpeechRecognitionResult(o[1]); |
| 293 } | 320 } |
| 294 | 321 |
| 295 core.int buildCounterRecognizeResponse = 0; | 322 core.int buildCounterRecognizeResponse = 0; |
| 296 buildRecognizeResponse() { | 323 buildRecognizeResponse() { |
| 297 var o = new api.RecognizeResponse(); | 324 var o = new api.RecognizeResponse(); |
| 298 buildCounterRecognizeResponse++; | 325 buildCounterRecognizeResponse++; |
| 299 if (buildCounterRecognizeResponse < 3) { | 326 if (buildCounterRecognizeResponse < 3) { |
| 300 o.results = buildUnnamed2711(); | 327 o.results = buildUnnamed2704(); |
| 301 } | 328 } |
| 302 buildCounterRecognizeResponse--; | 329 buildCounterRecognizeResponse--; |
| 303 return o; | 330 return o; |
| 304 } | 331 } |
| 305 | 332 |
| 306 checkRecognizeResponse(api.RecognizeResponse o) { | 333 checkRecognizeResponse(api.RecognizeResponse o) { |
| 307 buildCounterRecognizeResponse++; | 334 buildCounterRecognizeResponse++; |
| 308 if (buildCounterRecognizeResponse < 3) { | 335 if (buildCounterRecognizeResponse < 3) { |
| 309 checkUnnamed2711(o.results); | 336 checkUnnamed2704(o.results); |
| 310 } | 337 } |
| 311 buildCounterRecognizeResponse--; | 338 buildCounterRecognizeResponse--; |
| 312 } | 339 } |
| 313 | 340 |
| 314 buildUnnamed2712() { | 341 buildUnnamed2705() { |
| 315 var o = new core.List<core.String>(); | 342 var o = new core.List<core.String>(); |
| 316 o.add("foo"); | 343 o.add("foo"); |
| 317 o.add("foo"); | 344 o.add("foo"); |
| 318 return o; | 345 return o; |
| 319 } | 346 } |
| 320 | 347 |
| 321 checkUnnamed2712(core.List<core.String> o) { | 348 checkUnnamed2705(core.List<core.String> o) { |
| 322 unittest.expect(o, unittest.hasLength(2)); | 349 unittest.expect(o, unittest.hasLength(2)); |
| 323 unittest.expect(o[0], unittest.equals('foo')); | 350 unittest.expect(o[0], unittest.equals('foo')); |
| 324 unittest.expect(o[1], unittest.equals('foo')); | 351 unittest.expect(o[1], unittest.equals('foo')); |
| 325 } | 352 } |
| 326 | 353 |
| 327 core.int buildCounterSpeechContext = 0; | 354 core.int buildCounterSpeechContext = 0; |
| 328 buildSpeechContext() { | 355 buildSpeechContext() { |
| 329 var o = new api.SpeechContext(); | 356 var o = new api.SpeechContext(); |
| 330 buildCounterSpeechContext++; | 357 buildCounterSpeechContext++; |
| 331 if (buildCounterSpeechContext < 3) { | 358 if (buildCounterSpeechContext < 3) { |
| 332 o.phrases = buildUnnamed2712(); | 359 o.phrases = buildUnnamed2705(); |
| 333 } | 360 } |
| 334 buildCounterSpeechContext--; | 361 buildCounterSpeechContext--; |
| 335 return o; | 362 return o; |
| 336 } | 363 } |
| 337 | 364 |
| 338 checkSpeechContext(api.SpeechContext o) { | 365 checkSpeechContext(api.SpeechContext o) { |
| 339 buildCounterSpeechContext++; | 366 buildCounterSpeechContext++; |
| 340 if (buildCounterSpeechContext < 3) { | 367 if (buildCounterSpeechContext < 3) { |
| 341 checkUnnamed2712(o.phrases); | 368 checkUnnamed2705(o.phrases); |
| 342 } | 369 } |
| 343 buildCounterSpeechContext--; | 370 buildCounterSpeechContext--; |
| 344 } | 371 } |
| 345 | 372 |
| 346 buildUnnamed2713() { | 373 buildUnnamed2706() { |
| 347 var o = new core.List<api.WordInfo>(); | 374 var o = new core.List<api.WordInfo>(); |
| 348 o.add(buildWordInfo()); | 375 o.add(buildWordInfo()); |
| 349 o.add(buildWordInfo()); | 376 o.add(buildWordInfo()); |
| 350 return o; | 377 return o; |
| 351 } | 378 } |
| 352 | 379 |
| 353 checkUnnamed2713(core.List<api.WordInfo> o) { | 380 checkUnnamed2706(core.List<api.WordInfo> o) { |
| 354 unittest.expect(o, unittest.hasLength(2)); | 381 unittest.expect(o, unittest.hasLength(2)); |
| 355 checkWordInfo(o[0]); | 382 checkWordInfo(o[0]); |
| 356 checkWordInfo(o[1]); | 383 checkWordInfo(o[1]); |
| 357 } | 384 } |
| 358 | 385 |
| 359 core.int buildCounterSpeechRecognitionAlternative = 0; | 386 core.int buildCounterSpeechRecognitionAlternative = 0; |
| 360 buildSpeechRecognitionAlternative() { | 387 buildSpeechRecognitionAlternative() { |
| 361 var o = new api.SpeechRecognitionAlternative(); | 388 var o = new api.SpeechRecognitionAlternative(); |
| 362 buildCounterSpeechRecognitionAlternative++; | 389 buildCounterSpeechRecognitionAlternative++; |
| 363 if (buildCounterSpeechRecognitionAlternative < 3) { | 390 if (buildCounterSpeechRecognitionAlternative < 3) { |
| 364 o.confidence = 42.0; | 391 o.confidence = 42.0; |
| 365 o.transcript = "foo"; | 392 o.transcript = "foo"; |
| 366 o.words = buildUnnamed2713(); | 393 o.words = buildUnnamed2706(); |
| 367 } | 394 } |
| 368 buildCounterSpeechRecognitionAlternative--; | 395 buildCounterSpeechRecognitionAlternative--; |
| 369 return o; | 396 return o; |
| 370 } | 397 } |
| 371 | 398 |
| 372 checkSpeechRecognitionAlternative(api.SpeechRecognitionAlternative o) { | 399 checkSpeechRecognitionAlternative(api.SpeechRecognitionAlternative o) { |
| 373 buildCounterSpeechRecognitionAlternative++; | 400 buildCounterSpeechRecognitionAlternative++; |
| 374 if (buildCounterSpeechRecognitionAlternative < 3) { | 401 if (buildCounterSpeechRecognitionAlternative < 3) { |
| 375 unittest.expect(o.confidence, unittest.equals(42.0)); | 402 unittest.expect(o.confidence, unittest.equals(42.0)); |
| 376 unittest.expect(o.transcript, unittest.equals('foo')); | 403 unittest.expect(o.transcript, unittest.equals('foo')); |
| 377 checkUnnamed2713(o.words); | 404 checkUnnamed2706(o.words); |
| 378 } | 405 } |
| 379 buildCounterSpeechRecognitionAlternative--; | 406 buildCounterSpeechRecognitionAlternative--; |
| 380 } | 407 } |
| 381 | 408 |
| 382 buildUnnamed2714() { | 409 buildUnnamed2707() { |
| 383 var o = new core.List<api.SpeechRecognitionAlternative>(); | 410 var o = new core.List<api.SpeechRecognitionAlternative>(); |
| 384 o.add(buildSpeechRecognitionAlternative()); | 411 o.add(buildSpeechRecognitionAlternative()); |
| 385 o.add(buildSpeechRecognitionAlternative()); | 412 o.add(buildSpeechRecognitionAlternative()); |
| 386 return o; | 413 return o; |
| 387 } | 414 } |
| 388 | 415 |
| 389 checkUnnamed2714(core.List<api.SpeechRecognitionAlternative> o) { | 416 checkUnnamed2707(core.List<api.SpeechRecognitionAlternative> o) { |
| 390 unittest.expect(o, unittest.hasLength(2)); | 417 unittest.expect(o, unittest.hasLength(2)); |
| 391 checkSpeechRecognitionAlternative(o[0]); | 418 checkSpeechRecognitionAlternative(o[0]); |
| 392 checkSpeechRecognitionAlternative(o[1]); | 419 checkSpeechRecognitionAlternative(o[1]); |
| 393 } | 420 } |
| 394 | 421 |
| 395 core.int buildCounterSpeechRecognitionResult = 0; | 422 core.int buildCounterSpeechRecognitionResult = 0; |
| 396 buildSpeechRecognitionResult() { | 423 buildSpeechRecognitionResult() { |
| 397 var o = new api.SpeechRecognitionResult(); | 424 var o = new api.SpeechRecognitionResult(); |
| 398 buildCounterSpeechRecognitionResult++; | 425 buildCounterSpeechRecognitionResult++; |
| 399 if (buildCounterSpeechRecognitionResult < 3) { | 426 if (buildCounterSpeechRecognitionResult < 3) { |
| 400 o.alternatives = buildUnnamed2714(); | 427 o.alternatives = buildUnnamed2707(); |
| 401 } | 428 } |
| 402 buildCounterSpeechRecognitionResult--; | 429 buildCounterSpeechRecognitionResult--; |
| 403 return o; | 430 return o; |
| 404 } | 431 } |
| 405 | 432 |
| 406 checkSpeechRecognitionResult(api.SpeechRecognitionResult o) { | 433 checkSpeechRecognitionResult(api.SpeechRecognitionResult o) { |
| 407 buildCounterSpeechRecognitionResult++; | 434 buildCounterSpeechRecognitionResult++; |
| 408 if (buildCounterSpeechRecognitionResult < 3) { | 435 if (buildCounterSpeechRecognitionResult < 3) { |
| 409 checkUnnamed2714(o.alternatives); | 436 checkUnnamed2707(o.alternatives); |
| 410 } | 437 } |
| 411 buildCounterSpeechRecognitionResult--; | 438 buildCounterSpeechRecognitionResult--; |
| 412 } | 439 } |
| 413 | 440 |
| 414 buildUnnamed2715() { | 441 buildUnnamed2708() { |
| 415 var o = new core.Map<core.String, core.Object>(); | 442 var o = new core.Map<core.String, core.Object>(); |
| 416 o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; | 443 o["x"] = { |
| 417 o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; | 444 'list': [1, 2, 3], |
| 445 'bool': true, |
| 446 'string': 'foo' |
| 447 }; |
| 448 o["y"] = { |
| 449 'list': [1, 2, 3], |
| 450 'bool': true, |
| 451 'string': 'foo' |
| 452 }; |
| 418 return o; | 453 return o; |
| 419 } | 454 } |
| 420 | 455 |
| 421 checkUnnamed2715(core.Map<core.String, core.Object> o) { | 456 checkUnnamed2708(core.Map<core.String, core.Object> o) { |
| 422 unittest.expect(o, unittest.hasLength(2)); | 457 unittest.expect(o, unittest.hasLength(2)); |
| 423 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')); | 458 var casted5 = (o["x"]) as core.Map; |
| 424 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')); | 459 unittest.expect(casted5, unittest.hasLength(3)); |
| 460 unittest.expect(casted5["list"], unittest.equals([1, 2, 3])); |
| 461 unittest.expect(casted5["bool"], unittest.equals(true)); |
| 462 unittest.expect(casted5["string"], unittest.equals('foo')); |
| 463 var casted6 = (o["y"]) as core.Map; |
| 464 unittest.expect(casted6, unittest.hasLength(3)); |
| 465 unittest.expect(casted6["list"], unittest.equals([1, 2, 3])); |
| 466 unittest.expect(casted6["bool"], unittest.equals(true)); |
| 467 unittest.expect(casted6["string"], unittest.equals('foo')); |
| 425 } | 468 } |
| 426 | 469 |
| 427 buildUnnamed2716() { | 470 buildUnnamed2709() { |
| 428 var o = new core.List<core.Map<core.String, core.Object>>(); | 471 var o = new core.List<core.Map<core.String, core.Object>>(); |
| 429 o.add(buildUnnamed2715()); | 472 o.add(buildUnnamed2708()); |
| 430 o.add(buildUnnamed2715()); | 473 o.add(buildUnnamed2708()); |
| 431 return o; | 474 return o; |
| 432 } | 475 } |
| 433 | 476 |
| 434 checkUnnamed2716(core.List<core.Map<core.String, core.Object>> o) { | 477 checkUnnamed2709(core.List<core.Map<core.String, core.Object>> o) { |
| 435 unittest.expect(o, unittest.hasLength(2)); | 478 unittest.expect(o, unittest.hasLength(2)); |
| 436 checkUnnamed2715(o[0]); | 479 checkUnnamed2708(o[0]); |
| 437 checkUnnamed2715(o[1]); | 480 checkUnnamed2708(o[1]); |
| 438 } | 481 } |
| 439 | 482 |
| 440 core.int buildCounterStatus = 0; | 483 core.int buildCounterStatus = 0; |
| 441 buildStatus() { | 484 buildStatus() { |
| 442 var o = new api.Status(); | 485 var o = new api.Status(); |
| 443 buildCounterStatus++; | 486 buildCounterStatus++; |
| 444 if (buildCounterStatus < 3) { | 487 if (buildCounterStatus < 3) { |
| 445 o.code = 42; | 488 o.code = 42; |
| 446 o.details = buildUnnamed2716(); | 489 o.details = buildUnnamed2709(); |
| 447 o.message = "foo"; | 490 o.message = "foo"; |
| 448 } | 491 } |
| 449 buildCounterStatus--; | 492 buildCounterStatus--; |
| 450 return o; | 493 return o; |
| 451 } | 494 } |
| 452 | 495 |
| 453 checkStatus(api.Status o) { | 496 checkStatus(api.Status o) { |
| 454 buildCounterStatus++; | 497 buildCounterStatus++; |
| 455 if (buildCounterStatus < 3) { | 498 if (buildCounterStatus < 3) { |
| 456 unittest.expect(o.code, unittest.equals(42)); | 499 unittest.expect(o.code, unittest.equals(42)); |
| 457 checkUnnamed2716(o.details); | 500 checkUnnamed2709(o.details); |
| 458 unittest.expect(o.message, unittest.equals('foo')); | 501 unittest.expect(o.message, unittest.equals('foo')); |
| 459 } | 502 } |
| 460 buildCounterStatus--; | 503 buildCounterStatus--; |
| 461 } | 504 } |
| 462 | 505 |
| 463 core.int buildCounterWordInfo = 0; | 506 core.int buildCounterWordInfo = 0; |
| 464 buildWordInfo() { | 507 buildWordInfo() { |
| 465 var o = new api.WordInfo(); | 508 var o = new api.WordInfo(); |
| 466 buildCounterWordInfo++; | 509 buildCounterWordInfo++; |
| 467 if (buildCounterWordInfo < 3) { | 510 if (buildCounterWordInfo < 3) { |
| 468 o.endTime = "foo"; | 511 o.endTime = "foo"; |
| 469 o.startTime = "foo"; | 512 o.startTime = "foo"; |
| 470 o.word = "foo"; | 513 o.word = "foo"; |
| 471 } | 514 } |
| 472 buildCounterWordInfo--; | 515 buildCounterWordInfo--; |
| 473 return o; | 516 return o; |
| 474 } | 517 } |
| 475 | 518 |
| 476 checkWordInfo(api.WordInfo o) { | 519 checkWordInfo(api.WordInfo o) { |
| 477 buildCounterWordInfo++; | 520 buildCounterWordInfo++; |
| 478 if (buildCounterWordInfo < 3) { | 521 if (buildCounterWordInfo < 3) { |
| 479 unittest.expect(o.endTime, unittest.equals('foo')); | 522 unittest.expect(o.endTime, unittest.equals('foo')); |
| 480 unittest.expect(o.startTime, unittest.equals('foo')); | 523 unittest.expect(o.startTime, unittest.equals('foo')); |
| 481 unittest.expect(o.word, unittest.equals('foo')); | 524 unittest.expect(o.word, unittest.equals('foo')); |
| 482 } | 525 } |
| 483 buildCounterWordInfo--; | 526 buildCounterWordInfo--; |
| 484 } | 527 } |
| 485 | 528 |
| 486 | |
| 487 main() { | 529 main() { |
| 488 unittest.group("obj-schema-CancelOperationRequest", () { | 530 unittest.group("obj-schema-CancelOperationRequest", () { |
| 489 unittest.test("to-json--from-json", () { | 531 unittest.test("to-json--from-json", () { |
| 490 var o = buildCancelOperationRequest(); | 532 var o = buildCancelOperationRequest(); |
| 491 var od = new api.CancelOperationRequest.fromJson(o.toJson()); | 533 var od = new api.CancelOperationRequest.fromJson(o.toJson()); |
| 492 checkCancelOperationRequest(od); | 534 checkCancelOperationRequest(od); |
| 493 }); | 535 }); |
| 494 }); | 536 }); |
| 495 | 537 |
| 496 | |
| 497 unittest.group("obj-schema-Empty", () { | 538 unittest.group("obj-schema-Empty", () { |
| 498 unittest.test("to-json--from-json", () { | 539 unittest.test("to-json--from-json", () { |
| 499 var o = buildEmpty(); | 540 var o = buildEmpty(); |
| 500 var od = new api.Empty.fromJson(o.toJson()); | 541 var od = new api.Empty.fromJson(o.toJson()); |
| 501 checkEmpty(od); | 542 checkEmpty(od); |
| 502 }); | 543 }); |
| 503 }); | 544 }); |
| 504 | 545 |
| 505 | |
| 506 unittest.group("obj-schema-ListOperationsResponse", () { | 546 unittest.group("obj-schema-ListOperationsResponse", () { |
| 507 unittest.test("to-json--from-json", () { | 547 unittest.test("to-json--from-json", () { |
| 508 var o = buildListOperationsResponse(); | 548 var o = buildListOperationsResponse(); |
| 509 var od = new api.ListOperationsResponse.fromJson(o.toJson()); | 549 var od = new api.ListOperationsResponse.fromJson(o.toJson()); |
| 510 checkListOperationsResponse(od); | 550 checkListOperationsResponse(od); |
| 511 }); | 551 }); |
| 512 }); | 552 }); |
| 513 | 553 |
| 514 | |
| 515 unittest.group("obj-schema-LongRunningRecognizeRequest", () { | 554 unittest.group("obj-schema-LongRunningRecognizeRequest", () { |
| 516 unittest.test("to-json--from-json", () { | 555 unittest.test("to-json--from-json", () { |
| 517 var o = buildLongRunningRecognizeRequest(); | 556 var o = buildLongRunningRecognizeRequest(); |
| 518 var od = new api.LongRunningRecognizeRequest.fromJson(o.toJson()); | 557 var od = new api.LongRunningRecognizeRequest.fromJson(o.toJson()); |
| 519 checkLongRunningRecognizeRequest(od); | 558 checkLongRunningRecognizeRequest(od); |
| 520 }); | 559 }); |
| 521 }); | 560 }); |
| 522 | 561 |
| 523 | |
| 524 unittest.group("obj-schema-Operation", () { | 562 unittest.group("obj-schema-Operation", () { |
| 525 unittest.test("to-json--from-json", () { | 563 unittest.test("to-json--from-json", () { |
| 526 var o = buildOperation(); | 564 var o = buildOperation(); |
| 527 var od = new api.Operation.fromJson(o.toJson()); | 565 var od = new api.Operation.fromJson(o.toJson()); |
| 528 checkOperation(od); | 566 checkOperation(od); |
| 529 }); | 567 }); |
| 530 }); | 568 }); |
| 531 | 569 |
| 532 | |
| 533 unittest.group("obj-schema-RecognitionAudio", () { | 570 unittest.group("obj-schema-RecognitionAudio", () { |
| 534 unittest.test("to-json--from-json", () { | 571 unittest.test("to-json--from-json", () { |
| 535 var o = buildRecognitionAudio(); | 572 var o = buildRecognitionAudio(); |
| 536 var od = new api.RecognitionAudio.fromJson(o.toJson()); | 573 var od = new api.RecognitionAudio.fromJson(o.toJson()); |
| 537 checkRecognitionAudio(od); | 574 checkRecognitionAudio(od); |
| 538 }); | 575 }); |
| 539 }); | 576 }); |
| 540 | 577 |
| 541 | |
| 542 unittest.group("obj-schema-RecognitionConfig", () { | 578 unittest.group("obj-schema-RecognitionConfig", () { |
| 543 unittest.test("to-json--from-json", () { | 579 unittest.test("to-json--from-json", () { |
| 544 var o = buildRecognitionConfig(); | 580 var o = buildRecognitionConfig(); |
| 545 var od = new api.RecognitionConfig.fromJson(o.toJson()); | 581 var od = new api.RecognitionConfig.fromJson(o.toJson()); |
| 546 checkRecognitionConfig(od); | 582 checkRecognitionConfig(od); |
| 547 }); | 583 }); |
| 548 }); | 584 }); |
| 549 | 585 |
| 550 | |
| 551 unittest.group("obj-schema-RecognizeRequest", () { | 586 unittest.group("obj-schema-RecognizeRequest", () { |
| 552 unittest.test("to-json--from-json", () { | 587 unittest.test("to-json--from-json", () { |
| 553 var o = buildRecognizeRequest(); | 588 var o = buildRecognizeRequest(); |
| 554 var od = new api.RecognizeRequest.fromJson(o.toJson()); | 589 var od = new api.RecognizeRequest.fromJson(o.toJson()); |
| 555 checkRecognizeRequest(od); | 590 checkRecognizeRequest(od); |
| 556 }); | 591 }); |
| 557 }); | 592 }); |
| 558 | 593 |
| 559 | |
| 560 unittest.group("obj-schema-RecognizeResponse", () { | 594 unittest.group("obj-schema-RecognizeResponse", () { |
| 561 unittest.test("to-json--from-json", () { | 595 unittest.test("to-json--from-json", () { |
| 562 var o = buildRecognizeResponse(); | 596 var o = buildRecognizeResponse(); |
| 563 var od = new api.RecognizeResponse.fromJson(o.toJson()); | 597 var od = new api.RecognizeResponse.fromJson(o.toJson()); |
| 564 checkRecognizeResponse(od); | 598 checkRecognizeResponse(od); |
| 565 }); | 599 }); |
| 566 }); | 600 }); |
| 567 | 601 |
| 568 | |
| 569 unittest.group("obj-schema-SpeechContext", () { | 602 unittest.group("obj-schema-SpeechContext", () { |
| 570 unittest.test("to-json--from-json", () { | 603 unittest.test("to-json--from-json", () { |
| 571 var o = buildSpeechContext(); | 604 var o = buildSpeechContext(); |
| 572 var od = new api.SpeechContext.fromJson(o.toJson()); | 605 var od = new api.SpeechContext.fromJson(o.toJson()); |
| 573 checkSpeechContext(od); | 606 checkSpeechContext(od); |
| 574 }); | 607 }); |
| 575 }); | 608 }); |
| 576 | 609 |
| 577 | |
| 578 unittest.group("obj-schema-SpeechRecognitionAlternative", () { | 610 unittest.group("obj-schema-SpeechRecognitionAlternative", () { |
| 579 unittest.test("to-json--from-json", () { | 611 unittest.test("to-json--from-json", () { |
| 580 var o = buildSpeechRecognitionAlternative(); | 612 var o = buildSpeechRecognitionAlternative(); |
| 581 var od = new api.SpeechRecognitionAlternative.fromJson(o.toJson()); | 613 var od = new api.SpeechRecognitionAlternative.fromJson(o.toJson()); |
| 582 checkSpeechRecognitionAlternative(od); | 614 checkSpeechRecognitionAlternative(od); |
| 583 }); | 615 }); |
| 584 }); | 616 }); |
| 585 | 617 |
| 586 | |
| 587 unittest.group("obj-schema-SpeechRecognitionResult", () { | 618 unittest.group("obj-schema-SpeechRecognitionResult", () { |
| 588 unittest.test("to-json--from-json", () { | 619 unittest.test("to-json--from-json", () { |
| 589 var o = buildSpeechRecognitionResult(); | 620 var o = buildSpeechRecognitionResult(); |
| 590 var od = new api.SpeechRecognitionResult.fromJson(o.toJson()); | 621 var od = new api.SpeechRecognitionResult.fromJson(o.toJson()); |
| 591 checkSpeechRecognitionResult(od); | 622 checkSpeechRecognitionResult(od); |
| 592 }); | 623 }); |
| 593 }); | 624 }); |
| 594 | 625 |
| 595 | |
| 596 unittest.group("obj-schema-Status", () { | 626 unittest.group("obj-schema-Status", () { |
| 597 unittest.test("to-json--from-json", () { | 627 unittest.test("to-json--from-json", () { |
| 598 var o = buildStatus(); | 628 var o = buildStatus(); |
| 599 var od = new api.Status.fromJson(o.toJson()); | 629 var od = new api.Status.fromJson(o.toJson()); |
| 600 checkStatus(od); | 630 checkStatus(od); |
| 601 }); | 631 }); |
| 602 }); | 632 }); |
| 603 | 633 |
| 604 | |
| 605 unittest.group("obj-schema-WordInfo", () { | 634 unittest.group("obj-schema-WordInfo", () { |
| 606 unittest.test("to-json--from-json", () { | 635 unittest.test("to-json--from-json", () { |
| 607 var o = buildWordInfo(); | 636 var o = buildWordInfo(); |
| 608 var od = new api.WordInfo.fromJson(o.toJson()); | 637 var od = new api.WordInfo.fromJson(o.toJson()); |
| 609 checkWordInfo(od); | 638 checkWordInfo(od); |
| 610 }); | 639 }); |
| 611 }); | 640 }); |
| 612 | 641 |
| 613 | |
| 614 unittest.group("resource-OperationsResourceApi", () { | 642 unittest.group("resource-OperationsResourceApi", () { |
| 615 unittest.test("method--cancel", () { | 643 unittest.test("method--cancel", () { |
| 616 | |
| 617 var mock = new HttpServerMock(); | 644 var mock = new HttpServerMock(); |
| 618 api.OperationsResourceApi res = new api.SpeechApi(mock).operations; | 645 api.OperationsResourceApi res = new api.SpeechApi(mock).operations; |
| 619 var arg_request = buildCancelOperationRequest(); | 646 var arg_request = buildCancelOperationRequest(); |
| 620 var arg_name = "foo"; | 647 var arg_name = "foo"; |
| 621 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 648 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| 622 var obj = new api.CancelOperationRequest.fromJson(json); | 649 var obj = new api.CancelOperationRequest.fromJson(json); |
| 623 checkCancelOperationRequest(obj); | 650 checkCancelOperationRequest(obj); |
| 624 | 651 |
| 625 var path = (req.url).path; | 652 var path = (req.url).path; |
| 626 var pathOffset = 0; | 653 var pathOffset = 0; |
| 627 var index; | 654 var index; |
| 628 var subPart; | 655 var subPart; |
| 629 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 656 unittest.expect( |
| 657 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
| 630 pathOffset += 1; | 658 pathOffset += 1; |
| 631 unittest.expect(path.substring(pathOffset, pathOffset + 14), unittest.eq
uals("v1/operations/")); | 659 unittest.expect(path.substring(pathOffset, pathOffset + 14), |
| 660 unittest.equals("v1/operations/")); |
| 632 pathOffset += 14; | 661 pathOffset += 14; |
| 633 // NOTE: We cannot test reserved expansions due to the inability to reve
rse the operation; | 662 // NOTE: We cannot test reserved expansions due to the inability to reve
rse the operation; |
| 634 | 663 |
| 635 var query = (req.url).query; | 664 var query = (req.url).query; |
| 636 var queryOffset = 0; | 665 var queryOffset = 0; |
| 637 var queryMap = {}; | 666 var queryMap = {}; |
| 638 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 667 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 639 parseBool(n) { | 668 parseBool(n) { |
| 640 if (n == "true") return true; | 669 if (n == "true") return true; |
| 641 if (n == "false") return false; | 670 if (n == "false") return false; |
| 642 if (n == null) return null; | 671 if (n == null) return null; |
| 643 throw new core.ArgumentError("Invalid boolean: $n"); | 672 throw new core.ArgumentError("Invalid boolean: $n"); |
| 644 } | 673 } |
| 674 |
| 645 if (query.length > 0) { | 675 if (query.length > 0) { |
| 646 for (var part in query.split("&")) { | 676 for (var part in query.split("&")) { |
| 647 var keyvalue = part.split("="); | 677 var keyvalue = part.split("="); |
| 648 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 678 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 679 core.Uri.decodeQueryComponent(keyvalue[1])); |
| 649 } | 680 } |
| 650 } | 681 } |
| 651 | 682 |
| 652 | |
| 653 var h = { | 683 var h = { |
| 654 "content-type" : "application/json; charset=utf-8", | 684 "content-type": "application/json; charset=utf-8", |
| 655 }; | 685 }; |
| 656 var resp = convert.JSON.encode(buildEmpty()); | 686 var resp = convert.JSON.encode(buildEmpty()); |
| 657 return new async.Future.value(stringResponse(200, h, resp)); | 687 return new async.Future.value(stringResponse(200, h, resp)); |
| 658 }), true); | 688 }), true); |
| 659 res.cancel(arg_request, arg_name).then(unittest.expectAsync1(((api.Empty r
esponse) { | 689 res |
| 690 .cancel(arg_request, arg_name) |
| 691 .then(unittest.expectAsync1(((api.Empty response) { |
| 660 checkEmpty(response); | 692 checkEmpty(response); |
| 661 }))); | 693 }))); |
| 662 }); | 694 }); |
| 663 | 695 |
| 664 unittest.test("method--delete", () { | 696 unittest.test("method--delete", () { |
| 665 | |
| 666 var mock = new HttpServerMock(); | 697 var mock = new HttpServerMock(); |
| 667 api.OperationsResourceApi res = new api.SpeechApi(mock).operations; | 698 api.OperationsResourceApi res = new api.SpeechApi(mock).operations; |
| 668 var arg_name = "foo"; | 699 var arg_name = "foo"; |
| 669 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 700 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| 670 var path = (req.url).path; | 701 var path = (req.url).path; |
| 671 var pathOffset = 0; | 702 var pathOffset = 0; |
| 672 var index; | 703 var index; |
| 673 var subPart; | 704 var subPart; |
| 674 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 705 unittest.expect( |
| 706 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
| 675 pathOffset += 1; | 707 pathOffset += 1; |
| 676 unittest.expect(path.substring(pathOffset, pathOffset + 14), unittest.eq
uals("v1/operations/")); | 708 unittest.expect(path.substring(pathOffset, pathOffset + 14), |
| 709 unittest.equals("v1/operations/")); |
| 677 pathOffset += 14; | 710 pathOffset += 14; |
| 678 // NOTE: We cannot test reserved expansions due to the inability to reve
rse the operation; | 711 // NOTE: We cannot test reserved expansions due to the inability to reve
rse the operation; |
| 679 | 712 |
| 680 var query = (req.url).query; | 713 var query = (req.url).query; |
| 681 var queryOffset = 0; | 714 var queryOffset = 0; |
| 682 var queryMap = {}; | 715 var queryMap = {}; |
| 683 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 716 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 684 parseBool(n) { | 717 parseBool(n) { |
| 685 if (n == "true") return true; | 718 if (n == "true") return true; |
| 686 if (n == "false") return false; | 719 if (n == "false") return false; |
| 687 if (n == null) return null; | 720 if (n == null) return null; |
| 688 throw new core.ArgumentError("Invalid boolean: $n"); | 721 throw new core.ArgumentError("Invalid boolean: $n"); |
| 689 } | 722 } |
| 723 |
| 690 if (query.length > 0) { | 724 if (query.length > 0) { |
| 691 for (var part in query.split("&")) { | 725 for (var part in query.split("&")) { |
| 692 var keyvalue = part.split("="); | 726 var keyvalue = part.split("="); |
| 693 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 727 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 728 core.Uri.decodeQueryComponent(keyvalue[1])); |
| 694 } | 729 } |
| 695 } | 730 } |
| 696 | 731 |
| 697 | |
| 698 var h = { | 732 var h = { |
| 699 "content-type" : "application/json; charset=utf-8", | 733 "content-type": "application/json; charset=utf-8", |
| 700 }; | 734 }; |
| 701 var resp = convert.JSON.encode(buildEmpty()); | 735 var resp = convert.JSON.encode(buildEmpty()); |
| 702 return new async.Future.value(stringResponse(200, h, resp)); | 736 return new async.Future.value(stringResponse(200, h, resp)); |
| 703 }), true); | 737 }), true); |
| 704 res.delete(arg_name).then(unittest.expectAsync1(((api.Empty response) { | 738 res.delete(arg_name).then(unittest.expectAsync1(((api.Empty response) { |
| 705 checkEmpty(response); | 739 checkEmpty(response); |
| 706 }))); | 740 }))); |
| 707 }); | 741 }); |
| 708 | 742 |
| 709 unittest.test("method--get", () { | 743 unittest.test("method--get", () { |
| 710 | |
| 711 var mock = new HttpServerMock(); | 744 var mock = new HttpServerMock(); |
| 712 api.OperationsResourceApi res = new api.SpeechApi(mock).operations; | 745 api.OperationsResourceApi res = new api.SpeechApi(mock).operations; |
| 713 var arg_name = "foo"; | 746 var arg_name = "foo"; |
| 714 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 747 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| 715 var path = (req.url).path; | 748 var path = (req.url).path; |
| 716 var pathOffset = 0; | 749 var pathOffset = 0; |
| 717 var index; | 750 var index; |
| 718 var subPart; | 751 var subPart; |
| 719 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 752 unittest.expect( |
| 753 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
| 720 pathOffset += 1; | 754 pathOffset += 1; |
| 721 unittest.expect(path.substring(pathOffset, pathOffset + 14), unittest.eq
uals("v1/operations/")); | 755 unittest.expect(path.substring(pathOffset, pathOffset + 14), |
| 756 unittest.equals("v1/operations/")); |
| 722 pathOffset += 14; | 757 pathOffset += 14; |
| 723 // NOTE: We cannot test reserved expansions due to the inability to reve
rse the operation; | 758 // NOTE: We cannot test reserved expansions due to the inability to reve
rse the operation; |
| 724 | 759 |
| 725 var query = (req.url).query; | 760 var query = (req.url).query; |
| 726 var queryOffset = 0; | 761 var queryOffset = 0; |
| 727 var queryMap = {}; | 762 var queryMap = {}; |
| 728 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 763 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 729 parseBool(n) { | 764 parseBool(n) { |
| 730 if (n == "true") return true; | 765 if (n == "true") return true; |
| 731 if (n == "false") return false; | 766 if (n == "false") return false; |
| 732 if (n == null) return null; | 767 if (n == null) return null; |
| 733 throw new core.ArgumentError("Invalid boolean: $n"); | 768 throw new core.ArgumentError("Invalid boolean: $n"); |
| 734 } | 769 } |
| 770 |
| 735 if (query.length > 0) { | 771 if (query.length > 0) { |
| 736 for (var part in query.split("&")) { | 772 for (var part in query.split("&")) { |
| 737 var keyvalue = part.split("="); | 773 var keyvalue = part.split("="); |
| 738 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 774 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 775 core.Uri.decodeQueryComponent(keyvalue[1])); |
| 739 } | 776 } |
| 740 } | 777 } |
| 741 | 778 |
| 742 | |
| 743 var h = { | 779 var h = { |
| 744 "content-type" : "application/json; charset=utf-8", | 780 "content-type": "application/json; charset=utf-8", |
| 745 }; | 781 }; |
| 746 var resp = convert.JSON.encode(buildOperation()); | 782 var resp = convert.JSON.encode(buildOperation()); |
| 747 return new async.Future.value(stringResponse(200, h, resp)); | 783 return new async.Future.value(stringResponse(200, h, resp)); |
| 748 }), true); | 784 }), true); |
| 749 res.get(arg_name).then(unittest.expectAsync1(((api.Operation response) { | 785 res.get(arg_name).then(unittest.expectAsync1(((api.Operation response) { |
| 750 checkOperation(response); | 786 checkOperation(response); |
| 751 }))); | 787 }))); |
| 752 }); | 788 }); |
| 753 | 789 |
| 754 unittest.test("method--list", () { | 790 unittest.test("method--list", () { |
| 755 | |
| 756 var mock = new HttpServerMock(); | 791 var mock = new HttpServerMock(); |
| 757 api.OperationsResourceApi res = new api.SpeechApi(mock).operations; | 792 api.OperationsResourceApi res = new api.SpeechApi(mock).operations; |
| 758 var arg_filter = "foo"; | 793 var arg_filter = "foo"; |
| 759 var arg_pageToken = "foo"; | 794 var arg_pageToken = "foo"; |
| 760 var arg_name = "foo"; | 795 var arg_name = "foo"; |
| 761 var arg_pageSize = 42; | 796 var arg_pageSize = 42; |
| 762 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 797 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| 763 var path = (req.url).path; | 798 var path = (req.url).path; |
| 764 var pathOffset = 0; | 799 var pathOffset = 0; |
| 765 var index; | 800 var index; |
| 766 var subPart; | 801 var subPart; |
| 767 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 802 unittest.expect( |
| 803 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
| 768 pathOffset += 1; | 804 pathOffset += 1; |
| 769 unittest.expect(path.substring(pathOffset, pathOffset + 13), unittest.eq
uals("v1/operations")); | 805 unittest.expect(path.substring(pathOffset, pathOffset + 13), |
| 806 unittest.equals("v1/operations")); |
| 770 pathOffset += 13; | 807 pathOffset += 13; |
| 771 | 808 |
| 772 var query = (req.url).query; | 809 var query = (req.url).query; |
| 773 var queryOffset = 0; | 810 var queryOffset = 0; |
| 774 var queryMap = {}; | 811 var queryMap = {}; |
| 775 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 812 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 776 parseBool(n) { | 813 parseBool(n) { |
| 777 if (n == "true") return true; | 814 if (n == "true") return true; |
| 778 if (n == "false") return false; | 815 if (n == "false") return false; |
| 779 if (n == null) return null; | 816 if (n == null) return null; |
| 780 throw new core.ArgumentError("Invalid boolean: $n"); | 817 throw new core.ArgumentError("Invalid boolean: $n"); |
| 781 } | 818 } |
| 819 |
| 782 if (query.length > 0) { | 820 if (query.length > 0) { |
| 783 for (var part in query.split("&")) { | 821 for (var part in query.split("&")) { |
| 784 var keyvalue = part.split("="); | 822 var keyvalue = part.split("="); |
| 785 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 823 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 824 core.Uri.decodeQueryComponent(keyvalue[1])); |
| 786 } | 825 } |
| 787 } | 826 } |
| 788 unittest.expect(queryMap["filter"].first, unittest.equals(arg_filter)); | 827 unittest.expect(queryMap["filter"].first, unittest.equals(arg_filter)); |
| 789 unittest.expect(queryMap["pageToken"].first, unittest.equals(arg_pageTok
en)); | 828 unittest.expect( |
| 829 queryMap["pageToken"].first, unittest.equals(arg_pageToken)); |
| 790 unittest.expect(queryMap["name"].first, unittest.equals(arg_name)); | 830 unittest.expect(queryMap["name"].first, unittest.equals(arg_name)); |
| 791 unittest.expect(core.int.parse(queryMap["pageSize"].first), unittest.equ
als(arg_pageSize)); | 831 unittest.expect(core.int.parse(queryMap["pageSize"].first), |
| 792 | 832 unittest.equals(arg_pageSize)); |
| 793 | 833 |
| 794 var h = { | 834 var h = { |
| 795 "content-type" : "application/json; charset=utf-8", | 835 "content-type": "application/json; charset=utf-8", |
| 796 }; | 836 }; |
| 797 var resp = convert.JSON.encode(buildListOperationsResponse()); | 837 var resp = convert.JSON.encode(buildListOperationsResponse()); |
| 798 return new async.Future.value(stringResponse(200, h, resp)); | 838 return new async.Future.value(stringResponse(200, h, resp)); |
| 799 }), true); | 839 }), true); |
| 800 res.list(filter: arg_filter, pageToken: arg_pageToken, name: arg_name, pag
eSize: arg_pageSize).then(unittest.expectAsync1(((api.ListOperationsResponse res
ponse) { | 840 res |
| 841 .list( |
| 842 filter: arg_filter, |
| 843 pageToken: arg_pageToken, |
| 844 name: arg_name, |
| 845 pageSize: arg_pageSize) |
| 846 .then(unittest.expectAsync1(((api.ListOperationsResponse response) { |
| 801 checkListOperationsResponse(response); | 847 checkListOperationsResponse(response); |
| 802 }))); | 848 }))); |
| 803 }); | 849 }); |
| 804 | |
| 805 }); | 850 }); |
| 806 | 851 |
| 807 | |
| 808 unittest.group("resource-SpeechResourceApi", () { | 852 unittest.group("resource-SpeechResourceApi", () { |
| 809 unittest.test("method--longrunningrecognize", () { | 853 unittest.test("method--longrunningrecognize", () { |
| 810 | |
| 811 var mock = new HttpServerMock(); | 854 var mock = new HttpServerMock(); |
| 812 api.SpeechResourceApi res = new api.SpeechApi(mock).speech; | 855 api.SpeechResourceApi res = new api.SpeechApi(mock).speech; |
| 813 var arg_request = buildLongRunningRecognizeRequest(); | 856 var arg_request = buildLongRunningRecognizeRequest(); |
| 814 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 857 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| 815 var obj = new api.LongRunningRecognizeRequest.fromJson(json); | 858 var obj = new api.LongRunningRecognizeRequest.fromJson(json); |
| 816 checkLongRunningRecognizeRequest(obj); | 859 checkLongRunningRecognizeRequest(obj); |
| 817 | 860 |
| 818 var path = (req.url).path; | 861 var path = (req.url).path; |
| 819 var pathOffset = 0; | 862 var pathOffset = 0; |
| 820 var index; | 863 var index; |
| 821 var subPart; | 864 var subPart; |
| 822 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 865 unittest.expect( |
| 866 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
| 823 pathOffset += 1; | 867 pathOffset += 1; |
| 824 unittest.expect(path.substring(pathOffset, pathOffset + 30), unittest.eq
uals("v1/speech:longrunningrecognize")); | 868 unittest.expect(path.substring(pathOffset, pathOffset + 30), |
| 869 unittest.equals("v1/speech:longrunningrecognize")); |
| 825 pathOffset += 30; | 870 pathOffset += 30; |
| 826 | 871 |
| 827 var query = (req.url).query; | 872 var query = (req.url).query; |
| 828 var queryOffset = 0; | 873 var queryOffset = 0; |
| 829 var queryMap = {}; | 874 var queryMap = {}; |
| 830 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 875 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 831 parseBool(n) { | 876 parseBool(n) { |
| 832 if (n == "true") return true; | 877 if (n == "true") return true; |
| 833 if (n == "false") return false; | 878 if (n == "false") return false; |
| 834 if (n == null) return null; | 879 if (n == null) return null; |
| 835 throw new core.ArgumentError("Invalid boolean: $n"); | 880 throw new core.ArgumentError("Invalid boolean: $n"); |
| 836 } | 881 } |
| 882 |
| 837 if (query.length > 0) { | 883 if (query.length > 0) { |
| 838 for (var part in query.split("&")) { | 884 for (var part in query.split("&")) { |
| 839 var keyvalue = part.split("="); | 885 var keyvalue = part.split("="); |
| 840 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 886 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 887 core.Uri.decodeQueryComponent(keyvalue[1])); |
| 841 } | 888 } |
| 842 } | 889 } |
| 843 | 890 |
| 844 | |
| 845 var h = { | 891 var h = { |
| 846 "content-type" : "application/json; charset=utf-8", | 892 "content-type": "application/json; charset=utf-8", |
| 847 }; | 893 }; |
| 848 var resp = convert.JSON.encode(buildOperation()); | 894 var resp = convert.JSON.encode(buildOperation()); |
| 849 return new async.Future.value(stringResponse(200, h, resp)); | 895 return new async.Future.value(stringResponse(200, h, resp)); |
| 850 }), true); | 896 }), true); |
| 851 res.longrunningrecognize(arg_request).then(unittest.expectAsync1(((api.Ope
ration response) { | 897 res |
| 898 .longrunningrecognize(arg_request) |
| 899 .then(unittest.expectAsync1(((api.Operation response) { |
| 852 checkOperation(response); | 900 checkOperation(response); |
| 853 }))); | 901 }))); |
| 854 }); | 902 }); |
| 855 | 903 |
| 856 unittest.test("method--recognize", () { | 904 unittest.test("method--recognize", () { |
| 857 | |
| 858 var mock = new HttpServerMock(); | 905 var mock = new HttpServerMock(); |
| 859 api.SpeechResourceApi res = new api.SpeechApi(mock).speech; | 906 api.SpeechResourceApi res = new api.SpeechApi(mock).speech; |
| 860 var arg_request = buildRecognizeRequest(); | 907 var arg_request = buildRecognizeRequest(); |
| 861 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 908 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| 862 var obj = new api.RecognizeRequest.fromJson(json); | 909 var obj = new api.RecognizeRequest.fromJson(json); |
| 863 checkRecognizeRequest(obj); | 910 checkRecognizeRequest(obj); |
| 864 | 911 |
| 865 var path = (req.url).path; | 912 var path = (req.url).path; |
| 866 var pathOffset = 0; | 913 var pathOffset = 0; |
| 867 var index; | 914 var index; |
| 868 var subPart; | 915 var subPart; |
| 869 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 916 unittest.expect( |
| 917 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
| 870 pathOffset += 1; | 918 pathOffset += 1; |
| 871 unittest.expect(path.substring(pathOffset, pathOffset + 19), unittest.eq
uals("v1/speech:recognize")); | 919 unittest.expect(path.substring(pathOffset, pathOffset + 19), |
| 920 unittest.equals("v1/speech:recognize")); |
| 872 pathOffset += 19; | 921 pathOffset += 19; |
| 873 | 922 |
| 874 var query = (req.url).query; | 923 var query = (req.url).query; |
| 875 var queryOffset = 0; | 924 var queryOffset = 0; |
| 876 var queryMap = {}; | 925 var queryMap = {}; |
| 877 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 926 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 878 parseBool(n) { | 927 parseBool(n) { |
| 879 if (n == "true") return true; | 928 if (n == "true") return true; |
| 880 if (n == "false") return false; | 929 if (n == "false") return false; |
| 881 if (n == null) return null; | 930 if (n == null) return null; |
| 882 throw new core.ArgumentError("Invalid boolean: $n"); | 931 throw new core.ArgumentError("Invalid boolean: $n"); |
| 883 } | 932 } |
| 933 |
| 884 if (query.length > 0) { | 934 if (query.length > 0) { |
| 885 for (var part in query.split("&")) { | 935 for (var part in query.split("&")) { |
| 886 var keyvalue = part.split("="); | 936 var keyvalue = part.split("="); |
| 887 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 937 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 938 core.Uri.decodeQueryComponent(keyvalue[1])); |
| 888 } | 939 } |
| 889 } | 940 } |
| 890 | 941 |
| 891 | |
| 892 var h = { | 942 var h = { |
| 893 "content-type" : "application/json; charset=utf-8", | 943 "content-type": "application/json; charset=utf-8", |
| 894 }; | 944 }; |
| 895 var resp = convert.JSON.encode(buildRecognizeResponse()); | 945 var resp = convert.JSON.encode(buildRecognizeResponse()); |
| 896 return new async.Future.value(stringResponse(200, h, resp)); | 946 return new async.Future.value(stringResponse(200, h, resp)); |
| 897 }), true); | 947 }), true); |
| 898 res.recognize(arg_request).then(unittest.expectAsync1(((api.RecognizeRespo
nse response) { | 948 res |
| 949 .recognize(arg_request) |
| 950 .then(unittest.expectAsync1(((api.RecognizeResponse response) { |
| 899 checkRecognizeResponse(response); | 951 checkRecognizeResponse(response); |
| 900 }))); | 952 }))); |
| 901 }); | 953 }); |
| 902 | |
| 903 }); | 954 }); |
| 904 | |
| 905 | |
| 906 } | 955 } |
| 907 | |
| OLD | NEW |