OLD | NEW |
(Empty) | |
| 1 library googleapis_beta.container.v1beta1.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_beta/common/common.dart' as common; |
| 12 import 'package:googleapis_beta/src/common_internal.dart' as common_internal; |
| 13 import '../common/common_internal_test.dart' as common_test; |
| 14 |
| 15 import 'package:googleapis_beta/container/v1beta1.dart' as api; |
| 16 |
| 17 |
| 18 |
| 19 core.int buildCounterCluster = 0; |
| 20 buildCluster() { |
| 21 var o = new api.Cluster(); |
| 22 buildCounterCluster++; |
| 23 if (buildCounterCluster < 3) { |
| 24 o.clusterApiVersion = "foo"; |
| 25 o.containerIpv4Cidr = "foo"; |
| 26 o.creationTimestamp = "foo"; |
| 27 o.description = "foo"; |
| 28 o.endpoint = "foo"; |
| 29 o.masterAuth = buildMasterAuth(); |
| 30 o.name = "foo"; |
| 31 o.nodeConfig = buildNodeConfig(); |
| 32 o.nodeRoutingPrefixSize = 42; |
| 33 o.numNodes = 42; |
| 34 o.servicesIpv4Cidr = "foo"; |
| 35 o.status = "foo"; |
| 36 o.statusMessage = "foo"; |
| 37 o.zone = "foo"; |
| 38 } |
| 39 buildCounterCluster--; |
| 40 return o; |
| 41 } |
| 42 |
| 43 checkCluster(api.Cluster o) { |
| 44 buildCounterCluster++; |
| 45 if (buildCounterCluster < 3) { |
| 46 unittest.expect(o.clusterApiVersion, unittest.equals('foo')); |
| 47 unittest.expect(o.containerIpv4Cidr, unittest.equals('foo')); |
| 48 unittest.expect(o.creationTimestamp, unittest.equals('foo')); |
| 49 unittest.expect(o.description, unittest.equals('foo')); |
| 50 unittest.expect(o.endpoint, unittest.equals('foo')); |
| 51 checkMasterAuth(o.masterAuth); |
| 52 unittest.expect(o.name, unittest.equals('foo')); |
| 53 checkNodeConfig(o.nodeConfig); |
| 54 unittest.expect(o.nodeRoutingPrefixSize, unittest.equals(42)); |
| 55 unittest.expect(o.numNodes, unittest.equals(42)); |
| 56 unittest.expect(o.servicesIpv4Cidr, unittest.equals('foo')); |
| 57 unittest.expect(o.status, unittest.equals('foo')); |
| 58 unittest.expect(o.statusMessage, unittest.equals('foo')); |
| 59 unittest.expect(o.zone, unittest.equals('foo')); |
| 60 } |
| 61 buildCounterCluster--; |
| 62 } |
| 63 |
| 64 core.int buildCounterCreateClusterRequest = 0; |
| 65 buildCreateClusterRequest() { |
| 66 var o = new api.CreateClusterRequest(); |
| 67 buildCounterCreateClusterRequest++; |
| 68 if (buildCounterCreateClusterRequest < 3) { |
| 69 o.cluster = buildCluster(); |
| 70 } |
| 71 buildCounterCreateClusterRequest--; |
| 72 return o; |
| 73 } |
| 74 |
| 75 checkCreateClusterRequest(api.CreateClusterRequest o) { |
| 76 buildCounterCreateClusterRequest++; |
| 77 if (buildCounterCreateClusterRequest < 3) { |
| 78 checkCluster(o.cluster); |
| 79 } |
| 80 buildCounterCreateClusterRequest--; |
| 81 } |
| 82 |
| 83 buildUnnamed1179() { |
| 84 var o = new core.List<api.Cluster>(); |
| 85 o.add(buildCluster()); |
| 86 o.add(buildCluster()); |
| 87 return o; |
| 88 } |
| 89 |
| 90 checkUnnamed1179(core.List<api.Cluster> o) { |
| 91 unittest.expect(o, unittest.hasLength(2)); |
| 92 checkCluster(o[0]); |
| 93 checkCluster(o[1]); |
| 94 } |
| 95 |
| 96 core.int buildCounterListAggregatedClustersResponse = 0; |
| 97 buildListAggregatedClustersResponse() { |
| 98 var o = new api.ListAggregatedClustersResponse(); |
| 99 buildCounterListAggregatedClustersResponse++; |
| 100 if (buildCounterListAggregatedClustersResponse < 3) { |
| 101 o.clusters = buildUnnamed1179(); |
| 102 } |
| 103 buildCounterListAggregatedClustersResponse--; |
| 104 return o; |
| 105 } |
| 106 |
| 107 checkListAggregatedClustersResponse(api.ListAggregatedClustersResponse o) { |
| 108 buildCounterListAggregatedClustersResponse++; |
| 109 if (buildCounterListAggregatedClustersResponse < 3) { |
| 110 checkUnnamed1179(o.clusters); |
| 111 } |
| 112 buildCounterListAggregatedClustersResponse--; |
| 113 } |
| 114 |
| 115 buildUnnamed1180() { |
| 116 var o = new core.List<api.Operation>(); |
| 117 o.add(buildOperation()); |
| 118 o.add(buildOperation()); |
| 119 return o; |
| 120 } |
| 121 |
| 122 checkUnnamed1180(core.List<api.Operation> o) { |
| 123 unittest.expect(o, unittest.hasLength(2)); |
| 124 checkOperation(o[0]); |
| 125 checkOperation(o[1]); |
| 126 } |
| 127 |
| 128 core.int buildCounterListAggregatedOperationsResponse = 0; |
| 129 buildListAggregatedOperationsResponse() { |
| 130 var o = new api.ListAggregatedOperationsResponse(); |
| 131 buildCounterListAggregatedOperationsResponse++; |
| 132 if (buildCounterListAggregatedOperationsResponse < 3) { |
| 133 o.operations = buildUnnamed1180(); |
| 134 } |
| 135 buildCounterListAggregatedOperationsResponse--; |
| 136 return o; |
| 137 } |
| 138 |
| 139 checkListAggregatedOperationsResponse(api.ListAggregatedOperationsResponse o) { |
| 140 buildCounterListAggregatedOperationsResponse++; |
| 141 if (buildCounterListAggregatedOperationsResponse < 3) { |
| 142 checkUnnamed1180(o.operations); |
| 143 } |
| 144 buildCounterListAggregatedOperationsResponse--; |
| 145 } |
| 146 |
| 147 buildUnnamed1181() { |
| 148 var o = new core.List<api.Cluster>(); |
| 149 o.add(buildCluster()); |
| 150 o.add(buildCluster()); |
| 151 return o; |
| 152 } |
| 153 |
| 154 checkUnnamed1181(core.List<api.Cluster> o) { |
| 155 unittest.expect(o, unittest.hasLength(2)); |
| 156 checkCluster(o[0]); |
| 157 checkCluster(o[1]); |
| 158 } |
| 159 |
| 160 core.int buildCounterListClustersResponse = 0; |
| 161 buildListClustersResponse() { |
| 162 var o = new api.ListClustersResponse(); |
| 163 buildCounterListClustersResponse++; |
| 164 if (buildCounterListClustersResponse < 3) { |
| 165 o.clusters = buildUnnamed1181(); |
| 166 } |
| 167 buildCounterListClustersResponse--; |
| 168 return o; |
| 169 } |
| 170 |
| 171 checkListClustersResponse(api.ListClustersResponse o) { |
| 172 buildCounterListClustersResponse++; |
| 173 if (buildCounterListClustersResponse < 3) { |
| 174 checkUnnamed1181(o.clusters); |
| 175 } |
| 176 buildCounterListClustersResponse--; |
| 177 } |
| 178 |
| 179 buildUnnamed1182() { |
| 180 var o = new core.List<api.Operation>(); |
| 181 o.add(buildOperation()); |
| 182 o.add(buildOperation()); |
| 183 return o; |
| 184 } |
| 185 |
| 186 checkUnnamed1182(core.List<api.Operation> o) { |
| 187 unittest.expect(o, unittest.hasLength(2)); |
| 188 checkOperation(o[0]); |
| 189 checkOperation(o[1]); |
| 190 } |
| 191 |
| 192 core.int buildCounterListOperationsResponse = 0; |
| 193 buildListOperationsResponse() { |
| 194 var o = new api.ListOperationsResponse(); |
| 195 buildCounterListOperationsResponse++; |
| 196 if (buildCounterListOperationsResponse < 3) { |
| 197 o.operations = buildUnnamed1182(); |
| 198 } |
| 199 buildCounterListOperationsResponse--; |
| 200 return o; |
| 201 } |
| 202 |
| 203 checkListOperationsResponse(api.ListOperationsResponse o) { |
| 204 buildCounterListOperationsResponse++; |
| 205 if (buildCounterListOperationsResponse < 3) { |
| 206 checkUnnamed1182(o.operations); |
| 207 } |
| 208 buildCounterListOperationsResponse--; |
| 209 } |
| 210 |
| 211 core.int buildCounterMasterAuth = 0; |
| 212 buildMasterAuth() { |
| 213 var o = new api.MasterAuth(); |
| 214 buildCounterMasterAuth++; |
| 215 if (buildCounterMasterAuth < 3) { |
| 216 o.password = "foo"; |
| 217 o.user = "foo"; |
| 218 } |
| 219 buildCounterMasterAuth--; |
| 220 return o; |
| 221 } |
| 222 |
| 223 checkMasterAuth(api.MasterAuth o) { |
| 224 buildCounterMasterAuth++; |
| 225 if (buildCounterMasterAuth < 3) { |
| 226 unittest.expect(o.password, unittest.equals('foo')); |
| 227 unittest.expect(o.user, unittest.equals('foo')); |
| 228 } |
| 229 buildCounterMasterAuth--; |
| 230 } |
| 231 |
| 232 core.int buildCounterNodeConfig = 0; |
| 233 buildNodeConfig() { |
| 234 var o = new api.NodeConfig(); |
| 235 buildCounterNodeConfig++; |
| 236 if (buildCounterNodeConfig < 3) { |
| 237 o.machineType = "foo"; |
| 238 o.sourceImage = "foo"; |
| 239 } |
| 240 buildCounterNodeConfig--; |
| 241 return o; |
| 242 } |
| 243 |
| 244 checkNodeConfig(api.NodeConfig o) { |
| 245 buildCounterNodeConfig++; |
| 246 if (buildCounterNodeConfig < 3) { |
| 247 unittest.expect(o.machineType, unittest.equals('foo')); |
| 248 unittest.expect(o.sourceImage, unittest.equals('foo')); |
| 249 } |
| 250 buildCounterNodeConfig--; |
| 251 } |
| 252 |
| 253 core.int buildCounterOperation = 0; |
| 254 buildOperation() { |
| 255 var o = new api.Operation(); |
| 256 buildCounterOperation++; |
| 257 if (buildCounterOperation < 3) { |
| 258 o.errorMessage = "foo"; |
| 259 o.name = "foo"; |
| 260 o.operationType = "foo"; |
| 261 o.status = "foo"; |
| 262 o.target = "foo"; |
| 263 o.zone = "foo"; |
| 264 } |
| 265 buildCounterOperation--; |
| 266 return o; |
| 267 } |
| 268 |
| 269 checkOperation(api.Operation o) { |
| 270 buildCounterOperation++; |
| 271 if (buildCounterOperation < 3) { |
| 272 unittest.expect(o.errorMessage, unittest.equals('foo')); |
| 273 unittest.expect(o.name, unittest.equals('foo')); |
| 274 unittest.expect(o.operationType, unittest.equals('foo')); |
| 275 unittest.expect(o.status, unittest.equals('foo')); |
| 276 unittest.expect(o.target, unittest.equals('foo')); |
| 277 unittest.expect(o.zone, unittest.equals('foo')); |
| 278 } |
| 279 buildCounterOperation--; |
| 280 } |
| 281 |
| 282 |
| 283 main() { |
| 284 unittest.group("obj-schema-Cluster", () { |
| 285 unittest.test("to-json--from-json", () { |
| 286 var o = buildCluster(); |
| 287 var od = new api.Cluster.fromJson(o.toJson()); |
| 288 checkCluster(od); |
| 289 }); |
| 290 }); |
| 291 |
| 292 |
| 293 unittest.group("obj-schema-CreateClusterRequest", () { |
| 294 unittest.test("to-json--from-json", () { |
| 295 var o = buildCreateClusterRequest(); |
| 296 var od = new api.CreateClusterRequest.fromJson(o.toJson()); |
| 297 checkCreateClusterRequest(od); |
| 298 }); |
| 299 }); |
| 300 |
| 301 |
| 302 unittest.group("obj-schema-ListAggregatedClustersResponse", () { |
| 303 unittest.test("to-json--from-json", () { |
| 304 var o = buildListAggregatedClustersResponse(); |
| 305 var od = new api.ListAggregatedClustersResponse.fromJson(o.toJson()); |
| 306 checkListAggregatedClustersResponse(od); |
| 307 }); |
| 308 }); |
| 309 |
| 310 |
| 311 unittest.group("obj-schema-ListAggregatedOperationsResponse", () { |
| 312 unittest.test("to-json--from-json", () { |
| 313 var o = buildListAggregatedOperationsResponse(); |
| 314 var od = new api.ListAggregatedOperationsResponse.fromJson(o.toJson()); |
| 315 checkListAggregatedOperationsResponse(od); |
| 316 }); |
| 317 }); |
| 318 |
| 319 |
| 320 unittest.group("obj-schema-ListClustersResponse", () { |
| 321 unittest.test("to-json--from-json", () { |
| 322 var o = buildListClustersResponse(); |
| 323 var od = new api.ListClustersResponse.fromJson(o.toJson()); |
| 324 checkListClustersResponse(od); |
| 325 }); |
| 326 }); |
| 327 |
| 328 |
| 329 unittest.group("obj-schema-ListOperationsResponse", () { |
| 330 unittest.test("to-json--from-json", () { |
| 331 var o = buildListOperationsResponse(); |
| 332 var od = new api.ListOperationsResponse.fromJson(o.toJson()); |
| 333 checkListOperationsResponse(od); |
| 334 }); |
| 335 }); |
| 336 |
| 337 |
| 338 unittest.group("obj-schema-MasterAuth", () { |
| 339 unittest.test("to-json--from-json", () { |
| 340 var o = buildMasterAuth(); |
| 341 var od = new api.MasterAuth.fromJson(o.toJson()); |
| 342 checkMasterAuth(od); |
| 343 }); |
| 344 }); |
| 345 |
| 346 |
| 347 unittest.group("obj-schema-NodeConfig", () { |
| 348 unittest.test("to-json--from-json", () { |
| 349 var o = buildNodeConfig(); |
| 350 var od = new api.NodeConfig.fromJson(o.toJson()); |
| 351 checkNodeConfig(od); |
| 352 }); |
| 353 }); |
| 354 |
| 355 |
| 356 unittest.group("obj-schema-Operation", () { |
| 357 unittest.test("to-json--from-json", () { |
| 358 var o = buildOperation(); |
| 359 var od = new api.Operation.fromJson(o.toJson()); |
| 360 checkOperation(od); |
| 361 }); |
| 362 }); |
| 363 |
| 364 |
| 365 unittest.group("resource-ProjectsClustersResourceApi", () { |
| 366 unittest.test("method--list", () { |
| 367 |
| 368 var mock = new common_test.HttpServerMock(); |
| 369 api.ProjectsClustersResourceApi res = new api.ContainerApi(mock).projects.
clusters; |
| 370 var arg_projectId = "foo"; |
| 371 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| 372 var path = (req.url).path; |
| 373 var pathOffset = 0; |
| 374 var index; |
| 375 var subPart; |
| 376 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
| 377 pathOffset += 1; |
| 378 |
| 379 var query = (req.url).query; |
| 380 var queryOffset = 0; |
| 381 var queryMap = {}; |
| 382 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 383 parseBool(n) { |
| 384 if (n == "true") return true; |
| 385 if (n == "false") return false; |
| 386 if (n == null) return null; |
| 387 throw new core.ArgumentError("Invalid boolean: $n"); |
| 388 } |
| 389 if (query.length > 0) { |
| 390 for (var part in query.split("&")) { |
| 391 var keyvalue = part.split("="); |
| 392 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
| 393 } |
| 394 } |
| 395 |
| 396 |
| 397 var h = { |
| 398 "content-type" : "application/json; charset=utf-8", |
| 399 }; |
| 400 var resp = convert.JSON.encode(buildListAggregatedClustersResponse()); |
| 401 return new async.Future.value(common_test.stringResponse(200, h, resp)); |
| 402 }), true); |
| 403 res.list(arg_projectId).then(unittest.expectAsync(((api.ListAggregatedClus
tersResponse response) { |
| 404 checkListAggregatedClustersResponse(response); |
| 405 }))); |
| 406 }); |
| 407 |
| 408 }); |
| 409 |
| 410 |
| 411 unittest.group("resource-ProjectsOperationsResourceApi", () { |
| 412 unittest.test("method--list", () { |
| 413 |
| 414 var mock = new common_test.HttpServerMock(); |
| 415 api.ProjectsOperationsResourceApi res = new api.ContainerApi(mock).project
s.operations; |
| 416 var arg_projectId = "foo"; |
| 417 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| 418 var path = (req.url).path; |
| 419 var pathOffset = 0; |
| 420 var index; |
| 421 var subPart; |
| 422 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
| 423 pathOffset += 1; |
| 424 |
| 425 var query = (req.url).query; |
| 426 var queryOffset = 0; |
| 427 var queryMap = {}; |
| 428 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 429 parseBool(n) { |
| 430 if (n == "true") return true; |
| 431 if (n == "false") return false; |
| 432 if (n == null) return null; |
| 433 throw new core.ArgumentError("Invalid boolean: $n"); |
| 434 } |
| 435 if (query.length > 0) { |
| 436 for (var part in query.split("&")) { |
| 437 var keyvalue = part.split("="); |
| 438 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
| 439 } |
| 440 } |
| 441 |
| 442 |
| 443 var h = { |
| 444 "content-type" : "application/json; charset=utf-8", |
| 445 }; |
| 446 var resp = convert.JSON.encode(buildListAggregatedOperationsResponse()); |
| 447 return new async.Future.value(common_test.stringResponse(200, h, resp)); |
| 448 }), true); |
| 449 res.list(arg_projectId).then(unittest.expectAsync(((api.ListAggregatedOper
ationsResponse response) { |
| 450 checkListAggregatedOperationsResponse(response); |
| 451 }))); |
| 452 }); |
| 453 |
| 454 }); |
| 455 |
| 456 |
| 457 unittest.group("resource-ProjectsZonesClustersResourceApi", () { |
| 458 unittest.test("method--create", () { |
| 459 |
| 460 var mock = new common_test.HttpServerMock(); |
| 461 api.ProjectsZonesClustersResourceApi res = new api.ContainerApi(mock).proj
ects.zones.clusters; |
| 462 var arg_request = buildCreateClusterRequest(); |
| 463 var arg_projectId = "foo"; |
| 464 var arg_zoneId = "foo"; |
| 465 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| 466 var obj = new api.CreateClusterRequest.fromJson(json); |
| 467 checkCreateClusterRequest(obj); |
| 468 |
| 469 var path = (req.url).path; |
| 470 var pathOffset = 0; |
| 471 var index; |
| 472 var subPart; |
| 473 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
| 474 pathOffset += 1; |
| 475 |
| 476 var query = (req.url).query; |
| 477 var queryOffset = 0; |
| 478 var queryMap = {}; |
| 479 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 480 parseBool(n) { |
| 481 if (n == "true") return true; |
| 482 if (n == "false") return false; |
| 483 if (n == null) return null; |
| 484 throw new core.ArgumentError("Invalid boolean: $n"); |
| 485 } |
| 486 if (query.length > 0) { |
| 487 for (var part in query.split("&")) { |
| 488 var keyvalue = part.split("="); |
| 489 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
| 490 } |
| 491 } |
| 492 |
| 493 |
| 494 var h = { |
| 495 "content-type" : "application/json; charset=utf-8", |
| 496 }; |
| 497 var resp = convert.JSON.encode(buildOperation()); |
| 498 return new async.Future.value(common_test.stringResponse(200, h, resp)); |
| 499 }), true); |
| 500 res.create(arg_request, arg_projectId, arg_zoneId).then(unittest.expectAsy
nc(((api.Operation response) { |
| 501 checkOperation(response); |
| 502 }))); |
| 503 }); |
| 504 |
| 505 unittest.test("method--delete", () { |
| 506 |
| 507 var mock = new common_test.HttpServerMock(); |
| 508 api.ProjectsZonesClustersResourceApi res = new api.ContainerApi(mock).proj
ects.zones.clusters; |
| 509 var arg_projectId = "foo"; |
| 510 var arg_zoneId = "foo"; |
| 511 var arg_clusterId = "foo"; |
| 512 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| 513 var path = (req.url).path; |
| 514 var pathOffset = 0; |
| 515 var index; |
| 516 var subPart; |
| 517 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
| 518 pathOffset += 1; |
| 519 |
| 520 var query = (req.url).query; |
| 521 var queryOffset = 0; |
| 522 var queryMap = {}; |
| 523 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 524 parseBool(n) { |
| 525 if (n == "true") return true; |
| 526 if (n == "false") return false; |
| 527 if (n == null) return null; |
| 528 throw new core.ArgumentError("Invalid boolean: $n"); |
| 529 } |
| 530 if (query.length > 0) { |
| 531 for (var part in query.split("&")) { |
| 532 var keyvalue = part.split("="); |
| 533 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
| 534 } |
| 535 } |
| 536 |
| 537 |
| 538 var h = { |
| 539 "content-type" : "application/json; charset=utf-8", |
| 540 }; |
| 541 var resp = convert.JSON.encode(buildOperation()); |
| 542 return new async.Future.value(common_test.stringResponse(200, h, resp)); |
| 543 }), true); |
| 544 res.delete(arg_projectId, arg_zoneId, arg_clusterId).then(unittest.expectA
sync(((api.Operation response) { |
| 545 checkOperation(response); |
| 546 }))); |
| 547 }); |
| 548 |
| 549 unittest.test("method--get", () { |
| 550 |
| 551 var mock = new common_test.HttpServerMock(); |
| 552 api.ProjectsZonesClustersResourceApi res = new api.ContainerApi(mock).proj
ects.zones.clusters; |
| 553 var arg_projectId = "foo"; |
| 554 var arg_zoneId = "foo"; |
| 555 var arg_clusterId = "foo"; |
| 556 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| 557 var path = (req.url).path; |
| 558 var pathOffset = 0; |
| 559 var index; |
| 560 var subPart; |
| 561 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
| 562 pathOffset += 1; |
| 563 |
| 564 var query = (req.url).query; |
| 565 var queryOffset = 0; |
| 566 var queryMap = {}; |
| 567 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 568 parseBool(n) { |
| 569 if (n == "true") return true; |
| 570 if (n == "false") return false; |
| 571 if (n == null) return null; |
| 572 throw new core.ArgumentError("Invalid boolean: $n"); |
| 573 } |
| 574 if (query.length > 0) { |
| 575 for (var part in query.split("&")) { |
| 576 var keyvalue = part.split("="); |
| 577 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
| 578 } |
| 579 } |
| 580 |
| 581 |
| 582 var h = { |
| 583 "content-type" : "application/json; charset=utf-8", |
| 584 }; |
| 585 var resp = convert.JSON.encode(buildCluster()); |
| 586 return new async.Future.value(common_test.stringResponse(200, h, resp)); |
| 587 }), true); |
| 588 res.get(arg_projectId, arg_zoneId, arg_clusterId).then(unittest.expectAsyn
c(((api.Cluster response) { |
| 589 checkCluster(response); |
| 590 }))); |
| 591 }); |
| 592 |
| 593 unittest.test("method--list", () { |
| 594 |
| 595 var mock = new common_test.HttpServerMock(); |
| 596 api.ProjectsZonesClustersResourceApi res = new api.ContainerApi(mock).proj
ects.zones.clusters; |
| 597 var arg_projectId = "foo"; |
| 598 var arg_zoneId = "foo"; |
| 599 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| 600 var path = (req.url).path; |
| 601 var pathOffset = 0; |
| 602 var index; |
| 603 var subPart; |
| 604 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
| 605 pathOffset += 1; |
| 606 |
| 607 var query = (req.url).query; |
| 608 var queryOffset = 0; |
| 609 var queryMap = {}; |
| 610 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 611 parseBool(n) { |
| 612 if (n == "true") return true; |
| 613 if (n == "false") return false; |
| 614 if (n == null) return null; |
| 615 throw new core.ArgumentError("Invalid boolean: $n"); |
| 616 } |
| 617 if (query.length > 0) { |
| 618 for (var part in query.split("&")) { |
| 619 var keyvalue = part.split("="); |
| 620 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
| 621 } |
| 622 } |
| 623 |
| 624 |
| 625 var h = { |
| 626 "content-type" : "application/json; charset=utf-8", |
| 627 }; |
| 628 var resp = convert.JSON.encode(buildListClustersResponse()); |
| 629 return new async.Future.value(common_test.stringResponse(200, h, resp)); |
| 630 }), true); |
| 631 res.list(arg_projectId, arg_zoneId).then(unittest.expectAsync(((api.ListCl
ustersResponse response) { |
| 632 checkListClustersResponse(response); |
| 633 }))); |
| 634 }); |
| 635 |
| 636 }); |
| 637 |
| 638 |
| 639 unittest.group("resource-ProjectsZonesOperationsResourceApi", () { |
| 640 unittest.test("method--get", () { |
| 641 |
| 642 var mock = new common_test.HttpServerMock(); |
| 643 api.ProjectsZonesOperationsResourceApi res = new api.ContainerApi(mock).pr
ojects.zones.operations; |
| 644 var arg_projectId = "foo"; |
| 645 var arg_zoneId = "foo"; |
| 646 var arg_operationId = "foo"; |
| 647 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| 648 var path = (req.url).path; |
| 649 var pathOffset = 0; |
| 650 var index; |
| 651 var subPart; |
| 652 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
| 653 pathOffset += 1; |
| 654 |
| 655 var query = (req.url).query; |
| 656 var queryOffset = 0; |
| 657 var queryMap = {}; |
| 658 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 659 parseBool(n) { |
| 660 if (n == "true") return true; |
| 661 if (n == "false") return false; |
| 662 if (n == null) return null; |
| 663 throw new core.ArgumentError("Invalid boolean: $n"); |
| 664 } |
| 665 if (query.length > 0) { |
| 666 for (var part in query.split("&")) { |
| 667 var keyvalue = part.split("="); |
| 668 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
| 669 } |
| 670 } |
| 671 |
| 672 |
| 673 var h = { |
| 674 "content-type" : "application/json; charset=utf-8", |
| 675 }; |
| 676 var resp = convert.JSON.encode(buildOperation()); |
| 677 return new async.Future.value(common_test.stringResponse(200, h, resp)); |
| 678 }), true); |
| 679 res.get(arg_projectId, arg_zoneId, arg_operationId).then(unittest.expectAs
ync(((api.Operation response) { |
| 680 checkOperation(response); |
| 681 }))); |
| 682 }); |
| 683 |
| 684 unittest.test("method--list", () { |
| 685 |
| 686 var mock = new common_test.HttpServerMock(); |
| 687 api.ProjectsZonesOperationsResourceApi res = new api.ContainerApi(mock).pr
ojects.zones.operations; |
| 688 var arg_projectId = "foo"; |
| 689 var arg_zoneId = "foo"; |
| 690 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| 691 var path = (req.url).path; |
| 692 var pathOffset = 0; |
| 693 var index; |
| 694 var subPart; |
| 695 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
| 696 pathOffset += 1; |
| 697 |
| 698 var query = (req.url).query; |
| 699 var queryOffset = 0; |
| 700 var queryMap = {}; |
| 701 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 702 parseBool(n) { |
| 703 if (n == "true") return true; |
| 704 if (n == "false") return false; |
| 705 if (n == null) return null; |
| 706 throw new core.ArgumentError("Invalid boolean: $n"); |
| 707 } |
| 708 if (query.length > 0) { |
| 709 for (var part in query.split("&")) { |
| 710 var keyvalue = part.split("="); |
| 711 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
| 712 } |
| 713 } |
| 714 |
| 715 |
| 716 var h = { |
| 717 "content-type" : "application/json; charset=utf-8", |
| 718 }; |
| 719 var resp = convert.JSON.encode(buildListOperationsResponse()); |
| 720 return new async.Future.value(common_test.stringResponse(200, h, resp)); |
| 721 }), true); |
| 722 res.list(arg_projectId, arg_zoneId).then(unittest.expectAsync(((api.ListOp
erationsResponse response) { |
| 723 checkListOperationsResponse(response); |
| 724 }))); |
| 725 }); |
| 726 |
| 727 }); |
| 728 |
| 729 |
| 730 } |
| 731 |
OLD | NEW |