OLD | NEW |
| (Empty) |
1 library googleapis.reseller.v1.test; | |
2 | |
3 import "dart:core" as core; | |
4 import "dart:collection" as collection; | |
5 import "dart:async" as async; | |
6 import "dart:convert" as convert; | |
7 | |
8 import 'package:http/http.dart' as http; | |
9 import 'package:http/testing.dart' as http_testing; | |
10 import 'package:unittest/unittest.dart' as unittest; | |
11 import 'package:googleapis/common/common.dart' as common; | |
12 import 'package:googleapis/src/common_internal.dart' as common_internal; | |
13 import '../common/common_internal_test.dart' as common_test; | |
14 | |
15 import 'package:googleapis/reseller/v1.dart' as api; | |
16 | |
17 | |
18 | |
19 core.int buildCounterAddress = 0; | |
20 buildAddress() { | |
21 var o = new api.Address(); | |
22 buildCounterAddress++; | |
23 if (buildCounterAddress < 3) { | |
24 o.addressLine1 = "foo"; | |
25 o.addressLine2 = "foo"; | |
26 o.addressLine3 = "foo"; | |
27 o.contactName = "foo"; | |
28 o.countryCode = "foo"; | |
29 o.kind = "foo"; | |
30 o.locality = "foo"; | |
31 o.organizationName = "foo"; | |
32 o.postalCode = "foo"; | |
33 o.region = "foo"; | |
34 } | |
35 buildCounterAddress--; | |
36 return o; | |
37 } | |
38 | |
39 checkAddress(api.Address o) { | |
40 buildCounterAddress++; | |
41 if (buildCounterAddress < 3) { | |
42 unittest.expect(o.addressLine1, unittest.equals('foo')); | |
43 unittest.expect(o.addressLine2, unittest.equals('foo')); | |
44 unittest.expect(o.addressLine3, unittest.equals('foo')); | |
45 unittest.expect(o.contactName, unittest.equals('foo')); | |
46 unittest.expect(o.countryCode, unittest.equals('foo')); | |
47 unittest.expect(o.kind, unittest.equals('foo')); | |
48 unittest.expect(o.locality, unittest.equals('foo')); | |
49 unittest.expect(o.organizationName, unittest.equals('foo')); | |
50 unittest.expect(o.postalCode, unittest.equals('foo')); | |
51 unittest.expect(o.region, unittest.equals('foo')); | |
52 } | |
53 buildCounterAddress--; | |
54 } | |
55 | |
56 core.int buildCounterChangePlanRequest = 0; | |
57 buildChangePlanRequest() { | |
58 var o = new api.ChangePlanRequest(); | |
59 buildCounterChangePlanRequest++; | |
60 if (buildCounterChangePlanRequest < 3) { | |
61 o.kind = "foo"; | |
62 o.planName = "foo"; | |
63 o.purchaseOrderId = "foo"; | |
64 o.seats = buildSeats(); | |
65 } | |
66 buildCounterChangePlanRequest--; | |
67 return o; | |
68 } | |
69 | |
70 checkChangePlanRequest(api.ChangePlanRequest o) { | |
71 buildCounterChangePlanRequest++; | |
72 if (buildCounterChangePlanRequest < 3) { | |
73 unittest.expect(o.kind, unittest.equals('foo')); | |
74 unittest.expect(o.planName, unittest.equals('foo')); | |
75 unittest.expect(o.purchaseOrderId, unittest.equals('foo')); | |
76 checkSeats(o.seats); | |
77 } | |
78 buildCounterChangePlanRequest--; | |
79 } | |
80 | |
81 core.int buildCounterCustomer = 0; | |
82 buildCustomer() { | |
83 var o = new api.Customer(); | |
84 buildCounterCustomer++; | |
85 if (buildCounterCustomer < 3) { | |
86 o.alternateEmail = "foo"; | |
87 o.customerDomain = "foo"; | |
88 o.customerId = "foo"; | |
89 o.kind = "foo"; | |
90 o.phoneNumber = "foo"; | |
91 o.postalAddress = buildAddress(); | |
92 o.resourceUiUrl = "foo"; | |
93 } | |
94 buildCounterCustomer--; | |
95 return o; | |
96 } | |
97 | |
98 checkCustomer(api.Customer o) { | |
99 buildCounterCustomer++; | |
100 if (buildCounterCustomer < 3) { | |
101 unittest.expect(o.alternateEmail, unittest.equals('foo')); | |
102 unittest.expect(o.customerDomain, unittest.equals('foo')); | |
103 unittest.expect(o.customerId, unittest.equals('foo')); | |
104 unittest.expect(o.kind, unittest.equals('foo')); | |
105 unittest.expect(o.phoneNumber, unittest.equals('foo')); | |
106 checkAddress(o.postalAddress); | |
107 unittest.expect(o.resourceUiUrl, unittest.equals('foo')); | |
108 } | |
109 buildCounterCustomer--; | |
110 } | |
111 | |
112 core.int buildCounterRenewalSettings = 0; | |
113 buildRenewalSettings() { | |
114 var o = new api.RenewalSettings(); | |
115 buildCounterRenewalSettings++; | |
116 if (buildCounterRenewalSettings < 3) { | |
117 o.kind = "foo"; | |
118 o.renewalType = "foo"; | |
119 } | |
120 buildCounterRenewalSettings--; | |
121 return o; | |
122 } | |
123 | |
124 checkRenewalSettings(api.RenewalSettings o) { | |
125 buildCounterRenewalSettings++; | |
126 if (buildCounterRenewalSettings < 3) { | |
127 unittest.expect(o.kind, unittest.equals('foo')); | |
128 unittest.expect(o.renewalType, unittest.equals('foo')); | |
129 } | |
130 buildCounterRenewalSettings--; | |
131 } | |
132 | |
133 core.int buildCounterSeats = 0; | |
134 buildSeats() { | |
135 var o = new api.Seats(); | |
136 buildCounterSeats++; | |
137 if (buildCounterSeats < 3) { | |
138 o.kind = "foo"; | |
139 o.maximumNumberOfSeats = 42; | |
140 o.numberOfSeats = 42; | |
141 } | |
142 buildCounterSeats--; | |
143 return o; | |
144 } | |
145 | |
146 checkSeats(api.Seats o) { | |
147 buildCounterSeats++; | |
148 if (buildCounterSeats < 3) { | |
149 unittest.expect(o.kind, unittest.equals('foo')); | |
150 unittest.expect(o.maximumNumberOfSeats, unittest.equals(42)); | |
151 unittest.expect(o.numberOfSeats, unittest.equals(42)); | |
152 } | |
153 buildCounterSeats--; | |
154 } | |
155 | |
156 core.int buildCounterSubscriptionPlanCommitmentInterval = 0; | |
157 buildSubscriptionPlanCommitmentInterval() { | |
158 var o = new api.SubscriptionPlanCommitmentInterval(); | |
159 buildCounterSubscriptionPlanCommitmentInterval++; | |
160 if (buildCounterSubscriptionPlanCommitmentInterval < 3) { | |
161 o.endTime = "foo"; | |
162 o.startTime = "foo"; | |
163 } | |
164 buildCounterSubscriptionPlanCommitmentInterval--; | |
165 return o; | |
166 } | |
167 | |
168 checkSubscriptionPlanCommitmentInterval(api.SubscriptionPlanCommitmentInterval o
) { | |
169 buildCounterSubscriptionPlanCommitmentInterval++; | |
170 if (buildCounterSubscriptionPlanCommitmentInterval < 3) { | |
171 unittest.expect(o.endTime, unittest.equals('foo')); | |
172 unittest.expect(o.startTime, unittest.equals('foo')); | |
173 } | |
174 buildCounterSubscriptionPlanCommitmentInterval--; | |
175 } | |
176 | |
177 core.int buildCounterSubscriptionPlan = 0; | |
178 buildSubscriptionPlan() { | |
179 var o = new api.SubscriptionPlan(); | |
180 buildCounterSubscriptionPlan++; | |
181 if (buildCounterSubscriptionPlan < 3) { | |
182 o.commitmentInterval = buildSubscriptionPlanCommitmentInterval(); | |
183 o.isCommitmentPlan = true; | |
184 o.planName = "foo"; | |
185 } | |
186 buildCounterSubscriptionPlan--; | |
187 return o; | |
188 } | |
189 | |
190 checkSubscriptionPlan(api.SubscriptionPlan o) { | |
191 buildCounterSubscriptionPlan++; | |
192 if (buildCounterSubscriptionPlan < 3) { | |
193 checkSubscriptionPlanCommitmentInterval(o.commitmentInterval); | |
194 unittest.expect(o.isCommitmentPlan, unittest.isTrue); | |
195 unittest.expect(o.planName, unittest.equals('foo')); | |
196 } | |
197 buildCounterSubscriptionPlan--; | |
198 } | |
199 | |
200 core.int buildCounterSubscriptionTransferInfo = 0; | |
201 buildSubscriptionTransferInfo() { | |
202 var o = new api.SubscriptionTransferInfo(); | |
203 buildCounterSubscriptionTransferInfo++; | |
204 if (buildCounterSubscriptionTransferInfo < 3) { | |
205 o.minimumTransferableSeats = 42; | |
206 o.transferabilityExpirationTime = "foo"; | |
207 } | |
208 buildCounterSubscriptionTransferInfo--; | |
209 return o; | |
210 } | |
211 | |
212 checkSubscriptionTransferInfo(api.SubscriptionTransferInfo o) { | |
213 buildCounterSubscriptionTransferInfo++; | |
214 if (buildCounterSubscriptionTransferInfo < 3) { | |
215 unittest.expect(o.minimumTransferableSeats, unittest.equals(42)); | |
216 unittest.expect(o.transferabilityExpirationTime, unittest.equals('foo')); | |
217 } | |
218 buildCounterSubscriptionTransferInfo--; | |
219 } | |
220 | |
221 core.int buildCounterSubscriptionTrialSettings = 0; | |
222 buildSubscriptionTrialSettings() { | |
223 var o = new api.SubscriptionTrialSettings(); | |
224 buildCounterSubscriptionTrialSettings++; | |
225 if (buildCounterSubscriptionTrialSettings < 3) { | |
226 o.isInTrial = true; | |
227 o.trialEndTime = "foo"; | |
228 } | |
229 buildCounterSubscriptionTrialSettings--; | |
230 return o; | |
231 } | |
232 | |
233 checkSubscriptionTrialSettings(api.SubscriptionTrialSettings o) { | |
234 buildCounterSubscriptionTrialSettings++; | |
235 if (buildCounterSubscriptionTrialSettings < 3) { | |
236 unittest.expect(o.isInTrial, unittest.isTrue); | |
237 unittest.expect(o.trialEndTime, unittest.equals('foo')); | |
238 } | |
239 buildCounterSubscriptionTrialSettings--; | |
240 } | |
241 | |
242 core.int buildCounterSubscription = 0; | |
243 buildSubscription() { | |
244 var o = new api.Subscription(); | |
245 buildCounterSubscription++; | |
246 if (buildCounterSubscription < 3) { | |
247 o.creationTime = "foo"; | |
248 o.customerId = "foo"; | |
249 o.kind = "foo"; | |
250 o.plan = buildSubscriptionPlan(); | |
251 o.purchaseOrderId = "foo"; | |
252 o.renewalSettings = buildRenewalSettings(); | |
253 o.resourceUiUrl = "foo"; | |
254 o.seats = buildSeats(); | |
255 o.skuId = "foo"; | |
256 o.status = "foo"; | |
257 o.subscriptionId = "foo"; | |
258 o.transferInfo = buildSubscriptionTransferInfo(); | |
259 o.trialSettings = buildSubscriptionTrialSettings(); | |
260 } | |
261 buildCounterSubscription--; | |
262 return o; | |
263 } | |
264 | |
265 checkSubscription(api.Subscription o) { | |
266 buildCounterSubscription++; | |
267 if (buildCounterSubscription < 3) { | |
268 unittest.expect(o.creationTime, unittest.equals('foo')); | |
269 unittest.expect(o.customerId, unittest.equals('foo')); | |
270 unittest.expect(o.kind, unittest.equals('foo')); | |
271 checkSubscriptionPlan(o.plan); | |
272 unittest.expect(o.purchaseOrderId, unittest.equals('foo')); | |
273 checkRenewalSettings(o.renewalSettings); | |
274 unittest.expect(o.resourceUiUrl, unittest.equals('foo')); | |
275 checkSeats(o.seats); | |
276 unittest.expect(o.skuId, unittest.equals('foo')); | |
277 unittest.expect(o.status, unittest.equals('foo')); | |
278 unittest.expect(o.subscriptionId, unittest.equals('foo')); | |
279 checkSubscriptionTransferInfo(o.transferInfo); | |
280 checkSubscriptionTrialSettings(o.trialSettings); | |
281 } | |
282 buildCounterSubscription--; | |
283 } | |
284 | |
285 buildUnnamed932() { | |
286 var o = new core.List<api.Subscription>(); | |
287 o.add(buildSubscription()); | |
288 o.add(buildSubscription()); | |
289 return o; | |
290 } | |
291 | |
292 checkUnnamed932(core.List<api.Subscription> o) { | |
293 unittest.expect(o, unittest.hasLength(2)); | |
294 checkSubscription(o[0]); | |
295 checkSubscription(o[1]); | |
296 } | |
297 | |
298 core.int buildCounterSubscriptions = 0; | |
299 buildSubscriptions() { | |
300 var o = new api.Subscriptions(); | |
301 buildCounterSubscriptions++; | |
302 if (buildCounterSubscriptions < 3) { | |
303 o.kind = "foo"; | |
304 o.nextPageToken = "foo"; | |
305 o.subscriptions = buildUnnamed932(); | |
306 } | |
307 buildCounterSubscriptions--; | |
308 return o; | |
309 } | |
310 | |
311 checkSubscriptions(api.Subscriptions o) { | |
312 buildCounterSubscriptions++; | |
313 if (buildCounterSubscriptions < 3) { | |
314 unittest.expect(o.kind, unittest.equals('foo')); | |
315 unittest.expect(o.nextPageToken, unittest.equals('foo')); | |
316 checkUnnamed932(o.subscriptions); | |
317 } | |
318 buildCounterSubscriptions--; | |
319 } | |
320 | |
321 | |
322 main() { | |
323 unittest.group("obj-schema-Address", () { | |
324 unittest.test("to-json--from-json", () { | |
325 var o = buildAddress(); | |
326 var od = new api.Address.fromJson(o.toJson()); | |
327 checkAddress(od); | |
328 }); | |
329 }); | |
330 | |
331 | |
332 unittest.group("obj-schema-ChangePlanRequest", () { | |
333 unittest.test("to-json--from-json", () { | |
334 var o = buildChangePlanRequest(); | |
335 var od = new api.ChangePlanRequest.fromJson(o.toJson()); | |
336 checkChangePlanRequest(od); | |
337 }); | |
338 }); | |
339 | |
340 | |
341 unittest.group("obj-schema-Customer", () { | |
342 unittest.test("to-json--from-json", () { | |
343 var o = buildCustomer(); | |
344 var od = new api.Customer.fromJson(o.toJson()); | |
345 checkCustomer(od); | |
346 }); | |
347 }); | |
348 | |
349 | |
350 unittest.group("obj-schema-RenewalSettings", () { | |
351 unittest.test("to-json--from-json", () { | |
352 var o = buildRenewalSettings(); | |
353 var od = new api.RenewalSettings.fromJson(o.toJson()); | |
354 checkRenewalSettings(od); | |
355 }); | |
356 }); | |
357 | |
358 | |
359 unittest.group("obj-schema-Seats", () { | |
360 unittest.test("to-json--from-json", () { | |
361 var o = buildSeats(); | |
362 var od = new api.Seats.fromJson(o.toJson()); | |
363 checkSeats(od); | |
364 }); | |
365 }); | |
366 | |
367 | |
368 unittest.group("obj-schema-SubscriptionPlanCommitmentInterval", () { | |
369 unittest.test("to-json--from-json", () { | |
370 var o = buildSubscriptionPlanCommitmentInterval(); | |
371 var od = new api.SubscriptionPlanCommitmentInterval.fromJson(o.toJson()); | |
372 checkSubscriptionPlanCommitmentInterval(od); | |
373 }); | |
374 }); | |
375 | |
376 | |
377 unittest.group("obj-schema-SubscriptionPlan", () { | |
378 unittest.test("to-json--from-json", () { | |
379 var o = buildSubscriptionPlan(); | |
380 var od = new api.SubscriptionPlan.fromJson(o.toJson()); | |
381 checkSubscriptionPlan(od); | |
382 }); | |
383 }); | |
384 | |
385 | |
386 unittest.group("obj-schema-SubscriptionTransferInfo", () { | |
387 unittest.test("to-json--from-json", () { | |
388 var o = buildSubscriptionTransferInfo(); | |
389 var od = new api.SubscriptionTransferInfo.fromJson(o.toJson()); | |
390 checkSubscriptionTransferInfo(od); | |
391 }); | |
392 }); | |
393 | |
394 | |
395 unittest.group("obj-schema-SubscriptionTrialSettings", () { | |
396 unittest.test("to-json--from-json", () { | |
397 var o = buildSubscriptionTrialSettings(); | |
398 var od = new api.SubscriptionTrialSettings.fromJson(o.toJson()); | |
399 checkSubscriptionTrialSettings(od); | |
400 }); | |
401 }); | |
402 | |
403 | |
404 unittest.group("obj-schema-Subscription", () { | |
405 unittest.test("to-json--from-json", () { | |
406 var o = buildSubscription(); | |
407 var od = new api.Subscription.fromJson(o.toJson()); | |
408 checkSubscription(od); | |
409 }); | |
410 }); | |
411 | |
412 | |
413 unittest.group("obj-schema-Subscriptions", () { | |
414 unittest.test("to-json--from-json", () { | |
415 var o = buildSubscriptions(); | |
416 var od = new api.Subscriptions.fromJson(o.toJson()); | |
417 checkSubscriptions(od); | |
418 }); | |
419 }); | |
420 | |
421 | |
422 unittest.group("resource-CustomersResourceApi", () { | |
423 unittest.test("method--get", () { | |
424 | |
425 var mock = new common_test.HttpServerMock(); | |
426 api.CustomersResourceApi res = new api.ResellerApi(mock).customers; | |
427 var arg_customerId = "foo"; | |
428 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
429 var path = (req.url).path; | |
430 var pathOffset = 0; | |
431 var index; | |
432 var subPart; | |
433 unittest.expect(path.substring(pathOffset, pathOffset + 18), unittest.eq
uals("/apps/reseller/v1/")); | |
434 pathOffset += 18; | |
435 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("customers/")); | |
436 pathOffset += 10; | |
437 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); | |
438 pathOffset = path.length; | |
439 unittest.expect(subPart, unittest.equals("$arg_customerId")); | |
440 | |
441 var query = (req.url).query; | |
442 var queryOffset = 0; | |
443 var queryMap = {}; | |
444 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
445 parseBool(n) { | |
446 if (n == "true") return true; | |
447 if (n == "false") return false; | |
448 if (n == null) return null; | |
449 throw new core.ArgumentError("Invalid boolean: $n"); | |
450 } | |
451 if (query.length > 0) { | |
452 for (var part in query.split("&")) { | |
453 var keyvalue = part.split("="); | |
454 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
455 } | |
456 } | |
457 | |
458 | |
459 var h = { | |
460 "content-type" : "application/json; charset=utf-8", | |
461 }; | |
462 var resp = convert.JSON.encode(buildCustomer()); | |
463 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
464 }), true); | |
465 res.get(arg_customerId).then(unittest.expectAsync(((api.Customer response)
{ | |
466 checkCustomer(response); | |
467 }))); | |
468 }); | |
469 | |
470 unittest.test("method--insert", () { | |
471 | |
472 var mock = new common_test.HttpServerMock(); | |
473 api.CustomersResourceApi res = new api.ResellerApi(mock).customers; | |
474 var arg_request = buildCustomer(); | |
475 var arg_customerAuthToken = "foo"; | |
476 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
477 var obj = new api.Customer.fromJson(json); | |
478 checkCustomer(obj); | |
479 | |
480 var path = (req.url).path; | |
481 var pathOffset = 0; | |
482 var index; | |
483 var subPart; | |
484 unittest.expect(path.substring(pathOffset, pathOffset + 18), unittest.eq
uals("/apps/reseller/v1/")); | |
485 pathOffset += 18; | |
486 unittest.expect(path.substring(pathOffset, pathOffset + 9), unittest.equ
als("customers")); | |
487 pathOffset += 9; | |
488 | |
489 var query = (req.url).query; | |
490 var queryOffset = 0; | |
491 var queryMap = {}; | |
492 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
493 parseBool(n) { | |
494 if (n == "true") return true; | |
495 if (n == "false") return false; | |
496 if (n == null) return null; | |
497 throw new core.ArgumentError("Invalid boolean: $n"); | |
498 } | |
499 if (query.length > 0) { | |
500 for (var part in query.split("&")) { | |
501 var keyvalue = part.split("="); | |
502 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
503 } | |
504 } | |
505 unittest.expect(queryMap["customerAuthToken"].first, unittest.equals(arg
_customerAuthToken)); | |
506 | |
507 | |
508 var h = { | |
509 "content-type" : "application/json; charset=utf-8", | |
510 }; | |
511 var resp = convert.JSON.encode(buildCustomer()); | |
512 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
513 }), true); | |
514 res.insert(arg_request, customerAuthToken: arg_customerAuthToken).then(uni
ttest.expectAsync(((api.Customer response) { | |
515 checkCustomer(response); | |
516 }))); | |
517 }); | |
518 | |
519 unittest.test("method--patch", () { | |
520 | |
521 var mock = new common_test.HttpServerMock(); | |
522 api.CustomersResourceApi res = new api.ResellerApi(mock).customers; | |
523 var arg_request = buildCustomer(); | |
524 var arg_customerId = "foo"; | |
525 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
526 var obj = new api.Customer.fromJson(json); | |
527 checkCustomer(obj); | |
528 | |
529 var path = (req.url).path; | |
530 var pathOffset = 0; | |
531 var index; | |
532 var subPart; | |
533 unittest.expect(path.substring(pathOffset, pathOffset + 18), unittest.eq
uals("/apps/reseller/v1/")); | |
534 pathOffset += 18; | |
535 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("customers/")); | |
536 pathOffset += 10; | |
537 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); | |
538 pathOffset = path.length; | |
539 unittest.expect(subPart, unittest.equals("$arg_customerId")); | |
540 | |
541 var query = (req.url).query; | |
542 var queryOffset = 0; | |
543 var queryMap = {}; | |
544 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
545 parseBool(n) { | |
546 if (n == "true") return true; | |
547 if (n == "false") return false; | |
548 if (n == null) return null; | |
549 throw new core.ArgumentError("Invalid boolean: $n"); | |
550 } | |
551 if (query.length > 0) { | |
552 for (var part in query.split("&")) { | |
553 var keyvalue = part.split("="); | |
554 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
555 } | |
556 } | |
557 | |
558 | |
559 var h = { | |
560 "content-type" : "application/json; charset=utf-8", | |
561 }; | |
562 var resp = convert.JSON.encode(buildCustomer()); | |
563 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
564 }), true); | |
565 res.patch(arg_request, arg_customerId).then(unittest.expectAsync(((api.Cus
tomer response) { | |
566 checkCustomer(response); | |
567 }))); | |
568 }); | |
569 | |
570 unittest.test("method--update", () { | |
571 | |
572 var mock = new common_test.HttpServerMock(); | |
573 api.CustomersResourceApi res = new api.ResellerApi(mock).customers; | |
574 var arg_request = buildCustomer(); | |
575 var arg_customerId = "foo"; | |
576 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
577 var obj = new api.Customer.fromJson(json); | |
578 checkCustomer(obj); | |
579 | |
580 var path = (req.url).path; | |
581 var pathOffset = 0; | |
582 var index; | |
583 var subPart; | |
584 unittest.expect(path.substring(pathOffset, pathOffset + 18), unittest.eq
uals("/apps/reseller/v1/")); | |
585 pathOffset += 18; | |
586 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("customers/")); | |
587 pathOffset += 10; | |
588 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); | |
589 pathOffset = path.length; | |
590 unittest.expect(subPart, unittest.equals("$arg_customerId")); | |
591 | |
592 var query = (req.url).query; | |
593 var queryOffset = 0; | |
594 var queryMap = {}; | |
595 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
596 parseBool(n) { | |
597 if (n == "true") return true; | |
598 if (n == "false") return false; | |
599 if (n == null) return null; | |
600 throw new core.ArgumentError("Invalid boolean: $n"); | |
601 } | |
602 if (query.length > 0) { | |
603 for (var part in query.split("&")) { | |
604 var keyvalue = part.split("="); | |
605 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
606 } | |
607 } | |
608 | |
609 | |
610 var h = { | |
611 "content-type" : "application/json; charset=utf-8", | |
612 }; | |
613 var resp = convert.JSON.encode(buildCustomer()); | |
614 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
615 }), true); | |
616 res.update(arg_request, arg_customerId).then(unittest.expectAsync(((api.Cu
stomer response) { | |
617 checkCustomer(response); | |
618 }))); | |
619 }); | |
620 | |
621 }); | |
622 | |
623 | |
624 unittest.group("resource-SubscriptionsResourceApi", () { | |
625 unittest.test("method--changePlan", () { | |
626 | |
627 var mock = new common_test.HttpServerMock(); | |
628 api.SubscriptionsResourceApi res = new api.ResellerApi(mock).subscriptions
; | |
629 var arg_request = buildChangePlanRequest(); | |
630 var arg_customerId = "foo"; | |
631 var arg_subscriptionId = "foo"; | |
632 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
633 var obj = new api.ChangePlanRequest.fromJson(json); | |
634 checkChangePlanRequest(obj); | |
635 | |
636 var path = (req.url).path; | |
637 var pathOffset = 0; | |
638 var index; | |
639 var subPart; | |
640 unittest.expect(path.substring(pathOffset, pathOffset + 18), unittest.eq
uals("/apps/reseller/v1/")); | |
641 pathOffset += 18; | |
642 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("customers/")); | |
643 pathOffset += 10; | |
644 index = path.indexOf("/subscriptions/", pathOffset); | |
645 unittest.expect(index >= 0, unittest.isTrue); | |
646 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
647 pathOffset = index; | |
648 unittest.expect(subPart, unittest.equals("$arg_customerId")); | |
649 unittest.expect(path.substring(pathOffset, pathOffset + 15), unittest.eq
uals("/subscriptions/")); | |
650 pathOffset += 15; | |
651 index = path.indexOf("/changePlan", pathOffset); | |
652 unittest.expect(index >= 0, unittest.isTrue); | |
653 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
654 pathOffset = index; | |
655 unittest.expect(subPart, unittest.equals("$arg_subscriptionId")); | |
656 unittest.expect(path.substring(pathOffset, pathOffset + 11), unittest.eq
uals("/changePlan")); | |
657 pathOffset += 11; | |
658 | |
659 var query = (req.url).query; | |
660 var queryOffset = 0; | |
661 var queryMap = {}; | |
662 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
663 parseBool(n) { | |
664 if (n == "true") return true; | |
665 if (n == "false") return false; | |
666 if (n == null) return null; | |
667 throw new core.ArgumentError("Invalid boolean: $n"); | |
668 } | |
669 if (query.length > 0) { | |
670 for (var part in query.split("&")) { | |
671 var keyvalue = part.split("="); | |
672 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
673 } | |
674 } | |
675 | |
676 | |
677 var h = { | |
678 "content-type" : "application/json; charset=utf-8", | |
679 }; | |
680 var resp = convert.JSON.encode(buildSubscription()); | |
681 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
682 }), true); | |
683 res.changePlan(arg_request, arg_customerId, arg_subscriptionId).then(unitt
est.expectAsync(((api.Subscription response) { | |
684 checkSubscription(response); | |
685 }))); | |
686 }); | |
687 | |
688 unittest.test("method--changeRenewalSettings", () { | |
689 | |
690 var mock = new common_test.HttpServerMock(); | |
691 api.SubscriptionsResourceApi res = new api.ResellerApi(mock).subscriptions
; | |
692 var arg_request = buildRenewalSettings(); | |
693 var arg_customerId = "foo"; | |
694 var arg_subscriptionId = "foo"; | |
695 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
696 var obj = new api.RenewalSettings.fromJson(json); | |
697 checkRenewalSettings(obj); | |
698 | |
699 var path = (req.url).path; | |
700 var pathOffset = 0; | |
701 var index; | |
702 var subPart; | |
703 unittest.expect(path.substring(pathOffset, pathOffset + 18), unittest.eq
uals("/apps/reseller/v1/")); | |
704 pathOffset += 18; | |
705 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("customers/")); | |
706 pathOffset += 10; | |
707 index = path.indexOf("/subscriptions/", pathOffset); | |
708 unittest.expect(index >= 0, unittest.isTrue); | |
709 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
710 pathOffset = index; | |
711 unittest.expect(subPart, unittest.equals("$arg_customerId")); | |
712 unittest.expect(path.substring(pathOffset, pathOffset + 15), unittest.eq
uals("/subscriptions/")); | |
713 pathOffset += 15; | |
714 index = path.indexOf("/changeRenewalSettings", pathOffset); | |
715 unittest.expect(index >= 0, unittest.isTrue); | |
716 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
717 pathOffset = index; | |
718 unittest.expect(subPart, unittest.equals("$arg_subscriptionId")); | |
719 unittest.expect(path.substring(pathOffset, pathOffset + 22), unittest.eq
uals("/changeRenewalSettings")); | |
720 pathOffset += 22; | |
721 | |
722 var query = (req.url).query; | |
723 var queryOffset = 0; | |
724 var queryMap = {}; | |
725 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
726 parseBool(n) { | |
727 if (n == "true") return true; | |
728 if (n == "false") return false; | |
729 if (n == null) return null; | |
730 throw new core.ArgumentError("Invalid boolean: $n"); | |
731 } | |
732 if (query.length > 0) { | |
733 for (var part in query.split("&")) { | |
734 var keyvalue = part.split("="); | |
735 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
736 } | |
737 } | |
738 | |
739 | |
740 var h = { | |
741 "content-type" : "application/json; charset=utf-8", | |
742 }; | |
743 var resp = convert.JSON.encode(buildSubscription()); | |
744 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
745 }), true); | |
746 res.changeRenewalSettings(arg_request, arg_customerId, arg_subscriptionId)
.then(unittest.expectAsync(((api.Subscription response) { | |
747 checkSubscription(response); | |
748 }))); | |
749 }); | |
750 | |
751 unittest.test("method--changeSeats", () { | |
752 | |
753 var mock = new common_test.HttpServerMock(); | |
754 api.SubscriptionsResourceApi res = new api.ResellerApi(mock).subscriptions
; | |
755 var arg_request = buildSeats(); | |
756 var arg_customerId = "foo"; | |
757 var arg_subscriptionId = "foo"; | |
758 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
759 var obj = new api.Seats.fromJson(json); | |
760 checkSeats(obj); | |
761 | |
762 var path = (req.url).path; | |
763 var pathOffset = 0; | |
764 var index; | |
765 var subPart; | |
766 unittest.expect(path.substring(pathOffset, pathOffset + 18), unittest.eq
uals("/apps/reseller/v1/")); | |
767 pathOffset += 18; | |
768 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("customers/")); | |
769 pathOffset += 10; | |
770 index = path.indexOf("/subscriptions/", pathOffset); | |
771 unittest.expect(index >= 0, unittest.isTrue); | |
772 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
773 pathOffset = index; | |
774 unittest.expect(subPart, unittest.equals("$arg_customerId")); | |
775 unittest.expect(path.substring(pathOffset, pathOffset + 15), unittest.eq
uals("/subscriptions/")); | |
776 pathOffset += 15; | |
777 index = path.indexOf("/changeSeats", pathOffset); | |
778 unittest.expect(index >= 0, unittest.isTrue); | |
779 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
780 pathOffset = index; | |
781 unittest.expect(subPart, unittest.equals("$arg_subscriptionId")); | |
782 unittest.expect(path.substring(pathOffset, pathOffset + 12), unittest.eq
uals("/changeSeats")); | |
783 pathOffset += 12; | |
784 | |
785 var query = (req.url).query; | |
786 var queryOffset = 0; | |
787 var queryMap = {}; | |
788 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
789 parseBool(n) { | |
790 if (n == "true") return true; | |
791 if (n == "false") return false; | |
792 if (n == null) return null; | |
793 throw new core.ArgumentError("Invalid boolean: $n"); | |
794 } | |
795 if (query.length > 0) { | |
796 for (var part in query.split("&")) { | |
797 var keyvalue = part.split("="); | |
798 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
799 } | |
800 } | |
801 | |
802 | |
803 var h = { | |
804 "content-type" : "application/json; charset=utf-8", | |
805 }; | |
806 var resp = convert.JSON.encode(buildSubscription()); | |
807 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
808 }), true); | |
809 res.changeSeats(arg_request, arg_customerId, arg_subscriptionId).then(unit
test.expectAsync(((api.Subscription response) { | |
810 checkSubscription(response); | |
811 }))); | |
812 }); | |
813 | |
814 unittest.test("method--delete", () { | |
815 | |
816 var mock = new common_test.HttpServerMock(); | |
817 api.SubscriptionsResourceApi res = new api.ResellerApi(mock).subscriptions
; | |
818 var arg_customerId = "foo"; | |
819 var arg_subscriptionId = "foo"; | |
820 var arg_deletionType = "foo"; | |
821 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
822 var path = (req.url).path; | |
823 var pathOffset = 0; | |
824 var index; | |
825 var subPart; | |
826 unittest.expect(path.substring(pathOffset, pathOffset + 18), unittest.eq
uals("/apps/reseller/v1/")); | |
827 pathOffset += 18; | |
828 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("customers/")); | |
829 pathOffset += 10; | |
830 index = path.indexOf("/subscriptions/", pathOffset); | |
831 unittest.expect(index >= 0, unittest.isTrue); | |
832 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
833 pathOffset = index; | |
834 unittest.expect(subPart, unittest.equals("$arg_customerId")); | |
835 unittest.expect(path.substring(pathOffset, pathOffset + 15), unittest.eq
uals("/subscriptions/")); | |
836 pathOffset += 15; | |
837 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); | |
838 pathOffset = path.length; | |
839 unittest.expect(subPart, unittest.equals("$arg_subscriptionId")); | |
840 | |
841 var query = (req.url).query; | |
842 var queryOffset = 0; | |
843 var queryMap = {}; | |
844 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
845 parseBool(n) { | |
846 if (n == "true") return true; | |
847 if (n == "false") return false; | |
848 if (n == null) return null; | |
849 throw new core.ArgumentError("Invalid boolean: $n"); | |
850 } | |
851 if (query.length > 0) { | |
852 for (var part in query.split("&")) { | |
853 var keyvalue = part.split("="); | |
854 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
855 } | |
856 } | |
857 unittest.expect(queryMap["deletionType"].first, unittest.equals(arg_dele
tionType)); | |
858 | |
859 | |
860 var h = { | |
861 "content-type" : "application/json; charset=utf-8", | |
862 }; | |
863 var resp = ""; | |
864 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
865 }), true); | |
866 res.delete(arg_customerId, arg_subscriptionId, arg_deletionType).then(unit
test.expectAsync((_) {})); | |
867 }); | |
868 | |
869 unittest.test("method--get", () { | |
870 | |
871 var mock = new common_test.HttpServerMock(); | |
872 api.SubscriptionsResourceApi res = new api.ResellerApi(mock).subscriptions
; | |
873 var arg_customerId = "foo"; | |
874 var arg_subscriptionId = "foo"; | |
875 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
876 var path = (req.url).path; | |
877 var pathOffset = 0; | |
878 var index; | |
879 var subPart; | |
880 unittest.expect(path.substring(pathOffset, pathOffset + 18), unittest.eq
uals("/apps/reseller/v1/")); | |
881 pathOffset += 18; | |
882 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("customers/")); | |
883 pathOffset += 10; | |
884 index = path.indexOf("/subscriptions/", pathOffset); | |
885 unittest.expect(index >= 0, unittest.isTrue); | |
886 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
887 pathOffset = index; | |
888 unittest.expect(subPart, unittest.equals("$arg_customerId")); | |
889 unittest.expect(path.substring(pathOffset, pathOffset + 15), unittest.eq
uals("/subscriptions/")); | |
890 pathOffset += 15; | |
891 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); | |
892 pathOffset = path.length; | |
893 unittest.expect(subPart, unittest.equals("$arg_subscriptionId")); | |
894 | |
895 var query = (req.url).query; | |
896 var queryOffset = 0; | |
897 var queryMap = {}; | |
898 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
899 parseBool(n) { | |
900 if (n == "true") return true; | |
901 if (n == "false") return false; | |
902 if (n == null) return null; | |
903 throw new core.ArgumentError("Invalid boolean: $n"); | |
904 } | |
905 if (query.length > 0) { | |
906 for (var part in query.split("&")) { | |
907 var keyvalue = part.split("="); | |
908 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
909 } | |
910 } | |
911 | |
912 | |
913 var h = { | |
914 "content-type" : "application/json; charset=utf-8", | |
915 }; | |
916 var resp = convert.JSON.encode(buildSubscription()); | |
917 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
918 }), true); | |
919 res.get(arg_customerId, arg_subscriptionId).then(unittest.expectAsync(((ap
i.Subscription response) { | |
920 checkSubscription(response); | |
921 }))); | |
922 }); | |
923 | |
924 unittest.test("method--insert", () { | |
925 | |
926 var mock = new common_test.HttpServerMock(); | |
927 api.SubscriptionsResourceApi res = new api.ResellerApi(mock).subscriptions
; | |
928 var arg_request = buildSubscription(); | |
929 var arg_customerId = "foo"; | |
930 var arg_customerAuthToken = "foo"; | |
931 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
932 var obj = new api.Subscription.fromJson(json); | |
933 checkSubscription(obj); | |
934 | |
935 var path = (req.url).path; | |
936 var pathOffset = 0; | |
937 var index; | |
938 var subPart; | |
939 unittest.expect(path.substring(pathOffset, pathOffset + 18), unittest.eq
uals("/apps/reseller/v1/")); | |
940 pathOffset += 18; | |
941 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("customers/")); | |
942 pathOffset += 10; | |
943 index = path.indexOf("/subscriptions", pathOffset); | |
944 unittest.expect(index >= 0, unittest.isTrue); | |
945 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
946 pathOffset = index; | |
947 unittest.expect(subPart, unittest.equals("$arg_customerId")); | |
948 unittest.expect(path.substring(pathOffset, pathOffset + 14), unittest.eq
uals("/subscriptions")); | |
949 pathOffset += 14; | |
950 | |
951 var query = (req.url).query; | |
952 var queryOffset = 0; | |
953 var queryMap = {}; | |
954 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
955 parseBool(n) { | |
956 if (n == "true") return true; | |
957 if (n == "false") return false; | |
958 if (n == null) return null; | |
959 throw new core.ArgumentError("Invalid boolean: $n"); | |
960 } | |
961 if (query.length > 0) { | |
962 for (var part in query.split("&")) { | |
963 var keyvalue = part.split("="); | |
964 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
965 } | |
966 } | |
967 unittest.expect(queryMap["customerAuthToken"].first, unittest.equals(arg
_customerAuthToken)); | |
968 | |
969 | |
970 var h = { | |
971 "content-type" : "application/json; charset=utf-8", | |
972 }; | |
973 var resp = convert.JSON.encode(buildSubscription()); | |
974 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
975 }), true); | |
976 res.insert(arg_request, arg_customerId, customerAuthToken: arg_customerAut
hToken).then(unittest.expectAsync(((api.Subscription response) { | |
977 checkSubscription(response); | |
978 }))); | |
979 }); | |
980 | |
981 unittest.test("method--list", () { | |
982 | |
983 var mock = new common_test.HttpServerMock(); | |
984 api.SubscriptionsResourceApi res = new api.ResellerApi(mock).subscriptions
; | |
985 var arg_customerAuthToken = "foo"; | |
986 var arg_customerId = "foo"; | |
987 var arg_customerNamePrefix = "foo"; | |
988 var arg_maxResults = 42; | |
989 var arg_pageToken = "foo"; | |
990 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
991 var path = (req.url).path; | |
992 var pathOffset = 0; | |
993 var index; | |
994 var subPart; | |
995 unittest.expect(path.substring(pathOffset, pathOffset + 18), unittest.eq
uals("/apps/reseller/v1/")); | |
996 pathOffset += 18; | |
997 unittest.expect(path.substring(pathOffset, pathOffset + 13), unittest.eq
uals("subscriptions")); | |
998 pathOffset += 13; | |
999 | |
1000 var query = (req.url).query; | |
1001 var queryOffset = 0; | |
1002 var queryMap = {}; | |
1003 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
1004 parseBool(n) { | |
1005 if (n == "true") return true; | |
1006 if (n == "false") return false; | |
1007 if (n == null) return null; | |
1008 throw new core.ArgumentError("Invalid boolean: $n"); | |
1009 } | |
1010 if (query.length > 0) { | |
1011 for (var part in query.split("&")) { | |
1012 var keyvalue = part.split("="); | |
1013 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
1014 } | |
1015 } | |
1016 unittest.expect(queryMap["customerAuthToken"].first, unittest.equals(arg
_customerAuthToken)); | |
1017 unittest.expect(queryMap["customerId"].first, unittest.equals(arg_custom
erId)); | |
1018 unittest.expect(queryMap["customerNamePrefix"].first, unittest.equals(ar
g_customerNamePrefix)); | |
1019 unittest.expect(core.int.parse(queryMap["maxResults"].first), unittest.e
quals(arg_maxResults)); | |
1020 unittest.expect(queryMap["pageToken"].first, unittest.equals(arg_pageTok
en)); | |
1021 | |
1022 | |
1023 var h = { | |
1024 "content-type" : "application/json; charset=utf-8", | |
1025 }; | |
1026 var resp = convert.JSON.encode(buildSubscriptions()); | |
1027 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
1028 }), true); | |
1029 res.list(customerAuthToken: arg_customerAuthToken, customerId: arg_custome
rId, customerNamePrefix: arg_customerNamePrefix, maxResults: arg_maxResults, pag
eToken: arg_pageToken).then(unittest.expectAsync(((api.Subscriptions response) { | |
1030 checkSubscriptions(response); | |
1031 }))); | |
1032 }); | |
1033 | |
1034 unittest.test("method--startPaidService", () { | |
1035 | |
1036 var mock = new common_test.HttpServerMock(); | |
1037 api.SubscriptionsResourceApi res = new api.ResellerApi(mock).subscriptions
; | |
1038 var arg_customerId = "foo"; | |
1039 var arg_subscriptionId = "foo"; | |
1040 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
1041 var path = (req.url).path; | |
1042 var pathOffset = 0; | |
1043 var index; | |
1044 var subPart; | |
1045 unittest.expect(path.substring(pathOffset, pathOffset + 18), unittest.eq
uals("/apps/reseller/v1/")); | |
1046 pathOffset += 18; | |
1047 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("customers/")); | |
1048 pathOffset += 10; | |
1049 index = path.indexOf("/subscriptions/", pathOffset); | |
1050 unittest.expect(index >= 0, unittest.isTrue); | |
1051 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1052 pathOffset = index; | |
1053 unittest.expect(subPart, unittest.equals("$arg_customerId")); | |
1054 unittest.expect(path.substring(pathOffset, pathOffset + 15), unittest.eq
uals("/subscriptions/")); | |
1055 pathOffset += 15; | |
1056 index = path.indexOf("/startPaidService", pathOffset); | |
1057 unittest.expect(index >= 0, unittest.isTrue); | |
1058 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1059 pathOffset = index; | |
1060 unittest.expect(subPart, unittest.equals("$arg_subscriptionId")); | |
1061 unittest.expect(path.substring(pathOffset, pathOffset + 17), unittest.eq
uals("/startPaidService")); | |
1062 pathOffset += 17; | |
1063 | |
1064 var query = (req.url).query; | |
1065 var queryOffset = 0; | |
1066 var queryMap = {}; | |
1067 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
1068 parseBool(n) { | |
1069 if (n == "true") return true; | |
1070 if (n == "false") return false; | |
1071 if (n == null) return null; | |
1072 throw new core.ArgumentError("Invalid boolean: $n"); | |
1073 } | |
1074 if (query.length > 0) { | |
1075 for (var part in query.split("&")) { | |
1076 var keyvalue = part.split("="); | |
1077 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
1078 } | |
1079 } | |
1080 | |
1081 | |
1082 var h = { | |
1083 "content-type" : "application/json; charset=utf-8", | |
1084 }; | |
1085 var resp = convert.JSON.encode(buildSubscription()); | |
1086 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
1087 }), true); | |
1088 res.startPaidService(arg_customerId, arg_subscriptionId).then(unittest.exp
ectAsync(((api.Subscription response) { | |
1089 checkSubscription(response); | |
1090 }))); | |
1091 }); | |
1092 | |
1093 }); | |
1094 | |
1095 | |
1096 } | |
1097 | |
OLD | NEW |