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