| OLD | NEW |
| 1 library googleapis.script.v1.test; | 1 library googleapis.script.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/script/v1.dart' as api; | 10 import 'package:googleapis/script/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 buildUnnamed799() { | 53 buildUnnamed802() { |
| 55 var o = new core.List<api.ScriptStackTraceElement>(); | 54 var o = new core.List<api.ScriptStackTraceElement>(); |
| 56 o.add(buildScriptStackTraceElement()); | 55 o.add(buildScriptStackTraceElement()); |
| 57 o.add(buildScriptStackTraceElement()); | 56 o.add(buildScriptStackTraceElement()); |
| 58 return o; | 57 return o; |
| 59 } | 58 } |
| 60 | 59 |
| 61 checkUnnamed799(core.List<api.ScriptStackTraceElement> o) { | 60 checkUnnamed802(core.List<api.ScriptStackTraceElement> o) { |
| 62 unittest.expect(o, unittest.hasLength(2)); | 61 unittest.expect(o, unittest.hasLength(2)); |
| 63 checkScriptStackTraceElement(o[0]); | 62 checkScriptStackTraceElement(o[0]); |
| 64 checkScriptStackTraceElement(o[1]); | 63 checkScriptStackTraceElement(o[1]); |
| 65 } | 64 } |
| 66 | 65 |
| 67 core.int buildCounterExecutionError = 0; | 66 core.int buildCounterExecutionError = 0; |
| 68 buildExecutionError() { | 67 buildExecutionError() { |
| 69 var o = new api.ExecutionError(); | 68 var o = new api.ExecutionError(); |
| 70 buildCounterExecutionError++; | 69 buildCounterExecutionError++; |
| 71 if (buildCounterExecutionError < 3) { | 70 if (buildCounterExecutionError < 3) { |
| 72 o.errorMessage = "foo"; | 71 o.errorMessage = "foo"; |
| 73 o.errorType = "foo"; | 72 o.errorType = "foo"; |
| 74 o.scriptStackTraceElements = buildUnnamed799(); | 73 o.scriptStackTraceElements = buildUnnamed802(); |
| 75 } | 74 } |
| 76 buildCounterExecutionError--; | 75 buildCounterExecutionError--; |
| 77 return o; | 76 return o; |
| 78 } | 77 } |
| 79 | 78 |
| 80 checkExecutionError(api.ExecutionError o) { | 79 checkExecutionError(api.ExecutionError o) { |
| 81 buildCounterExecutionError++; | 80 buildCounterExecutionError++; |
| 82 if (buildCounterExecutionError < 3) { | 81 if (buildCounterExecutionError < 3) { |
| 83 unittest.expect(o.errorMessage, unittest.equals('foo')); | 82 unittest.expect(o.errorMessage, unittest.equals('foo')); |
| 84 unittest.expect(o.errorType, unittest.equals('foo')); | 83 unittest.expect(o.errorType, unittest.equals('foo')); |
| 85 checkUnnamed799(o.scriptStackTraceElements); | 84 checkUnnamed802(o.scriptStackTraceElements); |
| 86 } | 85 } |
| 87 buildCounterExecutionError--; | 86 buildCounterExecutionError--; |
| 88 } | 87 } |
| 89 | 88 |
| 90 buildUnnamed800() { | 89 buildUnnamed803() { |
| 91 var o = new core.List<core.Object>(); | 90 var o = new core.List<core.Object>(); |
| 92 o.add({'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}); | 91 o.add({ |
| 93 o.add({'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}); | 92 'list': [1, 2, 3], |
| 93 'bool': true, |
| 94 'string': 'foo' |
| 95 }); |
| 96 o.add({ |
| 97 'list': [1, 2, 3], |
| 98 'bool': true, |
| 99 'string': 'foo' |
| 100 }); |
| 94 return o; | 101 return o; |
| 95 } | 102 } |
| 96 | 103 |
| 97 checkUnnamed800(core.List<core.Object> o) { | 104 checkUnnamed803(core.List<core.Object> o) { |
| 98 unittest.expect(o, unittest.hasLength(2)); | 105 unittest.expect(o, unittest.hasLength(2)); |
| 99 var casted1 = (o[0]) as core.Map; unittest.expect(casted1, unittest.hasLength(
3)); unittest.expect(casted1["list"], unittest.equals([1, 2, 3])); unittest.expe
ct(casted1["bool"], unittest.equals(true)); unittest.expect(casted1["string"], u
nittest.equals('foo')); | 106 var casted1 = (o[0]) as core.Map; |
| 100 var casted2 = (o[1]) as core.Map; unittest.expect(casted2, unittest.hasLength(
3)); unittest.expect(casted2["list"], unittest.equals([1, 2, 3])); unittest.expe
ct(casted2["bool"], unittest.equals(true)); unittest.expect(casted2["string"], u
nittest.equals('foo')); | 107 unittest.expect(casted1, unittest.hasLength(3)); |
| 108 unittest.expect(casted1["list"], unittest.equals([1, 2, 3])); |
| 109 unittest.expect(casted1["bool"], unittest.equals(true)); |
| 110 unittest.expect(casted1["string"], unittest.equals('foo')); |
| 111 var casted2 = (o[1]) as core.Map; |
| 112 unittest.expect(casted2, unittest.hasLength(3)); |
| 113 unittest.expect(casted2["list"], unittest.equals([1, 2, 3])); |
| 114 unittest.expect(casted2["bool"], unittest.equals(true)); |
| 115 unittest.expect(casted2["string"], unittest.equals('foo')); |
| 101 } | 116 } |
| 102 | 117 |
| 103 core.int buildCounterExecutionRequest = 0; | 118 core.int buildCounterExecutionRequest = 0; |
| 104 buildExecutionRequest() { | 119 buildExecutionRequest() { |
| 105 var o = new api.ExecutionRequest(); | 120 var o = new api.ExecutionRequest(); |
| 106 buildCounterExecutionRequest++; | 121 buildCounterExecutionRequest++; |
| 107 if (buildCounterExecutionRequest < 3) { | 122 if (buildCounterExecutionRequest < 3) { |
| 108 o.devMode = true; | 123 o.devMode = true; |
| 109 o.function = "foo"; | 124 o.function = "foo"; |
| 110 o.parameters = buildUnnamed800(); | 125 o.parameters = buildUnnamed803(); |
| 111 o.sessionState = "foo"; | 126 o.sessionState = "foo"; |
| 112 } | 127 } |
| 113 buildCounterExecutionRequest--; | 128 buildCounterExecutionRequest--; |
| 114 return o; | 129 return o; |
| 115 } | 130 } |
| 116 | 131 |
| 117 checkExecutionRequest(api.ExecutionRequest o) { | 132 checkExecutionRequest(api.ExecutionRequest o) { |
| 118 buildCounterExecutionRequest++; | 133 buildCounterExecutionRequest++; |
| 119 if (buildCounterExecutionRequest < 3) { | 134 if (buildCounterExecutionRequest < 3) { |
| 120 unittest.expect(o.devMode, unittest.isTrue); | 135 unittest.expect(o.devMode, unittest.isTrue); |
| 121 unittest.expect(o.function, unittest.equals('foo')); | 136 unittest.expect(o.function, unittest.equals('foo')); |
| 122 checkUnnamed800(o.parameters); | 137 checkUnnamed803(o.parameters); |
| 123 unittest.expect(o.sessionState, unittest.equals('foo')); | 138 unittest.expect(o.sessionState, unittest.equals('foo')); |
| 124 } | 139 } |
| 125 buildCounterExecutionRequest--; | 140 buildCounterExecutionRequest--; |
| 126 } | 141 } |
| 127 | 142 |
| 128 core.int buildCounterExecutionResponse = 0; | 143 core.int buildCounterExecutionResponse = 0; |
| 129 buildExecutionResponse() { | 144 buildExecutionResponse() { |
| 130 var o = new api.ExecutionResponse(); | 145 var o = new api.ExecutionResponse(); |
| 131 buildCounterExecutionResponse++; | 146 buildCounterExecutionResponse++; |
| 132 if (buildCounterExecutionResponse < 3) { | 147 if (buildCounterExecutionResponse < 3) { |
| 133 o.result = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; | 148 o.result = { |
| 149 'list': [1, 2, 3], |
| 150 'bool': true, |
| 151 'string': 'foo' |
| 152 }; |
| 134 } | 153 } |
| 135 buildCounterExecutionResponse--; | 154 buildCounterExecutionResponse--; |
| 136 return o; | 155 return o; |
| 137 } | 156 } |
| 138 | 157 |
| 139 checkExecutionResponse(api.ExecutionResponse o) { | 158 checkExecutionResponse(api.ExecutionResponse o) { |
| 140 buildCounterExecutionResponse++; | 159 buildCounterExecutionResponse++; |
| 141 if (buildCounterExecutionResponse < 3) { | 160 if (buildCounterExecutionResponse < 3) { |
| 142 var casted3 = (o.result) as core.Map; unittest.expect(casted3, unittest.hasL
ength(3)); unittest.expect(casted3["list"], unittest.equals([1, 2, 3])); unittes
t.expect(casted3["bool"], unittest.equals(true)); unittest.expect(casted3["strin
g"], unittest.equals('foo')); | 161 var casted3 = (o.result) as core.Map; |
| 162 unittest.expect(casted3, unittest.hasLength(3)); |
| 163 unittest.expect(casted3["list"], unittest.equals([1, 2, 3])); |
| 164 unittest.expect(casted3["bool"], unittest.equals(true)); |
| 165 unittest.expect(casted3["string"], unittest.equals('foo')); |
| 143 } | 166 } |
| 144 buildCounterExecutionResponse--; | 167 buildCounterExecutionResponse--; |
| 145 } | 168 } |
| 146 | 169 |
| 147 buildUnnamed801() { | 170 buildUnnamed804() { |
| 148 var o = new core.Map<core.String, core.Object>(); | 171 var o = new core.Map<core.String, core.Object>(); |
| 149 o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; | 172 o["x"] = { |
| 150 o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; | 173 'list': [1, 2, 3], |
| 174 'bool': true, |
| 175 'string': 'foo' |
| 176 }; |
| 177 o["y"] = { |
| 178 'list': [1, 2, 3], |
| 179 'bool': true, |
| 180 'string': 'foo' |
| 181 }; |
| 151 return o; | 182 return o; |
| 152 } | 183 } |
| 153 | 184 |
| 154 checkUnnamed801(core.Map<core.String, core.Object> o) { | 185 checkUnnamed804(core.Map<core.String, core.Object> o) { |
| 155 unittest.expect(o, unittest.hasLength(2)); | 186 unittest.expect(o, unittest.hasLength(2)); |
| 156 var casted4 = (o["x"]) 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')); | 187 var casted4 = (o["x"]) as core.Map; |
| 157 var casted5 = (o["y"]) 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')); | 188 unittest.expect(casted4, unittest.hasLength(3)); |
| 189 unittest.expect(casted4["list"], unittest.equals([1, 2, 3])); |
| 190 unittest.expect(casted4["bool"], unittest.equals(true)); |
| 191 unittest.expect(casted4["string"], unittest.equals('foo')); |
| 192 var casted5 = (o["y"]) as core.Map; |
| 193 unittest.expect(casted5, unittest.hasLength(3)); |
| 194 unittest.expect(casted5["list"], unittest.equals([1, 2, 3])); |
| 195 unittest.expect(casted5["bool"], unittest.equals(true)); |
| 196 unittest.expect(casted5["string"], unittest.equals('foo')); |
| 158 } | 197 } |
| 159 | 198 |
| 160 buildUnnamed802() { | 199 buildUnnamed805() { |
| 161 var o = new core.Map<core.String, core.Object>(); | 200 var o = new core.Map<core.String, core.Object>(); |
| 162 o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; | 201 o["x"] = { |
| 163 o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; | 202 'list': [1, 2, 3], |
| 203 'bool': true, |
| 204 'string': 'foo' |
| 205 }; |
| 206 o["y"] = { |
| 207 'list': [1, 2, 3], |
| 208 'bool': true, |
| 209 'string': 'foo' |
| 210 }; |
| 164 return o; | 211 return o; |
| 165 } | 212 } |
| 166 | 213 |
| 167 checkUnnamed802(core.Map<core.String, core.Object> o) { | 214 checkUnnamed805(core.Map<core.String, core.Object> o) { |
| 168 unittest.expect(o, unittest.hasLength(2)); | 215 unittest.expect(o, unittest.hasLength(2)); |
| 169 var casted6 = (o["x"]) 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')); | 216 var casted6 = (o["x"]) as core.Map; |
| 170 var casted7 = (o["y"]) as core.Map; unittest.expect(casted7, unittest.hasLengt
h(3)); unittest.expect(casted7["list"], unittest.equals([1, 2, 3])); unittest.ex
pect(casted7["bool"], unittest.equals(true)); unittest.expect(casted7["string"],
unittest.equals('foo')); | 217 unittest.expect(casted6, unittest.hasLength(3)); |
| 218 unittest.expect(casted6["list"], unittest.equals([1, 2, 3])); |
| 219 unittest.expect(casted6["bool"], unittest.equals(true)); |
| 220 unittest.expect(casted6["string"], unittest.equals('foo')); |
| 221 var casted7 = (o["y"]) as core.Map; |
| 222 unittest.expect(casted7, unittest.hasLength(3)); |
| 223 unittest.expect(casted7["list"], unittest.equals([1, 2, 3])); |
| 224 unittest.expect(casted7["bool"], unittest.equals(true)); |
| 225 unittest.expect(casted7["string"], unittest.equals('foo')); |
| 171 } | 226 } |
| 172 | 227 |
| 173 core.int buildCounterOperation = 0; | 228 core.int buildCounterOperation = 0; |
| 174 buildOperation() { | 229 buildOperation() { |
| 175 var o = new api.Operation(); | 230 var o = new api.Operation(); |
| 176 buildCounterOperation++; | 231 buildCounterOperation++; |
| 177 if (buildCounterOperation < 3) { | 232 if (buildCounterOperation < 3) { |
| 178 o.done = true; | 233 o.done = true; |
| 179 o.error = buildStatus(); | 234 o.error = buildStatus(); |
| 180 o.metadata = buildUnnamed801(); | 235 o.metadata = buildUnnamed804(); |
| 181 o.name = "foo"; | 236 o.response = buildUnnamed805(); |
| 182 o.response = buildUnnamed802(); | |
| 183 } | 237 } |
| 184 buildCounterOperation--; | 238 buildCounterOperation--; |
| 185 return o; | 239 return o; |
| 186 } | 240 } |
| 187 | 241 |
| 188 checkOperation(api.Operation o) { | 242 checkOperation(api.Operation o) { |
| 189 buildCounterOperation++; | 243 buildCounterOperation++; |
| 190 if (buildCounterOperation < 3) { | 244 if (buildCounterOperation < 3) { |
| 191 unittest.expect(o.done, unittest.isTrue); | 245 unittest.expect(o.done, unittest.isTrue); |
| 192 checkStatus(o.error); | 246 checkStatus(o.error); |
| 193 checkUnnamed801(o.metadata); | 247 checkUnnamed804(o.metadata); |
| 194 unittest.expect(o.name, unittest.equals('foo')); | 248 checkUnnamed805(o.response); |
| 195 checkUnnamed802(o.response); | |
| 196 } | 249 } |
| 197 buildCounterOperation--; | 250 buildCounterOperation--; |
| 198 } | 251 } |
| 199 | 252 |
| 200 core.int buildCounterScriptStackTraceElement = 0; | 253 core.int buildCounterScriptStackTraceElement = 0; |
| 201 buildScriptStackTraceElement() { | 254 buildScriptStackTraceElement() { |
| 202 var o = new api.ScriptStackTraceElement(); | 255 var o = new api.ScriptStackTraceElement(); |
| 203 buildCounterScriptStackTraceElement++; | 256 buildCounterScriptStackTraceElement++; |
| 204 if (buildCounterScriptStackTraceElement < 3) { | 257 if (buildCounterScriptStackTraceElement < 3) { |
| 205 o.function = "foo"; | 258 o.function = "foo"; |
| 206 o.lineNumber = 42; | 259 o.lineNumber = 42; |
| 207 } | 260 } |
| 208 buildCounterScriptStackTraceElement--; | 261 buildCounterScriptStackTraceElement--; |
| 209 return o; | 262 return o; |
| 210 } | 263 } |
| 211 | 264 |
| 212 checkScriptStackTraceElement(api.ScriptStackTraceElement o) { | 265 checkScriptStackTraceElement(api.ScriptStackTraceElement o) { |
| 213 buildCounterScriptStackTraceElement++; | 266 buildCounterScriptStackTraceElement++; |
| 214 if (buildCounterScriptStackTraceElement < 3) { | 267 if (buildCounterScriptStackTraceElement < 3) { |
| 215 unittest.expect(o.function, unittest.equals('foo')); | 268 unittest.expect(o.function, unittest.equals('foo')); |
| 216 unittest.expect(o.lineNumber, unittest.equals(42)); | 269 unittest.expect(o.lineNumber, unittest.equals(42)); |
| 217 } | 270 } |
| 218 buildCounterScriptStackTraceElement--; | 271 buildCounterScriptStackTraceElement--; |
| 219 } | 272 } |
| 220 | 273 |
| 221 buildUnnamed803() { | 274 buildUnnamed806() { |
| 222 var o = new core.Map<core.String, core.Object>(); | 275 var o = new core.Map<core.String, core.Object>(); |
| 223 o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; | 276 o["x"] = { |
| 224 o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; | 277 'list': [1, 2, 3], |
| 278 'bool': true, |
| 279 'string': 'foo' |
| 280 }; |
| 281 o["y"] = { |
| 282 'list': [1, 2, 3], |
| 283 'bool': true, |
| 284 'string': 'foo' |
| 285 }; |
| 225 return o; | 286 return o; |
| 226 } | 287 } |
| 227 | 288 |
| 228 checkUnnamed803(core.Map<core.String, core.Object> o) { | 289 checkUnnamed806(core.Map<core.String, core.Object> o) { |
| 229 unittest.expect(o, unittest.hasLength(2)); | 290 unittest.expect(o, unittest.hasLength(2)); |
| 230 var casted8 = (o["x"]) as core.Map; unittest.expect(casted8, unittest.hasLengt
h(3)); unittest.expect(casted8["list"], unittest.equals([1, 2, 3])); unittest.ex
pect(casted8["bool"], unittest.equals(true)); unittest.expect(casted8["string"],
unittest.equals('foo')); | 291 var casted8 = (o["x"]) as core.Map; |
| 231 var casted9 = (o["y"]) as core.Map; unittest.expect(casted9, unittest.hasLengt
h(3)); unittest.expect(casted9["list"], unittest.equals([1, 2, 3])); unittest.ex
pect(casted9["bool"], unittest.equals(true)); unittest.expect(casted9["string"],
unittest.equals('foo')); | 292 unittest.expect(casted8, unittest.hasLength(3)); |
| 293 unittest.expect(casted8["list"], unittest.equals([1, 2, 3])); |
| 294 unittest.expect(casted8["bool"], unittest.equals(true)); |
| 295 unittest.expect(casted8["string"], unittest.equals('foo')); |
| 296 var casted9 = (o["y"]) as core.Map; |
| 297 unittest.expect(casted9, unittest.hasLength(3)); |
| 298 unittest.expect(casted9["list"], unittest.equals([1, 2, 3])); |
| 299 unittest.expect(casted9["bool"], unittest.equals(true)); |
| 300 unittest.expect(casted9["string"], unittest.equals('foo')); |
| 232 } | 301 } |
| 233 | 302 |
| 234 buildUnnamed804() { | 303 buildUnnamed807() { |
| 235 var o = new core.List<core.Map<core.String, core.Object>>(); | 304 var o = new core.List<core.Map<core.String, core.Object>>(); |
| 236 o.add(buildUnnamed803()); | 305 o.add(buildUnnamed806()); |
| 237 o.add(buildUnnamed803()); | 306 o.add(buildUnnamed806()); |
| 238 return o; | 307 return o; |
| 239 } | 308 } |
| 240 | 309 |
| 241 checkUnnamed804(core.List<core.Map<core.String, core.Object>> o) { | 310 checkUnnamed807(core.List<core.Map<core.String, core.Object>> o) { |
| 242 unittest.expect(o, unittest.hasLength(2)); | 311 unittest.expect(o, unittest.hasLength(2)); |
| 243 checkUnnamed803(o[0]); | 312 checkUnnamed806(o[0]); |
| 244 checkUnnamed803(o[1]); | 313 checkUnnamed806(o[1]); |
| 245 } | 314 } |
| 246 | 315 |
| 247 core.int buildCounterStatus = 0; | 316 core.int buildCounterStatus = 0; |
| 248 buildStatus() { | 317 buildStatus() { |
| 249 var o = new api.Status(); | 318 var o = new api.Status(); |
| 250 buildCounterStatus++; | 319 buildCounterStatus++; |
| 251 if (buildCounterStatus < 3) { | 320 if (buildCounterStatus < 3) { |
| 252 o.code = 42; | 321 o.code = 42; |
| 253 o.details = buildUnnamed804(); | 322 o.details = buildUnnamed807(); |
| 254 o.message = "foo"; | 323 o.message = "foo"; |
| 255 } | 324 } |
| 256 buildCounterStatus--; | 325 buildCounterStatus--; |
| 257 return o; | 326 return o; |
| 258 } | 327 } |
| 259 | 328 |
| 260 checkStatus(api.Status o) { | 329 checkStatus(api.Status o) { |
| 261 buildCounterStatus++; | 330 buildCounterStatus++; |
| 262 if (buildCounterStatus < 3) { | 331 if (buildCounterStatus < 3) { |
| 263 unittest.expect(o.code, unittest.equals(42)); | 332 unittest.expect(o.code, unittest.equals(42)); |
| 264 checkUnnamed804(o.details); | 333 checkUnnamed807(o.details); |
| 265 unittest.expect(o.message, unittest.equals('foo')); | 334 unittest.expect(o.message, unittest.equals('foo')); |
| 266 } | 335 } |
| 267 buildCounterStatus--; | 336 buildCounterStatus--; |
| 268 } | 337 } |
| 269 | 338 |
| 270 | |
| 271 main() { | 339 main() { |
| 272 unittest.group("obj-schema-ExecutionError", () { | 340 unittest.group("obj-schema-ExecutionError", () { |
| 273 unittest.test("to-json--from-json", () { | 341 unittest.test("to-json--from-json", () { |
| 274 var o = buildExecutionError(); | 342 var o = buildExecutionError(); |
| 275 var od = new api.ExecutionError.fromJson(o.toJson()); | 343 var od = new api.ExecutionError.fromJson(o.toJson()); |
| 276 checkExecutionError(od); | 344 checkExecutionError(od); |
| 277 }); | 345 }); |
| 278 }); | 346 }); |
| 279 | 347 |
| 280 | |
| 281 unittest.group("obj-schema-ExecutionRequest", () { | 348 unittest.group("obj-schema-ExecutionRequest", () { |
| 282 unittest.test("to-json--from-json", () { | 349 unittest.test("to-json--from-json", () { |
| 283 var o = buildExecutionRequest(); | 350 var o = buildExecutionRequest(); |
| 284 var od = new api.ExecutionRequest.fromJson(o.toJson()); | 351 var od = new api.ExecutionRequest.fromJson(o.toJson()); |
| 285 checkExecutionRequest(od); | 352 checkExecutionRequest(od); |
| 286 }); | 353 }); |
| 287 }); | 354 }); |
| 288 | 355 |
| 289 | |
| 290 unittest.group("obj-schema-ExecutionResponse", () { | 356 unittest.group("obj-schema-ExecutionResponse", () { |
| 291 unittest.test("to-json--from-json", () { | 357 unittest.test("to-json--from-json", () { |
| 292 var o = buildExecutionResponse(); | 358 var o = buildExecutionResponse(); |
| 293 var od = new api.ExecutionResponse.fromJson(o.toJson()); | 359 var od = new api.ExecutionResponse.fromJson(o.toJson()); |
| 294 checkExecutionResponse(od); | 360 checkExecutionResponse(od); |
| 295 }); | 361 }); |
| 296 }); | 362 }); |
| 297 | 363 |
| 298 | |
| 299 unittest.group("obj-schema-Operation", () { | 364 unittest.group("obj-schema-Operation", () { |
| 300 unittest.test("to-json--from-json", () { | 365 unittest.test("to-json--from-json", () { |
| 301 var o = buildOperation(); | 366 var o = buildOperation(); |
| 302 var od = new api.Operation.fromJson(o.toJson()); | 367 var od = new api.Operation.fromJson(o.toJson()); |
| 303 checkOperation(od); | 368 checkOperation(od); |
| 304 }); | 369 }); |
| 305 }); | 370 }); |
| 306 | 371 |
| 307 | |
| 308 unittest.group("obj-schema-ScriptStackTraceElement", () { | 372 unittest.group("obj-schema-ScriptStackTraceElement", () { |
| 309 unittest.test("to-json--from-json", () { | 373 unittest.test("to-json--from-json", () { |
| 310 var o = buildScriptStackTraceElement(); | 374 var o = buildScriptStackTraceElement(); |
| 311 var od = new api.ScriptStackTraceElement.fromJson(o.toJson()); | 375 var od = new api.ScriptStackTraceElement.fromJson(o.toJson()); |
| 312 checkScriptStackTraceElement(od); | 376 checkScriptStackTraceElement(od); |
| 313 }); | 377 }); |
| 314 }); | 378 }); |
| 315 | 379 |
| 316 | |
| 317 unittest.group("obj-schema-Status", () { | 380 unittest.group("obj-schema-Status", () { |
| 318 unittest.test("to-json--from-json", () { | 381 unittest.test("to-json--from-json", () { |
| 319 var o = buildStatus(); | 382 var o = buildStatus(); |
| 320 var od = new api.Status.fromJson(o.toJson()); | 383 var od = new api.Status.fromJson(o.toJson()); |
| 321 checkStatus(od); | 384 checkStatus(od); |
| 322 }); | 385 }); |
| 323 }); | 386 }); |
| 324 | 387 |
| 325 | |
| 326 unittest.group("resource-ScriptsResourceApi", () { | 388 unittest.group("resource-ScriptsResourceApi", () { |
| 327 unittest.test("method--run", () { | 389 unittest.test("method--run", () { |
| 328 | |
| 329 var mock = new HttpServerMock(); | 390 var mock = new HttpServerMock(); |
| 330 api.ScriptsResourceApi res = new api.ScriptApi(mock).scripts; | 391 api.ScriptsResourceApi res = new api.ScriptApi(mock).scripts; |
| 331 var arg_request = buildExecutionRequest(); | 392 var arg_request = buildExecutionRequest(); |
| 332 var arg_scriptId = "foo"; | 393 var arg_scriptId = "foo"; |
| 333 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 394 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| 334 var obj = new api.ExecutionRequest.fromJson(json); | 395 var obj = new api.ExecutionRequest.fromJson(json); |
| 335 checkExecutionRequest(obj); | 396 checkExecutionRequest(obj); |
| 336 | 397 |
| 337 var path = (req.url).path; | 398 var path = (req.url).path; |
| 338 var pathOffset = 0; | 399 var pathOffset = 0; |
| 339 var index; | 400 var index; |
| 340 var subPart; | 401 var subPart; |
| 341 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 402 unittest.expect( |
| 403 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
| 342 pathOffset += 1; | 404 pathOffset += 1; |
| 343 unittest.expect(path.substring(pathOffset, pathOffset + 11), unittest.eq
uals("v1/scripts/")); | 405 unittest.expect(path.substring(pathOffset, pathOffset + 11), |
| 406 unittest.equals("v1/scripts/")); |
| 344 pathOffset += 11; | 407 pathOffset += 11; |
| 345 index = path.indexOf(":run", pathOffset); | 408 index = path.indexOf(":run", pathOffset); |
| 346 unittest.expect(index >= 0, unittest.isTrue); | 409 unittest.expect(index >= 0, unittest.isTrue); |
| 347 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | 410 subPart = |
| 411 core.Uri.decodeQueryComponent(path.substring(pathOffset, index)); |
| 348 pathOffset = index; | 412 pathOffset = index; |
| 349 unittest.expect(subPart, unittest.equals("$arg_scriptId")); | 413 unittest.expect(subPart, unittest.equals("$arg_scriptId")); |
| 350 unittest.expect(path.substring(pathOffset, pathOffset + 4), unittest.equ
als(":run")); | 414 unittest.expect(path.substring(pathOffset, pathOffset + 4), |
| 415 unittest.equals(":run")); |
| 351 pathOffset += 4; | 416 pathOffset += 4; |
| 352 | 417 |
| 353 var query = (req.url).query; | 418 var query = (req.url).query; |
| 354 var queryOffset = 0; | 419 var queryOffset = 0; |
| 355 var queryMap = {}; | 420 var queryMap = {}; |
| 356 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 421 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 357 parseBool(n) { | 422 parseBool(n) { |
| 358 if (n == "true") return true; | 423 if (n == "true") return true; |
| 359 if (n == "false") return false; | 424 if (n == "false") return false; |
| 360 if (n == null) return null; | 425 if (n == null) return null; |
| 361 throw new core.ArgumentError("Invalid boolean: $n"); | 426 throw new core.ArgumentError("Invalid boolean: $n"); |
| 362 } | 427 } |
| 428 |
| 363 if (query.length > 0) { | 429 if (query.length > 0) { |
| 364 for (var part in query.split("&")) { | 430 for (var part in query.split("&")) { |
| 365 var keyvalue = part.split("="); | 431 var keyvalue = part.split("="); |
| 366 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 432 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 433 core.Uri.decodeQueryComponent(keyvalue[1])); |
| 367 } | 434 } |
| 368 } | 435 } |
| 369 | 436 |
| 370 | |
| 371 var h = { | 437 var h = { |
| 372 "content-type" : "application/json; charset=utf-8", | 438 "content-type": "application/json; charset=utf-8", |
| 373 }; | 439 }; |
| 374 var resp = convert.JSON.encode(buildOperation()); | 440 var resp = convert.JSON.encode(buildOperation()); |
| 375 return new async.Future.value(stringResponse(200, h, resp)); | 441 return new async.Future.value(stringResponse(200, h, resp)); |
| 376 }), true); | 442 }), true); |
| 377 res.run(arg_request, arg_scriptId).then(unittest.expectAsync1(((api.Operat
ion response) { | 443 res |
| 444 .run(arg_request, arg_scriptId) |
| 445 .then(unittest.expectAsync1(((api.Operation response) { |
| 378 checkOperation(response); | 446 checkOperation(response); |
| 379 }))); | 447 }))); |
| 380 }); | 448 }); |
| 381 | |
| 382 }); | 449 }); |
| 383 | |
| 384 | |
| 385 } | 450 } |
| 386 | |
| OLD | NEW |