OLD | NEW |
1 library googleapis.cloudfunctions.v1.test; | 1 library googleapis.cloudfunctions.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/cloudfunctions/v1.dart' as api; | 10 import 'package:googleapis/cloudfunctions/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 buildUnnamed146() { | 53 buildUnnamed141() { |
55 var o = new core.List<api.Location>(); | 54 var o = new core.List<api.Location>(); |
56 o.add(buildLocation()); | 55 o.add(buildLocation()); |
57 o.add(buildLocation()); | 56 o.add(buildLocation()); |
58 return o; | 57 return o; |
59 } | 58 } |
60 | 59 |
61 checkUnnamed146(core.List<api.Location> o) { | 60 checkUnnamed141(core.List<api.Location> o) { |
62 unittest.expect(o, unittest.hasLength(2)); | 61 unittest.expect(o, unittest.hasLength(2)); |
63 checkLocation(o[0]); | 62 checkLocation(o[0]); |
64 checkLocation(o[1]); | 63 checkLocation(o[1]); |
65 } | 64 } |
66 | 65 |
67 core.int buildCounterListLocationsResponse = 0; | 66 core.int buildCounterListLocationsResponse = 0; |
68 buildListLocationsResponse() { | 67 buildListLocationsResponse() { |
69 var o = new api.ListLocationsResponse(); | 68 var o = new api.ListLocationsResponse(); |
70 buildCounterListLocationsResponse++; | 69 buildCounterListLocationsResponse++; |
71 if (buildCounterListLocationsResponse < 3) { | 70 if (buildCounterListLocationsResponse < 3) { |
72 o.locations = buildUnnamed146(); | 71 o.locations = buildUnnamed141(); |
73 o.nextPageToken = "foo"; | 72 o.nextPageToken = "foo"; |
74 } | 73 } |
75 buildCounterListLocationsResponse--; | 74 buildCounterListLocationsResponse--; |
76 return o; | 75 return o; |
77 } | 76 } |
78 | 77 |
79 checkListLocationsResponse(api.ListLocationsResponse o) { | 78 checkListLocationsResponse(api.ListLocationsResponse o) { |
80 buildCounterListLocationsResponse++; | 79 buildCounterListLocationsResponse++; |
81 if (buildCounterListLocationsResponse < 3) { | 80 if (buildCounterListLocationsResponse < 3) { |
82 checkUnnamed146(o.locations); | 81 checkUnnamed141(o.locations); |
83 unittest.expect(o.nextPageToken, unittest.equals('foo')); | 82 unittest.expect(o.nextPageToken, unittest.equals('foo')); |
84 } | 83 } |
85 buildCounterListLocationsResponse--; | 84 buildCounterListLocationsResponse--; |
86 } | 85 } |
87 | 86 |
88 buildUnnamed147() { | 87 buildUnnamed142() { |
89 var o = new core.List<api.Operation>(); | 88 var o = new core.List<api.Operation>(); |
90 o.add(buildOperation()); | 89 o.add(buildOperation()); |
91 o.add(buildOperation()); | 90 o.add(buildOperation()); |
92 return o; | 91 return o; |
93 } | 92 } |
94 | 93 |
95 checkUnnamed147(core.List<api.Operation> o) { | 94 checkUnnamed142(core.List<api.Operation> o) { |
96 unittest.expect(o, unittest.hasLength(2)); | 95 unittest.expect(o, unittest.hasLength(2)); |
97 checkOperation(o[0]); | 96 checkOperation(o[0]); |
98 checkOperation(o[1]); | 97 checkOperation(o[1]); |
99 } | 98 } |
100 | 99 |
101 core.int buildCounterListOperationsResponse = 0; | 100 core.int buildCounterListOperationsResponse = 0; |
102 buildListOperationsResponse() { | 101 buildListOperationsResponse() { |
103 var o = new api.ListOperationsResponse(); | 102 var o = new api.ListOperationsResponse(); |
104 buildCounterListOperationsResponse++; | 103 buildCounterListOperationsResponse++; |
105 if (buildCounterListOperationsResponse < 3) { | 104 if (buildCounterListOperationsResponse < 3) { |
106 o.nextPageToken = "foo"; | 105 o.nextPageToken = "foo"; |
107 o.operations = buildUnnamed147(); | 106 o.operations = buildUnnamed142(); |
108 } | 107 } |
109 buildCounterListOperationsResponse--; | 108 buildCounterListOperationsResponse--; |
110 return o; | 109 return o; |
111 } | 110 } |
112 | 111 |
113 checkListOperationsResponse(api.ListOperationsResponse o) { | 112 checkListOperationsResponse(api.ListOperationsResponse o) { |
114 buildCounterListOperationsResponse++; | 113 buildCounterListOperationsResponse++; |
115 if (buildCounterListOperationsResponse < 3) { | 114 if (buildCounterListOperationsResponse < 3) { |
116 unittest.expect(o.nextPageToken, unittest.equals('foo')); | 115 unittest.expect(o.nextPageToken, unittest.equals('foo')); |
117 checkUnnamed147(o.operations); | 116 checkUnnamed142(o.operations); |
118 } | 117 } |
119 buildCounterListOperationsResponse--; | 118 buildCounterListOperationsResponse--; |
120 } | 119 } |
121 | 120 |
122 buildUnnamed148() { | 121 buildUnnamed143() { |
123 var o = new core.Map<core.String, core.String>(); | 122 var o = new core.Map<core.String, core.String>(); |
124 o["x"] = "foo"; | 123 o["x"] = "foo"; |
125 o["y"] = "foo"; | 124 o["y"] = "foo"; |
126 return o; | 125 return o; |
127 } | 126 } |
128 | 127 |
129 checkUnnamed148(core.Map<core.String, core.String> o) { | 128 checkUnnamed143(core.Map<core.String, core.String> o) { |
130 unittest.expect(o, unittest.hasLength(2)); | 129 unittest.expect(o, unittest.hasLength(2)); |
131 unittest.expect(o["x"], unittest.equals('foo')); | 130 unittest.expect(o["x"], unittest.equals('foo')); |
132 unittest.expect(o["y"], unittest.equals('foo')); | 131 unittest.expect(o["y"], unittest.equals('foo')); |
133 } | 132 } |
134 | 133 |
135 buildUnnamed149() { | 134 buildUnnamed144() { |
136 var o = new core.Map<core.String, core.Object>(); | 135 var o = new core.Map<core.String, core.Object>(); |
137 o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; | 136 o["x"] = { |
138 o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; | 137 'list': [1, 2, 3], |
| 138 'bool': true, |
| 139 'string': 'foo' |
| 140 }; |
| 141 o["y"] = { |
| 142 'list': [1, 2, 3], |
| 143 'bool': true, |
| 144 'string': 'foo' |
| 145 }; |
139 return o; | 146 return o; |
140 } | 147 } |
141 | 148 |
142 checkUnnamed149(core.Map<core.String, core.Object> o) { | 149 checkUnnamed144(core.Map<core.String, core.Object> o) { |
143 unittest.expect(o, unittest.hasLength(2)); | 150 unittest.expect(o, unittest.hasLength(2)); |
144 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')); | 151 var casted1 = (o["x"]) as core.Map; |
145 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')); | 152 unittest.expect(casted1, unittest.hasLength(3)); |
| 153 unittest.expect(casted1["list"], unittest.equals([1, 2, 3])); |
| 154 unittest.expect(casted1["bool"], unittest.equals(true)); |
| 155 unittest.expect(casted1["string"], unittest.equals('foo')); |
| 156 var casted2 = (o["y"]) as core.Map; |
| 157 unittest.expect(casted2, unittest.hasLength(3)); |
| 158 unittest.expect(casted2["list"], unittest.equals([1, 2, 3])); |
| 159 unittest.expect(casted2["bool"], unittest.equals(true)); |
| 160 unittest.expect(casted2["string"], unittest.equals('foo')); |
146 } | 161 } |
147 | 162 |
148 core.int buildCounterLocation = 0; | 163 core.int buildCounterLocation = 0; |
149 buildLocation() { | 164 buildLocation() { |
150 var o = new api.Location(); | 165 var o = new api.Location(); |
151 buildCounterLocation++; | 166 buildCounterLocation++; |
152 if (buildCounterLocation < 3) { | 167 if (buildCounterLocation < 3) { |
153 o.labels = buildUnnamed148(); | 168 o.labels = buildUnnamed143(); |
154 o.locationId = "foo"; | 169 o.locationId = "foo"; |
155 o.metadata = buildUnnamed149(); | 170 o.metadata = buildUnnamed144(); |
156 o.name = "foo"; | 171 o.name = "foo"; |
157 } | 172 } |
158 buildCounterLocation--; | 173 buildCounterLocation--; |
159 return o; | 174 return o; |
160 } | 175 } |
161 | 176 |
162 checkLocation(api.Location o) { | 177 checkLocation(api.Location o) { |
163 buildCounterLocation++; | 178 buildCounterLocation++; |
164 if (buildCounterLocation < 3) { | 179 if (buildCounterLocation < 3) { |
165 checkUnnamed148(o.labels); | 180 checkUnnamed143(o.labels); |
166 unittest.expect(o.locationId, unittest.equals('foo')); | 181 unittest.expect(o.locationId, unittest.equals('foo')); |
167 checkUnnamed149(o.metadata); | 182 checkUnnamed144(o.metadata); |
168 unittest.expect(o.name, unittest.equals('foo')); | 183 unittest.expect(o.name, unittest.equals('foo')); |
169 } | 184 } |
170 buildCounterLocation--; | 185 buildCounterLocation--; |
171 } | 186 } |
172 | 187 |
173 buildUnnamed150() { | 188 buildUnnamed145() { |
174 var o = new core.Map<core.String, core.Object>(); | 189 var o = new core.Map<core.String, core.Object>(); |
175 o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; | 190 o["x"] = { |
176 o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; | 191 'list': [1, 2, 3], |
| 192 'bool': true, |
| 193 'string': 'foo' |
| 194 }; |
| 195 o["y"] = { |
| 196 'list': [1, 2, 3], |
| 197 'bool': true, |
| 198 'string': 'foo' |
| 199 }; |
177 return o; | 200 return o; |
178 } | 201 } |
179 | 202 |
180 checkUnnamed150(core.Map<core.String, core.Object> o) { | 203 checkUnnamed145(core.Map<core.String, core.Object> o) { |
181 unittest.expect(o, unittest.hasLength(2)); | 204 unittest.expect(o, unittest.hasLength(2)); |
182 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')); | 205 var casted3 = (o["x"]) as core.Map; |
183 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')); | 206 unittest.expect(casted3, unittest.hasLength(3)); |
| 207 unittest.expect(casted3["list"], unittest.equals([1, 2, 3])); |
| 208 unittest.expect(casted3["bool"], unittest.equals(true)); |
| 209 unittest.expect(casted3["string"], unittest.equals('foo')); |
| 210 var casted4 = (o["y"]) as core.Map; |
| 211 unittest.expect(casted4, unittest.hasLength(3)); |
| 212 unittest.expect(casted4["list"], unittest.equals([1, 2, 3])); |
| 213 unittest.expect(casted4["bool"], unittest.equals(true)); |
| 214 unittest.expect(casted4["string"], unittest.equals('foo')); |
184 } | 215 } |
185 | 216 |
186 buildUnnamed151() { | 217 buildUnnamed146() { |
187 var o = new core.Map<core.String, core.Object>(); | 218 var o = new core.Map<core.String, core.Object>(); |
188 o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; | 219 o["x"] = { |
189 o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; | 220 'list': [1, 2, 3], |
| 221 'bool': true, |
| 222 'string': 'foo' |
| 223 }; |
| 224 o["y"] = { |
| 225 'list': [1, 2, 3], |
| 226 'bool': true, |
| 227 'string': 'foo' |
| 228 }; |
190 return o; | 229 return o; |
191 } | 230 } |
192 | 231 |
193 checkUnnamed151(core.Map<core.String, core.Object> o) { | 232 checkUnnamed146(core.Map<core.String, core.Object> o) { |
194 unittest.expect(o, unittest.hasLength(2)); | 233 unittest.expect(o, unittest.hasLength(2)); |
195 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')); | 234 var casted5 = (o["x"]) as core.Map; |
196 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')); | 235 unittest.expect(casted5, unittest.hasLength(3)); |
| 236 unittest.expect(casted5["list"], unittest.equals([1, 2, 3])); |
| 237 unittest.expect(casted5["bool"], unittest.equals(true)); |
| 238 unittest.expect(casted5["string"], unittest.equals('foo')); |
| 239 var casted6 = (o["y"]) as core.Map; |
| 240 unittest.expect(casted6, unittest.hasLength(3)); |
| 241 unittest.expect(casted6["list"], unittest.equals([1, 2, 3])); |
| 242 unittest.expect(casted6["bool"], unittest.equals(true)); |
| 243 unittest.expect(casted6["string"], unittest.equals('foo')); |
197 } | 244 } |
198 | 245 |
199 core.int buildCounterOperation = 0; | 246 core.int buildCounterOperation = 0; |
200 buildOperation() { | 247 buildOperation() { |
201 var o = new api.Operation(); | 248 var o = new api.Operation(); |
202 buildCounterOperation++; | 249 buildCounterOperation++; |
203 if (buildCounterOperation < 3) { | 250 if (buildCounterOperation < 3) { |
204 o.done = true; | 251 o.done = true; |
205 o.error = buildStatus(); | 252 o.error = buildStatus(); |
206 o.metadata = buildUnnamed150(); | 253 o.metadata = buildUnnamed145(); |
207 o.name = "foo"; | 254 o.name = "foo"; |
208 o.response = buildUnnamed151(); | 255 o.response = buildUnnamed146(); |
209 } | 256 } |
210 buildCounterOperation--; | 257 buildCounterOperation--; |
211 return o; | 258 return o; |
212 } | 259 } |
213 | 260 |
214 checkOperation(api.Operation o) { | 261 checkOperation(api.Operation o) { |
215 buildCounterOperation++; | 262 buildCounterOperation++; |
216 if (buildCounterOperation < 3) { | 263 if (buildCounterOperation < 3) { |
217 unittest.expect(o.done, unittest.isTrue); | 264 unittest.expect(o.done, unittest.isTrue); |
218 checkStatus(o.error); | 265 checkStatus(o.error); |
219 checkUnnamed150(o.metadata); | 266 checkUnnamed145(o.metadata); |
220 unittest.expect(o.name, unittest.equals('foo')); | 267 unittest.expect(o.name, unittest.equals('foo')); |
221 checkUnnamed151(o.response); | 268 checkUnnamed146(o.response); |
222 } | 269 } |
223 buildCounterOperation--; | 270 buildCounterOperation--; |
224 } | 271 } |
225 | 272 |
226 buildUnnamed152() { | 273 buildUnnamed147() { |
227 var o = new core.Map<core.String, core.Object>(); | 274 var o = new core.Map<core.String, core.Object>(); |
228 o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; | 275 o["x"] = { |
229 o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; | 276 'list': [1, 2, 3], |
| 277 'bool': true, |
| 278 'string': 'foo' |
| 279 }; |
| 280 o["y"] = { |
| 281 'list': [1, 2, 3], |
| 282 'bool': true, |
| 283 'string': 'foo' |
| 284 }; |
230 return o; | 285 return o; |
231 } | 286 } |
232 | 287 |
233 checkUnnamed152(core.Map<core.String, core.Object> o) { | 288 checkUnnamed147(core.Map<core.String, core.Object> o) { |
234 unittest.expect(o, unittest.hasLength(2)); | 289 unittest.expect(o, unittest.hasLength(2)); |
235 var casted7 = (o["x"]) 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')); | 290 var casted7 = (o["x"]) as core.Map; |
236 var casted8 = (o["y"]) 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 unittest.expect(casted7, unittest.hasLength(3)); |
| 292 unittest.expect(casted7["list"], unittest.equals([1, 2, 3])); |
| 293 unittest.expect(casted7["bool"], unittest.equals(true)); |
| 294 unittest.expect(casted7["string"], unittest.equals('foo')); |
| 295 var casted8 = (o["y"]) as core.Map; |
| 296 unittest.expect(casted8, unittest.hasLength(3)); |
| 297 unittest.expect(casted8["list"], unittest.equals([1, 2, 3])); |
| 298 unittest.expect(casted8["bool"], unittest.equals(true)); |
| 299 unittest.expect(casted8["string"], unittest.equals('foo')); |
237 } | 300 } |
238 | 301 |
239 core.int buildCounterOperationMetadataV1Beta2 = 0; | 302 core.int buildCounterOperationMetadataV1Beta2 = 0; |
240 buildOperationMetadataV1Beta2() { | 303 buildOperationMetadataV1Beta2() { |
241 var o = new api.OperationMetadataV1Beta2(); | 304 var o = new api.OperationMetadataV1Beta2(); |
242 buildCounterOperationMetadataV1Beta2++; | 305 buildCounterOperationMetadataV1Beta2++; |
243 if (buildCounterOperationMetadataV1Beta2 < 3) { | 306 if (buildCounterOperationMetadataV1Beta2 < 3) { |
244 o.request = buildUnnamed152(); | 307 o.request = buildUnnamed147(); |
245 o.target = "foo"; | 308 o.target = "foo"; |
246 o.type = "foo"; | 309 o.type = "foo"; |
247 } | 310 } |
248 buildCounterOperationMetadataV1Beta2--; | 311 buildCounterOperationMetadataV1Beta2--; |
249 return o; | 312 return o; |
250 } | 313 } |
251 | 314 |
252 checkOperationMetadataV1Beta2(api.OperationMetadataV1Beta2 o) { | 315 checkOperationMetadataV1Beta2(api.OperationMetadataV1Beta2 o) { |
253 buildCounterOperationMetadataV1Beta2++; | 316 buildCounterOperationMetadataV1Beta2++; |
254 if (buildCounterOperationMetadataV1Beta2 < 3) { | 317 if (buildCounterOperationMetadataV1Beta2 < 3) { |
255 checkUnnamed152(o.request); | 318 checkUnnamed147(o.request); |
256 unittest.expect(o.target, unittest.equals('foo')); | 319 unittest.expect(o.target, unittest.equals('foo')); |
257 unittest.expect(o.type, unittest.equals('foo')); | 320 unittest.expect(o.type, unittest.equals('foo')); |
258 } | 321 } |
259 buildCounterOperationMetadataV1Beta2--; | 322 buildCounterOperationMetadataV1Beta2--; |
260 } | 323 } |
261 | 324 |
262 buildUnnamed153() { | 325 buildUnnamed148() { |
263 var o = new core.Map<core.String, core.Object>(); | 326 var o = new core.Map<core.String, core.Object>(); |
264 o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; | 327 o["x"] = { |
265 o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; | 328 'list': [1, 2, 3], |
| 329 'bool': true, |
| 330 'string': 'foo' |
| 331 }; |
| 332 o["y"] = { |
| 333 'list': [1, 2, 3], |
| 334 'bool': true, |
| 335 'string': 'foo' |
| 336 }; |
266 return o; | 337 return o; |
267 } | 338 } |
268 | 339 |
269 checkUnnamed153(core.Map<core.String, core.Object> o) { | 340 checkUnnamed148(core.Map<core.String, core.Object> o) { |
270 unittest.expect(o, unittest.hasLength(2)); | 341 unittest.expect(o, unittest.hasLength(2)); |
271 var casted9 = (o["x"]) 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')); | 342 var casted9 = (o["x"]) as core.Map; |
272 var casted10 = (o["y"]) as core.Map; unittest.expect(casted10, unittest.hasLen
gth(3)); unittest.expect(casted10["list"], unittest.equals([1, 2, 3])); unittest
.expect(casted10["bool"], unittest.equals(true)); unittest.expect(casted10["stri
ng"], unittest.equals('foo')); | 343 unittest.expect(casted9, unittest.hasLength(3)); |
| 344 unittest.expect(casted9["list"], unittest.equals([1, 2, 3])); |
| 345 unittest.expect(casted9["bool"], unittest.equals(true)); |
| 346 unittest.expect(casted9["string"], unittest.equals('foo')); |
| 347 var casted10 = (o["y"]) as core.Map; |
| 348 unittest.expect(casted10, unittest.hasLength(3)); |
| 349 unittest.expect(casted10["list"], unittest.equals([1, 2, 3])); |
| 350 unittest.expect(casted10["bool"], unittest.equals(true)); |
| 351 unittest.expect(casted10["string"], unittest.equals('foo')); |
273 } | 352 } |
274 | 353 |
275 buildUnnamed154() { | 354 buildUnnamed149() { |
276 var o = new core.List<core.Map<core.String, core.Object>>(); | 355 var o = new core.List<core.Map<core.String, core.Object>>(); |
277 o.add(buildUnnamed153()); | 356 o.add(buildUnnamed148()); |
278 o.add(buildUnnamed153()); | 357 o.add(buildUnnamed148()); |
279 return o; | 358 return o; |
280 } | 359 } |
281 | 360 |
282 checkUnnamed154(core.List<core.Map<core.String, core.Object>> o) { | 361 checkUnnamed149(core.List<core.Map<core.String, core.Object>> o) { |
283 unittest.expect(o, unittest.hasLength(2)); | 362 unittest.expect(o, unittest.hasLength(2)); |
284 checkUnnamed153(o[0]); | 363 checkUnnamed148(o[0]); |
285 checkUnnamed153(o[1]); | 364 checkUnnamed148(o[1]); |
286 } | 365 } |
287 | 366 |
288 core.int buildCounterStatus = 0; | 367 core.int buildCounterStatus = 0; |
289 buildStatus() { | 368 buildStatus() { |
290 var o = new api.Status(); | 369 var o = new api.Status(); |
291 buildCounterStatus++; | 370 buildCounterStatus++; |
292 if (buildCounterStatus < 3) { | 371 if (buildCounterStatus < 3) { |
293 o.code = 42; | 372 o.code = 42; |
294 o.details = buildUnnamed154(); | 373 o.details = buildUnnamed149(); |
295 o.message = "foo"; | 374 o.message = "foo"; |
296 } | 375 } |
297 buildCounterStatus--; | 376 buildCounterStatus--; |
298 return o; | 377 return o; |
299 } | 378 } |
300 | 379 |
301 checkStatus(api.Status o) { | 380 checkStatus(api.Status o) { |
302 buildCounterStatus++; | 381 buildCounterStatus++; |
303 if (buildCounterStatus < 3) { | 382 if (buildCounterStatus < 3) { |
304 unittest.expect(o.code, unittest.equals(42)); | 383 unittest.expect(o.code, unittest.equals(42)); |
305 checkUnnamed154(o.details); | 384 checkUnnamed149(o.details); |
306 unittest.expect(o.message, unittest.equals('foo')); | 385 unittest.expect(o.message, unittest.equals('foo')); |
307 } | 386 } |
308 buildCounterStatus--; | 387 buildCounterStatus--; |
309 } | 388 } |
310 | 389 |
311 | |
312 main() { | 390 main() { |
313 unittest.group("obj-schema-ListLocationsResponse", () { | 391 unittest.group("obj-schema-ListLocationsResponse", () { |
314 unittest.test("to-json--from-json", () { | 392 unittest.test("to-json--from-json", () { |
315 var o = buildListLocationsResponse(); | 393 var o = buildListLocationsResponse(); |
316 var od = new api.ListLocationsResponse.fromJson(o.toJson()); | 394 var od = new api.ListLocationsResponse.fromJson(o.toJson()); |
317 checkListLocationsResponse(od); | 395 checkListLocationsResponse(od); |
318 }); | 396 }); |
319 }); | 397 }); |
320 | 398 |
321 | |
322 unittest.group("obj-schema-ListOperationsResponse", () { | 399 unittest.group("obj-schema-ListOperationsResponse", () { |
323 unittest.test("to-json--from-json", () { | 400 unittest.test("to-json--from-json", () { |
324 var o = buildListOperationsResponse(); | 401 var o = buildListOperationsResponse(); |
325 var od = new api.ListOperationsResponse.fromJson(o.toJson()); | 402 var od = new api.ListOperationsResponse.fromJson(o.toJson()); |
326 checkListOperationsResponse(od); | 403 checkListOperationsResponse(od); |
327 }); | 404 }); |
328 }); | 405 }); |
329 | 406 |
330 | |
331 unittest.group("obj-schema-Location", () { | 407 unittest.group("obj-schema-Location", () { |
332 unittest.test("to-json--from-json", () { | 408 unittest.test("to-json--from-json", () { |
333 var o = buildLocation(); | 409 var o = buildLocation(); |
334 var od = new api.Location.fromJson(o.toJson()); | 410 var od = new api.Location.fromJson(o.toJson()); |
335 checkLocation(od); | 411 checkLocation(od); |
336 }); | 412 }); |
337 }); | 413 }); |
338 | 414 |
339 | |
340 unittest.group("obj-schema-Operation", () { | 415 unittest.group("obj-schema-Operation", () { |
341 unittest.test("to-json--from-json", () { | 416 unittest.test("to-json--from-json", () { |
342 var o = buildOperation(); | 417 var o = buildOperation(); |
343 var od = new api.Operation.fromJson(o.toJson()); | 418 var od = new api.Operation.fromJson(o.toJson()); |
344 checkOperation(od); | 419 checkOperation(od); |
345 }); | 420 }); |
346 }); | 421 }); |
347 | 422 |
348 | |
349 unittest.group("obj-schema-OperationMetadataV1Beta2", () { | 423 unittest.group("obj-schema-OperationMetadataV1Beta2", () { |
350 unittest.test("to-json--from-json", () { | 424 unittest.test("to-json--from-json", () { |
351 var o = buildOperationMetadataV1Beta2(); | 425 var o = buildOperationMetadataV1Beta2(); |
352 var od = new api.OperationMetadataV1Beta2.fromJson(o.toJson()); | 426 var od = new api.OperationMetadataV1Beta2.fromJson(o.toJson()); |
353 checkOperationMetadataV1Beta2(od); | 427 checkOperationMetadataV1Beta2(od); |
354 }); | 428 }); |
355 }); | 429 }); |
356 | 430 |
357 | |
358 unittest.group("obj-schema-Status", () { | 431 unittest.group("obj-schema-Status", () { |
359 unittest.test("to-json--from-json", () { | 432 unittest.test("to-json--from-json", () { |
360 var o = buildStatus(); | 433 var o = buildStatus(); |
361 var od = new api.Status.fromJson(o.toJson()); | 434 var od = new api.Status.fromJson(o.toJson()); |
362 checkStatus(od); | 435 checkStatus(od); |
363 }); | 436 }); |
364 }); | 437 }); |
365 | 438 |
366 | |
367 unittest.group("resource-OperationsResourceApi", () { | 439 unittest.group("resource-OperationsResourceApi", () { |
368 unittest.test("method--get", () { | 440 unittest.test("method--get", () { |
369 | |
370 var mock = new HttpServerMock(); | 441 var mock = new HttpServerMock(); |
371 api.OperationsResourceApi res = new api.CloudfunctionsApi(mock).operations
; | 442 api.OperationsResourceApi res = |
| 443 new api.CloudfunctionsApi(mock).operations; |
372 var arg_name = "foo"; | 444 var arg_name = "foo"; |
373 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 445 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
374 var path = (req.url).path; | 446 var path = (req.url).path; |
375 var pathOffset = 0; | 447 var pathOffset = 0; |
376 var index; | 448 var index; |
377 var subPart; | 449 var subPart; |
378 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 450 unittest.expect( |
| 451 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
379 pathOffset += 1; | 452 pathOffset += 1; |
380 unittest.expect(path.substring(pathOffset, pathOffset + 3), unittest.equ
als("v1/")); | 453 unittest.expect( |
| 454 path.substring(pathOffset, pathOffset + 3), unittest.equals("v1/")); |
381 pathOffset += 3; | 455 pathOffset += 3; |
382 // NOTE: We cannot test reserved expansions due to the inability to reve
rse the operation; | 456 // NOTE: We cannot test reserved expansions due to the inability to reve
rse the operation; |
383 | 457 |
384 var query = (req.url).query; | 458 var query = (req.url).query; |
385 var queryOffset = 0; | 459 var queryOffset = 0; |
386 var queryMap = {}; | 460 var queryMap = {}; |
387 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 461 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
388 parseBool(n) { | 462 parseBool(n) { |
389 if (n == "true") return true; | 463 if (n == "true") return true; |
390 if (n == "false") return false; | 464 if (n == "false") return false; |
391 if (n == null) return null; | 465 if (n == null) return null; |
392 throw new core.ArgumentError("Invalid boolean: $n"); | 466 throw new core.ArgumentError("Invalid boolean: $n"); |
393 } | 467 } |
| 468 |
394 if (query.length > 0) { | 469 if (query.length > 0) { |
395 for (var part in query.split("&")) { | 470 for (var part in query.split("&")) { |
396 var keyvalue = part.split("="); | 471 var keyvalue = part.split("="); |
397 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 472 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 473 core.Uri.decodeQueryComponent(keyvalue[1])); |
398 } | 474 } |
399 } | 475 } |
400 | 476 |
401 | |
402 var h = { | 477 var h = { |
403 "content-type" : "application/json; charset=utf-8", | 478 "content-type": "application/json; charset=utf-8", |
404 }; | 479 }; |
405 var resp = convert.JSON.encode(buildOperation()); | 480 var resp = convert.JSON.encode(buildOperation()); |
406 return new async.Future.value(stringResponse(200, h, resp)); | 481 return new async.Future.value(stringResponse(200, h, resp)); |
407 }), true); | 482 }), true); |
408 res.get(arg_name).then(unittest.expectAsync1(((api.Operation response) { | 483 res.get(arg_name).then(unittest.expectAsync1(((api.Operation response) { |
409 checkOperation(response); | 484 checkOperation(response); |
410 }))); | 485 }))); |
411 }); | 486 }); |
412 | 487 |
413 unittest.test("method--list", () { | 488 unittest.test("method--list", () { |
414 | |
415 var mock = new HttpServerMock(); | 489 var mock = new HttpServerMock(); |
416 api.OperationsResourceApi res = new api.CloudfunctionsApi(mock).operations
; | 490 api.OperationsResourceApi res = |
| 491 new api.CloudfunctionsApi(mock).operations; |
417 var arg_pageToken = "foo"; | 492 var arg_pageToken = "foo"; |
418 var arg_name = "foo"; | 493 var arg_name = "foo"; |
419 var arg_pageSize = 42; | 494 var arg_pageSize = 42; |
420 var arg_filter = "foo"; | 495 var arg_filter = "foo"; |
421 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 496 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
422 var path = (req.url).path; | 497 var path = (req.url).path; |
423 var pathOffset = 0; | 498 var pathOffset = 0; |
424 var index; | 499 var index; |
425 var subPart; | 500 var subPart; |
426 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 501 unittest.expect( |
| 502 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
427 pathOffset += 1; | 503 pathOffset += 1; |
428 unittest.expect(path.substring(pathOffset, pathOffset + 13), unittest.eq
uals("v1/operations")); | 504 unittest.expect(path.substring(pathOffset, pathOffset + 13), |
| 505 unittest.equals("v1/operations")); |
429 pathOffset += 13; | 506 pathOffset += 13; |
430 | 507 |
431 var query = (req.url).query; | 508 var query = (req.url).query; |
432 var queryOffset = 0; | 509 var queryOffset = 0; |
433 var queryMap = {}; | 510 var queryMap = {}; |
434 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 511 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
435 parseBool(n) { | 512 parseBool(n) { |
436 if (n == "true") return true; | 513 if (n == "true") return true; |
437 if (n == "false") return false; | 514 if (n == "false") return false; |
438 if (n == null) return null; | 515 if (n == null) return null; |
439 throw new core.ArgumentError("Invalid boolean: $n"); | 516 throw new core.ArgumentError("Invalid boolean: $n"); |
440 } | 517 } |
| 518 |
441 if (query.length > 0) { | 519 if (query.length > 0) { |
442 for (var part in query.split("&")) { | 520 for (var part in query.split("&")) { |
443 var keyvalue = part.split("="); | 521 var keyvalue = part.split("="); |
444 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 522 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 523 core.Uri.decodeQueryComponent(keyvalue[1])); |
445 } | 524 } |
446 } | 525 } |
447 unittest.expect(queryMap["pageToken"].first, unittest.equals(arg_pageTok
en)); | 526 unittest.expect( |
| 527 queryMap["pageToken"].first, unittest.equals(arg_pageToken)); |
448 unittest.expect(queryMap["name"].first, unittest.equals(arg_name)); | 528 unittest.expect(queryMap["name"].first, unittest.equals(arg_name)); |
449 unittest.expect(core.int.parse(queryMap["pageSize"].first), unittest.equ
als(arg_pageSize)); | 529 unittest.expect(core.int.parse(queryMap["pageSize"].first), |
| 530 unittest.equals(arg_pageSize)); |
450 unittest.expect(queryMap["filter"].first, unittest.equals(arg_filter)); | 531 unittest.expect(queryMap["filter"].first, unittest.equals(arg_filter)); |
451 | 532 |
452 | |
453 var h = { | 533 var h = { |
454 "content-type" : "application/json; charset=utf-8", | 534 "content-type": "application/json; charset=utf-8", |
455 }; | 535 }; |
456 var resp = convert.JSON.encode(buildListOperationsResponse()); | 536 var resp = convert.JSON.encode(buildListOperationsResponse()); |
457 return new async.Future.value(stringResponse(200, h, resp)); | 537 return new async.Future.value(stringResponse(200, h, resp)); |
458 }), true); | 538 }), true); |
459 res.list(pageToken: arg_pageToken, name: arg_name, pageSize: arg_pageSize,
filter: arg_filter).then(unittest.expectAsync1(((api.ListOperationsResponse res
ponse) { | 539 res |
| 540 .list( |
| 541 pageToken: arg_pageToken, |
| 542 name: arg_name, |
| 543 pageSize: arg_pageSize, |
| 544 filter: arg_filter) |
| 545 .then(unittest.expectAsync1(((api.ListOperationsResponse response) { |
460 checkListOperationsResponse(response); | 546 checkListOperationsResponse(response); |
461 }))); | 547 }))); |
462 }); | 548 }); |
463 | |
464 }); | 549 }); |
465 | 550 |
466 | |
467 unittest.group("resource-ProjectsLocationsResourceApi", () { | 551 unittest.group("resource-ProjectsLocationsResourceApi", () { |
468 unittest.test("method--list", () { | 552 unittest.test("method--list", () { |
469 | |
470 var mock = new HttpServerMock(); | 553 var mock = new HttpServerMock(); |
471 api.ProjectsLocationsResourceApi res = new api.CloudfunctionsApi(mock).pro
jects.locations; | 554 api.ProjectsLocationsResourceApi res = |
| 555 new api.CloudfunctionsApi(mock).projects.locations; |
472 var arg_name = "foo"; | 556 var arg_name = "foo"; |
473 var arg_filter = "foo"; | |
474 var arg_pageToken = "foo"; | 557 var arg_pageToken = "foo"; |
475 var arg_pageSize = 42; | 558 var arg_pageSize = 42; |
| 559 var arg_filter = "foo"; |
476 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 560 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
477 var path = (req.url).path; | 561 var path = (req.url).path; |
478 var pathOffset = 0; | 562 var pathOffset = 0; |
479 var index; | 563 var index; |
480 var subPart; | 564 var subPart; |
481 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 565 unittest.expect( |
| 566 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
482 pathOffset += 1; | 567 pathOffset += 1; |
483 unittest.expect(path.substring(pathOffset, pathOffset + 3), unittest.equ
als("v1/")); | 568 unittest.expect( |
| 569 path.substring(pathOffset, pathOffset + 3), unittest.equals("v1/")); |
484 pathOffset += 3; | 570 pathOffset += 3; |
485 // NOTE: We cannot test reserved expansions due to the inability to reve
rse the operation; | 571 // NOTE: We cannot test reserved expansions due to the inability to reve
rse the operation; |
486 | 572 |
487 var query = (req.url).query; | 573 var query = (req.url).query; |
488 var queryOffset = 0; | 574 var queryOffset = 0; |
489 var queryMap = {}; | 575 var queryMap = {}; |
490 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 576 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
491 parseBool(n) { | 577 parseBool(n) { |
492 if (n == "true") return true; | 578 if (n == "true") return true; |
493 if (n == "false") return false; | 579 if (n == "false") return false; |
494 if (n == null) return null; | 580 if (n == null) return null; |
495 throw new core.ArgumentError("Invalid boolean: $n"); | 581 throw new core.ArgumentError("Invalid boolean: $n"); |
496 } | 582 } |
| 583 |
497 if (query.length > 0) { | 584 if (query.length > 0) { |
498 for (var part in query.split("&")) { | 585 for (var part in query.split("&")) { |
499 var keyvalue = part.split("="); | 586 var keyvalue = part.split("="); |
500 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 587 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 588 core.Uri.decodeQueryComponent(keyvalue[1])); |
501 } | 589 } |
502 } | 590 } |
| 591 unittest.expect( |
| 592 queryMap["pageToken"].first, unittest.equals(arg_pageToken)); |
| 593 unittest.expect(core.int.parse(queryMap["pageSize"].first), |
| 594 unittest.equals(arg_pageSize)); |
503 unittest.expect(queryMap["filter"].first, unittest.equals(arg_filter)); | 595 unittest.expect(queryMap["filter"].first, unittest.equals(arg_filter)); |
504 unittest.expect(queryMap["pageToken"].first, unittest.equals(arg_pageTok
en)); | |
505 unittest.expect(core.int.parse(queryMap["pageSize"].first), unittest.equ
als(arg_pageSize)); | |
506 | |
507 | 596 |
508 var h = { | 597 var h = { |
509 "content-type" : "application/json; charset=utf-8", | 598 "content-type": "application/json; charset=utf-8", |
510 }; | 599 }; |
511 var resp = convert.JSON.encode(buildListLocationsResponse()); | 600 var resp = convert.JSON.encode(buildListLocationsResponse()); |
512 return new async.Future.value(stringResponse(200, h, resp)); | 601 return new async.Future.value(stringResponse(200, h, resp)); |
513 }), true); | 602 }), true); |
514 res.list(arg_name, filter: arg_filter, pageToken: arg_pageToken, pageSize:
arg_pageSize).then(unittest.expectAsync1(((api.ListLocationsResponse response)
{ | 603 res |
| 604 .list(arg_name, |
| 605 pageToken: arg_pageToken, |
| 606 pageSize: arg_pageSize, |
| 607 filter: arg_filter) |
| 608 .then(unittest.expectAsync1(((api.ListLocationsResponse response) { |
515 checkListLocationsResponse(response); | 609 checkListLocationsResponse(response); |
516 }))); | 610 }))); |
517 }); | 611 }); |
518 | |
519 }); | 612 }); |
520 | |
521 | |
522 } | 613 } |
523 | |
OLD | NEW |