OLD | NEW |
1 library googleapis.mirror.v1.test; | 1 library googleapis.mirror.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/mirror/v1.dart' as api; | 10 import 'package:googleapis/mirror/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 buildUnnamed1497() { | 53 buildUnnamed1488() { |
55 var o = new core.List<api.AuthToken>(); | 54 var o = new core.List<api.AuthToken>(); |
56 o.add(buildAuthToken()); | 55 o.add(buildAuthToken()); |
57 o.add(buildAuthToken()); | 56 o.add(buildAuthToken()); |
58 return o; | 57 return o; |
59 } | 58 } |
60 | 59 |
61 checkUnnamed1497(core.List<api.AuthToken> o) { | 60 checkUnnamed1488(core.List<api.AuthToken> o) { |
62 unittest.expect(o, unittest.hasLength(2)); | 61 unittest.expect(o, unittest.hasLength(2)); |
63 checkAuthToken(o[0]); | 62 checkAuthToken(o[0]); |
64 checkAuthToken(o[1]); | 63 checkAuthToken(o[1]); |
65 } | 64 } |
66 | 65 |
67 buildUnnamed1498() { | 66 buildUnnamed1489() { |
68 var o = new core.List<core.String>(); | 67 var o = new core.List<core.String>(); |
69 o.add("foo"); | 68 o.add("foo"); |
70 o.add("foo"); | 69 o.add("foo"); |
71 return o; | 70 return o; |
72 } | 71 } |
73 | 72 |
74 checkUnnamed1498(core.List<core.String> o) { | 73 checkUnnamed1489(core.List<core.String> o) { |
75 unittest.expect(o, unittest.hasLength(2)); | 74 unittest.expect(o, unittest.hasLength(2)); |
76 unittest.expect(o[0], unittest.equals('foo')); | 75 unittest.expect(o[0], unittest.equals('foo')); |
77 unittest.expect(o[1], unittest.equals('foo')); | 76 unittest.expect(o[1], unittest.equals('foo')); |
78 } | 77 } |
79 | 78 |
80 buildUnnamed1499() { | 79 buildUnnamed1490() { |
81 var o = new core.List<api.UserData>(); | 80 var o = new core.List<api.UserData>(); |
82 o.add(buildUserData()); | 81 o.add(buildUserData()); |
83 o.add(buildUserData()); | 82 o.add(buildUserData()); |
84 return o; | 83 return o; |
85 } | 84 } |
86 | 85 |
87 checkUnnamed1499(core.List<api.UserData> o) { | 86 checkUnnamed1490(core.List<api.UserData> o) { |
88 unittest.expect(o, unittest.hasLength(2)); | 87 unittest.expect(o, unittest.hasLength(2)); |
89 checkUserData(o[0]); | 88 checkUserData(o[0]); |
90 checkUserData(o[1]); | 89 checkUserData(o[1]); |
91 } | 90 } |
92 | 91 |
93 core.int buildCounterAccount = 0; | 92 core.int buildCounterAccount = 0; |
94 buildAccount() { | 93 buildAccount() { |
95 var o = new api.Account(); | 94 var o = new api.Account(); |
96 buildCounterAccount++; | 95 buildCounterAccount++; |
97 if (buildCounterAccount < 3) { | 96 if (buildCounterAccount < 3) { |
98 o.authTokens = buildUnnamed1497(); | 97 o.authTokens = buildUnnamed1488(); |
99 o.features = buildUnnamed1498(); | 98 o.features = buildUnnamed1489(); |
100 o.password = "foo"; | 99 o.password = "foo"; |
101 o.userData = buildUnnamed1499(); | 100 o.userData = buildUnnamed1490(); |
102 } | 101 } |
103 buildCounterAccount--; | 102 buildCounterAccount--; |
104 return o; | 103 return o; |
105 } | 104 } |
106 | 105 |
107 checkAccount(api.Account o) { | 106 checkAccount(api.Account o) { |
108 buildCounterAccount++; | 107 buildCounterAccount++; |
109 if (buildCounterAccount < 3) { | 108 if (buildCounterAccount < 3) { |
110 checkUnnamed1497(o.authTokens); | 109 checkUnnamed1488(o.authTokens); |
111 checkUnnamed1498(o.features); | 110 checkUnnamed1489(o.features); |
112 unittest.expect(o.password, unittest.equals('foo')); | 111 unittest.expect(o.password, unittest.equals('foo')); |
113 checkUnnamed1499(o.userData); | 112 checkUnnamed1490(o.userData); |
114 } | 113 } |
115 buildCounterAccount--; | 114 buildCounterAccount--; |
116 } | 115 } |
117 | 116 |
118 core.int buildCounterAttachment = 0; | 117 core.int buildCounterAttachment = 0; |
119 buildAttachment() { | 118 buildAttachment() { |
120 var o = new api.Attachment(); | 119 var o = new api.Attachment(); |
121 buildCounterAttachment++; | 120 buildCounterAttachment++; |
122 if (buildCounterAttachment < 3) { | 121 if (buildCounterAttachment < 3) { |
123 o.contentType = "foo"; | 122 o.contentType = "foo"; |
124 o.contentUrl = "foo"; | 123 o.contentUrl = "foo"; |
125 o.id = "foo"; | 124 o.id = "foo"; |
126 o.isProcessingContent = true; | 125 o.isProcessingContent = true; |
127 } | 126 } |
128 buildCounterAttachment--; | 127 buildCounterAttachment--; |
129 return o; | 128 return o; |
130 } | 129 } |
131 | 130 |
132 checkAttachment(api.Attachment o) { | 131 checkAttachment(api.Attachment o) { |
133 buildCounterAttachment++; | 132 buildCounterAttachment++; |
134 if (buildCounterAttachment < 3) { | 133 if (buildCounterAttachment < 3) { |
135 unittest.expect(o.contentType, unittest.equals('foo')); | 134 unittest.expect(o.contentType, unittest.equals('foo')); |
136 unittest.expect(o.contentUrl, unittest.equals('foo')); | 135 unittest.expect(o.contentUrl, unittest.equals('foo')); |
137 unittest.expect(o.id, unittest.equals('foo')); | 136 unittest.expect(o.id, unittest.equals('foo')); |
138 unittest.expect(o.isProcessingContent, unittest.isTrue); | 137 unittest.expect(o.isProcessingContent, unittest.isTrue); |
139 } | 138 } |
140 buildCounterAttachment--; | 139 buildCounterAttachment--; |
141 } | 140 } |
142 | 141 |
143 buildUnnamed1500() { | 142 buildUnnamed1491() { |
144 var o = new core.List<api.Attachment>(); | 143 var o = new core.List<api.Attachment>(); |
145 o.add(buildAttachment()); | 144 o.add(buildAttachment()); |
146 o.add(buildAttachment()); | 145 o.add(buildAttachment()); |
147 return o; | 146 return o; |
148 } | 147 } |
149 | 148 |
150 checkUnnamed1500(core.List<api.Attachment> o) { | 149 checkUnnamed1491(core.List<api.Attachment> o) { |
151 unittest.expect(o, unittest.hasLength(2)); | 150 unittest.expect(o, unittest.hasLength(2)); |
152 checkAttachment(o[0]); | 151 checkAttachment(o[0]); |
153 checkAttachment(o[1]); | 152 checkAttachment(o[1]); |
154 } | 153 } |
155 | 154 |
156 core.int buildCounterAttachmentsListResponse = 0; | 155 core.int buildCounterAttachmentsListResponse = 0; |
157 buildAttachmentsListResponse() { | 156 buildAttachmentsListResponse() { |
158 var o = new api.AttachmentsListResponse(); | 157 var o = new api.AttachmentsListResponse(); |
159 buildCounterAttachmentsListResponse++; | 158 buildCounterAttachmentsListResponse++; |
160 if (buildCounterAttachmentsListResponse < 3) { | 159 if (buildCounterAttachmentsListResponse < 3) { |
161 o.items = buildUnnamed1500(); | 160 o.items = buildUnnamed1491(); |
162 o.kind = "foo"; | 161 o.kind = "foo"; |
163 } | 162 } |
164 buildCounterAttachmentsListResponse--; | 163 buildCounterAttachmentsListResponse--; |
165 return o; | 164 return o; |
166 } | 165 } |
167 | 166 |
168 checkAttachmentsListResponse(api.AttachmentsListResponse o) { | 167 checkAttachmentsListResponse(api.AttachmentsListResponse o) { |
169 buildCounterAttachmentsListResponse++; | 168 buildCounterAttachmentsListResponse++; |
170 if (buildCounterAttachmentsListResponse < 3) { | 169 if (buildCounterAttachmentsListResponse < 3) { |
171 checkUnnamed1500(o.items); | 170 checkUnnamed1491(o.items); |
172 unittest.expect(o.kind, unittest.equals('foo')); | 171 unittest.expect(o.kind, unittest.equals('foo')); |
173 } | 172 } |
174 buildCounterAttachmentsListResponse--; | 173 buildCounterAttachmentsListResponse--; |
175 } | 174 } |
176 | 175 |
177 core.int buildCounterAuthToken = 0; | 176 core.int buildCounterAuthToken = 0; |
178 buildAuthToken() { | 177 buildAuthToken() { |
179 var o = new api.AuthToken(); | 178 var o = new api.AuthToken(); |
180 buildCounterAuthToken++; | 179 buildCounterAuthToken++; |
181 if (buildCounterAuthToken < 3) { | 180 if (buildCounterAuthToken < 3) { |
(...skipping 25 matching lines...) Expand all Loading... |
207 } | 206 } |
208 | 207 |
209 checkCommand(api.Command o) { | 208 checkCommand(api.Command o) { |
210 buildCounterCommand++; | 209 buildCounterCommand++; |
211 if (buildCounterCommand < 3) { | 210 if (buildCounterCommand < 3) { |
212 unittest.expect(o.type, unittest.equals('foo')); | 211 unittest.expect(o.type, unittest.equals('foo')); |
213 } | 212 } |
214 buildCounterCommand--; | 213 buildCounterCommand--; |
215 } | 214 } |
216 | 215 |
217 buildUnnamed1501() { | 216 buildUnnamed1492() { |
218 var o = new core.List<api.Command>(); | 217 var o = new core.List<api.Command>(); |
219 o.add(buildCommand()); | 218 o.add(buildCommand()); |
220 o.add(buildCommand()); | 219 o.add(buildCommand()); |
221 return o; | 220 return o; |
222 } | 221 } |
223 | 222 |
224 checkUnnamed1501(core.List<api.Command> o) { | 223 checkUnnamed1492(core.List<api.Command> o) { |
225 unittest.expect(o, unittest.hasLength(2)); | 224 unittest.expect(o, unittest.hasLength(2)); |
226 checkCommand(o[0]); | 225 checkCommand(o[0]); |
227 checkCommand(o[1]); | 226 checkCommand(o[1]); |
228 } | 227 } |
229 | 228 |
230 buildUnnamed1502() { | 229 buildUnnamed1493() { |
231 var o = new core.List<core.String>(); | 230 var o = new core.List<core.String>(); |
232 o.add("foo"); | 231 o.add("foo"); |
233 o.add("foo"); | 232 o.add("foo"); |
234 return o; | 233 return o; |
235 } | 234 } |
236 | 235 |
237 checkUnnamed1502(core.List<core.String> o) { | 236 checkUnnamed1493(core.List<core.String> o) { |
238 unittest.expect(o, unittest.hasLength(2)); | 237 unittest.expect(o, unittest.hasLength(2)); |
239 unittest.expect(o[0], unittest.equals('foo')); | 238 unittest.expect(o[0], unittest.equals('foo')); |
240 unittest.expect(o[1], unittest.equals('foo')); | 239 unittest.expect(o[1], unittest.equals('foo')); |
241 } | 240 } |
242 | 241 |
243 buildUnnamed1503() { | 242 buildUnnamed1494() { |
244 var o = new core.List<core.String>(); | 243 var o = new core.List<core.String>(); |
245 o.add("foo"); | 244 o.add("foo"); |
246 o.add("foo"); | 245 o.add("foo"); |
247 return o; | 246 return o; |
248 } | 247 } |
249 | 248 |
250 checkUnnamed1503(core.List<core.String> o) { | 249 checkUnnamed1494(core.List<core.String> o) { |
251 unittest.expect(o, unittest.hasLength(2)); | 250 unittest.expect(o, unittest.hasLength(2)); |
252 unittest.expect(o[0], unittest.equals('foo')); | 251 unittest.expect(o[0], unittest.equals('foo')); |
253 unittest.expect(o[1], unittest.equals('foo')); | 252 unittest.expect(o[1], unittest.equals('foo')); |
254 } | 253 } |
255 | 254 |
256 buildUnnamed1504() { | 255 buildUnnamed1495() { |
257 var o = new core.List<core.String>(); | 256 var o = new core.List<core.String>(); |
258 o.add("foo"); | 257 o.add("foo"); |
259 o.add("foo"); | 258 o.add("foo"); |
260 return o; | 259 return o; |
261 } | 260 } |
262 | 261 |
263 checkUnnamed1504(core.List<core.String> o) { | 262 checkUnnamed1495(core.List<core.String> o) { |
264 unittest.expect(o, unittest.hasLength(2)); | 263 unittest.expect(o, unittest.hasLength(2)); |
265 unittest.expect(o[0], unittest.equals('foo')); | 264 unittest.expect(o[0], unittest.equals('foo')); |
266 unittest.expect(o[1], unittest.equals('foo')); | 265 unittest.expect(o[1], unittest.equals('foo')); |
267 } | 266 } |
268 | 267 |
269 core.int buildCounterContact = 0; | 268 core.int buildCounterContact = 0; |
270 buildContact() { | 269 buildContact() { |
271 var o = new api.Contact(); | 270 var o = new api.Contact(); |
272 buildCounterContact++; | 271 buildCounterContact++; |
273 if (buildCounterContact < 3) { | 272 if (buildCounterContact < 3) { |
274 o.acceptCommands = buildUnnamed1501(); | 273 o.acceptCommands = buildUnnamed1492(); |
275 o.acceptTypes = buildUnnamed1502(); | 274 o.acceptTypes = buildUnnamed1493(); |
276 o.displayName = "foo"; | 275 o.displayName = "foo"; |
277 o.id = "foo"; | 276 o.id = "foo"; |
278 o.imageUrls = buildUnnamed1503(); | 277 o.imageUrls = buildUnnamed1494(); |
279 o.kind = "foo"; | 278 o.kind = "foo"; |
280 o.phoneNumber = "foo"; | 279 o.phoneNumber = "foo"; |
281 o.priority = 42; | 280 o.priority = 42; |
282 o.sharingFeatures = buildUnnamed1504(); | 281 o.sharingFeatures = buildUnnamed1495(); |
283 o.source = "foo"; | 282 o.source = "foo"; |
284 o.speakableName = "foo"; | 283 o.speakableName = "foo"; |
285 o.type = "foo"; | 284 o.type = "foo"; |
286 } | 285 } |
287 buildCounterContact--; | 286 buildCounterContact--; |
288 return o; | 287 return o; |
289 } | 288 } |
290 | 289 |
291 checkContact(api.Contact o) { | 290 checkContact(api.Contact o) { |
292 buildCounterContact++; | 291 buildCounterContact++; |
293 if (buildCounterContact < 3) { | 292 if (buildCounterContact < 3) { |
294 checkUnnamed1501(o.acceptCommands); | 293 checkUnnamed1492(o.acceptCommands); |
295 checkUnnamed1502(o.acceptTypes); | 294 checkUnnamed1493(o.acceptTypes); |
296 unittest.expect(o.displayName, unittest.equals('foo')); | 295 unittest.expect(o.displayName, unittest.equals('foo')); |
297 unittest.expect(o.id, unittest.equals('foo')); | 296 unittest.expect(o.id, unittest.equals('foo')); |
298 checkUnnamed1503(o.imageUrls); | 297 checkUnnamed1494(o.imageUrls); |
299 unittest.expect(o.kind, unittest.equals('foo')); | 298 unittest.expect(o.kind, unittest.equals('foo')); |
300 unittest.expect(o.phoneNumber, unittest.equals('foo')); | 299 unittest.expect(o.phoneNumber, unittest.equals('foo')); |
301 unittest.expect(o.priority, unittest.equals(42)); | 300 unittest.expect(o.priority, unittest.equals(42)); |
302 checkUnnamed1504(o.sharingFeatures); | 301 checkUnnamed1495(o.sharingFeatures); |
303 unittest.expect(o.source, unittest.equals('foo')); | 302 unittest.expect(o.source, unittest.equals('foo')); |
304 unittest.expect(o.speakableName, unittest.equals('foo')); | 303 unittest.expect(o.speakableName, unittest.equals('foo')); |
305 unittest.expect(o.type, unittest.equals('foo')); | 304 unittest.expect(o.type, unittest.equals('foo')); |
306 } | 305 } |
307 buildCounterContact--; | 306 buildCounterContact--; |
308 } | 307 } |
309 | 308 |
310 buildUnnamed1505() { | 309 buildUnnamed1496() { |
311 var o = new core.List<api.Contact>(); | 310 var o = new core.List<api.Contact>(); |
312 o.add(buildContact()); | 311 o.add(buildContact()); |
313 o.add(buildContact()); | 312 o.add(buildContact()); |
314 return o; | 313 return o; |
315 } | 314 } |
316 | 315 |
317 checkUnnamed1505(core.List<api.Contact> o) { | 316 checkUnnamed1496(core.List<api.Contact> o) { |
318 unittest.expect(o, unittest.hasLength(2)); | 317 unittest.expect(o, unittest.hasLength(2)); |
319 checkContact(o[0]); | 318 checkContact(o[0]); |
320 checkContact(o[1]); | 319 checkContact(o[1]); |
321 } | 320 } |
322 | 321 |
323 core.int buildCounterContactsListResponse = 0; | 322 core.int buildCounterContactsListResponse = 0; |
324 buildContactsListResponse() { | 323 buildContactsListResponse() { |
325 var o = new api.ContactsListResponse(); | 324 var o = new api.ContactsListResponse(); |
326 buildCounterContactsListResponse++; | 325 buildCounterContactsListResponse++; |
327 if (buildCounterContactsListResponse < 3) { | 326 if (buildCounterContactsListResponse < 3) { |
328 o.items = buildUnnamed1505(); | 327 o.items = buildUnnamed1496(); |
329 o.kind = "foo"; | 328 o.kind = "foo"; |
330 } | 329 } |
331 buildCounterContactsListResponse--; | 330 buildCounterContactsListResponse--; |
332 return o; | 331 return o; |
333 } | 332 } |
334 | 333 |
335 checkContactsListResponse(api.ContactsListResponse o) { | 334 checkContactsListResponse(api.ContactsListResponse o) { |
336 buildCounterContactsListResponse++; | 335 buildCounterContactsListResponse++; |
337 if (buildCounterContactsListResponse < 3) { | 336 if (buildCounterContactsListResponse < 3) { |
338 checkUnnamed1505(o.items); | 337 checkUnnamed1496(o.items); |
339 unittest.expect(o.kind, unittest.equals('foo')); | 338 unittest.expect(o.kind, unittest.equals('foo')); |
340 } | 339 } |
341 buildCounterContactsListResponse--; | 340 buildCounterContactsListResponse--; |
342 } | 341 } |
343 | 342 |
344 core.int buildCounterLocation = 0; | 343 core.int buildCounterLocation = 0; |
345 buildLocation() { | 344 buildLocation() { |
346 var o = new api.Location(); | 345 var o = new api.Location(); |
347 buildCounterLocation++; | 346 buildCounterLocation++; |
348 if (buildCounterLocation < 3) { | 347 if (buildCounterLocation < 3) { |
(...skipping 13 matching lines...) Expand all Loading... |
362 checkLocation(api.Location o) { | 361 checkLocation(api.Location o) { |
363 buildCounterLocation++; | 362 buildCounterLocation++; |
364 if (buildCounterLocation < 3) { | 363 if (buildCounterLocation < 3) { |
365 unittest.expect(o.accuracy, unittest.equals(42.0)); | 364 unittest.expect(o.accuracy, unittest.equals(42.0)); |
366 unittest.expect(o.address, unittest.equals('foo')); | 365 unittest.expect(o.address, unittest.equals('foo')); |
367 unittest.expect(o.displayName, unittest.equals('foo')); | 366 unittest.expect(o.displayName, unittest.equals('foo')); |
368 unittest.expect(o.id, unittest.equals('foo')); | 367 unittest.expect(o.id, unittest.equals('foo')); |
369 unittest.expect(o.kind, unittest.equals('foo')); | 368 unittest.expect(o.kind, unittest.equals('foo')); |
370 unittest.expect(o.latitude, unittest.equals(42.0)); | 369 unittest.expect(o.latitude, unittest.equals(42.0)); |
371 unittest.expect(o.longitude, unittest.equals(42.0)); | 370 unittest.expect(o.longitude, unittest.equals(42.0)); |
372 unittest.expect(o.timestamp, unittest.equals(core.DateTime.parse("2002-02-27
T14:01:02"))); | 371 unittest.expect(o.timestamp, |
| 372 unittest.equals(core.DateTime.parse("2002-02-27T14:01:02"))); |
373 } | 373 } |
374 buildCounterLocation--; | 374 buildCounterLocation--; |
375 } | 375 } |
376 | 376 |
377 buildUnnamed1506() { | 377 buildUnnamed1497() { |
378 var o = new core.List<api.Location>(); | 378 var o = new core.List<api.Location>(); |
379 o.add(buildLocation()); | 379 o.add(buildLocation()); |
380 o.add(buildLocation()); | 380 o.add(buildLocation()); |
381 return o; | 381 return o; |
382 } | 382 } |
383 | 383 |
384 checkUnnamed1506(core.List<api.Location> o) { | 384 checkUnnamed1497(core.List<api.Location> o) { |
385 unittest.expect(o, unittest.hasLength(2)); | 385 unittest.expect(o, unittest.hasLength(2)); |
386 checkLocation(o[0]); | 386 checkLocation(o[0]); |
387 checkLocation(o[1]); | 387 checkLocation(o[1]); |
388 } | 388 } |
389 | 389 |
390 core.int buildCounterLocationsListResponse = 0; | 390 core.int buildCounterLocationsListResponse = 0; |
391 buildLocationsListResponse() { | 391 buildLocationsListResponse() { |
392 var o = new api.LocationsListResponse(); | 392 var o = new api.LocationsListResponse(); |
393 buildCounterLocationsListResponse++; | 393 buildCounterLocationsListResponse++; |
394 if (buildCounterLocationsListResponse < 3) { | 394 if (buildCounterLocationsListResponse < 3) { |
395 o.items = buildUnnamed1506(); | 395 o.items = buildUnnamed1497(); |
396 o.kind = "foo"; | 396 o.kind = "foo"; |
397 } | 397 } |
398 buildCounterLocationsListResponse--; | 398 buildCounterLocationsListResponse--; |
399 return o; | 399 return o; |
400 } | 400 } |
401 | 401 |
402 checkLocationsListResponse(api.LocationsListResponse o) { | 402 checkLocationsListResponse(api.LocationsListResponse o) { |
403 buildCounterLocationsListResponse++; | 403 buildCounterLocationsListResponse++; |
404 if (buildCounterLocationsListResponse < 3) { | 404 if (buildCounterLocationsListResponse < 3) { |
405 checkUnnamed1506(o.items); | 405 checkUnnamed1497(o.items); |
406 unittest.expect(o.kind, unittest.equals('foo')); | 406 unittest.expect(o.kind, unittest.equals('foo')); |
407 } | 407 } |
408 buildCounterLocationsListResponse--; | 408 buildCounterLocationsListResponse--; |
409 } | 409 } |
410 | 410 |
411 buildUnnamed1507() { | 411 buildUnnamed1498() { |
412 var o = new core.List<api.MenuValue>(); | 412 var o = new core.List<api.MenuValue>(); |
413 o.add(buildMenuValue()); | 413 o.add(buildMenuValue()); |
414 o.add(buildMenuValue()); | 414 o.add(buildMenuValue()); |
415 return o; | 415 return o; |
416 } | 416 } |
417 | 417 |
418 checkUnnamed1507(core.List<api.MenuValue> o) { | 418 checkUnnamed1498(core.List<api.MenuValue> o) { |
419 unittest.expect(o, unittest.hasLength(2)); | 419 unittest.expect(o, unittest.hasLength(2)); |
420 checkMenuValue(o[0]); | 420 checkMenuValue(o[0]); |
421 checkMenuValue(o[1]); | 421 checkMenuValue(o[1]); |
422 } | 422 } |
423 | 423 |
424 core.int buildCounterMenuItem = 0; | 424 core.int buildCounterMenuItem = 0; |
425 buildMenuItem() { | 425 buildMenuItem() { |
426 var o = new api.MenuItem(); | 426 var o = new api.MenuItem(); |
427 buildCounterMenuItem++; | 427 buildCounterMenuItem++; |
428 if (buildCounterMenuItem < 3) { | 428 if (buildCounterMenuItem < 3) { |
429 o.action = "foo"; | 429 o.action = "foo"; |
430 o.contextualCommand = "foo"; | 430 o.contextualCommand = "foo"; |
431 o.id = "foo"; | 431 o.id = "foo"; |
432 o.payload = "foo"; | 432 o.payload = "foo"; |
433 o.removeWhenSelected = true; | 433 o.removeWhenSelected = true; |
434 o.values = buildUnnamed1507(); | 434 o.values = buildUnnamed1498(); |
435 } | 435 } |
436 buildCounterMenuItem--; | 436 buildCounterMenuItem--; |
437 return o; | 437 return o; |
438 } | 438 } |
439 | 439 |
440 checkMenuItem(api.MenuItem o) { | 440 checkMenuItem(api.MenuItem o) { |
441 buildCounterMenuItem++; | 441 buildCounterMenuItem++; |
442 if (buildCounterMenuItem < 3) { | 442 if (buildCounterMenuItem < 3) { |
443 unittest.expect(o.action, unittest.equals('foo')); | 443 unittest.expect(o.action, unittest.equals('foo')); |
444 unittest.expect(o.contextualCommand, unittest.equals('foo')); | 444 unittest.expect(o.contextualCommand, unittest.equals('foo')); |
445 unittest.expect(o.id, unittest.equals('foo')); | 445 unittest.expect(o.id, unittest.equals('foo')); |
446 unittest.expect(o.payload, unittest.equals('foo')); | 446 unittest.expect(o.payload, unittest.equals('foo')); |
447 unittest.expect(o.removeWhenSelected, unittest.isTrue); | 447 unittest.expect(o.removeWhenSelected, unittest.isTrue); |
448 checkUnnamed1507(o.values); | 448 checkUnnamed1498(o.values); |
449 } | 449 } |
450 buildCounterMenuItem--; | 450 buildCounterMenuItem--; |
451 } | 451 } |
452 | 452 |
453 core.int buildCounterMenuValue = 0; | 453 core.int buildCounterMenuValue = 0; |
454 buildMenuValue() { | 454 buildMenuValue() { |
455 var o = new api.MenuValue(); | 455 var o = new api.MenuValue(); |
456 buildCounterMenuValue++; | 456 buildCounterMenuValue++; |
457 if (buildCounterMenuValue < 3) { | 457 if (buildCounterMenuValue < 3) { |
458 o.displayName = "foo"; | 458 o.displayName = "foo"; |
459 o.iconUrl = "foo"; | 459 o.iconUrl = "foo"; |
460 o.state = "foo"; | 460 o.state = "foo"; |
461 } | 461 } |
462 buildCounterMenuValue--; | 462 buildCounterMenuValue--; |
463 return o; | 463 return o; |
464 } | 464 } |
465 | 465 |
466 checkMenuValue(api.MenuValue o) { | 466 checkMenuValue(api.MenuValue o) { |
467 buildCounterMenuValue++; | 467 buildCounterMenuValue++; |
468 if (buildCounterMenuValue < 3) { | 468 if (buildCounterMenuValue < 3) { |
469 unittest.expect(o.displayName, unittest.equals('foo')); | 469 unittest.expect(o.displayName, unittest.equals('foo')); |
470 unittest.expect(o.iconUrl, unittest.equals('foo')); | 470 unittest.expect(o.iconUrl, unittest.equals('foo')); |
471 unittest.expect(o.state, unittest.equals('foo')); | 471 unittest.expect(o.state, unittest.equals('foo')); |
472 } | 472 } |
473 buildCounterMenuValue--; | 473 buildCounterMenuValue--; |
474 } | 474 } |
475 | 475 |
476 buildUnnamed1508() { | 476 buildUnnamed1499() { |
477 var o = new core.List<api.UserAction>(); | 477 var o = new core.List<api.UserAction>(); |
478 o.add(buildUserAction()); | 478 o.add(buildUserAction()); |
479 o.add(buildUserAction()); | 479 o.add(buildUserAction()); |
480 return o; | 480 return o; |
481 } | 481 } |
482 | 482 |
483 checkUnnamed1508(core.List<api.UserAction> o) { | 483 checkUnnamed1499(core.List<api.UserAction> o) { |
484 unittest.expect(o, unittest.hasLength(2)); | 484 unittest.expect(o, unittest.hasLength(2)); |
485 checkUserAction(o[0]); | 485 checkUserAction(o[0]); |
486 checkUserAction(o[1]); | 486 checkUserAction(o[1]); |
487 } | 487 } |
488 | 488 |
489 core.int buildCounterNotification = 0; | 489 core.int buildCounterNotification = 0; |
490 buildNotification() { | 490 buildNotification() { |
491 var o = new api.Notification(); | 491 var o = new api.Notification(); |
492 buildCounterNotification++; | 492 buildCounterNotification++; |
493 if (buildCounterNotification < 3) { | 493 if (buildCounterNotification < 3) { |
494 o.collection = "foo"; | 494 o.collection = "foo"; |
495 o.itemId = "foo"; | 495 o.itemId = "foo"; |
496 o.operation = "foo"; | 496 o.operation = "foo"; |
497 o.userActions = buildUnnamed1508(); | 497 o.userActions = buildUnnamed1499(); |
498 o.userToken = "foo"; | 498 o.userToken = "foo"; |
499 o.verifyToken = "foo"; | 499 o.verifyToken = "foo"; |
500 } | 500 } |
501 buildCounterNotification--; | 501 buildCounterNotification--; |
502 return o; | 502 return o; |
503 } | 503 } |
504 | 504 |
505 checkNotification(api.Notification o) { | 505 checkNotification(api.Notification o) { |
506 buildCounterNotification++; | 506 buildCounterNotification++; |
507 if (buildCounterNotification < 3) { | 507 if (buildCounterNotification < 3) { |
508 unittest.expect(o.collection, unittest.equals('foo')); | 508 unittest.expect(o.collection, unittest.equals('foo')); |
509 unittest.expect(o.itemId, unittest.equals('foo')); | 509 unittest.expect(o.itemId, unittest.equals('foo')); |
510 unittest.expect(o.operation, unittest.equals('foo')); | 510 unittest.expect(o.operation, unittest.equals('foo')); |
511 checkUnnamed1508(o.userActions); | 511 checkUnnamed1499(o.userActions); |
512 unittest.expect(o.userToken, unittest.equals('foo')); | 512 unittest.expect(o.userToken, unittest.equals('foo')); |
513 unittest.expect(o.verifyToken, unittest.equals('foo')); | 513 unittest.expect(o.verifyToken, unittest.equals('foo')); |
514 } | 514 } |
515 buildCounterNotification--; | 515 buildCounterNotification--; |
516 } | 516 } |
517 | 517 |
518 core.int buildCounterNotificationConfig = 0; | 518 core.int buildCounterNotificationConfig = 0; |
519 buildNotificationConfig() { | 519 buildNotificationConfig() { |
520 var o = new api.NotificationConfig(); | 520 var o = new api.NotificationConfig(); |
521 buildCounterNotificationConfig++; | 521 buildCounterNotificationConfig++; |
522 if (buildCounterNotificationConfig < 3) { | 522 if (buildCounterNotificationConfig < 3) { |
523 o.deliveryTime = core.DateTime.parse("2002-02-27T14:01:02"); | 523 o.deliveryTime = core.DateTime.parse("2002-02-27T14:01:02"); |
524 o.level = "foo"; | 524 o.level = "foo"; |
525 } | 525 } |
526 buildCounterNotificationConfig--; | 526 buildCounterNotificationConfig--; |
527 return o; | 527 return o; |
528 } | 528 } |
529 | 529 |
530 checkNotificationConfig(api.NotificationConfig o) { | 530 checkNotificationConfig(api.NotificationConfig o) { |
531 buildCounterNotificationConfig++; | 531 buildCounterNotificationConfig++; |
532 if (buildCounterNotificationConfig < 3) { | 532 if (buildCounterNotificationConfig < 3) { |
533 unittest.expect(o.deliveryTime, unittest.equals(core.DateTime.parse("2002-02
-27T14:01:02"))); | 533 unittest.expect(o.deliveryTime, |
| 534 unittest.equals(core.DateTime.parse("2002-02-27T14:01:02"))); |
534 unittest.expect(o.level, unittest.equals('foo')); | 535 unittest.expect(o.level, unittest.equals('foo')); |
535 } | 536 } |
536 buildCounterNotificationConfig--; | 537 buildCounterNotificationConfig--; |
537 } | 538 } |
538 | 539 |
539 core.int buildCounterSetting = 0; | 540 core.int buildCounterSetting = 0; |
540 buildSetting() { | 541 buildSetting() { |
541 var o = new api.Setting(); | 542 var o = new api.Setting(); |
542 buildCounterSetting++; | 543 buildCounterSetting++; |
543 if (buildCounterSetting < 3) { | 544 if (buildCounterSetting < 3) { |
544 o.id = "foo"; | 545 o.id = "foo"; |
545 o.kind = "foo"; | 546 o.kind = "foo"; |
546 o.value = "foo"; | 547 o.value = "foo"; |
547 } | 548 } |
548 buildCounterSetting--; | 549 buildCounterSetting--; |
549 return o; | 550 return o; |
550 } | 551 } |
551 | 552 |
552 checkSetting(api.Setting o) { | 553 checkSetting(api.Setting o) { |
553 buildCounterSetting++; | 554 buildCounterSetting++; |
554 if (buildCounterSetting < 3) { | 555 if (buildCounterSetting < 3) { |
555 unittest.expect(o.id, unittest.equals('foo')); | 556 unittest.expect(o.id, unittest.equals('foo')); |
556 unittest.expect(o.kind, unittest.equals('foo')); | 557 unittest.expect(o.kind, unittest.equals('foo')); |
557 unittest.expect(o.value, unittest.equals('foo')); | 558 unittest.expect(o.value, unittest.equals('foo')); |
558 } | 559 } |
559 buildCounterSetting--; | 560 buildCounterSetting--; |
560 } | 561 } |
561 | 562 |
562 buildUnnamed1509() { | 563 buildUnnamed1500() { |
563 var o = new core.List<core.String>(); | 564 var o = new core.List<core.String>(); |
564 o.add("foo"); | 565 o.add("foo"); |
565 o.add("foo"); | 566 o.add("foo"); |
566 return o; | 567 return o; |
567 } | 568 } |
568 | 569 |
569 checkUnnamed1509(core.List<core.String> o) { | 570 checkUnnamed1500(core.List<core.String> o) { |
570 unittest.expect(o, unittest.hasLength(2)); | 571 unittest.expect(o, unittest.hasLength(2)); |
571 unittest.expect(o[0], unittest.equals('foo')); | 572 unittest.expect(o[0], unittest.equals('foo')); |
572 unittest.expect(o[1], unittest.equals('foo')); | 573 unittest.expect(o[1], unittest.equals('foo')); |
573 } | 574 } |
574 | 575 |
575 core.int buildCounterSubscription = 0; | 576 core.int buildCounterSubscription = 0; |
576 buildSubscription() { | 577 buildSubscription() { |
577 var o = new api.Subscription(); | 578 var o = new api.Subscription(); |
578 buildCounterSubscription++; | 579 buildCounterSubscription++; |
579 if (buildCounterSubscription < 3) { | 580 if (buildCounterSubscription < 3) { |
580 o.callbackUrl = "foo"; | 581 o.callbackUrl = "foo"; |
581 o.collection = "foo"; | 582 o.collection = "foo"; |
582 o.id = "foo"; | 583 o.id = "foo"; |
583 o.kind = "foo"; | 584 o.kind = "foo"; |
584 o.notification = buildNotification(); | 585 o.notification = buildNotification(); |
585 o.operation = buildUnnamed1509(); | 586 o.operation = buildUnnamed1500(); |
586 o.updated = core.DateTime.parse("2002-02-27T14:01:02"); | 587 o.updated = core.DateTime.parse("2002-02-27T14:01:02"); |
587 o.userToken = "foo"; | 588 o.userToken = "foo"; |
588 o.verifyToken = "foo"; | 589 o.verifyToken = "foo"; |
589 } | 590 } |
590 buildCounterSubscription--; | 591 buildCounterSubscription--; |
591 return o; | 592 return o; |
592 } | 593 } |
593 | 594 |
594 checkSubscription(api.Subscription o) { | 595 checkSubscription(api.Subscription o) { |
595 buildCounterSubscription++; | 596 buildCounterSubscription++; |
596 if (buildCounterSubscription < 3) { | 597 if (buildCounterSubscription < 3) { |
597 unittest.expect(o.callbackUrl, unittest.equals('foo')); | 598 unittest.expect(o.callbackUrl, unittest.equals('foo')); |
598 unittest.expect(o.collection, unittest.equals('foo')); | 599 unittest.expect(o.collection, unittest.equals('foo')); |
599 unittest.expect(o.id, unittest.equals('foo')); | 600 unittest.expect(o.id, unittest.equals('foo')); |
600 unittest.expect(o.kind, unittest.equals('foo')); | 601 unittest.expect(o.kind, unittest.equals('foo')); |
601 checkNotification(o.notification); | 602 checkNotification(o.notification); |
602 checkUnnamed1509(o.operation); | 603 checkUnnamed1500(o.operation); |
603 unittest.expect(o.updated, unittest.equals(core.DateTime.parse("2002-02-27T1
4:01:02"))); | 604 unittest.expect( |
| 605 o.updated, unittest.equals(core.DateTime.parse("2002-02-27T14:01:02"))); |
604 unittest.expect(o.userToken, unittest.equals('foo')); | 606 unittest.expect(o.userToken, unittest.equals('foo')); |
605 unittest.expect(o.verifyToken, unittest.equals('foo')); | 607 unittest.expect(o.verifyToken, unittest.equals('foo')); |
606 } | 608 } |
607 buildCounterSubscription--; | 609 buildCounterSubscription--; |
608 } | 610 } |
609 | 611 |
610 buildUnnamed1510() { | 612 buildUnnamed1501() { |
611 var o = new core.List<api.Subscription>(); | 613 var o = new core.List<api.Subscription>(); |
612 o.add(buildSubscription()); | 614 o.add(buildSubscription()); |
613 o.add(buildSubscription()); | 615 o.add(buildSubscription()); |
614 return o; | 616 return o; |
615 } | 617 } |
616 | 618 |
617 checkUnnamed1510(core.List<api.Subscription> o) { | 619 checkUnnamed1501(core.List<api.Subscription> o) { |
618 unittest.expect(o, unittest.hasLength(2)); | 620 unittest.expect(o, unittest.hasLength(2)); |
619 checkSubscription(o[0]); | 621 checkSubscription(o[0]); |
620 checkSubscription(o[1]); | 622 checkSubscription(o[1]); |
621 } | 623 } |
622 | 624 |
623 core.int buildCounterSubscriptionsListResponse = 0; | 625 core.int buildCounterSubscriptionsListResponse = 0; |
624 buildSubscriptionsListResponse() { | 626 buildSubscriptionsListResponse() { |
625 var o = new api.SubscriptionsListResponse(); | 627 var o = new api.SubscriptionsListResponse(); |
626 buildCounterSubscriptionsListResponse++; | 628 buildCounterSubscriptionsListResponse++; |
627 if (buildCounterSubscriptionsListResponse < 3) { | 629 if (buildCounterSubscriptionsListResponse < 3) { |
628 o.items = buildUnnamed1510(); | 630 o.items = buildUnnamed1501(); |
629 o.kind = "foo"; | 631 o.kind = "foo"; |
630 } | 632 } |
631 buildCounterSubscriptionsListResponse--; | 633 buildCounterSubscriptionsListResponse--; |
632 return o; | 634 return o; |
633 } | 635 } |
634 | 636 |
635 checkSubscriptionsListResponse(api.SubscriptionsListResponse o) { | 637 checkSubscriptionsListResponse(api.SubscriptionsListResponse o) { |
636 buildCounterSubscriptionsListResponse++; | 638 buildCounterSubscriptionsListResponse++; |
637 if (buildCounterSubscriptionsListResponse < 3) { | 639 if (buildCounterSubscriptionsListResponse < 3) { |
638 checkUnnamed1510(o.items); | 640 checkUnnamed1501(o.items); |
639 unittest.expect(o.kind, unittest.equals('foo')); | 641 unittest.expect(o.kind, unittest.equals('foo')); |
640 } | 642 } |
641 buildCounterSubscriptionsListResponse--; | 643 buildCounterSubscriptionsListResponse--; |
642 } | 644 } |
643 | 645 |
644 buildUnnamed1511() { | 646 buildUnnamed1502() { |
645 var o = new core.List<api.Attachment>(); | 647 var o = new core.List<api.Attachment>(); |
646 o.add(buildAttachment()); | 648 o.add(buildAttachment()); |
647 o.add(buildAttachment()); | 649 o.add(buildAttachment()); |
648 return o; | 650 return o; |
649 } | 651 } |
650 | 652 |
651 checkUnnamed1511(core.List<api.Attachment> o) { | 653 checkUnnamed1502(core.List<api.Attachment> o) { |
652 unittest.expect(o, unittest.hasLength(2)); | 654 unittest.expect(o, unittest.hasLength(2)); |
653 checkAttachment(o[0]); | 655 checkAttachment(o[0]); |
654 checkAttachment(o[1]); | 656 checkAttachment(o[1]); |
655 } | 657 } |
656 | 658 |
657 buildUnnamed1512() { | 659 buildUnnamed1503() { |
658 var o = new core.List<api.MenuItem>(); | 660 var o = new core.List<api.MenuItem>(); |
659 o.add(buildMenuItem()); | 661 o.add(buildMenuItem()); |
660 o.add(buildMenuItem()); | 662 o.add(buildMenuItem()); |
661 return o; | 663 return o; |
662 } | 664 } |
663 | 665 |
664 checkUnnamed1512(core.List<api.MenuItem> o) { | 666 checkUnnamed1503(core.List<api.MenuItem> o) { |
665 unittest.expect(o, unittest.hasLength(2)); | 667 unittest.expect(o, unittest.hasLength(2)); |
666 checkMenuItem(o[0]); | 668 checkMenuItem(o[0]); |
667 checkMenuItem(o[1]); | 669 checkMenuItem(o[1]); |
668 } | 670 } |
669 | 671 |
670 buildUnnamed1513() { | 672 buildUnnamed1504() { |
671 var o = new core.List<api.Contact>(); | 673 var o = new core.List<api.Contact>(); |
672 o.add(buildContact()); | 674 o.add(buildContact()); |
673 o.add(buildContact()); | 675 o.add(buildContact()); |
674 return o; | 676 return o; |
675 } | 677 } |
676 | 678 |
677 checkUnnamed1513(core.List<api.Contact> o) { | 679 checkUnnamed1504(core.List<api.Contact> o) { |
678 unittest.expect(o, unittest.hasLength(2)); | 680 unittest.expect(o, unittest.hasLength(2)); |
679 checkContact(o[0]); | 681 checkContact(o[0]); |
680 checkContact(o[1]); | 682 checkContact(o[1]); |
681 } | 683 } |
682 | 684 |
683 core.int buildCounterTimelineItem = 0; | 685 core.int buildCounterTimelineItem = 0; |
684 buildTimelineItem() { | 686 buildTimelineItem() { |
685 var o = new api.TimelineItem(); | 687 var o = new api.TimelineItem(); |
686 buildCounterTimelineItem++; | 688 buildCounterTimelineItem++; |
687 if (buildCounterTimelineItem < 3) { | 689 if (buildCounterTimelineItem < 3) { |
688 o.attachments = buildUnnamed1511(); | 690 o.attachments = buildUnnamed1502(); |
689 o.bundleId = "foo"; | 691 o.bundleId = "foo"; |
690 o.canonicalUrl = "foo"; | 692 o.canonicalUrl = "foo"; |
691 o.created = core.DateTime.parse("2002-02-27T14:01:02"); | 693 o.created = core.DateTime.parse("2002-02-27T14:01:02"); |
692 o.creator = buildContact(); | 694 o.creator = buildContact(); |
693 o.displayTime = core.DateTime.parse("2002-02-27T14:01:02"); | 695 o.displayTime = core.DateTime.parse("2002-02-27T14:01:02"); |
694 o.etag = "foo"; | 696 o.etag = "foo"; |
695 o.html = "foo"; | 697 o.html = "foo"; |
696 o.id = "foo"; | 698 o.id = "foo"; |
697 o.inReplyTo = "foo"; | 699 o.inReplyTo = "foo"; |
698 o.isBundleCover = true; | 700 o.isBundleCover = true; |
699 o.isDeleted = true; | 701 o.isDeleted = true; |
700 o.isPinned = true; | 702 o.isPinned = true; |
701 o.kind = "foo"; | 703 o.kind = "foo"; |
702 o.location = buildLocation(); | 704 o.location = buildLocation(); |
703 o.menuItems = buildUnnamed1512(); | 705 o.menuItems = buildUnnamed1503(); |
704 o.notification = buildNotificationConfig(); | 706 o.notification = buildNotificationConfig(); |
705 o.pinScore = 42; | 707 o.pinScore = 42; |
706 o.recipients = buildUnnamed1513(); | 708 o.recipients = buildUnnamed1504(); |
707 o.selfLink = "foo"; | 709 o.selfLink = "foo"; |
708 o.sourceItemId = "foo"; | 710 o.sourceItemId = "foo"; |
709 o.speakableText = "foo"; | 711 o.speakableText = "foo"; |
710 o.speakableType = "foo"; | 712 o.speakableType = "foo"; |
711 o.text = "foo"; | 713 o.text = "foo"; |
712 o.title = "foo"; | 714 o.title = "foo"; |
713 o.updated = core.DateTime.parse("2002-02-27T14:01:02"); | 715 o.updated = core.DateTime.parse("2002-02-27T14:01:02"); |
714 } | 716 } |
715 buildCounterTimelineItem--; | 717 buildCounterTimelineItem--; |
716 return o; | 718 return o; |
717 } | 719 } |
718 | 720 |
719 checkTimelineItem(api.TimelineItem o) { | 721 checkTimelineItem(api.TimelineItem o) { |
720 buildCounterTimelineItem++; | 722 buildCounterTimelineItem++; |
721 if (buildCounterTimelineItem < 3) { | 723 if (buildCounterTimelineItem < 3) { |
722 checkUnnamed1511(o.attachments); | 724 checkUnnamed1502(o.attachments); |
723 unittest.expect(o.bundleId, unittest.equals('foo')); | 725 unittest.expect(o.bundleId, unittest.equals('foo')); |
724 unittest.expect(o.canonicalUrl, unittest.equals('foo')); | 726 unittest.expect(o.canonicalUrl, unittest.equals('foo')); |
725 unittest.expect(o.created, unittest.equals(core.DateTime.parse("2002-02-27T1
4:01:02"))); | 727 unittest.expect( |
| 728 o.created, unittest.equals(core.DateTime.parse("2002-02-27T14:01:02"))); |
726 checkContact(o.creator); | 729 checkContact(o.creator); |
727 unittest.expect(o.displayTime, unittest.equals(core.DateTime.parse("2002-02-
27T14:01:02"))); | 730 unittest.expect(o.displayTime, |
| 731 unittest.equals(core.DateTime.parse("2002-02-27T14:01:02"))); |
728 unittest.expect(o.etag, unittest.equals('foo')); | 732 unittest.expect(o.etag, unittest.equals('foo')); |
729 unittest.expect(o.html, unittest.equals('foo')); | 733 unittest.expect(o.html, unittest.equals('foo')); |
730 unittest.expect(o.id, unittest.equals('foo')); | 734 unittest.expect(o.id, unittest.equals('foo')); |
731 unittest.expect(o.inReplyTo, unittest.equals('foo')); | 735 unittest.expect(o.inReplyTo, unittest.equals('foo')); |
732 unittest.expect(o.isBundleCover, unittest.isTrue); | 736 unittest.expect(o.isBundleCover, unittest.isTrue); |
733 unittest.expect(o.isDeleted, unittest.isTrue); | 737 unittest.expect(o.isDeleted, unittest.isTrue); |
734 unittest.expect(o.isPinned, unittest.isTrue); | 738 unittest.expect(o.isPinned, unittest.isTrue); |
735 unittest.expect(o.kind, unittest.equals('foo')); | 739 unittest.expect(o.kind, unittest.equals('foo')); |
736 checkLocation(o.location); | 740 checkLocation(o.location); |
737 checkUnnamed1512(o.menuItems); | 741 checkUnnamed1503(o.menuItems); |
738 checkNotificationConfig(o.notification); | 742 checkNotificationConfig(o.notification); |
739 unittest.expect(o.pinScore, unittest.equals(42)); | 743 unittest.expect(o.pinScore, unittest.equals(42)); |
740 checkUnnamed1513(o.recipients); | 744 checkUnnamed1504(o.recipients); |
741 unittest.expect(o.selfLink, unittest.equals('foo')); | 745 unittest.expect(o.selfLink, unittest.equals('foo')); |
742 unittest.expect(o.sourceItemId, unittest.equals('foo')); | 746 unittest.expect(o.sourceItemId, unittest.equals('foo')); |
743 unittest.expect(o.speakableText, unittest.equals('foo')); | 747 unittest.expect(o.speakableText, unittest.equals('foo')); |
744 unittest.expect(o.speakableType, unittest.equals('foo')); | 748 unittest.expect(o.speakableType, unittest.equals('foo')); |
745 unittest.expect(o.text, unittest.equals('foo')); | 749 unittest.expect(o.text, unittest.equals('foo')); |
746 unittest.expect(o.title, unittest.equals('foo')); | 750 unittest.expect(o.title, unittest.equals('foo')); |
747 unittest.expect(o.updated, unittest.equals(core.DateTime.parse("2002-02-27T1
4:01:02"))); | 751 unittest.expect( |
| 752 o.updated, unittest.equals(core.DateTime.parse("2002-02-27T14:01:02"))); |
748 } | 753 } |
749 buildCounterTimelineItem--; | 754 buildCounterTimelineItem--; |
750 } | 755 } |
751 | 756 |
752 buildUnnamed1514() { | 757 buildUnnamed1505() { |
753 var o = new core.List<api.TimelineItem>(); | 758 var o = new core.List<api.TimelineItem>(); |
754 o.add(buildTimelineItem()); | 759 o.add(buildTimelineItem()); |
755 o.add(buildTimelineItem()); | 760 o.add(buildTimelineItem()); |
756 return o; | 761 return o; |
757 } | 762 } |
758 | 763 |
759 checkUnnamed1514(core.List<api.TimelineItem> o) { | 764 checkUnnamed1505(core.List<api.TimelineItem> o) { |
760 unittest.expect(o, unittest.hasLength(2)); | 765 unittest.expect(o, unittest.hasLength(2)); |
761 checkTimelineItem(o[0]); | 766 checkTimelineItem(o[0]); |
762 checkTimelineItem(o[1]); | 767 checkTimelineItem(o[1]); |
763 } | 768 } |
764 | 769 |
765 core.int buildCounterTimelineListResponse = 0; | 770 core.int buildCounterTimelineListResponse = 0; |
766 buildTimelineListResponse() { | 771 buildTimelineListResponse() { |
767 var o = new api.TimelineListResponse(); | 772 var o = new api.TimelineListResponse(); |
768 buildCounterTimelineListResponse++; | 773 buildCounterTimelineListResponse++; |
769 if (buildCounterTimelineListResponse < 3) { | 774 if (buildCounterTimelineListResponse < 3) { |
770 o.items = buildUnnamed1514(); | 775 o.items = buildUnnamed1505(); |
771 o.kind = "foo"; | 776 o.kind = "foo"; |
772 o.nextPageToken = "foo"; | 777 o.nextPageToken = "foo"; |
773 } | 778 } |
774 buildCounterTimelineListResponse--; | 779 buildCounterTimelineListResponse--; |
775 return o; | 780 return o; |
776 } | 781 } |
777 | 782 |
778 checkTimelineListResponse(api.TimelineListResponse o) { | 783 checkTimelineListResponse(api.TimelineListResponse o) { |
779 buildCounterTimelineListResponse++; | 784 buildCounterTimelineListResponse++; |
780 if (buildCounterTimelineListResponse < 3) { | 785 if (buildCounterTimelineListResponse < 3) { |
781 checkUnnamed1514(o.items); | 786 checkUnnamed1505(o.items); |
782 unittest.expect(o.kind, unittest.equals('foo')); | 787 unittest.expect(o.kind, unittest.equals('foo')); |
783 unittest.expect(o.nextPageToken, unittest.equals('foo')); | 788 unittest.expect(o.nextPageToken, unittest.equals('foo')); |
784 } | 789 } |
785 buildCounterTimelineListResponse--; | 790 buildCounterTimelineListResponse--; |
786 } | 791 } |
787 | 792 |
788 core.int buildCounterUserAction = 0; | 793 core.int buildCounterUserAction = 0; |
789 buildUserAction() { | 794 buildUserAction() { |
790 var o = new api.UserAction(); | 795 var o = new api.UserAction(); |
791 buildCounterUserAction++; | 796 buildCounterUserAction++; |
(...skipping 28 matching lines...) Expand all Loading... |
820 | 825 |
821 checkUserData(api.UserData o) { | 826 checkUserData(api.UserData o) { |
822 buildCounterUserData++; | 827 buildCounterUserData++; |
823 if (buildCounterUserData < 3) { | 828 if (buildCounterUserData < 3) { |
824 unittest.expect(o.key, unittest.equals('foo')); | 829 unittest.expect(o.key, unittest.equals('foo')); |
825 unittest.expect(o.value, unittest.equals('foo')); | 830 unittest.expect(o.value, unittest.equals('foo')); |
826 } | 831 } |
827 buildCounterUserData--; | 832 buildCounterUserData--; |
828 } | 833 } |
829 | 834 |
830 | |
831 main() { | 835 main() { |
832 unittest.group("obj-schema-Account", () { | 836 unittest.group("obj-schema-Account", () { |
833 unittest.test("to-json--from-json", () { | 837 unittest.test("to-json--from-json", () { |
834 var o = buildAccount(); | 838 var o = buildAccount(); |
835 var od = new api.Account.fromJson(o.toJson()); | 839 var od = new api.Account.fromJson(o.toJson()); |
836 checkAccount(od); | 840 checkAccount(od); |
837 }); | 841 }); |
838 }); | 842 }); |
839 | 843 |
840 | |
841 unittest.group("obj-schema-Attachment", () { | 844 unittest.group("obj-schema-Attachment", () { |
842 unittest.test("to-json--from-json", () { | 845 unittest.test("to-json--from-json", () { |
843 var o = buildAttachment(); | 846 var o = buildAttachment(); |
844 var od = new api.Attachment.fromJson(o.toJson()); | 847 var od = new api.Attachment.fromJson(o.toJson()); |
845 checkAttachment(od); | 848 checkAttachment(od); |
846 }); | 849 }); |
847 }); | 850 }); |
848 | 851 |
849 | |
850 unittest.group("obj-schema-AttachmentsListResponse", () { | 852 unittest.group("obj-schema-AttachmentsListResponse", () { |
851 unittest.test("to-json--from-json", () { | 853 unittest.test("to-json--from-json", () { |
852 var o = buildAttachmentsListResponse(); | 854 var o = buildAttachmentsListResponse(); |
853 var od = new api.AttachmentsListResponse.fromJson(o.toJson()); | 855 var od = new api.AttachmentsListResponse.fromJson(o.toJson()); |
854 checkAttachmentsListResponse(od); | 856 checkAttachmentsListResponse(od); |
855 }); | 857 }); |
856 }); | 858 }); |
857 | 859 |
858 | |
859 unittest.group("obj-schema-AuthToken", () { | 860 unittest.group("obj-schema-AuthToken", () { |
860 unittest.test("to-json--from-json", () { | 861 unittest.test("to-json--from-json", () { |
861 var o = buildAuthToken(); | 862 var o = buildAuthToken(); |
862 var od = new api.AuthToken.fromJson(o.toJson()); | 863 var od = new api.AuthToken.fromJson(o.toJson()); |
863 checkAuthToken(od); | 864 checkAuthToken(od); |
864 }); | 865 }); |
865 }); | 866 }); |
866 | 867 |
867 | |
868 unittest.group("obj-schema-Command", () { | 868 unittest.group("obj-schema-Command", () { |
869 unittest.test("to-json--from-json", () { | 869 unittest.test("to-json--from-json", () { |
870 var o = buildCommand(); | 870 var o = buildCommand(); |
871 var od = new api.Command.fromJson(o.toJson()); | 871 var od = new api.Command.fromJson(o.toJson()); |
872 checkCommand(od); | 872 checkCommand(od); |
873 }); | 873 }); |
874 }); | 874 }); |
875 | 875 |
876 | |
877 unittest.group("obj-schema-Contact", () { | 876 unittest.group("obj-schema-Contact", () { |
878 unittest.test("to-json--from-json", () { | 877 unittest.test("to-json--from-json", () { |
879 var o = buildContact(); | 878 var o = buildContact(); |
880 var od = new api.Contact.fromJson(o.toJson()); | 879 var od = new api.Contact.fromJson(o.toJson()); |
881 checkContact(od); | 880 checkContact(od); |
882 }); | 881 }); |
883 }); | 882 }); |
884 | 883 |
885 | |
886 unittest.group("obj-schema-ContactsListResponse", () { | 884 unittest.group("obj-schema-ContactsListResponse", () { |
887 unittest.test("to-json--from-json", () { | 885 unittest.test("to-json--from-json", () { |
888 var o = buildContactsListResponse(); | 886 var o = buildContactsListResponse(); |
889 var od = new api.ContactsListResponse.fromJson(o.toJson()); | 887 var od = new api.ContactsListResponse.fromJson(o.toJson()); |
890 checkContactsListResponse(od); | 888 checkContactsListResponse(od); |
891 }); | 889 }); |
892 }); | 890 }); |
893 | 891 |
894 | |
895 unittest.group("obj-schema-Location", () { | 892 unittest.group("obj-schema-Location", () { |
896 unittest.test("to-json--from-json", () { | 893 unittest.test("to-json--from-json", () { |
897 var o = buildLocation(); | 894 var o = buildLocation(); |
898 var od = new api.Location.fromJson(o.toJson()); | 895 var od = new api.Location.fromJson(o.toJson()); |
899 checkLocation(od); | 896 checkLocation(od); |
900 }); | 897 }); |
901 }); | 898 }); |
902 | 899 |
903 | |
904 unittest.group("obj-schema-LocationsListResponse", () { | 900 unittest.group("obj-schema-LocationsListResponse", () { |
905 unittest.test("to-json--from-json", () { | 901 unittest.test("to-json--from-json", () { |
906 var o = buildLocationsListResponse(); | 902 var o = buildLocationsListResponse(); |
907 var od = new api.LocationsListResponse.fromJson(o.toJson()); | 903 var od = new api.LocationsListResponse.fromJson(o.toJson()); |
908 checkLocationsListResponse(od); | 904 checkLocationsListResponse(od); |
909 }); | 905 }); |
910 }); | 906 }); |
911 | 907 |
912 | |
913 unittest.group("obj-schema-MenuItem", () { | 908 unittest.group("obj-schema-MenuItem", () { |
914 unittest.test("to-json--from-json", () { | 909 unittest.test("to-json--from-json", () { |
915 var o = buildMenuItem(); | 910 var o = buildMenuItem(); |
916 var od = new api.MenuItem.fromJson(o.toJson()); | 911 var od = new api.MenuItem.fromJson(o.toJson()); |
917 checkMenuItem(od); | 912 checkMenuItem(od); |
918 }); | 913 }); |
919 }); | 914 }); |
920 | 915 |
921 | |
922 unittest.group("obj-schema-MenuValue", () { | 916 unittest.group("obj-schema-MenuValue", () { |
923 unittest.test("to-json--from-json", () { | 917 unittest.test("to-json--from-json", () { |
924 var o = buildMenuValue(); | 918 var o = buildMenuValue(); |
925 var od = new api.MenuValue.fromJson(o.toJson()); | 919 var od = new api.MenuValue.fromJson(o.toJson()); |
926 checkMenuValue(od); | 920 checkMenuValue(od); |
927 }); | 921 }); |
928 }); | 922 }); |
929 | 923 |
930 | |
931 unittest.group("obj-schema-Notification", () { | 924 unittest.group("obj-schema-Notification", () { |
932 unittest.test("to-json--from-json", () { | 925 unittest.test("to-json--from-json", () { |
933 var o = buildNotification(); | 926 var o = buildNotification(); |
934 var od = new api.Notification.fromJson(o.toJson()); | 927 var od = new api.Notification.fromJson(o.toJson()); |
935 checkNotification(od); | 928 checkNotification(od); |
936 }); | 929 }); |
937 }); | 930 }); |
938 | 931 |
939 | |
940 unittest.group("obj-schema-NotificationConfig", () { | 932 unittest.group("obj-schema-NotificationConfig", () { |
941 unittest.test("to-json--from-json", () { | 933 unittest.test("to-json--from-json", () { |
942 var o = buildNotificationConfig(); | 934 var o = buildNotificationConfig(); |
943 var od = new api.NotificationConfig.fromJson(o.toJson()); | 935 var od = new api.NotificationConfig.fromJson(o.toJson()); |
944 checkNotificationConfig(od); | 936 checkNotificationConfig(od); |
945 }); | 937 }); |
946 }); | 938 }); |
947 | 939 |
948 | |
949 unittest.group("obj-schema-Setting", () { | 940 unittest.group("obj-schema-Setting", () { |
950 unittest.test("to-json--from-json", () { | 941 unittest.test("to-json--from-json", () { |
951 var o = buildSetting(); | 942 var o = buildSetting(); |
952 var od = new api.Setting.fromJson(o.toJson()); | 943 var od = new api.Setting.fromJson(o.toJson()); |
953 checkSetting(od); | 944 checkSetting(od); |
954 }); | 945 }); |
955 }); | 946 }); |
956 | 947 |
957 | |
958 unittest.group("obj-schema-Subscription", () { | 948 unittest.group("obj-schema-Subscription", () { |
959 unittest.test("to-json--from-json", () { | 949 unittest.test("to-json--from-json", () { |
960 var o = buildSubscription(); | 950 var o = buildSubscription(); |
961 var od = new api.Subscription.fromJson(o.toJson()); | 951 var od = new api.Subscription.fromJson(o.toJson()); |
962 checkSubscription(od); | 952 checkSubscription(od); |
963 }); | 953 }); |
964 }); | 954 }); |
965 | 955 |
966 | |
967 unittest.group("obj-schema-SubscriptionsListResponse", () { | 956 unittest.group("obj-schema-SubscriptionsListResponse", () { |
968 unittest.test("to-json--from-json", () { | 957 unittest.test("to-json--from-json", () { |
969 var o = buildSubscriptionsListResponse(); | 958 var o = buildSubscriptionsListResponse(); |
970 var od = new api.SubscriptionsListResponse.fromJson(o.toJson()); | 959 var od = new api.SubscriptionsListResponse.fromJson(o.toJson()); |
971 checkSubscriptionsListResponse(od); | 960 checkSubscriptionsListResponse(od); |
972 }); | 961 }); |
973 }); | 962 }); |
974 | 963 |
975 | |
976 unittest.group("obj-schema-TimelineItem", () { | 964 unittest.group("obj-schema-TimelineItem", () { |
977 unittest.test("to-json--from-json", () { | 965 unittest.test("to-json--from-json", () { |
978 var o = buildTimelineItem(); | 966 var o = buildTimelineItem(); |
979 var od = new api.TimelineItem.fromJson(o.toJson()); | 967 var od = new api.TimelineItem.fromJson(o.toJson()); |
980 checkTimelineItem(od); | 968 checkTimelineItem(od); |
981 }); | 969 }); |
982 }); | 970 }); |
983 | 971 |
984 | |
985 unittest.group("obj-schema-TimelineListResponse", () { | 972 unittest.group("obj-schema-TimelineListResponse", () { |
986 unittest.test("to-json--from-json", () { | 973 unittest.test("to-json--from-json", () { |
987 var o = buildTimelineListResponse(); | 974 var o = buildTimelineListResponse(); |
988 var od = new api.TimelineListResponse.fromJson(o.toJson()); | 975 var od = new api.TimelineListResponse.fromJson(o.toJson()); |
989 checkTimelineListResponse(od); | 976 checkTimelineListResponse(od); |
990 }); | 977 }); |
991 }); | 978 }); |
992 | 979 |
993 | |
994 unittest.group("obj-schema-UserAction", () { | 980 unittest.group("obj-schema-UserAction", () { |
995 unittest.test("to-json--from-json", () { | 981 unittest.test("to-json--from-json", () { |
996 var o = buildUserAction(); | 982 var o = buildUserAction(); |
997 var od = new api.UserAction.fromJson(o.toJson()); | 983 var od = new api.UserAction.fromJson(o.toJson()); |
998 checkUserAction(od); | 984 checkUserAction(od); |
999 }); | 985 }); |
1000 }); | 986 }); |
1001 | 987 |
1002 | |
1003 unittest.group("obj-schema-UserData", () { | 988 unittest.group("obj-schema-UserData", () { |
1004 unittest.test("to-json--from-json", () { | 989 unittest.test("to-json--from-json", () { |
1005 var o = buildUserData(); | 990 var o = buildUserData(); |
1006 var od = new api.UserData.fromJson(o.toJson()); | 991 var od = new api.UserData.fromJson(o.toJson()); |
1007 checkUserData(od); | 992 checkUserData(od); |
1008 }); | 993 }); |
1009 }); | 994 }); |
1010 | 995 |
1011 | |
1012 unittest.group("resource-AccountsResourceApi", () { | 996 unittest.group("resource-AccountsResourceApi", () { |
1013 unittest.test("method--insert", () { | 997 unittest.test("method--insert", () { |
1014 | |
1015 var mock = new HttpServerMock(); | 998 var mock = new HttpServerMock(); |
1016 api.AccountsResourceApi res = new api.MirrorApi(mock).accounts; | 999 api.AccountsResourceApi res = new api.MirrorApi(mock).accounts; |
1017 var arg_request = buildAccount(); | 1000 var arg_request = buildAccount(); |
1018 var arg_userToken = "foo"; | 1001 var arg_userToken = "foo"; |
1019 var arg_accountType = "foo"; | 1002 var arg_accountType = "foo"; |
1020 var arg_accountName = "foo"; | 1003 var arg_accountName = "foo"; |
1021 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 1004 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
1022 var obj = new api.Account.fromJson(json); | 1005 var obj = new api.Account.fromJson(json); |
1023 checkAccount(obj); | 1006 checkAccount(obj); |
1024 | 1007 |
1025 var path = (req.url).path; | 1008 var path = (req.url).path; |
1026 var pathOffset = 0; | 1009 var pathOffset = 0; |
1027 var index; | 1010 var index; |
1028 var subPart; | 1011 var subPart; |
1029 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 1012 unittest.expect( |
| 1013 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
1030 pathOffset += 1; | 1014 pathOffset += 1; |
1031 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("mirror/v1/")); | 1015 unittest.expect(path.substring(pathOffset, pathOffset + 10), |
| 1016 unittest.equals("mirror/v1/")); |
1032 pathOffset += 10; | 1017 pathOffset += 10; |
1033 unittest.expect(path.substring(pathOffset, pathOffset + 9), unittest.equ
als("accounts/")); | 1018 unittest.expect(path.substring(pathOffset, pathOffset + 9), |
| 1019 unittest.equals("accounts/")); |
1034 pathOffset += 9; | 1020 pathOffset += 9; |
1035 index = path.indexOf("/", pathOffset); | 1021 index = path.indexOf("/", pathOffset); |
1036 unittest.expect(index >= 0, unittest.isTrue); | 1022 unittest.expect(index >= 0, unittest.isTrue); |
1037 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | 1023 subPart = |
| 1024 core.Uri.decodeQueryComponent(path.substring(pathOffset, index)); |
1038 pathOffset = index; | 1025 pathOffset = index; |
1039 unittest.expect(subPart, unittest.equals("$arg_userToken")); | 1026 unittest.expect(subPart, unittest.equals("$arg_userToken")); |
1040 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 1027 unittest.expect( |
| 1028 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
1041 pathOffset += 1; | 1029 pathOffset += 1; |
1042 index = path.indexOf("/", pathOffset); | 1030 index = path.indexOf("/", pathOffset); |
1043 unittest.expect(index >= 0, unittest.isTrue); | 1031 unittest.expect(index >= 0, unittest.isTrue); |
1044 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | 1032 subPart = |
| 1033 core.Uri.decodeQueryComponent(path.substring(pathOffset, index)); |
1045 pathOffset = index; | 1034 pathOffset = index; |
1046 unittest.expect(subPart, unittest.equals("$arg_accountType")); | 1035 unittest.expect(subPart, unittest.equals("$arg_accountType")); |
1047 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 1036 unittest.expect( |
| 1037 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
1048 pathOffset += 1; | 1038 pathOffset += 1; |
1049 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); | 1039 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); |
1050 pathOffset = path.length; | 1040 pathOffset = path.length; |
1051 unittest.expect(subPart, unittest.equals("$arg_accountName")); | 1041 unittest.expect(subPart, unittest.equals("$arg_accountName")); |
1052 | 1042 |
1053 var query = (req.url).query; | 1043 var query = (req.url).query; |
1054 var queryOffset = 0; | 1044 var queryOffset = 0; |
1055 var queryMap = {}; | 1045 var queryMap = {}; |
1056 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 1046 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
1057 parseBool(n) { | 1047 parseBool(n) { |
1058 if (n == "true") return true; | 1048 if (n == "true") return true; |
1059 if (n == "false") return false; | 1049 if (n == "false") return false; |
1060 if (n == null) return null; | 1050 if (n == null) return null; |
1061 throw new core.ArgumentError("Invalid boolean: $n"); | 1051 throw new core.ArgumentError("Invalid boolean: $n"); |
1062 } | 1052 } |
| 1053 |
1063 if (query.length > 0) { | 1054 if (query.length > 0) { |
1064 for (var part in query.split("&")) { | 1055 for (var part in query.split("&")) { |
1065 var keyvalue = part.split("="); | 1056 var keyvalue = part.split("="); |
1066 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 1057 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 1058 core.Uri.decodeQueryComponent(keyvalue[1])); |
1067 } | 1059 } |
1068 } | 1060 } |
1069 | 1061 |
1070 | |
1071 var h = { | 1062 var h = { |
1072 "content-type" : "application/json; charset=utf-8", | 1063 "content-type": "application/json; charset=utf-8", |
1073 }; | 1064 }; |
1074 var resp = convert.JSON.encode(buildAccount()); | 1065 var resp = convert.JSON.encode(buildAccount()); |
1075 return new async.Future.value(stringResponse(200, h, resp)); | 1066 return new async.Future.value(stringResponse(200, h, resp)); |
1076 }), true); | 1067 }), true); |
1077 res.insert(arg_request, arg_userToken, arg_accountType, arg_accountName).t
hen(unittest.expectAsync1(((api.Account response) { | 1068 res |
| 1069 .insert(arg_request, arg_userToken, arg_accountType, arg_accountName) |
| 1070 .then(unittest.expectAsync1(((api.Account response) { |
1078 checkAccount(response); | 1071 checkAccount(response); |
1079 }))); | 1072 }))); |
1080 }); | 1073 }); |
1081 | |
1082 }); | 1074 }); |
1083 | 1075 |
1084 | |
1085 unittest.group("resource-ContactsResourceApi", () { | 1076 unittest.group("resource-ContactsResourceApi", () { |
1086 unittest.test("method--delete", () { | 1077 unittest.test("method--delete", () { |
1087 | |
1088 var mock = new HttpServerMock(); | 1078 var mock = new HttpServerMock(); |
1089 api.ContactsResourceApi res = new api.MirrorApi(mock).contacts; | 1079 api.ContactsResourceApi res = new api.MirrorApi(mock).contacts; |
1090 var arg_id = "foo"; | 1080 var arg_id = "foo"; |
1091 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 1081 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
1092 var path = (req.url).path; | 1082 var path = (req.url).path; |
1093 var pathOffset = 0; | 1083 var pathOffset = 0; |
1094 var index; | 1084 var index; |
1095 var subPart; | 1085 var subPart; |
1096 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 1086 unittest.expect( |
| 1087 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
1097 pathOffset += 1; | 1088 pathOffset += 1; |
1098 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("mirror/v1/")); | 1089 unittest.expect(path.substring(pathOffset, pathOffset + 10), |
| 1090 unittest.equals("mirror/v1/")); |
1099 pathOffset += 10; | 1091 pathOffset += 10; |
1100 unittest.expect(path.substring(pathOffset, pathOffset + 9), unittest.equ
als("contacts/")); | 1092 unittest.expect(path.substring(pathOffset, pathOffset + 9), |
| 1093 unittest.equals("contacts/")); |
1101 pathOffset += 9; | 1094 pathOffset += 9; |
1102 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); | 1095 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); |
1103 pathOffset = path.length; | 1096 pathOffset = path.length; |
1104 unittest.expect(subPart, unittest.equals("$arg_id")); | 1097 unittest.expect(subPart, unittest.equals("$arg_id")); |
1105 | 1098 |
1106 var query = (req.url).query; | 1099 var query = (req.url).query; |
1107 var queryOffset = 0; | 1100 var queryOffset = 0; |
1108 var queryMap = {}; | 1101 var queryMap = {}; |
1109 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 1102 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
1110 parseBool(n) { | 1103 parseBool(n) { |
1111 if (n == "true") return true; | 1104 if (n == "true") return true; |
1112 if (n == "false") return false; | 1105 if (n == "false") return false; |
1113 if (n == null) return null; | 1106 if (n == null) return null; |
1114 throw new core.ArgumentError("Invalid boolean: $n"); | 1107 throw new core.ArgumentError("Invalid boolean: $n"); |
1115 } | 1108 } |
| 1109 |
1116 if (query.length > 0) { | 1110 if (query.length > 0) { |
1117 for (var part in query.split("&")) { | 1111 for (var part in query.split("&")) { |
1118 var keyvalue = part.split("="); | 1112 var keyvalue = part.split("="); |
1119 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 1113 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 1114 core.Uri.decodeQueryComponent(keyvalue[1])); |
1120 } | 1115 } |
1121 } | 1116 } |
1122 | 1117 |
1123 | |
1124 var h = { | 1118 var h = { |
1125 "content-type" : "application/json; charset=utf-8", | 1119 "content-type": "application/json; charset=utf-8", |
1126 }; | 1120 }; |
1127 var resp = ""; | 1121 var resp = ""; |
1128 return new async.Future.value(stringResponse(200, h, resp)); | 1122 return new async.Future.value(stringResponse(200, h, resp)); |
1129 }), true); | 1123 }), true); |
1130 res.delete(arg_id).then(unittest.expectAsync1((_) {})); | 1124 res.delete(arg_id).then(unittest.expectAsync1((_) {})); |
1131 }); | 1125 }); |
1132 | 1126 |
1133 unittest.test("method--get", () { | 1127 unittest.test("method--get", () { |
1134 | |
1135 var mock = new HttpServerMock(); | 1128 var mock = new HttpServerMock(); |
1136 api.ContactsResourceApi res = new api.MirrorApi(mock).contacts; | 1129 api.ContactsResourceApi res = new api.MirrorApi(mock).contacts; |
1137 var arg_id = "foo"; | 1130 var arg_id = "foo"; |
1138 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 1131 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
1139 var path = (req.url).path; | 1132 var path = (req.url).path; |
1140 var pathOffset = 0; | 1133 var pathOffset = 0; |
1141 var index; | 1134 var index; |
1142 var subPart; | 1135 var subPart; |
1143 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 1136 unittest.expect( |
| 1137 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
1144 pathOffset += 1; | 1138 pathOffset += 1; |
1145 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("mirror/v1/")); | 1139 unittest.expect(path.substring(pathOffset, pathOffset + 10), |
| 1140 unittest.equals("mirror/v1/")); |
1146 pathOffset += 10; | 1141 pathOffset += 10; |
1147 unittest.expect(path.substring(pathOffset, pathOffset + 9), unittest.equ
als("contacts/")); | 1142 unittest.expect(path.substring(pathOffset, pathOffset + 9), |
| 1143 unittest.equals("contacts/")); |
1148 pathOffset += 9; | 1144 pathOffset += 9; |
1149 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); | 1145 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); |
1150 pathOffset = path.length; | 1146 pathOffset = path.length; |
1151 unittest.expect(subPart, unittest.equals("$arg_id")); | 1147 unittest.expect(subPart, unittest.equals("$arg_id")); |
1152 | 1148 |
1153 var query = (req.url).query; | 1149 var query = (req.url).query; |
1154 var queryOffset = 0; | 1150 var queryOffset = 0; |
1155 var queryMap = {}; | 1151 var queryMap = {}; |
1156 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 1152 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
1157 parseBool(n) { | 1153 parseBool(n) { |
1158 if (n == "true") return true; | 1154 if (n == "true") return true; |
1159 if (n == "false") return false; | 1155 if (n == "false") return false; |
1160 if (n == null) return null; | 1156 if (n == null) return null; |
1161 throw new core.ArgumentError("Invalid boolean: $n"); | 1157 throw new core.ArgumentError("Invalid boolean: $n"); |
1162 } | 1158 } |
| 1159 |
1163 if (query.length > 0) { | 1160 if (query.length > 0) { |
1164 for (var part in query.split("&")) { | 1161 for (var part in query.split("&")) { |
1165 var keyvalue = part.split("="); | 1162 var keyvalue = part.split("="); |
1166 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 1163 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 1164 core.Uri.decodeQueryComponent(keyvalue[1])); |
1167 } | 1165 } |
1168 } | 1166 } |
1169 | 1167 |
1170 | |
1171 var h = { | 1168 var h = { |
1172 "content-type" : "application/json; charset=utf-8", | 1169 "content-type": "application/json; charset=utf-8", |
1173 }; | 1170 }; |
1174 var resp = convert.JSON.encode(buildContact()); | 1171 var resp = convert.JSON.encode(buildContact()); |
1175 return new async.Future.value(stringResponse(200, h, resp)); | 1172 return new async.Future.value(stringResponse(200, h, resp)); |
1176 }), true); | 1173 }), true); |
1177 res.get(arg_id).then(unittest.expectAsync1(((api.Contact response) { | 1174 res.get(arg_id).then(unittest.expectAsync1(((api.Contact response) { |
1178 checkContact(response); | 1175 checkContact(response); |
1179 }))); | 1176 }))); |
1180 }); | 1177 }); |
1181 | 1178 |
1182 unittest.test("method--insert", () { | 1179 unittest.test("method--insert", () { |
1183 | |
1184 var mock = new HttpServerMock(); | 1180 var mock = new HttpServerMock(); |
1185 api.ContactsResourceApi res = new api.MirrorApi(mock).contacts; | 1181 api.ContactsResourceApi res = new api.MirrorApi(mock).contacts; |
1186 var arg_request = buildContact(); | 1182 var arg_request = buildContact(); |
1187 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 1183 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
1188 var obj = new api.Contact.fromJson(json); | 1184 var obj = new api.Contact.fromJson(json); |
1189 checkContact(obj); | 1185 checkContact(obj); |
1190 | 1186 |
1191 var path = (req.url).path; | 1187 var path = (req.url).path; |
1192 var pathOffset = 0; | 1188 var pathOffset = 0; |
1193 var index; | 1189 var index; |
1194 var subPart; | 1190 var subPart; |
1195 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 1191 unittest.expect( |
| 1192 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
1196 pathOffset += 1; | 1193 pathOffset += 1; |
1197 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("mirror/v1/")); | 1194 unittest.expect(path.substring(pathOffset, pathOffset + 10), |
| 1195 unittest.equals("mirror/v1/")); |
1198 pathOffset += 10; | 1196 pathOffset += 10; |
1199 unittest.expect(path.substring(pathOffset, pathOffset + 8), unittest.equ
als("contacts")); | 1197 unittest.expect(path.substring(pathOffset, pathOffset + 8), |
| 1198 unittest.equals("contacts")); |
1200 pathOffset += 8; | 1199 pathOffset += 8; |
1201 | 1200 |
1202 var query = (req.url).query; | 1201 var query = (req.url).query; |
1203 var queryOffset = 0; | 1202 var queryOffset = 0; |
1204 var queryMap = {}; | 1203 var queryMap = {}; |
1205 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 1204 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
1206 parseBool(n) { | 1205 parseBool(n) { |
1207 if (n == "true") return true; | 1206 if (n == "true") return true; |
1208 if (n == "false") return false; | 1207 if (n == "false") return false; |
1209 if (n == null) return null; | 1208 if (n == null) return null; |
1210 throw new core.ArgumentError("Invalid boolean: $n"); | 1209 throw new core.ArgumentError("Invalid boolean: $n"); |
1211 } | 1210 } |
| 1211 |
1212 if (query.length > 0) { | 1212 if (query.length > 0) { |
1213 for (var part in query.split("&")) { | 1213 for (var part in query.split("&")) { |
1214 var keyvalue = part.split("="); | 1214 var keyvalue = part.split("="); |
1215 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 1215 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 1216 core.Uri.decodeQueryComponent(keyvalue[1])); |
1216 } | 1217 } |
1217 } | 1218 } |
1218 | 1219 |
1219 | |
1220 var h = { | 1220 var h = { |
1221 "content-type" : "application/json; charset=utf-8", | 1221 "content-type": "application/json; charset=utf-8", |
1222 }; | 1222 }; |
1223 var resp = convert.JSON.encode(buildContact()); | 1223 var resp = convert.JSON.encode(buildContact()); |
1224 return new async.Future.value(stringResponse(200, h, resp)); | 1224 return new async.Future.value(stringResponse(200, h, resp)); |
1225 }), true); | 1225 }), true); |
1226 res.insert(arg_request).then(unittest.expectAsync1(((api.Contact response)
{ | 1226 res |
| 1227 .insert(arg_request) |
| 1228 .then(unittest.expectAsync1(((api.Contact response) { |
1227 checkContact(response); | 1229 checkContact(response); |
1228 }))); | 1230 }))); |
1229 }); | 1231 }); |
1230 | 1232 |
1231 unittest.test("method--list", () { | 1233 unittest.test("method--list", () { |
1232 | |
1233 var mock = new HttpServerMock(); | 1234 var mock = new HttpServerMock(); |
1234 api.ContactsResourceApi res = new api.MirrorApi(mock).contacts; | 1235 api.ContactsResourceApi res = new api.MirrorApi(mock).contacts; |
1235 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 1236 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
1236 var path = (req.url).path; | 1237 var path = (req.url).path; |
1237 var pathOffset = 0; | 1238 var pathOffset = 0; |
1238 var index; | 1239 var index; |
1239 var subPart; | 1240 var subPart; |
1240 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 1241 unittest.expect( |
| 1242 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
1241 pathOffset += 1; | 1243 pathOffset += 1; |
1242 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("mirror/v1/")); | 1244 unittest.expect(path.substring(pathOffset, pathOffset + 10), |
| 1245 unittest.equals("mirror/v1/")); |
1243 pathOffset += 10; | 1246 pathOffset += 10; |
1244 unittest.expect(path.substring(pathOffset, pathOffset + 8), unittest.equ
als("contacts")); | 1247 unittest.expect(path.substring(pathOffset, pathOffset + 8), |
| 1248 unittest.equals("contacts")); |
1245 pathOffset += 8; | 1249 pathOffset += 8; |
1246 | 1250 |
1247 var query = (req.url).query; | 1251 var query = (req.url).query; |
1248 var queryOffset = 0; | 1252 var queryOffset = 0; |
1249 var queryMap = {}; | 1253 var queryMap = {}; |
1250 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 1254 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
1251 parseBool(n) { | 1255 parseBool(n) { |
1252 if (n == "true") return true; | 1256 if (n == "true") return true; |
1253 if (n == "false") return false; | 1257 if (n == "false") return false; |
1254 if (n == null) return null; | 1258 if (n == null) return null; |
1255 throw new core.ArgumentError("Invalid boolean: $n"); | 1259 throw new core.ArgumentError("Invalid boolean: $n"); |
1256 } | 1260 } |
| 1261 |
1257 if (query.length > 0) { | 1262 if (query.length > 0) { |
1258 for (var part in query.split("&")) { | 1263 for (var part in query.split("&")) { |
1259 var keyvalue = part.split("="); | 1264 var keyvalue = part.split("="); |
1260 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 1265 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 1266 core.Uri.decodeQueryComponent(keyvalue[1])); |
1261 } | 1267 } |
1262 } | 1268 } |
1263 | 1269 |
1264 | |
1265 var h = { | 1270 var h = { |
1266 "content-type" : "application/json; charset=utf-8", | 1271 "content-type": "application/json; charset=utf-8", |
1267 }; | 1272 }; |
1268 var resp = convert.JSON.encode(buildContactsListResponse()); | 1273 var resp = convert.JSON.encode(buildContactsListResponse()); |
1269 return new async.Future.value(stringResponse(200, h, resp)); | 1274 return new async.Future.value(stringResponse(200, h, resp)); |
1270 }), true); | 1275 }), true); |
1271 res.list().then(unittest.expectAsync1(((api.ContactsListResponse response)
{ | 1276 res |
| 1277 .list() |
| 1278 .then(unittest.expectAsync1(((api.ContactsListResponse response) { |
1272 checkContactsListResponse(response); | 1279 checkContactsListResponse(response); |
1273 }))); | 1280 }))); |
1274 }); | 1281 }); |
1275 | 1282 |
1276 unittest.test("method--patch", () { | 1283 unittest.test("method--patch", () { |
1277 | |
1278 var mock = new HttpServerMock(); | 1284 var mock = new HttpServerMock(); |
1279 api.ContactsResourceApi res = new api.MirrorApi(mock).contacts; | 1285 api.ContactsResourceApi res = new api.MirrorApi(mock).contacts; |
1280 var arg_request = buildContact(); | 1286 var arg_request = buildContact(); |
1281 var arg_id = "foo"; | 1287 var arg_id = "foo"; |
1282 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 1288 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
1283 var obj = new api.Contact.fromJson(json); | 1289 var obj = new api.Contact.fromJson(json); |
1284 checkContact(obj); | 1290 checkContact(obj); |
1285 | 1291 |
1286 var path = (req.url).path; | 1292 var path = (req.url).path; |
1287 var pathOffset = 0; | 1293 var pathOffset = 0; |
1288 var index; | 1294 var index; |
1289 var subPart; | 1295 var subPart; |
1290 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 1296 unittest.expect( |
| 1297 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
1291 pathOffset += 1; | 1298 pathOffset += 1; |
1292 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("mirror/v1/")); | 1299 unittest.expect(path.substring(pathOffset, pathOffset + 10), |
| 1300 unittest.equals("mirror/v1/")); |
1293 pathOffset += 10; | 1301 pathOffset += 10; |
1294 unittest.expect(path.substring(pathOffset, pathOffset + 9), unittest.equ
als("contacts/")); | 1302 unittest.expect(path.substring(pathOffset, pathOffset + 9), |
| 1303 unittest.equals("contacts/")); |
1295 pathOffset += 9; | 1304 pathOffset += 9; |
1296 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); | 1305 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); |
1297 pathOffset = path.length; | 1306 pathOffset = path.length; |
1298 unittest.expect(subPart, unittest.equals("$arg_id")); | 1307 unittest.expect(subPart, unittest.equals("$arg_id")); |
1299 | 1308 |
1300 var query = (req.url).query; | 1309 var query = (req.url).query; |
1301 var queryOffset = 0; | 1310 var queryOffset = 0; |
1302 var queryMap = {}; | 1311 var queryMap = {}; |
1303 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 1312 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
1304 parseBool(n) { | 1313 parseBool(n) { |
1305 if (n == "true") return true; | 1314 if (n == "true") return true; |
1306 if (n == "false") return false; | 1315 if (n == "false") return false; |
1307 if (n == null) return null; | 1316 if (n == null) return null; |
1308 throw new core.ArgumentError("Invalid boolean: $n"); | 1317 throw new core.ArgumentError("Invalid boolean: $n"); |
1309 } | 1318 } |
| 1319 |
1310 if (query.length > 0) { | 1320 if (query.length > 0) { |
1311 for (var part in query.split("&")) { | 1321 for (var part in query.split("&")) { |
1312 var keyvalue = part.split("="); | 1322 var keyvalue = part.split("="); |
1313 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 1323 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 1324 core.Uri.decodeQueryComponent(keyvalue[1])); |
1314 } | 1325 } |
1315 } | 1326 } |
1316 | 1327 |
1317 | |
1318 var h = { | 1328 var h = { |
1319 "content-type" : "application/json; charset=utf-8", | 1329 "content-type": "application/json; charset=utf-8", |
1320 }; | 1330 }; |
1321 var resp = convert.JSON.encode(buildContact()); | 1331 var resp = convert.JSON.encode(buildContact()); |
1322 return new async.Future.value(stringResponse(200, h, resp)); | 1332 return new async.Future.value(stringResponse(200, h, resp)); |
1323 }), true); | 1333 }), true); |
1324 res.patch(arg_request, arg_id).then(unittest.expectAsync1(((api.Contact re
sponse) { | 1334 res |
| 1335 .patch(arg_request, arg_id) |
| 1336 .then(unittest.expectAsync1(((api.Contact response) { |
1325 checkContact(response); | 1337 checkContact(response); |
1326 }))); | 1338 }))); |
1327 }); | 1339 }); |
1328 | 1340 |
1329 unittest.test("method--update", () { | 1341 unittest.test("method--update", () { |
1330 | |
1331 var mock = new HttpServerMock(); | 1342 var mock = new HttpServerMock(); |
1332 api.ContactsResourceApi res = new api.MirrorApi(mock).contacts; | 1343 api.ContactsResourceApi res = new api.MirrorApi(mock).contacts; |
1333 var arg_request = buildContact(); | 1344 var arg_request = buildContact(); |
1334 var arg_id = "foo"; | 1345 var arg_id = "foo"; |
1335 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 1346 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
1336 var obj = new api.Contact.fromJson(json); | 1347 var obj = new api.Contact.fromJson(json); |
1337 checkContact(obj); | 1348 checkContact(obj); |
1338 | 1349 |
1339 var path = (req.url).path; | 1350 var path = (req.url).path; |
1340 var pathOffset = 0; | 1351 var pathOffset = 0; |
1341 var index; | 1352 var index; |
1342 var subPart; | 1353 var subPart; |
1343 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 1354 unittest.expect( |
| 1355 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
1344 pathOffset += 1; | 1356 pathOffset += 1; |
1345 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("mirror/v1/")); | 1357 unittest.expect(path.substring(pathOffset, pathOffset + 10), |
| 1358 unittest.equals("mirror/v1/")); |
1346 pathOffset += 10; | 1359 pathOffset += 10; |
1347 unittest.expect(path.substring(pathOffset, pathOffset + 9), unittest.equ
als("contacts/")); | 1360 unittest.expect(path.substring(pathOffset, pathOffset + 9), |
| 1361 unittest.equals("contacts/")); |
1348 pathOffset += 9; | 1362 pathOffset += 9; |
1349 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); | 1363 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); |
1350 pathOffset = path.length; | 1364 pathOffset = path.length; |
1351 unittest.expect(subPart, unittest.equals("$arg_id")); | 1365 unittest.expect(subPart, unittest.equals("$arg_id")); |
1352 | 1366 |
1353 var query = (req.url).query; | 1367 var query = (req.url).query; |
1354 var queryOffset = 0; | 1368 var queryOffset = 0; |
1355 var queryMap = {}; | 1369 var queryMap = {}; |
1356 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 1370 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
1357 parseBool(n) { | 1371 parseBool(n) { |
1358 if (n == "true") return true; | 1372 if (n == "true") return true; |
1359 if (n == "false") return false; | 1373 if (n == "false") return false; |
1360 if (n == null) return null; | 1374 if (n == null) return null; |
1361 throw new core.ArgumentError("Invalid boolean: $n"); | 1375 throw new core.ArgumentError("Invalid boolean: $n"); |
1362 } | 1376 } |
| 1377 |
1363 if (query.length > 0) { | 1378 if (query.length > 0) { |
1364 for (var part in query.split("&")) { | 1379 for (var part in query.split("&")) { |
1365 var keyvalue = part.split("="); | 1380 var keyvalue = part.split("="); |
1366 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 1381 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 1382 core.Uri.decodeQueryComponent(keyvalue[1])); |
1367 } | 1383 } |
1368 } | 1384 } |
1369 | 1385 |
1370 | |
1371 var h = { | 1386 var h = { |
1372 "content-type" : "application/json; charset=utf-8", | 1387 "content-type": "application/json; charset=utf-8", |
1373 }; | 1388 }; |
1374 var resp = convert.JSON.encode(buildContact()); | 1389 var resp = convert.JSON.encode(buildContact()); |
1375 return new async.Future.value(stringResponse(200, h, resp)); | 1390 return new async.Future.value(stringResponse(200, h, resp)); |
1376 }), true); | 1391 }), true); |
1377 res.update(arg_request, arg_id).then(unittest.expectAsync1(((api.Contact r
esponse) { | 1392 res |
| 1393 .update(arg_request, arg_id) |
| 1394 .then(unittest.expectAsync1(((api.Contact response) { |
1378 checkContact(response); | 1395 checkContact(response); |
1379 }))); | 1396 }))); |
1380 }); | 1397 }); |
1381 | |
1382 }); | 1398 }); |
1383 | 1399 |
1384 | |
1385 unittest.group("resource-LocationsResourceApi", () { | 1400 unittest.group("resource-LocationsResourceApi", () { |
1386 unittest.test("method--get", () { | 1401 unittest.test("method--get", () { |
1387 | |
1388 var mock = new HttpServerMock(); | 1402 var mock = new HttpServerMock(); |
1389 api.LocationsResourceApi res = new api.MirrorApi(mock).locations; | 1403 api.LocationsResourceApi res = new api.MirrorApi(mock).locations; |
1390 var arg_id = "foo"; | 1404 var arg_id = "foo"; |
1391 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 1405 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
1392 var path = (req.url).path; | 1406 var path = (req.url).path; |
1393 var pathOffset = 0; | 1407 var pathOffset = 0; |
1394 var index; | 1408 var index; |
1395 var subPart; | 1409 var subPart; |
1396 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 1410 unittest.expect( |
| 1411 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
1397 pathOffset += 1; | 1412 pathOffset += 1; |
1398 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("mirror/v1/")); | 1413 unittest.expect(path.substring(pathOffset, pathOffset + 10), |
| 1414 unittest.equals("mirror/v1/")); |
1399 pathOffset += 10; | 1415 pathOffset += 10; |
1400 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("locations/")); | 1416 unittest.expect(path.substring(pathOffset, pathOffset + 10), |
| 1417 unittest.equals("locations/")); |
1401 pathOffset += 10; | 1418 pathOffset += 10; |
1402 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); | 1419 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); |
1403 pathOffset = path.length; | 1420 pathOffset = path.length; |
1404 unittest.expect(subPart, unittest.equals("$arg_id")); | 1421 unittest.expect(subPart, unittest.equals("$arg_id")); |
1405 | 1422 |
1406 var query = (req.url).query; | 1423 var query = (req.url).query; |
1407 var queryOffset = 0; | 1424 var queryOffset = 0; |
1408 var queryMap = {}; | 1425 var queryMap = {}; |
1409 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 1426 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
1410 parseBool(n) { | 1427 parseBool(n) { |
1411 if (n == "true") return true; | 1428 if (n == "true") return true; |
1412 if (n == "false") return false; | 1429 if (n == "false") return false; |
1413 if (n == null) return null; | 1430 if (n == null) return null; |
1414 throw new core.ArgumentError("Invalid boolean: $n"); | 1431 throw new core.ArgumentError("Invalid boolean: $n"); |
1415 } | 1432 } |
| 1433 |
1416 if (query.length > 0) { | 1434 if (query.length > 0) { |
1417 for (var part in query.split("&")) { | 1435 for (var part in query.split("&")) { |
1418 var keyvalue = part.split("="); | 1436 var keyvalue = part.split("="); |
1419 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 1437 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 1438 core.Uri.decodeQueryComponent(keyvalue[1])); |
1420 } | 1439 } |
1421 } | 1440 } |
1422 | 1441 |
1423 | |
1424 var h = { | 1442 var h = { |
1425 "content-type" : "application/json; charset=utf-8", | 1443 "content-type": "application/json; charset=utf-8", |
1426 }; | 1444 }; |
1427 var resp = convert.JSON.encode(buildLocation()); | 1445 var resp = convert.JSON.encode(buildLocation()); |
1428 return new async.Future.value(stringResponse(200, h, resp)); | 1446 return new async.Future.value(stringResponse(200, h, resp)); |
1429 }), true); | 1447 }), true); |
1430 res.get(arg_id).then(unittest.expectAsync1(((api.Location response) { | 1448 res.get(arg_id).then(unittest.expectAsync1(((api.Location response) { |
1431 checkLocation(response); | 1449 checkLocation(response); |
1432 }))); | 1450 }))); |
1433 }); | 1451 }); |
1434 | 1452 |
1435 unittest.test("method--list", () { | 1453 unittest.test("method--list", () { |
1436 | |
1437 var mock = new HttpServerMock(); | 1454 var mock = new HttpServerMock(); |
1438 api.LocationsResourceApi res = new api.MirrorApi(mock).locations; | 1455 api.LocationsResourceApi res = new api.MirrorApi(mock).locations; |
1439 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 1456 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
1440 var path = (req.url).path; | 1457 var path = (req.url).path; |
1441 var pathOffset = 0; | 1458 var pathOffset = 0; |
1442 var index; | 1459 var index; |
1443 var subPart; | 1460 var subPart; |
1444 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 1461 unittest.expect( |
| 1462 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
1445 pathOffset += 1; | 1463 pathOffset += 1; |
1446 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("mirror/v1/")); | 1464 unittest.expect(path.substring(pathOffset, pathOffset + 10), |
| 1465 unittest.equals("mirror/v1/")); |
1447 pathOffset += 10; | 1466 pathOffset += 10; |
1448 unittest.expect(path.substring(pathOffset, pathOffset + 9), unittest.equ
als("locations")); | 1467 unittest.expect(path.substring(pathOffset, pathOffset + 9), |
| 1468 unittest.equals("locations")); |
1449 pathOffset += 9; | 1469 pathOffset += 9; |
1450 | 1470 |
1451 var query = (req.url).query; | 1471 var query = (req.url).query; |
1452 var queryOffset = 0; | 1472 var queryOffset = 0; |
1453 var queryMap = {}; | 1473 var queryMap = {}; |
1454 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 1474 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
1455 parseBool(n) { | 1475 parseBool(n) { |
1456 if (n == "true") return true; | 1476 if (n == "true") return true; |
1457 if (n == "false") return false; | 1477 if (n == "false") return false; |
1458 if (n == null) return null; | 1478 if (n == null) return null; |
1459 throw new core.ArgumentError("Invalid boolean: $n"); | 1479 throw new core.ArgumentError("Invalid boolean: $n"); |
1460 } | 1480 } |
| 1481 |
1461 if (query.length > 0) { | 1482 if (query.length > 0) { |
1462 for (var part in query.split("&")) { | 1483 for (var part in query.split("&")) { |
1463 var keyvalue = part.split("="); | 1484 var keyvalue = part.split("="); |
1464 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 1485 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 1486 core.Uri.decodeQueryComponent(keyvalue[1])); |
1465 } | 1487 } |
1466 } | 1488 } |
1467 | 1489 |
1468 | |
1469 var h = { | 1490 var h = { |
1470 "content-type" : "application/json; charset=utf-8", | 1491 "content-type": "application/json; charset=utf-8", |
1471 }; | 1492 }; |
1472 var resp = convert.JSON.encode(buildLocationsListResponse()); | 1493 var resp = convert.JSON.encode(buildLocationsListResponse()); |
1473 return new async.Future.value(stringResponse(200, h, resp)); | 1494 return new async.Future.value(stringResponse(200, h, resp)); |
1474 }), true); | 1495 }), true); |
1475 res.list().then(unittest.expectAsync1(((api.LocationsListResponse response
) { | 1496 res |
| 1497 .list() |
| 1498 .then(unittest.expectAsync1(((api.LocationsListResponse response) { |
1476 checkLocationsListResponse(response); | 1499 checkLocationsListResponse(response); |
1477 }))); | 1500 }))); |
1478 }); | 1501 }); |
1479 | |
1480 }); | 1502 }); |
1481 | 1503 |
1482 | |
1483 unittest.group("resource-SettingsResourceApi", () { | 1504 unittest.group("resource-SettingsResourceApi", () { |
1484 unittest.test("method--get", () { | 1505 unittest.test("method--get", () { |
1485 | |
1486 var mock = new HttpServerMock(); | 1506 var mock = new HttpServerMock(); |
1487 api.SettingsResourceApi res = new api.MirrorApi(mock).settings; | 1507 api.SettingsResourceApi res = new api.MirrorApi(mock).settings; |
1488 var arg_id = "foo"; | 1508 var arg_id = "foo"; |
1489 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 1509 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
1490 var path = (req.url).path; | 1510 var path = (req.url).path; |
1491 var pathOffset = 0; | 1511 var pathOffset = 0; |
1492 var index; | 1512 var index; |
1493 var subPart; | 1513 var subPart; |
1494 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 1514 unittest.expect( |
| 1515 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
1495 pathOffset += 1; | 1516 pathOffset += 1; |
1496 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("mirror/v1/")); | 1517 unittest.expect(path.substring(pathOffset, pathOffset + 10), |
| 1518 unittest.equals("mirror/v1/")); |
1497 pathOffset += 10; | 1519 pathOffset += 10; |
1498 unittest.expect(path.substring(pathOffset, pathOffset + 9), unittest.equ
als("settings/")); | 1520 unittest.expect(path.substring(pathOffset, pathOffset + 9), |
| 1521 unittest.equals("settings/")); |
1499 pathOffset += 9; | 1522 pathOffset += 9; |
1500 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); | 1523 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); |
1501 pathOffset = path.length; | 1524 pathOffset = path.length; |
1502 unittest.expect(subPart, unittest.equals("$arg_id")); | 1525 unittest.expect(subPart, unittest.equals("$arg_id")); |
1503 | 1526 |
1504 var query = (req.url).query; | 1527 var query = (req.url).query; |
1505 var queryOffset = 0; | 1528 var queryOffset = 0; |
1506 var queryMap = {}; | 1529 var queryMap = {}; |
1507 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 1530 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
1508 parseBool(n) { | 1531 parseBool(n) { |
1509 if (n == "true") return true; | 1532 if (n == "true") return true; |
1510 if (n == "false") return false; | 1533 if (n == "false") return false; |
1511 if (n == null) return null; | 1534 if (n == null) return null; |
1512 throw new core.ArgumentError("Invalid boolean: $n"); | 1535 throw new core.ArgumentError("Invalid boolean: $n"); |
1513 } | 1536 } |
| 1537 |
1514 if (query.length > 0) { | 1538 if (query.length > 0) { |
1515 for (var part in query.split("&")) { | 1539 for (var part in query.split("&")) { |
1516 var keyvalue = part.split("="); | 1540 var keyvalue = part.split("="); |
1517 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 1541 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 1542 core.Uri.decodeQueryComponent(keyvalue[1])); |
1518 } | 1543 } |
1519 } | 1544 } |
1520 | 1545 |
1521 | |
1522 var h = { | 1546 var h = { |
1523 "content-type" : "application/json; charset=utf-8", | 1547 "content-type": "application/json; charset=utf-8", |
1524 }; | 1548 }; |
1525 var resp = convert.JSON.encode(buildSetting()); | 1549 var resp = convert.JSON.encode(buildSetting()); |
1526 return new async.Future.value(stringResponse(200, h, resp)); | 1550 return new async.Future.value(stringResponse(200, h, resp)); |
1527 }), true); | 1551 }), true); |
1528 res.get(arg_id).then(unittest.expectAsync1(((api.Setting response) { | 1552 res.get(arg_id).then(unittest.expectAsync1(((api.Setting response) { |
1529 checkSetting(response); | 1553 checkSetting(response); |
1530 }))); | 1554 }))); |
1531 }); | 1555 }); |
1532 | |
1533 }); | 1556 }); |
1534 | 1557 |
1535 | |
1536 unittest.group("resource-SubscriptionsResourceApi", () { | 1558 unittest.group("resource-SubscriptionsResourceApi", () { |
1537 unittest.test("method--delete", () { | 1559 unittest.test("method--delete", () { |
1538 | |
1539 var mock = new HttpServerMock(); | 1560 var mock = new HttpServerMock(); |
1540 api.SubscriptionsResourceApi res = new api.MirrorApi(mock).subscriptions; | 1561 api.SubscriptionsResourceApi res = new api.MirrorApi(mock).subscriptions; |
1541 var arg_id = "foo"; | 1562 var arg_id = "foo"; |
1542 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 1563 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
1543 var path = (req.url).path; | 1564 var path = (req.url).path; |
1544 var pathOffset = 0; | 1565 var pathOffset = 0; |
1545 var index; | 1566 var index; |
1546 var subPart; | 1567 var subPart; |
1547 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 1568 unittest.expect( |
| 1569 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
1548 pathOffset += 1; | 1570 pathOffset += 1; |
1549 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("mirror/v1/")); | 1571 unittest.expect(path.substring(pathOffset, pathOffset + 10), |
| 1572 unittest.equals("mirror/v1/")); |
1550 pathOffset += 10; | 1573 pathOffset += 10; |
1551 unittest.expect(path.substring(pathOffset, pathOffset + 14), unittest.eq
uals("subscriptions/")); | 1574 unittest.expect(path.substring(pathOffset, pathOffset + 14), |
| 1575 unittest.equals("subscriptions/")); |
1552 pathOffset += 14; | 1576 pathOffset += 14; |
1553 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); | 1577 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); |
1554 pathOffset = path.length; | 1578 pathOffset = path.length; |
1555 unittest.expect(subPart, unittest.equals("$arg_id")); | 1579 unittest.expect(subPart, unittest.equals("$arg_id")); |
1556 | 1580 |
1557 var query = (req.url).query; | 1581 var query = (req.url).query; |
1558 var queryOffset = 0; | 1582 var queryOffset = 0; |
1559 var queryMap = {}; | 1583 var queryMap = {}; |
1560 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 1584 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
1561 parseBool(n) { | 1585 parseBool(n) { |
1562 if (n == "true") return true; | 1586 if (n == "true") return true; |
1563 if (n == "false") return false; | 1587 if (n == "false") return false; |
1564 if (n == null) return null; | 1588 if (n == null) return null; |
1565 throw new core.ArgumentError("Invalid boolean: $n"); | 1589 throw new core.ArgumentError("Invalid boolean: $n"); |
1566 } | 1590 } |
| 1591 |
1567 if (query.length > 0) { | 1592 if (query.length > 0) { |
1568 for (var part in query.split("&")) { | 1593 for (var part in query.split("&")) { |
1569 var keyvalue = part.split("="); | 1594 var keyvalue = part.split("="); |
1570 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 1595 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 1596 core.Uri.decodeQueryComponent(keyvalue[1])); |
1571 } | 1597 } |
1572 } | 1598 } |
1573 | 1599 |
1574 | |
1575 var h = { | 1600 var h = { |
1576 "content-type" : "application/json; charset=utf-8", | 1601 "content-type": "application/json; charset=utf-8", |
1577 }; | 1602 }; |
1578 var resp = ""; | 1603 var resp = ""; |
1579 return new async.Future.value(stringResponse(200, h, resp)); | 1604 return new async.Future.value(stringResponse(200, h, resp)); |
1580 }), true); | 1605 }), true); |
1581 res.delete(arg_id).then(unittest.expectAsync1((_) {})); | 1606 res.delete(arg_id).then(unittest.expectAsync1((_) {})); |
1582 }); | 1607 }); |
1583 | 1608 |
1584 unittest.test("method--insert", () { | 1609 unittest.test("method--insert", () { |
1585 | |
1586 var mock = new HttpServerMock(); | 1610 var mock = new HttpServerMock(); |
1587 api.SubscriptionsResourceApi res = new api.MirrorApi(mock).subscriptions; | 1611 api.SubscriptionsResourceApi res = new api.MirrorApi(mock).subscriptions; |
1588 var arg_request = buildSubscription(); | 1612 var arg_request = buildSubscription(); |
1589 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 1613 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
1590 var obj = new api.Subscription.fromJson(json); | 1614 var obj = new api.Subscription.fromJson(json); |
1591 checkSubscription(obj); | 1615 checkSubscription(obj); |
1592 | 1616 |
1593 var path = (req.url).path; | 1617 var path = (req.url).path; |
1594 var pathOffset = 0; | 1618 var pathOffset = 0; |
1595 var index; | 1619 var index; |
1596 var subPart; | 1620 var subPart; |
1597 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 1621 unittest.expect( |
| 1622 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
1598 pathOffset += 1; | 1623 pathOffset += 1; |
1599 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("mirror/v1/")); | 1624 unittest.expect(path.substring(pathOffset, pathOffset + 10), |
| 1625 unittest.equals("mirror/v1/")); |
1600 pathOffset += 10; | 1626 pathOffset += 10; |
1601 unittest.expect(path.substring(pathOffset, pathOffset + 13), unittest.eq
uals("subscriptions")); | 1627 unittest.expect(path.substring(pathOffset, pathOffset + 13), |
| 1628 unittest.equals("subscriptions")); |
1602 pathOffset += 13; | 1629 pathOffset += 13; |
1603 | 1630 |
1604 var query = (req.url).query; | 1631 var query = (req.url).query; |
1605 var queryOffset = 0; | 1632 var queryOffset = 0; |
1606 var queryMap = {}; | 1633 var queryMap = {}; |
1607 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 1634 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
1608 parseBool(n) { | 1635 parseBool(n) { |
1609 if (n == "true") return true; | 1636 if (n == "true") return true; |
1610 if (n == "false") return false; | 1637 if (n == "false") return false; |
1611 if (n == null) return null; | 1638 if (n == null) return null; |
1612 throw new core.ArgumentError("Invalid boolean: $n"); | 1639 throw new core.ArgumentError("Invalid boolean: $n"); |
1613 } | 1640 } |
| 1641 |
1614 if (query.length > 0) { | 1642 if (query.length > 0) { |
1615 for (var part in query.split("&")) { | 1643 for (var part in query.split("&")) { |
1616 var keyvalue = part.split("="); | 1644 var keyvalue = part.split("="); |
1617 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 1645 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 1646 core.Uri.decodeQueryComponent(keyvalue[1])); |
1618 } | 1647 } |
1619 } | 1648 } |
1620 | 1649 |
1621 | |
1622 var h = { | 1650 var h = { |
1623 "content-type" : "application/json; charset=utf-8", | 1651 "content-type": "application/json; charset=utf-8", |
1624 }; | 1652 }; |
1625 var resp = convert.JSON.encode(buildSubscription()); | 1653 var resp = convert.JSON.encode(buildSubscription()); |
1626 return new async.Future.value(stringResponse(200, h, resp)); | 1654 return new async.Future.value(stringResponse(200, h, resp)); |
1627 }), true); | 1655 }), true); |
1628 res.insert(arg_request).then(unittest.expectAsync1(((api.Subscription resp
onse) { | 1656 res |
| 1657 .insert(arg_request) |
| 1658 .then(unittest.expectAsync1(((api.Subscription response) { |
1629 checkSubscription(response); | 1659 checkSubscription(response); |
1630 }))); | 1660 }))); |
1631 }); | 1661 }); |
1632 | 1662 |
1633 unittest.test("method--list", () { | 1663 unittest.test("method--list", () { |
1634 | |
1635 var mock = new HttpServerMock(); | 1664 var mock = new HttpServerMock(); |
1636 api.SubscriptionsResourceApi res = new api.MirrorApi(mock).subscriptions; | 1665 api.SubscriptionsResourceApi res = new api.MirrorApi(mock).subscriptions; |
1637 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 1666 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
1638 var path = (req.url).path; | 1667 var path = (req.url).path; |
1639 var pathOffset = 0; | 1668 var pathOffset = 0; |
1640 var index; | 1669 var index; |
1641 var subPart; | 1670 var subPart; |
1642 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 1671 unittest.expect( |
| 1672 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
1643 pathOffset += 1; | 1673 pathOffset += 1; |
1644 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("mirror/v1/")); | 1674 unittest.expect(path.substring(pathOffset, pathOffset + 10), |
| 1675 unittest.equals("mirror/v1/")); |
1645 pathOffset += 10; | 1676 pathOffset += 10; |
1646 unittest.expect(path.substring(pathOffset, pathOffset + 13), unittest.eq
uals("subscriptions")); | 1677 unittest.expect(path.substring(pathOffset, pathOffset + 13), |
| 1678 unittest.equals("subscriptions")); |
1647 pathOffset += 13; | 1679 pathOffset += 13; |
1648 | 1680 |
1649 var query = (req.url).query; | 1681 var query = (req.url).query; |
1650 var queryOffset = 0; | 1682 var queryOffset = 0; |
1651 var queryMap = {}; | 1683 var queryMap = {}; |
1652 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 1684 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
1653 parseBool(n) { | 1685 parseBool(n) { |
1654 if (n == "true") return true; | 1686 if (n == "true") return true; |
1655 if (n == "false") return false; | 1687 if (n == "false") return false; |
1656 if (n == null) return null; | 1688 if (n == null) return null; |
1657 throw new core.ArgumentError("Invalid boolean: $n"); | 1689 throw new core.ArgumentError("Invalid boolean: $n"); |
1658 } | 1690 } |
| 1691 |
1659 if (query.length > 0) { | 1692 if (query.length > 0) { |
1660 for (var part in query.split("&")) { | 1693 for (var part in query.split("&")) { |
1661 var keyvalue = part.split("="); | 1694 var keyvalue = part.split("="); |
1662 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 1695 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 1696 core.Uri.decodeQueryComponent(keyvalue[1])); |
1663 } | 1697 } |
1664 } | 1698 } |
1665 | 1699 |
1666 | |
1667 var h = { | 1700 var h = { |
1668 "content-type" : "application/json; charset=utf-8", | 1701 "content-type": "application/json; charset=utf-8", |
1669 }; | 1702 }; |
1670 var resp = convert.JSON.encode(buildSubscriptionsListResponse()); | 1703 var resp = convert.JSON.encode(buildSubscriptionsListResponse()); |
1671 return new async.Future.value(stringResponse(200, h, resp)); | 1704 return new async.Future.value(stringResponse(200, h, resp)); |
1672 }), true); | 1705 }), true); |
1673 res.list().then(unittest.expectAsync1(((api.SubscriptionsListResponse resp
onse) { | 1706 res.list().then( |
| 1707 unittest.expectAsync1(((api.SubscriptionsListResponse response) { |
1674 checkSubscriptionsListResponse(response); | 1708 checkSubscriptionsListResponse(response); |
1675 }))); | 1709 }))); |
1676 }); | 1710 }); |
1677 | 1711 |
1678 unittest.test("method--update", () { | 1712 unittest.test("method--update", () { |
1679 | |
1680 var mock = new HttpServerMock(); | 1713 var mock = new HttpServerMock(); |
1681 api.SubscriptionsResourceApi res = new api.MirrorApi(mock).subscriptions; | 1714 api.SubscriptionsResourceApi res = new api.MirrorApi(mock).subscriptions; |
1682 var arg_request = buildSubscription(); | 1715 var arg_request = buildSubscription(); |
1683 var arg_id = "foo"; | 1716 var arg_id = "foo"; |
1684 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 1717 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
1685 var obj = new api.Subscription.fromJson(json); | 1718 var obj = new api.Subscription.fromJson(json); |
1686 checkSubscription(obj); | 1719 checkSubscription(obj); |
1687 | 1720 |
1688 var path = (req.url).path; | 1721 var path = (req.url).path; |
1689 var pathOffset = 0; | 1722 var pathOffset = 0; |
1690 var index; | 1723 var index; |
1691 var subPart; | 1724 var subPart; |
1692 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 1725 unittest.expect( |
| 1726 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
1693 pathOffset += 1; | 1727 pathOffset += 1; |
1694 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("mirror/v1/")); | 1728 unittest.expect(path.substring(pathOffset, pathOffset + 10), |
| 1729 unittest.equals("mirror/v1/")); |
1695 pathOffset += 10; | 1730 pathOffset += 10; |
1696 unittest.expect(path.substring(pathOffset, pathOffset + 14), unittest.eq
uals("subscriptions/")); | 1731 unittest.expect(path.substring(pathOffset, pathOffset + 14), |
| 1732 unittest.equals("subscriptions/")); |
1697 pathOffset += 14; | 1733 pathOffset += 14; |
1698 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); | 1734 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); |
1699 pathOffset = path.length; | 1735 pathOffset = path.length; |
1700 unittest.expect(subPart, unittest.equals("$arg_id")); | 1736 unittest.expect(subPart, unittest.equals("$arg_id")); |
1701 | 1737 |
1702 var query = (req.url).query; | 1738 var query = (req.url).query; |
1703 var queryOffset = 0; | 1739 var queryOffset = 0; |
1704 var queryMap = {}; | 1740 var queryMap = {}; |
1705 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 1741 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
1706 parseBool(n) { | 1742 parseBool(n) { |
1707 if (n == "true") return true; | 1743 if (n == "true") return true; |
1708 if (n == "false") return false; | 1744 if (n == "false") return false; |
1709 if (n == null) return null; | 1745 if (n == null) return null; |
1710 throw new core.ArgumentError("Invalid boolean: $n"); | 1746 throw new core.ArgumentError("Invalid boolean: $n"); |
1711 } | 1747 } |
| 1748 |
1712 if (query.length > 0) { | 1749 if (query.length > 0) { |
1713 for (var part in query.split("&")) { | 1750 for (var part in query.split("&")) { |
1714 var keyvalue = part.split("="); | 1751 var keyvalue = part.split("="); |
1715 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 1752 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 1753 core.Uri.decodeQueryComponent(keyvalue[1])); |
1716 } | 1754 } |
1717 } | 1755 } |
1718 | 1756 |
1719 | |
1720 var h = { | 1757 var h = { |
1721 "content-type" : "application/json; charset=utf-8", | 1758 "content-type": "application/json; charset=utf-8", |
1722 }; | 1759 }; |
1723 var resp = convert.JSON.encode(buildSubscription()); | 1760 var resp = convert.JSON.encode(buildSubscription()); |
1724 return new async.Future.value(stringResponse(200, h, resp)); | 1761 return new async.Future.value(stringResponse(200, h, resp)); |
1725 }), true); | 1762 }), true); |
1726 res.update(arg_request, arg_id).then(unittest.expectAsync1(((api.Subscript
ion response) { | 1763 res |
| 1764 .update(arg_request, arg_id) |
| 1765 .then(unittest.expectAsync1(((api.Subscription response) { |
1727 checkSubscription(response); | 1766 checkSubscription(response); |
1728 }))); | 1767 }))); |
1729 }); | 1768 }); |
1730 | |
1731 }); | 1769 }); |
1732 | 1770 |
1733 | |
1734 unittest.group("resource-TimelineResourceApi", () { | 1771 unittest.group("resource-TimelineResourceApi", () { |
1735 unittest.test("method--delete", () { | 1772 unittest.test("method--delete", () { |
1736 | |
1737 var mock = new HttpServerMock(); | 1773 var mock = new HttpServerMock(); |
1738 api.TimelineResourceApi res = new api.MirrorApi(mock).timeline; | 1774 api.TimelineResourceApi res = new api.MirrorApi(mock).timeline; |
1739 var arg_id = "foo"; | 1775 var arg_id = "foo"; |
1740 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 1776 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
1741 var path = (req.url).path; | 1777 var path = (req.url).path; |
1742 var pathOffset = 0; | 1778 var pathOffset = 0; |
1743 var index; | 1779 var index; |
1744 var subPart; | 1780 var subPart; |
1745 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 1781 unittest.expect( |
| 1782 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
1746 pathOffset += 1; | 1783 pathOffset += 1; |
1747 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("mirror/v1/")); | 1784 unittest.expect(path.substring(pathOffset, pathOffset + 10), |
| 1785 unittest.equals("mirror/v1/")); |
1748 pathOffset += 10; | 1786 pathOffset += 10; |
1749 unittest.expect(path.substring(pathOffset, pathOffset + 9), unittest.equ
als("timeline/")); | 1787 unittest.expect(path.substring(pathOffset, pathOffset + 9), |
| 1788 unittest.equals("timeline/")); |
1750 pathOffset += 9; | 1789 pathOffset += 9; |
1751 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); | 1790 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); |
1752 pathOffset = path.length; | 1791 pathOffset = path.length; |
1753 unittest.expect(subPart, unittest.equals("$arg_id")); | 1792 unittest.expect(subPart, unittest.equals("$arg_id")); |
1754 | 1793 |
1755 var query = (req.url).query; | 1794 var query = (req.url).query; |
1756 var queryOffset = 0; | 1795 var queryOffset = 0; |
1757 var queryMap = {}; | 1796 var queryMap = {}; |
1758 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 1797 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
1759 parseBool(n) { | 1798 parseBool(n) { |
1760 if (n == "true") return true; | 1799 if (n == "true") return true; |
1761 if (n == "false") return false; | 1800 if (n == "false") return false; |
1762 if (n == null) return null; | 1801 if (n == null) return null; |
1763 throw new core.ArgumentError("Invalid boolean: $n"); | 1802 throw new core.ArgumentError("Invalid boolean: $n"); |
1764 } | 1803 } |
| 1804 |
1765 if (query.length > 0) { | 1805 if (query.length > 0) { |
1766 for (var part in query.split("&")) { | 1806 for (var part in query.split("&")) { |
1767 var keyvalue = part.split("="); | 1807 var keyvalue = part.split("="); |
1768 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 1808 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 1809 core.Uri.decodeQueryComponent(keyvalue[1])); |
1769 } | 1810 } |
1770 } | 1811 } |
1771 | 1812 |
1772 | |
1773 var h = { | 1813 var h = { |
1774 "content-type" : "application/json; charset=utf-8", | 1814 "content-type": "application/json; charset=utf-8", |
1775 }; | 1815 }; |
1776 var resp = ""; | 1816 var resp = ""; |
1777 return new async.Future.value(stringResponse(200, h, resp)); | 1817 return new async.Future.value(stringResponse(200, h, resp)); |
1778 }), true); | 1818 }), true); |
1779 res.delete(arg_id).then(unittest.expectAsync1((_) {})); | 1819 res.delete(arg_id).then(unittest.expectAsync1((_) {})); |
1780 }); | 1820 }); |
1781 | 1821 |
1782 unittest.test("method--get", () { | 1822 unittest.test("method--get", () { |
1783 | |
1784 var mock = new HttpServerMock(); | 1823 var mock = new HttpServerMock(); |
1785 api.TimelineResourceApi res = new api.MirrorApi(mock).timeline; | 1824 api.TimelineResourceApi res = new api.MirrorApi(mock).timeline; |
1786 var arg_id = "foo"; | 1825 var arg_id = "foo"; |
1787 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 1826 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
1788 var path = (req.url).path; | 1827 var path = (req.url).path; |
1789 var pathOffset = 0; | 1828 var pathOffset = 0; |
1790 var index; | 1829 var index; |
1791 var subPart; | 1830 var subPart; |
1792 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 1831 unittest.expect( |
| 1832 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
1793 pathOffset += 1; | 1833 pathOffset += 1; |
1794 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("mirror/v1/")); | 1834 unittest.expect(path.substring(pathOffset, pathOffset + 10), |
| 1835 unittest.equals("mirror/v1/")); |
1795 pathOffset += 10; | 1836 pathOffset += 10; |
1796 unittest.expect(path.substring(pathOffset, pathOffset + 9), unittest.equ
als("timeline/")); | 1837 unittest.expect(path.substring(pathOffset, pathOffset + 9), |
| 1838 unittest.equals("timeline/")); |
1797 pathOffset += 9; | 1839 pathOffset += 9; |
1798 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); | 1840 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); |
1799 pathOffset = path.length; | 1841 pathOffset = path.length; |
1800 unittest.expect(subPart, unittest.equals("$arg_id")); | 1842 unittest.expect(subPart, unittest.equals("$arg_id")); |
1801 | 1843 |
1802 var query = (req.url).query; | 1844 var query = (req.url).query; |
1803 var queryOffset = 0; | 1845 var queryOffset = 0; |
1804 var queryMap = {}; | 1846 var queryMap = {}; |
1805 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 1847 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
1806 parseBool(n) { | 1848 parseBool(n) { |
1807 if (n == "true") return true; | 1849 if (n == "true") return true; |
1808 if (n == "false") return false; | 1850 if (n == "false") return false; |
1809 if (n == null) return null; | 1851 if (n == null) return null; |
1810 throw new core.ArgumentError("Invalid boolean: $n"); | 1852 throw new core.ArgumentError("Invalid boolean: $n"); |
1811 } | 1853 } |
| 1854 |
1812 if (query.length > 0) { | 1855 if (query.length > 0) { |
1813 for (var part in query.split("&")) { | 1856 for (var part in query.split("&")) { |
1814 var keyvalue = part.split("="); | 1857 var keyvalue = part.split("="); |
1815 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 1858 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 1859 core.Uri.decodeQueryComponent(keyvalue[1])); |
1816 } | 1860 } |
1817 } | 1861 } |
1818 | 1862 |
1819 | |
1820 var h = { | 1863 var h = { |
1821 "content-type" : "application/json; charset=utf-8", | 1864 "content-type": "application/json; charset=utf-8", |
1822 }; | 1865 }; |
1823 var resp = convert.JSON.encode(buildTimelineItem()); | 1866 var resp = convert.JSON.encode(buildTimelineItem()); |
1824 return new async.Future.value(stringResponse(200, h, resp)); | 1867 return new async.Future.value(stringResponse(200, h, resp)); |
1825 }), true); | 1868 }), true); |
1826 res.get(arg_id).then(unittest.expectAsync1(((api.TimelineItem response) { | 1869 res.get(arg_id).then(unittest.expectAsync1(((api.TimelineItem response) { |
1827 checkTimelineItem(response); | 1870 checkTimelineItem(response); |
1828 }))); | 1871 }))); |
1829 }); | 1872 }); |
1830 | 1873 |
1831 unittest.test("method--insert", () { | 1874 unittest.test("method--insert", () { |
1832 // TODO: Implement tests for media upload; | 1875 // TODO: Implement tests for media upload; |
1833 // TODO: Implement tests for media download; | 1876 // TODO: Implement tests for media download; |
1834 | 1877 |
1835 var mock = new HttpServerMock(); | 1878 var mock = new HttpServerMock(); |
1836 api.TimelineResourceApi res = new api.MirrorApi(mock).timeline; | 1879 api.TimelineResourceApi res = new api.MirrorApi(mock).timeline; |
1837 var arg_request = buildTimelineItem(); | 1880 var arg_request = buildTimelineItem(); |
1838 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 1881 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
1839 var obj = new api.TimelineItem.fromJson(json); | 1882 var obj = new api.TimelineItem.fromJson(json); |
1840 checkTimelineItem(obj); | 1883 checkTimelineItem(obj); |
1841 | 1884 |
1842 var path = (req.url).path; | 1885 var path = (req.url).path; |
1843 var pathOffset = 0; | 1886 var pathOffset = 0; |
1844 var index; | 1887 var index; |
1845 var subPart; | 1888 var subPart; |
1846 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 1889 unittest.expect( |
| 1890 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
1847 pathOffset += 1; | 1891 pathOffset += 1; |
1848 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("mirror/v1/")); | 1892 unittest.expect(path.substring(pathOffset, pathOffset + 10), |
| 1893 unittest.equals("mirror/v1/")); |
1849 pathOffset += 10; | 1894 pathOffset += 10; |
1850 unittest.expect(path.substring(pathOffset, pathOffset + 8), unittest.equ
als("timeline")); | 1895 unittest.expect(path.substring(pathOffset, pathOffset + 8), |
| 1896 unittest.equals("timeline")); |
1851 pathOffset += 8; | 1897 pathOffset += 8; |
1852 | 1898 |
1853 var query = (req.url).query; | 1899 var query = (req.url).query; |
1854 var queryOffset = 0; | 1900 var queryOffset = 0; |
1855 var queryMap = {}; | 1901 var queryMap = {}; |
1856 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 1902 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
1857 parseBool(n) { | 1903 parseBool(n) { |
1858 if (n == "true") return true; | 1904 if (n == "true") return true; |
1859 if (n == "false") return false; | 1905 if (n == "false") return false; |
1860 if (n == null) return null; | 1906 if (n == null) return null; |
1861 throw new core.ArgumentError("Invalid boolean: $n"); | 1907 throw new core.ArgumentError("Invalid boolean: $n"); |
1862 } | 1908 } |
| 1909 |
1863 if (query.length > 0) { | 1910 if (query.length > 0) { |
1864 for (var part in query.split("&")) { | 1911 for (var part in query.split("&")) { |
1865 var keyvalue = part.split("="); | 1912 var keyvalue = part.split("="); |
1866 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 1913 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 1914 core.Uri.decodeQueryComponent(keyvalue[1])); |
1867 } | 1915 } |
1868 } | 1916 } |
1869 | 1917 |
1870 | |
1871 var h = { | 1918 var h = { |
1872 "content-type" : "application/json; charset=utf-8", | 1919 "content-type": "application/json; charset=utf-8", |
1873 }; | 1920 }; |
1874 var resp = convert.JSON.encode(buildTimelineItem()); | 1921 var resp = convert.JSON.encode(buildTimelineItem()); |
1875 return new async.Future.value(stringResponse(200, h, resp)); | 1922 return new async.Future.value(stringResponse(200, h, resp)); |
1876 }), true); | 1923 }), true); |
1877 res.insert(arg_request).then(unittest.expectAsync1(((api.TimelineItem resp
onse) { | 1924 res |
| 1925 .insert(arg_request) |
| 1926 .then(unittest.expectAsync1(((api.TimelineItem response) { |
1878 checkTimelineItem(response); | 1927 checkTimelineItem(response); |
1879 }))); | 1928 }))); |
1880 }); | 1929 }); |
1881 | 1930 |
1882 unittest.test("method--list", () { | 1931 unittest.test("method--list", () { |
1883 | |
1884 var mock = new HttpServerMock(); | 1932 var mock = new HttpServerMock(); |
1885 api.TimelineResourceApi res = new api.MirrorApi(mock).timeline; | 1933 api.TimelineResourceApi res = new api.MirrorApi(mock).timeline; |
1886 var arg_bundleId = "foo"; | 1934 var arg_bundleId = "foo"; |
1887 var arg_includeDeleted = true; | 1935 var arg_includeDeleted = true; |
1888 var arg_maxResults = 42; | 1936 var arg_maxResults = 42; |
1889 var arg_orderBy = "foo"; | 1937 var arg_orderBy = "foo"; |
1890 var arg_pageToken = "foo"; | 1938 var arg_pageToken = "foo"; |
1891 var arg_pinnedOnly = true; | 1939 var arg_pinnedOnly = true; |
1892 var arg_sourceItemId = "foo"; | 1940 var arg_sourceItemId = "foo"; |
1893 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 1941 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
1894 var path = (req.url).path; | 1942 var path = (req.url).path; |
1895 var pathOffset = 0; | 1943 var pathOffset = 0; |
1896 var index; | 1944 var index; |
1897 var subPart; | 1945 var subPart; |
1898 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 1946 unittest.expect( |
| 1947 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
1899 pathOffset += 1; | 1948 pathOffset += 1; |
1900 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("mirror/v1/")); | 1949 unittest.expect(path.substring(pathOffset, pathOffset + 10), |
| 1950 unittest.equals("mirror/v1/")); |
1901 pathOffset += 10; | 1951 pathOffset += 10; |
1902 unittest.expect(path.substring(pathOffset, pathOffset + 8), unittest.equ
als("timeline")); | 1952 unittest.expect(path.substring(pathOffset, pathOffset + 8), |
| 1953 unittest.equals("timeline")); |
1903 pathOffset += 8; | 1954 pathOffset += 8; |
1904 | 1955 |
1905 var query = (req.url).query; | 1956 var query = (req.url).query; |
1906 var queryOffset = 0; | 1957 var queryOffset = 0; |
1907 var queryMap = {}; | 1958 var queryMap = {}; |
1908 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 1959 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
1909 parseBool(n) { | 1960 parseBool(n) { |
1910 if (n == "true") return true; | 1961 if (n == "true") return true; |
1911 if (n == "false") return false; | 1962 if (n == "false") return false; |
1912 if (n == null) return null; | 1963 if (n == null) return null; |
1913 throw new core.ArgumentError("Invalid boolean: $n"); | 1964 throw new core.ArgumentError("Invalid boolean: $n"); |
1914 } | 1965 } |
| 1966 |
1915 if (query.length > 0) { | 1967 if (query.length > 0) { |
1916 for (var part in query.split("&")) { | 1968 for (var part in query.split("&")) { |
1917 var keyvalue = part.split("="); | 1969 var keyvalue = part.split("="); |
1918 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 1970 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 1971 core.Uri.decodeQueryComponent(keyvalue[1])); |
1919 } | 1972 } |
1920 } | 1973 } |
1921 unittest.expect(queryMap["bundleId"].first, unittest.equals(arg_bundleId
)); | 1974 unittest.expect( |
1922 unittest.expect(queryMap["includeDeleted"].first, unittest.equals("$arg_
includeDeleted")); | 1975 queryMap["bundleId"].first, unittest.equals(arg_bundleId)); |
1923 unittest.expect(core.int.parse(queryMap["maxResults"].first), unittest.e
quals(arg_maxResults)); | 1976 unittest.expect(queryMap["includeDeleted"].first, |
1924 unittest.expect(queryMap["orderBy"].first, unittest.equals(arg_orderBy))
; | 1977 unittest.equals("$arg_includeDeleted")); |
1925 unittest.expect(queryMap["pageToken"].first, unittest.equals(arg_pageTok
en)); | 1978 unittest.expect(core.int.parse(queryMap["maxResults"].first), |
1926 unittest.expect(queryMap["pinnedOnly"].first, unittest.equals("$arg_pinn
edOnly")); | 1979 unittest.equals(arg_maxResults)); |
1927 unittest.expect(queryMap["sourceItemId"].first, unittest.equals(arg_sour
ceItemId)); | 1980 unittest.expect( |
1928 | 1981 queryMap["orderBy"].first, unittest.equals(arg_orderBy)); |
| 1982 unittest.expect( |
| 1983 queryMap["pageToken"].first, unittest.equals(arg_pageToken)); |
| 1984 unittest.expect( |
| 1985 queryMap["pinnedOnly"].first, unittest.equals("$arg_pinnedOnly")); |
| 1986 unittest.expect( |
| 1987 queryMap["sourceItemId"].first, unittest.equals(arg_sourceItemId)); |
1929 | 1988 |
1930 var h = { | 1989 var h = { |
1931 "content-type" : "application/json; charset=utf-8", | 1990 "content-type": "application/json; charset=utf-8", |
1932 }; | 1991 }; |
1933 var resp = convert.JSON.encode(buildTimelineListResponse()); | 1992 var resp = convert.JSON.encode(buildTimelineListResponse()); |
1934 return new async.Future.value(stringResponse(200, h, resp)); | 1993 return new async.Future.value(stringResponse(200, h, resp)); |
1935 }), true); | 1994 }), true); |
1936 res.list(bundleId: arg_bundleId, includeDeleted: arg_includeDeleted, maxRe
sults: arg_maxResults, orderBy: arg_orderBy, pageToken: arg_pageToken, pinnedOnl
y: arg_pinnedOnly, sourceItemId: arg_sourceItemId).then(unittest.expectAsync1(((
api.TimelineListResponse response) { | 1995 res |
| 1996 .list( |
| 1997 bundleId: arg_bundleId, |
| 1998 includeDeleted: arg_includeDeleted, |
| 1999 maxResults: arg_maxResults, |
| 2000 orderBy: arg_orderBy, |
| 2001 pageToken: arg_pageToken, |
| 2002 pinnedOnly: arg_pinnedOnly, |
| 2003 sourceItemId: arg_sourceItemId) |
| 2004 .then(unittest.expectAsync1(((api.TimelineListResponse response) { |
1937 checkTimelineListResponse(response); | 2005 checkTimelineListResponse(response); |
1938 }))); | 2006 }))); |
1939 }); | 2007 }); |
1940 | 2008 |
1941 unittest.test("method--patch", () { | 2009 unittest.test("method--patch", () { |
1942 | |
1943 var mock = new HttpServerMock(); | 2010 var mock = new HttpServerMock(); |
1944 api.TimelineResourceApi res = new api.MirrorApi(mock).timeline; | 2011 api.TimelineResourceApi res = new api.MirrorApi(mock).timeline; |
1945 var arg_request = buildTimelineItem(); | 2012 var arg_request = buildTimelineItem(); |
1946 var arg_id = "foo"; | 2013 var arg_id = "foo"; |
1947 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 2014 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
1948 var obj = new api.TimelineItem.fromJson(json); | 2015 var obj = new api.TimelineItem.fromJson(json); |
1949 checkTimelineItem(obj); | 2016 checkTimelineItem(obj); |
1950 | 2017 |
1951 var path = (req.url).path; | 2018 var path = (req.url).path; |
1952 var pathOffset = 0; | 2019 var pathOffset = 0; |
1953 var index; | 2020 var index; |
1954 var subPart; | 2021 var subPart; |
1955 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 2022 unittest.expect( |
| 2023 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
1956 pathOffset += 1; | 2024 pathOffset += 1; |
1957 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("mirror/v1/")); | 2025 unittest.expect(path.substring(pathOffset, pathOffset + 10), |
| 2026 unittest.equals("mirror/v1/")); |
1958 pathOffset += 10; | 2027 pathOffset += 10; |
1959 unittest.expect(path.substring(pathOffset, pathOffset + 9), unittest.equ
als("timeline/")); | 2028 unittest.expect(path.substring(pathOffset, pathOffset + 9), |
| 2029 unittest.equals("timeline/")); |
1960 pathOffset += 9; | 2030 pathOffset += 9; |
1961 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); | 2031 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); |
1962 pathOffset = path.length; | 2032 pathOffset = path.length; |
1963 unittest.expect(subPart, unittest.equals("$arg_id")); | 2033 unittest.expect(subPart, unittest.equals("$arg_id")); |
1964 | 2034 |
1965 var query = (req.url).query; | 2035 var query = (req.url).query; |
1966 var queryOffset = 0; | 2036 var queryOffset = 0; |
1967 var queryMap = {}; | 2037 var queryMap = {}; |
1968 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 2038 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
1969 parseBool(n) { | 2039 parseBool(n) { |
1970 if (n == "true") return true; | 2040 if (n == "true") return true; |
1971 if (n == "false") return false; | 2041 if (n == "false") return false; |
1972 if (n == null) return null; | 2042 if (n == null) return null; |
1973 throw new core.ArgumentError("Invalid boolean: $n"); | 2043 throw new core.ArgumentError("Invalid boolean: $n"); |
1974 } | 2044 } |
| 2045 |
1975 if (query.length > 0) { | 2046 if (query.length > 0) { |
1976 for (var part in query.split("&")) { | 2047 for (var part in query.split("&")) { |
1977 var keyvalue = part.split("="); | 2048 var keyvalue = part.split("="); |
1978 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 2049 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 2050 core.Uri.decodeQueryComponent(keyvalue[1])); |
1979 } | 2051 } |
1980 } | 2052 } |
1981 | 2053 |
1982 | |
1983 var h = { | 2054 var h = { |
1984 "content-type" : "application/json; charset=utf-8", | 2055 "content-type": "application/json; charset=utf-8", |
1985 }; | 2056 }; |
1986 var resp = convert.JSON.encode(buildTimelineItem()); | 2057 var resp = convert.JSON.encode(buildTimelineItem()); |
1987 return new async.Future.value(stringResponse(200, h, resp)); | 2058 return new async.Future.value(stringResponse(200, h, resp)); |
1988 }), true); | 2059 }), true); |
1989 res.patch(arg_request, arg_id).then(unittest.expectAsync1(((api.TimelineIt
em response) { | 2060 res |
| 2061 .patch(arg_request, arg_id) |
| 2062 .then(unittest.expectAsync1(((api.TimelineItem response) { |
1990 checkTimelineItem(response); | 2063 checkTimelineItem(response); |
1991 }))); | 2064 }))); |
1992 }); | 2065 }); |
1993 | 2066 |
1994 unittest.test("method--update", () { | 2067 unittest.test("method--update", () { |
1995 // TODO: Implement tests for media upload; | 2068 // TODO: Implement tests for media upload; |
1996 // TODO: Implement tests for media download; | 2069 // TODO: Implement tests for media download; |
1997 | 2070 |
1998 var mock = new HttpServerMock(); | 2071 var mock = new HttpServerMock(); |
1999 api.TimelineResourceApi res = new api.MirrorApi(mock).timeline; | 2072 api.TimelineResourceApi res = new api.MirrorApi(mock).timeline; |
2000 var arg_request = buildTimelineItem(); | 2073 var arg_request = buildTimelineItem(); |
2001 var arg_id = "foo"; | 2074 var arg_id = "foo"; |
2002 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 2075 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
2003 var obj = new api.TimelineItem.fromJson(json); | 2076 var obj = new api.TimelineItem.fromJson(json); |
2004 checkTimelineItem(obj); | 2077 checkTimelineItem(obj); |
2005 | 2078 |
2006 var path = (req.url).path; | 2079 var path = (req.url).path; |
2007 var pathOffset = 0; | 2080 var pathOffset = 0; |
2008 var index; | 2081 var index; |
2009 var subPart; | 2082 var subPart; |
2010 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 2083 unittest.expect( |
| 2084 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
2011 pathOffset += 1; | 2085 pathOffset += 1; |
2012 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("mirror/v1/")); | 2086 unittest.expect(path.substring(pathOffset, pathOffset + 10), |
| 2087 unittest.equals("mirror/v1/")); |
2013 pathOffset += 10; | 2088 pathOffset += 10; |
2014 unittest.expect(path.substring(pathOffset, pathOffset + 9), unittest.equ
als("timeline/")); | 2089 unittest.expect(path.substring(pathOffset, pathOffset + 9), |
| 2090 unittest.equals("timeline/")); |
2015 pathOffset += 9; | 2091 pathOffset += 9; |
2016 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); | 2092 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); |
2017 pathOffset = path.length; | 2093 pathOffset = path.length; |
2018 unittest.expect(subPart, unittest.equals("$arg_id")); | 2094 unittest.expect(subPart, unittest.equals("$arg_id")); |
2019 | 2095 |
2020 var query = (req.url).query; | 2096 var query = (req.url).query; |
2021 var queryOffset = 0; | 2097 var queryOffset = 0; |
2022 var queryMap = {}; | 2098 var queryMap = {}; |
2023 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 2099 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
2024 parseBool(n) { | 2100 parseBool(n) { |
2025 if (n == "true") return true; | 2101 if (n == "true") return true; |
2026 if (n == "false") return false; | 2102 if (n == "false") return false; |
2027 if (n == null) return null; | 2103 if (n == null) return null; |
2028 throw new core.ArgumentError("Invalid boolean: $n"); | 2104 throw new core.ArgumentError("Invalid boolean: $n"); |
2029 } | 2105 } |
| 2106 |
2030 if (query.length > 0) { | 2107 if (query.length > 0) { |
2031 for (var part in query.split("&")) { | 2108 for (var part in query.split("&")) { |
2032 var keyvalue = part.split("="); | 2109 var keyvalue = part.split("="); |
2033 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 2110 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 2111 core.Uri.decodeQueryComponent(keyvalue[1])); |
2034 } | 2112 } |
2035 } | 2113 } |
2036 | 2114 |
2037 | |
2038 var h = { | 2115 var h = { |
2039 "content-type" : "application/json; charset=utf-8", | 2116 "content-type": "application/json; charset=utf-8", |
2040 }; | 2117 }; |
2041 var resp = convert.JSON.encode(buildTimelineItem()); | 2118 var resp = convert.JSON.encode(buildTimelineItem()); |
2042 return new async.Future.value(stringResponse(200, h, resp)); | 2119 return new async.Future.value(stringResponse(200, h, resp)); |
2043 }), true); | 2120 }), true); |
2044 res.update(arg_request, arg_id).then(unittest.expectAsync1(((api.TimelineI
tem response) { | 2121 res |
| 2122 .update(arg_request, arg_id) |
| 2123 .then(unittest.expectAsync1(((api.TimelineItem response) { |
2045 checkTimelineItem(response); | 2124 checkTimelineItem(response); |
2046 }))); | 2125 }))); |
2047 }); | 2126 }); |
2048 | |
2049 }); | 2127 }); |
2050 | 2128 |
2051 | |
2052 unittest.group("resource-TimelineAttachmentsResourceApi", () { | 2129 unittest.group("resource-TimelineAttachmentsResourceApi", () { |
2053 unittest.test("method--delete", () { | 2130 unittest.test("method--delete", () { |
2054 | |
2055 var mock = new HttpServerMock(); | 2131 var mock = new HttpServerMock(); |
2056 api.TimelineAttachmentsResourceApi res = new api.MirrorApi(mock).timeline.
attachments; | 2132 api.TimelineAttachmentsResourceApi res = |
| 2133 new api.MirrorApi(mock).timeline.attachments; |
2057 var arg_itemId = "foo"; | 2134 var arg_itemId = "foo"; |
2058 var arg_attachmentId = "foo"; | 2135 var arg_attachmentId = "foo"; |
2059 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 2136 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
2060 var path = (req.url).path; | 2137 var path = (req.url).path; |
2061 var pathOffset = 0; | 2138 var pathOffset = 0; |
2062 var index; | 2139 var index; |
2063 var subPart; | 2140 var subPart; |
2064 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 2141 unittest.expect( |
| 2142 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
2065 pathOffset += 1; | 2143 pathOffset += 1; |
2066 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("mirror/v1/")); | 2144 unittest.expect(path.substring(pathOffset, pathOffset + 10), |
| 2145 unittest.equals("mirror/v1/")); |
2067 pathOffset += 10; | 2146 pathOffset += 10; |
2068 unittest.expect(path.substring(pathOffset, pathOffset + 9), unittest.equ
als("timeline/")); | 2147 unittest.expect(path.substring(pathOffset, pathOffset + 9), |
| 2148 unittest.equals("timeline/")); |
2069 pathOffset += 9; | 2149 pathOffset += 9; |
2070 index = path.indexOf("/attachments/", pathOffset); | 2150 index = path.indexOf("/attachments/", pathOffset); |
2071 unittest.expect(index >= 0, unittest.isTrue); | 2151 unittest.expect(index >= 0, unittest.isTrue); |
2072 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | 2152 subPart = |
| 2153 core.Uri.decodeQueryComponent(path.substring(pathOffset, index)); |
2073 pathOffset = index; | 2154 pathOffset = index; |
2074 unittest.expect(subPart, unittest.equals("$arg_itemId")); | 2155 unittest.expect(subPart, unittest.equals("$arg_itemId")); |
2075 unittest.expect(path.substring(pathOffset, pathOffset + 13), unittest.eq
uals("/attachments/")); | 2156 unittest.expect(path.substring(pathOffset, pathOffset + 13), |
| 2157 unittest.equals("/attachments/")); |
2076 pathOffset += 13; | 2158 pathOffset += 13; |
2077 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); | 2159 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); |
2078 pathOffset = path.length; | 2160 pathOffset = path.length; |
2079 unittest.expect(subPart, unittest.equals("$arg_attachmentId")); | 2161 unittest.expect(subPart, unittest.equals("$arg_attachmentId")); |
2080 | 2162 |
2081 var query = (req.url).query; | 2163 var query = (req.url).query; |
2082 var queryOffset = 0; | 2164 var queryOffset = 0; |
2083 var queryMap = {}; | 2165 var queryMap = {}; |
2084 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 2166 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
2085 parseBool(n) { | 2167 parseBool(n) { |
2086 if (n == "true") return true; | 2168 if (n == "true") return true; |
2087 if (n == "false") return false; | 2169 if (n == "false") return false; |
2088 if (n == null) return null; | 2170 if (n == null) return null; |
2089 throw new core.ArgumentError("Invalid boolean: $n"); | 2171 throw new core.ArgumentError("Invalid boolean: $n"); |
2090 } | 2172 } |
| 2173 |
2091 if (query.length > 0) { | 2174 if (query.length > 0) { |
2092 for (var part in query.split("&")) { | 2175 for (var part in query.split("&")) { |
2093 var keyvalue = part.split("="); | 2176 var keyvalue = part.split("="); |
2094 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 2177 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 2178 core.Uri.decodeQueryComponent(keyvalue[1])); |
2095 } | 2179 } |
2096 } | 2180 } |
2097 | 2181 |
2098 | |
2099 var h = { | 2182 var h = { |
2100 "content-type" : "application/json; charset=utf-8", | 2183 "content-type": "application/json; charset=utf-8", |
2101 }; | 2184 }; |
2102 var resp = ""; | 2185 var resp = ""; |
2103 return new async.Future.value(stringResponse(200, h, resp)); | 2186 return new async.Future.value(stringResponse(200, h, resp)); |
2104 }), true); | 2187 }), true); |
2105 res.delete(arg_itemId, arg_attachmentId).then(unittest.expectAsync1((_) {}
)); | 2188 res |
| 2189 .delete(arg_itemId, arg_attachmentId) |
| 2190 .then(unittest.expectAsync1((_) {})); |
2106 }); | 2191 }); |
2107 | 2192 |
2108 unittest.test("method--get", () { | 2193 unittest.test("method--get", () { |
2109 // TODO: Implement tests for media upload; | 2194 // TODO: Implement tests for media upload; |
2110 // TODO: Implement tests for media download; | 2195 // TODO: Implement tests for media download; |
2111 | 2196 |
2112 var mock = new HttpServerMock(); | 2197 var mock = new HttpServerMock(); |
2113 api.TimelineAttachmentsResourceApi res = new api.MirrorApi(mock).timeline.
attachments; | 2198 api.TimelineAttachmentsResourceApi res = |
| 2199 new api.MirrorApi(mock).timeline.attachments; |
2114 var arg_itemId = "foo"; | 2200 var arg_itemId = "foo"; |
2115 var arg_attachmentId = "foo"; | 2201 var arg_attachmentId = "foo"; |
2116 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 2202 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
2117 var path = (req.url).path; | 2203 var path = (req.url).path; |
2118 var pathOffset = 0; | 2204 var pathOffset = 0; |
2119 var index; | 2205 var index; |
2120 var subPart; | 2206 var subPart; |
2121 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 2207 unittest.expect( |
| 2208 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
2122 pathOffset += 1; | 2209 pathOffset += 1; |
2123 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("mirror/v1/")); | 2210 unittest.expect(path.substring(pathOffset, pathOffset + 10), |
| 2211 unittest.equals("mirror/v1/")); |
2124 pathOffset += 10; | 2212 pathOffset += 10; |
2125 unittest.expect(path.substring(pathOffset, pathOffset + 9), unittest.equ
als("timeline/")); | 2213 unittest.expect(path.substring(pathOffset, pathOffset + 9), |
| 2214 unittest.equals("timeline/")); |
2126 pathOffset += 9; | 2215 pathOffset += 9; |
2127 index = path.indexOf("/attachments/", pathOffset); | 2216 index = path.indexOf("/attachments/", pathOffset); |
2128 unittest.expect(index >= 0, unittest.isTrue); | 2217 unittest.expect(index >= 0, unittest.isTrue); |
2129 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | 2218 subPart = |
| 2219 core.Uri.decodeQueryComponent(path.substring(pathOffset, index)); |
2130 pathOffset = index; | 2220 pathOffset = index; |
2131 unittest.expect(subPart, unittest.equals("$arg_itemId")); | 2221 unittest.expect(subPart, unittest.equals("$arg_itemId")); |
2132 unittest.expect(path.substring(pathOffset, pathOffset + 13), unittest.eq
uals("/attachments/")); | 2222 unittest.expect(path.substring(pathOffset, pathOffset + 13), |
| 2223 unittest.equals("/attachments/")); |
2133 pathOffset += 13; | 2224 pathOffset += 13; |
2134 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); | 2225 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); |
2135 pathOffset = path.length; | 2226 pathOffset = path.length; |
2136 unittest.expect(subPart, unittest.equals("$arg_attachmentId")); | 2227 unittest.expect(subPart, unittest.equals("$arg_attachmentId")); |
2137 | 2228 |
2138 var query = (req.url).query; | 2229 var query = (req.url).query; |
2139 var queryOffset = 0; | 2230 var queryOffset = 0; |
2140 var queryMap = {}; | 2231 var queryMap = {}; |
2141 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 2232 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
2142 parseBool(n) { | 2233 parseBool(n) { |
2143 if (n == "true") return true; | 2234 if (n == "true") return true; |
2144 if (n == "false") return false; | 2235 if (n == "false") return false; |
2145 if (n == null) return null; | 2236 if (n == null) return null; |
2146 throw new core.ArgumentError("Invalid boolean: $n"); | 2237 throw new core.ArgumentError("Invalid boolean: $n"); |
2147 } | 2238 } |
| 2239 |
2148 if (query.length > 0) { | 2240 if (query.length > 0) { |
2149 for (var part in query.split("&")) { | 2241 for (var part in query.split("&")) { |
2150 var keyvalue = part.split("="); | 2242 var keyvalue = part.split("="); |
2151 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 2243 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 2244 core.Uri.decodeQueryComponent(keyvalue[1])); |
2152 } | 2245 } |
2153 } | 2246 } |
2154 | 2247 |
2155 | |
2156 var h = { | 2248 var h = { |
2157 "content-type" : "application/json; charset=utf-8", | 2249 "content-type": "application/json; charset=utf-8", |
2158 }; | 2250 }; |
2159 var resp = convert.JSON.encode(buildAttachment()); | 2251 var resp = convert.JSON.encode(buildAttachment()); |
2160 return new async.Future.value(stringResponse(200, h, resp)); | 2252 return new async.Future.value(stringResponse(200, h, resp)); |
2161 }), true); | 2253 }), true); |
2162 res.get(arg_itemId, arg_attachmentId).then(unittest.expectAsync1(((api.Att
achment response) { | 2254 res |
| 2255 .get(arg_itemId, arg_attachmentId) |
| 2256 .then(unittest.expectAsync1(((api.Attachment response) { |
2163 checkAttachment(response); | 2257 checkAttachment(response); |
2164 }))); | 2258 }))); |
2165 }); | 2259 }); |
2166 | 2260 |
2167 unittest.test("method--insert", () { | 2261 unittest.test("method--insert", () { |
2168 // TODO: Implement tests for media upload; | 2262 // TODO: Implement tests for media upload; |
2169 // TODO: Implement tests for media download; | 2263 // TODO: Implement tests for media download; |
2170 | 2264 |
2171 var mock = new HttpServerMock(); | 2265 var mock = new HttpServerMock(); |
2172 api.TimelineAttachmentsResourceApi res = new api.MirrorApi(mock).timeline.
attachments; | 2266 api.TimelineAttachmentsResourceApi res = |
| 2267 new api.MirrorApi(mock).timeline.attachments; |
2173 var arg_itemId = "foo"; | 2268 var arg_itemId = "foo"; |
2174 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 2269 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
2175 var path = (req.url).path; | 2270 var path = (req.url).path; |
2176 var pathOffset = 0; | 2271 var pathOffset = 0; |
2177 var index; | 2272 var index; |
2178 var subPart; | 2273 var subPart; |
2179 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 2274 unittest.expect( |
| 2275 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
2180 pathOffset += 1; | 2276 pathOffset += 1; |
2181 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("mirror/v1/")); | 2277 unittest.expect(path.substring(pathOffset, pathOffset + 10), |
| 2278 unittest.equals("mirror/v1/")); |
2182 pathOffset += 10; | 2279 pathOffset += 10; |
2183 unittest.expect(path.substring(pathOffset, pathOffset + 9), unittest.equ
als("timeline/")); | 2280 unittest.expect(path.substring(pathOffset, pathOffset + 9), |
| 2281 unittest.equals("timeline/")); |
2184 pathOffset += 9; | 2282 pathOffset += 9; |
2185 index = path.indexOf("/attachments", pathOffset); | 2283 index = path.indexOf("/attachments", pathOffset); |
2186 unittest.expect(index >= 0, unittest.isTrue); | 2284 unittest.expect(index >= 0, unittest.isTrue); |
2187 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | 2285 subPart = |
| 2286 core.Uri.decodeQueryComponent(path.substring(pathOffset, index)); |
2188 pathOffset = index; | 2287 pathOffset = index; |
2189 unittest.expect(subPart, unittest.equals("$arg_itemId")); | 2288 unittest.expect(subPart, unittest.equals("$arg_itemId")); |
2190 unittest.expect(path.substring(pathOffset, pathOffset + 12), unittest.eq
uals("/attachments")); | 2289 unittest.expect(path.substring(pathOffset, pathOffset + 12), |
| 2290 unittest.equals("/attachments")); |
2191 pathOffset += 12; | 2291 pathOffset += 12; |
2192 | 2292 |
2193 var query = (req.url).query; | 2293 var query = (req.url).query; |
2194 var queryOffset = 0; | 2294 var queryOffset = 0; |
2195 var queryMap = {}; | 2295 var queryMap = {}; |
2196 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 2296 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
2197 parseBool(n) { | 2297 parseBool(n) { |
2198 if (n == "true") return true; | 2298 if (n == "true") return true; |
2199 if (n == "false") return false; | 2299 if (n == "false") return false; |
2200 if (n == null) return null; | 2300 if (n == null) return null; |
2201 throw new core.ArgumentError("Invalid boolean: $n"); | 2301 throw new core.ArgumentError("Invalid boolean: $n"); |
2202 } | 2302 } |
| 2303 |
2203 if (query.length > 0) { | 2304 if (query.length > 0) { |
2204 for (var part in query.split("&")) { | 2305 for (var part in query.split("&")) { |
2205 var keyvalue = part.split("="); | 2306 var keyvalue = part.split("="); |
2206 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 2307 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 2308 core.Uri.decodeQueryComponent(keyvalue[1])); |
2207 } | 2309 } |
2208 } | 2310 } |
2209 | 2311 |
2210 | |
2211 var h = { | 2312 var h = { |
2212 "content-type" : "application/json; charset=utf-8", | 2313 "content-type": "application/json; charset=utf-8", |
2213 }; | 2314 }; |
2214 var resp = convert.JSON.encode(buildAttachment()); | 2315 var resp = convert.JSON.encode(buildAttachment()); |
2215 return new async.Future.value(stringResponse(200, h, resp)); | 2316 return new async.Future.value(stringResponse(200, h, resp)); |
2216 }), true); | 2317 }), true); |
2217 res.insert(arg_itemId).then(unittest.expectAsync1(((api.Attachment respons
e) { | 2318 res |
| 2319 .insert(arg_itemId) |
| 2320 .then(unittest.expectAsync1(((api.Attachment response) { |
2218 checkAttachment(response); | 2321 checkAttachment(response); |
2219 }))); | 2322 }))); |
2220 }); | 2323 }); |
2221 | 2324 |
2222 unittest.test("method--list", () { | 2325 unittest.test("method--list", () { |
2223 | |
2224 var mock = new HttpServerMock(); | 2326 var mock = new HttpServerMock(); |
2225 api.TimelineAttachmentsResourceApi res = new api.MirrorApi(mock).timeline.
attachments; | 2327 api.TimelineAttachmentsResourceApi res = |
| 2328 new api.MirrorApi(mock).timeline.attachments; |
2226 var arg_itemId = "foo"; | 2329 var arg_itemId = "foo"; |
2227 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 2330 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
2228 var path = (req.url).path; | 2331 var path = (req.url).path; |
2229 var pathOffset = 0; | 2332 var pathOffset = 0; |
2230 var index; | 2333 var index; |
2231 var subPart; | 2334 var subPart; |
2232 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 2335 unittest.expect( |
| 2336 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
2233 pathOffset += 1; | 2337 pathOffset += 1; |
2234 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("mirror/v1/")); | 2338 unittest.expect(path.substring(pathOffset, pathOffset + 10), |
| 2339 unittest.equals("mirror/v1/")); |
2235 pathOffset += 10; | 2340 pathOffset += 10; |
2236 unittest.expect(path.substring(pathOffset, pathOffset + 9), unittest.equ
als("timeline/")); | 2341 unittest.expect(path.substring(pathOffset, pathOffset + 9), |
| 2342 unittest.equals("timeline/")); |
2237 pathOffset += 9; | 2343 pathOffset += 9; |
2238 index = path.indexOf("/attachments", pathOffset); | 2344 index = path.indexOf("/attachments", pathOffset); |
2239 unittest.expect(index >= 0, unittest.isTrue); | 2345 unittest.expect(index >= 0, unittest.isTrue); |
2240 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | 2346 subPart = |
| 2347 core.Uri.decodeQueryComponent(path.substring(pathOffset, index)); |
2241 pathOffset = index; | 2348 pathOffset = index; |
2242 unittest.expect(subPart, unittest.equals("$arg_itemId")); | 2349 unittest.expect(subPart, unittest.equals("$arg_itemId")); |
2243 unittest.expect(path.substring(pathOffset, pathOffset + 12), unittest.eq
uals("/attachments")); | 2350 unittest.expect(path.substring(pathOffset, pathOffset + 12), |
| 2351 unittest.equals("/attachments")); |
2244 pathOffset += 12; | 2352 pathOffset += 12; |
2245 | 2353 |
2246 var query = (req.url).query; | 2354 var query = (req.url).query; |
2247 var queryOffset = 0; | 2355 var queryOffset = 0; |
2248 var queryMap = {}; | 2356 var queryMap = {}; |
2249 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 2357 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
2250 parseBool(n) { | 2358 parseBool(n) { |
2251 if (n == "true") return true; | 2359 if (n == "true") return true; |
2252 if (n == "false") return false; | 2360 if (n == "false") return false; |
2253 if (n == null) return null; | 2361 if (n == null) return null; |
2254 throw new core.ArgumentError("Invalid boolean: $n"); | 2362 throw new core.ArgumentError("Invalid boolean: $n"); |
2255 } | 2363 } |
| 2364 |
2256 if (query.length > 0) { | 2365 if (query.length > 0) { |
2257 for (var part in query.split("&")) { | 2366 for (var part in query.split("&")) { |
2258 var keyvalue = part.split("="); | 2367 var keyvalue = part.split("="); |
2259 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 2368 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 2369 core.Uri.decodeQueryComponent(keyvalue[1])); |
2260 } | 2370 } |
2261 } | 2371 } |
2262 | 2372 |
2263 | |
2264 var h = { | 2373 var h = { |
2265 "content-type" : "application/json; charset=utf-8", | 2374 "content-type": "application/json; charset=utf-8", |
2266 }; | 2375 }; |
2267 var resp = convert.JSON.encode(buildAttachmentsListResponse()); | 2376 var resp = convert.JSON.encode(buildAttachmentsListResponse()); |
2268 return new async.Future.value(stringResponse(200, h, resp)); | 2377 return new async.Future.value(stringResponse(200, h, resp)); |
2269 }), true); | 2378 }), true); |
2270 res.list(arg_itemId).then(unittest.expectAsync1(((api.AttachmentsListRespo
nse response) { | 2379 res |
| 2380 .list(arg_itemId) |
| 2381 .then(unittest.expectAsync1(((api.AttachmentsListResponse response) { |
2271 checkAttachmentsListResponse(response); | 2382 checkAttachmentsListResponse(response); |
2272 }))); | 2383 }))); |
2273 }); | 2384 }); |
2274 | |
2275 }); | 2385 }); |
2276 | |
2277 | |
2278 } | 2386 } |
2279 | |
OLD | NEW |