| OLD | NEW |
| 1 library googleapis.reseller.v1.test; | 1 library googleapis.reseller.v1.test; |
| 2 | 2 |
| 3 import "dart:core" as core; | 3 import "dart:core" as core; |
| 4 import "dart:collection" as collection; | 4 import "dart:collection" as collection; |
| 5 import "dart:async" as async; | 5 import "dart:async" as async; |
| 6 import "dart:convert" as convert; | 6 import "dart:convert" as convert; |
| 7 | 7 |
| 8 import 'package:http/http.dart' as http; | 8 import 'package:http/http.dart' as http; |
| 9 import 'package:http/testing.dart' as http_testing; | 9 import 'package:http/testing.dart' as http_testing; |
| 10 import 'package:unittest/unittest.dart' as unittest; | 10 import 'package:unittest/unittest.dart' as unittest; |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 } | 129 } |
| 130 buildCounterRenewalSettings--; | 130 buildCounterRenewalSettings--; |
| 131 } | 131 } |
| 132 | 132 |
| 133 core.int buildCounterSeats = 0; | 133 core.int buildCounterSeats = 0; |
| 134 buildSeats() { | 134 buildSeats() { |
| 135 var o = new api.Seats(); | 135 var o = new api.Seats(); |
| 136 buildCounterSeats++; | 136 buildCounterSeats++; |
| 137 if (buildCounterSeats < 3) { | 137 if (buildCounterSeats < 3) { |
| 138 o.kind = "foo"; | 138 o.kind = "foo"; |
| 139 o.licensedNumberOfSeats = 42; |
| 139 o.maximumNumberOfSeats = 42; | 140 o.maximumNumberOfSeats = 42; |
| 140 o.numberOfSeats = 42; | 141 o.numberOfSeats = 42; |
| 141 } | 142 } |
| 142 buildCounterSeats--; | 143 buildCounterSeats--; |
| 143 return o; | 144 return o; |
| 144 } | 145 } |
| 145 | 146 |
| 146 checkSeats(api.Seats o) { | 147 checkSeats(api.Seats o) { |
| 147 buildCounterSeats++; | 148 buildCounterSeats++; |
| 148 if (buildCounterSeats < 3) { | 149 if (buildCounterSeats < 3) { |
| 149 unittest.expect(o.kind, unittest.equals('foo')); | 150 unittest.expect(o.kind, unittest.equals('foo')); |
| 151 unittest.expect(o.licensedNumberOfSeats, unittest.equals(42)); |
| 150 unittest.expect(o.maximumNumberOfSeats, unittest.equals(42)); | 152 unittest.expect(o.maximumNumberOfSeats, unittest.equals(42)); |
| 151 unittest.expect(o.numberOfSeats, unittest.equals(42)); | 153 unittest.expect(o.numberOfSeats, unittest.equals(42)); |
| 152 } | 154 } |
| 153 buildCounterSeats--; | 155 buildCounterSeats--; |
| 154 } | 156 } |
| 155 | 157 |
| 156 core.int buildCounterSubscriptionPlanCommitmentInterval = 0; | 158 core.int buildCounterSubscriptionPlanCommitmentInterval = 0; |
| 157 buildSubscriptionPlanCommitmentInterval() { | 159 buildSubscriptionPlanCommitmentInterval() { |
| 158 var o = new api.SubscriptionPlanCommitmentInterval(); | 160 var o = new api.SubscriptionPlanCommitmentInterval(); |
| 159 buildCounterSubscriptionPlanCommitmentInterval++; | 161 buildCounterSubscriptionPlanCommitmentInterval++; |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 checkSeats(o.seats); | 277 checkSeats(o.seats); |
| 276 unittest.expect(o.skuId, unittest.equals('foo')); | 278 unittest.expect(o.skuId, unittest.equals('foo')); |
| 277 unittest.expect(o.status, unittest.equals('foo')); | 279 unittest.expect(o.status, unittest.equals('foo')); |
| 278 unittest.expect(o.subscriptionId, unittest.equals('foo')); | 280 unittest.expect(o.subscriptionId, unittest.equals('foo')); |
| 279 checkSubscriptionTransferInfo(o.transferInfo); | 281 checkSubscriptionTransferInfo(o.transferInfo); |
| 280 checkSubscriptionTrialSettings(o.trialSettings); | 282 checkSubscriptionTrialSettings(o.trialSettings); |
| 281 } | 283 } |
| 282 buildCounterSubscription--; | 284 buildCounterSubscription--; |
| 283 } | 285 } |
| 284 | 286 |
| 285 buildUnnamed629() { | 287 buildUnnamed970() { |
| 286 var o = new core.List<api.Subscription>(); | 288 var o = new core.List<api.Subscription>(); |
| 287 o.add(buildSubscription()); | 289 o.add(buildSubscription()); |
| 288 o.add(buildSubscription()); | 290 o.add(buildSubscription()); |
| 289 return o; | 291 return o; |
| 290 } | 292 } |
| 291 | 293 |
| 292 checkUnnamed629(core.List<api.Subscription> o) { | 294 checkUnnamed970(core.List<api.Subscription> o) { |
| 293 unittest.expect(o, unittest.hasLength(2)); | 295 unittest.expect(o, unittest.hasLength(2)); |
| 294 checkSubscription(o[0]); | 296 checkSubscription(o[0]); |
| 295 checkSubscription(o[1]); | 297 checkSubscription(o[1]); |
| 296 } | 298 } |
| 297 | 299 |
| 298 core.int buildCounterSubscriptions = 0; | 300 core.int buildCounterSubscriptions = 0; |
| 299 buildSubscriptions() { | 301 buildSubscriptions() { |
| 300 var o = new api.Subscriptions(); | 302 var o = new api.Subscriptions(); |
| 301 buildCounterSubscriptions++; | 303 buildCounterSubscriptions++; |
| 302 if (buildCounterSubscriptions < 3) { | 304 if (buildCounterSubscriptions < 3) { |
| 303 o.kind = "foo"; | 305 o.kind = "foo"; |
| 304 o.nextPageToken = "foo"; | 306 o.nextPageToken = "foo"; |
| 305 o.subscriptions = buildUnnamed629(); | 307 o.subscriptions = buildUnnamed970(); |
| 306 } | 308 } |
| 307 buildCounterSubscriptions--; | 309 buildCounterSubscriptions--; |
| 308 return o; | 310 return o; |
| 309 } | 311 } |
| 310 | 312 |
| 311 checkSubscriptions(api.Subscriptions o) { | 313 checkSubscriptions(api.Subscriptions o) { |
| 312 buildCounterSubscriptions++; | 314 buildCounterSubscriptions++; |
| 313 if (buildCounterSubscriptions < 3) { | 315 if (buildCounterSubscriptions < 3) { |
| 314 unittest.expect(o.kind, unittest.equals('foo')); | 316 unittest.expect(o.kind, unittest.equals('foo')); |
| 315 unittest.expect(o.nextPageToken, unittest.equals('foo')); | 317 unittest.expect(o.nextPageToken, unittest.equals('foo')); |
| 316 checkUnnamed629(o.subscriptions); | 318 checkUnnamed970(o.subscriptions); |
| 317 } | 319 } |
| 318 buildCounterSubscriptions--; | 320 buildCounterSubscriptions--; |
| 319 } | 321 } |
| 320 | 322 |
| 321 | 323 |
| 322 main() { | 324 main() { |
| 323 unittest.group("obj-schema-Address", () { | 325 unittest.group("obj-schema-Address", () { |
| 324 unittest.test("to-json--from-json", () { | 326 unittest.test("to-json--from-json", () { |
| 325 var o = buildAddress(); | 327 var o = buildAddress(); |
| 326 var od = new api.Address.fromJson(o.toJson()); | 328 var od = new api.Address.fromJson(o.toJson()); |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 }), true); | 625 }), true); |
| 624 res.update(arg_request, arg_customerId).then(unittest.expectAsync(((api.Cu
stomer response) { | 626 res.update(arg_request, arg_customerId).then(unittest.expectAsync(((api.Cu
stomer response) { |
| 625 checkCustomer(response); | 627 checkCustomer(response); |
| 626 }))); | 628 }))); |
| 627 }); | 629 }); |
| 628 | 630 |
| 629 }); | 631 }); |
| 630 | 632 |
| 631 | 633 |
| 632 unittest.group("resource-SubscriptionsResourceApi", () { | 634 unittest.group("resource-SubscriptionsResourceApi", () { |
| 635 unittest.test("method--activate", () { |
| 636 |
| 637 var mock = new common_test.HttpServerMock(); |
| 638 api.SubscriptionsResourceApi res = new api.ResellerApi(mock).subscriptions
; |
| 639 var arg_customerId = "foo"; |
| 640 var arg_subscriptionId = "foo"; |
| 641 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| 642 var path = (req.url).path; |
| 643 var pathOffset = 0; |
| 644 var index; |
| 645 var subPart; |
| 646 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
| 647 pathOffset += 1; |
| 648 unittest.expect(path.substring(pathOffset, pathOffset + 17), unittest.eq
uals("apps/reseller/v1/")); |
| 649 pathOffset += 17; |
| 650 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("customers/")); |
| 651 pathOffset += 10; |
| 652 index = path.indexOf("/subscriptions/", pathOffset); |
| 653 unittest.expect(index >= 0, unittest.isTrue); |
| 654 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); |
| 655 pathOffset = index; |
| 656 unittest.expect(subPart, unittest.equals("$arg_customerId")); |
| 657 unittest.expect(path.substring(pathOffset, pathOffset + 15), unittest.eq
uals("/subscriptions/")); |
| 658 pathOffset += 15; |
| 659 index = path.indexOf("/activate", pathOffset); |
| 660 unittest.expect(index >= 0, unittest.isTrue); |
| 661 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); |
| 662 pathOffset = index; |
| 663 unittest.expect(subPart, unittest.equals("$arg_subscriptionId")); |
| 664 unittest.expect(path.substring(pathOffset, pathOffset + 9), unittest.equ
als("/activate")); |
| 665 pathOffset += 9; |
| 666 |
| 667 var query = (req.url).query; |
| 668 var queryOffset = 0; |
| 669 var queryMap = {}; |
| 670 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 671 parseBool(n) { |
| 672 if (n == "true") return true; |
| 673 if (n == "false") return false; |
| 674 if (n == null) return null; |
| 675 throw new core.ArgumentError("Invalid boolean: $n"); |
| 676 } |
| 677 if (query.length > 0) { |
| 678 for (var part in query.split("&")) { |
| 679 var keyvalue = part.split("="); |
| 680 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
| 681 } |
| 682 } |
| 683 |
| 684 |
| 685 var h = { |
| 686 "content-type" : "application/json; charset=utf-8", |
| 687 }; |
| 688 var resp = convert.JSON.encode(buildSubscription()); |
| 689 return new async.Future.value(common_test.stringResponse(200, h, resp)); |
| 690 }), true); |
| 691 res.activate(arg_customerId, arg_subscriptionId).then(unittest.expectAsync
(((api.Subscription response) { |
| 692 checkSubscription(response); |
| 693 }))); |
| 694 }); |
| 695 |
| 633 unittest.test("method--changePlan", () { | 696 unittest.test("method--changePlan", () { |
| 634 | 697 |
| 635 var mock = new common_test.HttpServerMock(); | 698 var mock = new common_test.HttpServerMock(); |
| 636 api.SubscriptionsResourceApi res = new api.ResellerApi(mock).subscriptions
; | 699 api.SubscriptionsResourceApi res = new api.ResellerApi(mock).subscriptions
; |
| 637 var arg_request = buildChangePlanRequest(); | 700 var arg_request = buildChangePlanRequest(); |
| 638 var arg_customerId = "foo"; | 701 var arg_customerId = "foo"; |
| 639 var arg_subscriptionId = "foo"; | 702 var arg_subscriptionId = "foo"; |
| 640 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | 703 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| 641 var obj = new api.ChangePlanRequest.fromJson(json); | 704 var obj = new api.ChangePlanRequest.fromJson(json); |
| 642 checkChangePlanRequest(obj); | 705 checkChangePlanRequest(obj); |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1107 "content-type" : "application/json; charset=utf-8", | 1170 "content-type" : "application/json; charset=utf-8", |
| 1108 }; | 1171 }; |
| 1109 var resp = convert.JSON.encode(buildSubscription()); | 1172 var resp = convert.JSON.encode(buildSubscription()); |
| 1110 return new async.Future.value(common_test.stringResponse(200, h, resp)); | 1173 return new async.Future.value(common_test.stringResponse(200, h, resp)); |
| 1111 }), true); | 1174 }), true); |
| 1112 res.startPaidService(arg_customerId, arg_subscriptionId).then(unittest.exp
ectAsync(((api.Subscription response) { | 1175 res.startPaidService(arg_customerId, arg_subscriptionId).then(unittest.exp
ectAsync(((api.Subscription response) { |
| 1113 checkSubscription(response); | 1176 checkSubscription(response); |
| 1114 }))); | 1177 }))); |
| 1115 }); | 1178 }); |
| 1116 | 1179 |
| 1180 unittest.test("method--suspend", () { |
| 1181 |
| 1182 var mock = new common_test.HttpServerMock(); |
| 1183 api.SubscriptionsResourceApi res = new api.ResellerApi(mock).subscriptions
; |
| 1184 var arg_customerId = "foo"; |
| 1185 var arg_subscriptionId = "foo"; |
| 1186 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| 1187 var path = (req.url).path; |
| 1188 var pathOffset = 0; |
| 1189 var index; |
| 1190 var subPart; |
| 1191 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
| 1192 pathOffset += 1; |
| 1193 unittest.expect(path.substring(pathOffset, pathOffset + 17), unittest.eq
uals("apps/reseller/v1/")); |
| 1194 pathOffset += 17; |
| 1195 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("customers/")); |
| 1196 pathOffset += 10; |
| 1197 index = path.indexOf("/subscriptions/", pathOffset); |
| 1198 unittest.expect(index >= 0, unittest.isTrue); |
| 1199 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); |
| 1200 pathOffset = index; |
| 1201 unittest.expect(subPart, unittest.equals("$arg_customerId")); |
| 1202 unittest.expect(path.substring(pathOffset, pathOffset + 15), unittest.eq
uals("/subscriptions/")); |
| 1203 pathOffset += 15; |
| 1204 index = path.indexOf("/suspend", pathOffset); |
| 1205 unittest.expect(index >= 0, unittest.isTrue); |
| 1206 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); |
| 1207 pathOffset = index; |
| 1208 unittest.expect(subPart, unittest.equals("$arg_subscriptionId")); |
| 1209 unittest.expect(path.substring(pathOffset, pathOffset + 8), unittest.equ
als("/suspend")); |
| 1210 pathOffset += 8; |
| 1211 |
| 1212 var query = (req.url).query; |
| 1213 var queryOffset = 0; |
| 1214 var queryMap = {}; |
| 1215 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 1216 parseBool(n) { |
| 1217 if (n == "true") return true; |
| 1218 if (n == "false") return false; |
| 1219 if (n == null) return null; |
| 1220 throw new core.ArgumentError("Invalid boolean: $n"); |
| 1221 } |
| 1222 if (query.length > 0) { |
| 1223 for (var part in query.split("&")) { |
| 1224 var keyvalue = part.split("="); |
| 1225 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
| 1226 } |
| 1227 } |
| 1228 |
| 1229 |
| 1230 var h = { |
| 1231 "content-type" : "application/json; charset=utf-8", |
| 1232 }; |
| 1233 var resp = convert.JSON.encode(buildSubscription()); |
| 1234 return new async.Future.value(common_test.stringResponse(200, h, resp)); |
| 1235 }), true); |
| 1236 res.suspend(arg_customerId, arg_subscriptionId).then(unittest.expectAsync(
((api.Subscription response) { |
| 1237 checkSubscription(response); |
| 1238 }))); |
| 1239 }); |
| 1240 |
| 1117 }); | 1241 }); |
| 1118 | 1242 |
| 1119 | 1243 |
| 1120 } | 1244 } |
| 1121 | 1245 |
| OLD | NEW |