OLD | NEW |
(Empty) | |
| 1 library googleapis.storagetransfer.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 |
| 12 import 'package:googleapis/storagetransfer/v1.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 core.int buildCounterAwsAccessKey = 0; |
| 55 buildAwsAccessKey() { |
| 56 var o = new api.AwsAccessKey(); |
| 57 buildCounterAwsAccessKey++; |
| 58 if (buildCounterAwsAccessKey < 3) { |
| 59 o.accessKeyId = "foo"; |
| 60 o.secretAccessKey = "foo"; |
| 61 } |
| 62 buildCounterAwsAccessKey--; |
| 63 return o; |
| 64 } |
| 65 |
| 66 checkAwsAccessKey(api.AwsAccessKey o) { |
| 67 buildCounterAwsAccessKey++; |
| 68 if (buildCounterAwsAccessKey < 3) { |
| 69 unittest.expect(o.accessKeyId, unittest.equals('foo')); |
| 70 unittest.expect(o.secretAccessKey, unittest.equals('foo')); |
| 71 } |
| 72 buildCounterAwsAccessKey--; |
| 73 } |
| 74 |
| 75 core.int buildCounterAwsS3Data = 0; |
| 76 buildAwsS3Data() { |
| 77 var o = new api.AwsS3Data(); |
| 78 buildCounterAwsS3Data++; |
| 79 if (buildCounterAwsS3Data < 3) { |
| 80 o.awsAccessKey = buildAwsAccessKey(); |
| 81 o.bucketName = "foo"; |
| 82 } |
| 83 buildCounterAwsS3Data--; |
| 84 return o; |
| 85 } |
| 86 |
| 87 checkAwsS3Data(api.AwsS3Data o) { |
| 88 buildCounterAwsS3Data++; |
| 89 if (buildCounterAwsS3Data < 3) { |
| 90 checkAwsAccessKey(o.awsAccessKey); |
| 91 unittest.expect(o.bucketName, unittest.equals('foo')); |
| 92 } |
| 93 buildCounterAwsS3Data--; |
| 94 } |
| 95 |
| 96 core.int buildCounterDate = 0; |
| 97 buildDate() { |
| 98 var o = new api.Date(); |
| 99 buildCounterDate++; |
| 100 if (buildCounterDate < 3) { |
| 101 o.day = 42; |
| 102 o.month = 42; |
| 103 o.year = 42; |
| 104 } |
| 105 buildCounterDate--; |
| 106 return o; |
| 107 } |
| 108 |
| 109 checkDate(api.Date o) { |
| 110 buildCounterDate++; |
| 111 if (buildCounterDate < 3) { |
| 112 unittest.expect(o.day, unittest.equals(42)); |
| 113 unittest.expect(o.month, unittest.equals(42)); |
| 114 unittest.expect(o.year, unittest.equals(42)); |
| 115 } |
| 116 buildCounterDate--; |
| 117 } |
| 118 |
| 119 core.int buildCounterEmpty = 0; |
| 120 buildEmpty() { |
| 121 var o = new api.Empty(); |
| 122 buildCounterEmpty++; |
| 123 if (buildCounterEmpty < 3) { |
| 124 } |
| 125 buildCounterEmpty--; |
| 126 return o; |
| 127 } |
| 128 |
| 129 checkEmpty(api.Empty o) { |
| 130 buildCounterEmpty++; |
| 131 if (buildCounterEmpty < 3) { |
| 132 } |
| 133 buildCounterEmpty--; |
| 134 } |
| 135 |
| 136 buildUnnamed2099() { |
| 137 var o = new core.List<core.String>(); |
| 138 o.add("foo"); |
| 139 o.add("foo"); |
| 140 return o; |
| 141 } |
| 142 |
| 143 checkUnnamed2099(core.List<core.String> o) { |
| 144 unittest.expect(o, unittest.hasLength(2)); |
| 145 unittest.expect(o[0], unittest.equals('foo')); |
| 146 unittest.expect(o[1], unittest.equals('foo')); |
| 147 } |
| 148 |
| 149 core.int buildCounterErrorLogEntry = 0; |
| 150 buildErrorLogEntry() { |
| 151 var o = new api.ErrorLogEntry(); |
| 152 buildCounterErrorLogEntry++; |
| 153 if (buildCounterErrorLogEntry < 3) { |
| 154 o.errorDetails = buildUnnamed2099(); |
| 155 o.url = "foo"; |
| 156 } |
| 157 buildCounterErrorLogEntry--; |
| 158 return o; |
| 159 } |
| 160 |
| 161 checkErrorLogEntry(api.ErrorLogEntry o) { |
| 162 buildCounterErrorLogEntry++; |
| 163 if (buildCounterErrorLogEntry < 3) { |
| 164 checkUnnamed2099(o.errorDetails); |
| 165 unittest.expect(o.url, unittest.equals('foo')); |
| 166 } |
| 167 buildCounterErrorLogEntry--; |
| 168 } |
| 169 |
| 170 buildUnnamed2100() { |
| 171 var o = new core.List<api.ErrorLogEntry>(); |
| 172 o.add(buildErrorLogEntry()); |
| 173 o.add(buildErrorLogEntry()); |
| 174 return o; |
| 175 } |
| 176 |
| 177 checkUnnamed2100(core.List<api.ErrorLogEntry> o) { |
| 178 unittest.expect(o, unittest.hasLength(2)); |
| 179 checkErrorLogEntry(o[0]); |
| 180 checkErrorLogEntry(o[1]); |
| 181 } |
| 182 |
| 183 core.int buildCounterErrorSummary = 0; |
| 184 buildErrorSummary() { |
| 185 var o = new api.ErrorSummary(); |
| 186 buildCounterErrorSummary++; |
| 187 if (buildCounterErrorSummary < 3) { |
| 188 o.errorCode = "foo"; |
| 189 o.errorCount = "foo"; |
| 190 o.errorLogEntries = buildUnnamed2100(); |
| 191 } |
| 192 buildCounterErrorSummary--; |
| 193 return o; |
| 194 } |
| 195 |
| 196 checkErrorSummary(api.ErrorSummary o) { |
| 197 buildCounterErrorSummary++; |
| 198 if (buildCounterErrorSummary < 3) { |
| 199 unittest.expect(o.errorCode, unittest.equals('foo')); |
| 200 unittest.expect(o.errorCount, unittest.equals('foo')); |
| 201 checkUnnamed2100(o.errorLogEntries); |
| 202 } |
| 203 buildCounterErrorSummary--; |
| 204 } |
| 205 |
| 206 core.int buildCounterGcsData = 0; |
| 207 buildGcsData() { |
| 208 var o = new api.GcsData(); |
| 209 buildCounterGcsData++; |
| 210 if (buildCounterGcsData < 3) { |
| 211 o.bucketName = "foo"; |
| 212 } |
| 213 buildCounterGcsData--; |
| 214 return o; |
| 215 } |
| 216 |
| 217 checkGcsData(api.GcsData o) { |
| 218 buildCounterGcsData++; |
| 219 if (buildCounterGcsData < 3) { |
| 220 unittest.expect(o.bucketName, unittest.equals('foo')); |
| 221 } |
| 222 buildCounterGcsData--; |
| 223 } |
| 224 |
| 225 core.int buildCounterGoogleServiceAccount = 0; |
| 226 buildGoogleServiceAccount() { |
| 227 var o = new api.GoogleServiceAccount(); |
| 228 buildCounterGoogleServiceAccount++; |
| 229 if (buildCounterGoogleServiceAccount < 3) { |
| 230 o.accountEmail = "foo"; |
| 231 } |
| 232 buildCounterGoogleServiceAccount--; |
| 233 return o; |
| 234 } |
| 235 |
| 236 checkGoogleServiceAccount(api.GoogleServiceAccount o) { |
| 237 buildCounterGoogleServiceAccount++; |
| 238 if (buildCounterGoogleServiceAccount < 3) { |
| 239 unittest.expect(o.accountEmail, unittest.equals('foo')); |
| 240 } |
| 241 buildCounterGoogleServiceAccount--; |
| 242 } |
| 243 |
| 244 core.int buildCounterHttpData = 0; |
| 245 buildHttpData() { |
| 246 var o = new api.HttpData(); |
| 247 buildCounterHttpData++; |
| 248 if (buildCounterHttpData < 3) { |
| 249 o.listUrl = "foo"; |
| 250 } |
| 251 buildCounterHttpData--; |
| 252 return o; |
| 253 } |
| 254 |
| 255 checkHttpData(api.HttpData o) { |
| 256 buildCounterHttpData++; |
| 257 if (buildCounterHttpData < 3) { |
| 258 unittest.expect(o.listUrl, unittest.equals('foo')); |
| 259 } |
| 260 buildCounterHttpData--; |
| 261 } |
| 262 |
| 263 buildUnnamed2101() { |
| 264 var o = new core.List<api.Operation>(); |
| 265 o.add(buildOperation()); |
| 266 o.add(buildOperation()); |
| 267 return o; |
| 268 } |
| 269 |
| 270 checkUnnamed2101(core.List<api.Operation> o) { |
| 271 unittest.expect(o, unittest.hasLength(2)); |
| 272 checkOperation(o[0]); |
| 273 checkOperation(o[1]); |
| 274 } |
| 275 |
| 276 core.int buildCounterListOperationsResponse = 0; |
| 277 buildListOperationsResponse() { |
| 278 var o = new api.ListOperationsResponse(); |
| 279 buildCounterListOperationsResponse++; |
| 280 if (buildCounterListOperationsResponse < 3) { |
| 281 o.nextPageToken = "foo"; |
| 282 o.operations = buildUnnamed2101(); |
| 283 } |
| 284 buildCounterListOperationsResponse--; |
| 285 return o; |
| 286 } |
| 287 |
| 288 checkListOperationsResponse(api.ListOperationsResponse o) { |
| 289 buildCounterListOperationsResponse++; |
| 290 if (buildCounterListOperationsResponse < 3) { |
| 291 unittest.expect(o.nextPageToken, unittest.equals('foo')); |
| 292 checkUnnamed2101(o.operations); |
| 293 } |
| 294 buildCounterListOperationsResponse--; |
| 295 } |
| 296 |
| 297 buildUnnamed2102() { |
| 298 var o = new core.List<api.TransferJob>(); |
| 299 o.add(buildTransferJob()); |
| 300 o.add(buildTransferJob()); |
| 301 return o; |
| 302 } |
| 303 |
| 304 checkUnnamed2102(core.List<api.TransferJob> o) { |
| 305 unittest.expect(o, unittest.hasLength(2)); |
| 306 checkTransferJob(o[0]); |
| 307 checkTransferJob(o[1]); |
| 308 } |
| 309 |
| 310 core.int buildCounterListTransferJobsResponse = 0; |
| 311 buildListTransferJobsResponse() { |
| 312 var o = new api.ListTransferJobsResponse(); |
| 313 buildCounterListTransferJobsResponse++; |
| 314 if (buildCounterListTransferJobsResponse < 3) { |
| 315 o.nextPageToken = "foo"; |
| 316 o.transferJobs = buildUnnamed2102(); |
| 317 } |
| 318 buildCounterListTransferJobsResponse--; |
| 319 return o; |
| 320 } |
| 321 |
| 322 checkListTransferJobsResponse(api.ListTransferJobsResponse o) { |
| 323 buildCounterListTransferJobsResponse++; |
| 324 if (buildCounterListTransferJobsResponse < 3) { |
| 325 unittest.expect(o.nextPageToken, unittest.equals('foo')); |
| 326 checkUnnamed2102(o.transferJobs); |
| 327 } |
| 328 buildCounterListTransferJobsResponse--; |
| 329 } |
| 330 |
| 331 buildUnnamed2103() { |
| 332 var o = new core.List<core.String>(); |
| 333 o.add("foo"); |
| 334 o.add("foo"); |
| 335 return o; |
| 336 } |
| 337 |
| 338 checkUnnamed2103(core.List<core.String> o) { |
| 339 unittest.expect(o, unittest.hasLength(2)); |
| 340 unittest.expect(o[0], unittest.equals('foo')); |
| 341 unittest.expect(o[1], unittest.equals('foo')); |
| 342 } |
| 343 |
| 344 buildUnnamed2104() { |
| 345 var o = new core.List<core.String>(); |
| 346 o.add("foo"); |
| 347 o.add("foo"); |
| 348 return o; |
| 349 } |
| 350 |
| 351 checkUnnamed2104(core.List<core.String> o) { |
| 352 unittest.expect(o, unittest.hasLength(2)); |
| 353 unittest.expect(o[0], unittest.equals('foo')); |
| 354 unittest.expect(o[1], unittest.equals('foo')); |
| 355 } |
| 356 |
| 357 core.int buildCounterObjectConditions = 0; |
| 358 buildObjectConditions() { |
| 359 var o = new api.ObjectConditions(); |
| 360 buildCounterObjectConditions++; |
| 361 if (buildCounterObjectConditions < 3) { |
| 362 o.excludePrefixes = buildUnnamed2103(); |
| 363 o.includePrefixes = buildUnnamed2104(); |
| 364 o.maxTimeElapsedSinceLastModification = "foo"; |
| 365 o.minTimeElapsedSinceLastModification = "foo"; |
| 366 } |
| 367 buildCounterObjectConditions--; |
| 368 return o; |
| 369 } |
| 370 |
| 371 checkObjectConditions(api.ObjectConditions o) { |
| 372 buildCounterObjectConditions++; |
| 373 if (buildCounterObjectConditions < 3) { |
| 374 checkUnnamed2103(o.excludePrefixes); |
| 375 checkUnnamed2104(o.includePrefixes); |
| 376 unittest.expect(o.maxTimeElapsedSinceLastModification, unittest.equals('foo'
)); |
| 377 unittest.expect(o.minTimeElapsedSinceLastModification, unittest.equals('foo'
)); |
| 378 } |
| 379 buildCounterObjectConditions--; |
| 380 } |
| 381 |
| 382 buildUnnamed2105() { |
| 383 var o = new core.Map<core.String, core.Object>(); |
| 384 o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; |
| 385 o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; |
| 386 return o; |
| 387 } |
| 388 |
| 389 checkUnnamed2105(core.Map<core.String, core.Object> o) { |
| 390 unittest.expect(o, unittest.hasLength(2)); |
| 391 var casted1 = (o["x"]) as core.Map; unittest.expect(casted1, unittest.hasLengt
h(3)); unittest.expect(casted1["list"], unittest.equals([1, 2, 3])); unittest.ex
pect(casted1["bool"], unittest.equals(true)); unittest.expect(casted1["string"],
unittest.equals('foo')); |
| 392 var casted2 = (o["y"]) as core.Map; unittest.expect(casted2, unittest.hasLengt
h(3)); unittest.expect(casted2["list"], unittest.equals([1, 2, 3])); unittest.ex
pect(casted2["bool"], unittest.equals(true)); unittest.expect(casted2["string"],
unittest.equals('foo')); |
| 393 } |
| 394 |
| 395 buildUnnamed2106() { |
| 396 var o = new core.Map<core.String, core.Object>(); |
| 397 o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; |
| 398 o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; |
| 399 return o; |
| 400 } |
| 401 |
| 402 checkUnnamed2106(core.Map<core.String, core.Object> o) { |
| 403 unittest.expect(o, unittest.hasLength(2)); |
| 404 var casted3 = (o["x"]) as core.Map; unittest.expect(casted3, unittest.hasLengt
h(3)); unittest.expect(casted3["list"], unittest.equals([1, 2, 3])); unittest.ex
pect(casted3["bool"], unittest.equals(true)); unittest.expect(casted3["string"],
unittest.equals('foo')); |
| 405 var casted4 = (o["y"]) as core.Map; unittest.expect(casted4, unittest.hasLengt
h(3)); unittest.expect(casted4["list"], unittest.equals([1, 2, 3])); unittest.ex
pect(casted4["bool"], unittest.equals(true)); unittest.expect(casted4["string"],
unittest.equals('foo')); |
| 406 } |
| 407 |
| 408 core.int buildCounterOperation = 0; |
| 409 buildOperation() { |
| 410 var o = new api.Operation(); |
| 411 buildCounterOperation++; |
| 412 if (buildCounterOperation < 3) { |
| 413 o.done = true; |
| 414 o.error = buildStatus(); |
| 415 o.metadata = buildUnnamed2105(); |
| 416 o.name = "foo"; |
| 417 o.response = buildUnnamed2106(); |
| 418 } |
| 419 buildCounterOperation--; |
| 420 return o; |
| 421 } |
| 422 |
| 423 checkOperation(api.Operation o) { |
| 424 buildCounterOperation++; |
| 425 if (buildCounterOperation < 3) { |
| 426 unittest.expect(o.done, unittest.isTrue); |
| 427 checkStatus(o.error); |
| 428 checkUnnamed2105(o.metadata); |
| 429 unittest.expect(o.name, unittest.equals('foo')); |
| 430 checkUnnamed2106(o.response); |
| 431 } |
| 432 buildCounterOperation--; |
| 433 } |
| 434 |
| 435 core.int buildCounterPauseTransferOperationRequest = 0; |
| 436 buildPauseTransferOperationRequest() { |
| 437 var o = new api.PauseTransferOperationRequest(); |
| 438 buildCounterPauseTransferOperationRequest++; |
| 439 if (buildCounterPauseTransferOperationRequest < 3) { |
| 440 } |
| 441 buildCounterPauseTransferOperationRequest--; |
| 442 return o; |
| 443 } |
| 444 |
| 445 checkPauseTransferOperationRequest(api.PauseTransferOperationRequest o) { |
| 446 buildCounterPauseTransferOperationRequest++; |
| 447 if (buildCounterPauseTransferOperationRequest < 3) { |
| 448 } |
| 449 buildCounterPauseTransferOperationRequest--; |
| 450 } |
| 451 |
| 452 core.int buildCounterResumeTransferOperationRequest = 0; |
| 453 buildResumeTransferOperationRequest() { |
| 454 var o = new api.ResumeTransferOperationRequest(); |
| 455 buildCounterResumeTransferOperationRequest++; |
| 456 if (buildCounterResumeTransferOperationRequest < 3) { |
| 457 } |
| 458 buildCounterResumeTransferOperationRequest--; |
| 459 return o; |
| 460 } |
| 461 |
| 462 checkResumeTransferOperationRequest(api.ResumeTransferOperationRequest o) { |
| 463 buildCounterResumeTransferOperationRequest++; |
| 464 if (buildCounterResumeTransferOperationRequest < 3) { |
| 465 } |
| 466 buildCounterResumeTransferOperationRequest--; |
| 467 } |
| 468 |
| 469 core.int buildCounterSchedule = 0; |
| 470 buildSchedule() { |
| 471 var o = new api.Schedule(); |
| 472 buildCounterSchedule++; |
| 473 if (buildCounterSchedule < 3) { |
| 474 o.scheduleEndDate = buildDate(); |
| 475 o.scheduleStartDate = buildDate(); |
| 476 o.startTimeOfDay = buildTimeOfDay(); |
| 477 } |
| 478 buildCounterSchedule--; |
| 479 return o; |
| 480 } |
| 481 |
| 482 checkSchedule(api.Schedule o) { |
| 483 buildCounterSchedule++; |
| 484 if (buildCounterSchedule < 3) { |
| 485 checkDate(o.scheduleEndDate); |
| 486 checkDate(o.scheduleStartDate); |
| 487 checkTimeOfDay(o.startTimeOfDay); |
| 488 } |
| 489 buildCounterSchedule--; |
| 490 } |
| 491 |
| 492 buildUnnamed2107() { |
| 493 var o = new core.Map<core.String, core.Object>(); |
| 494 o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; |
| 495 o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; |
| 496 return o; |
| 497 } |
| 498 |
| 499 checkUnnamed2107(core.Map<core.String, core.Object> o) { |
| 500 unittest.expect(o, unittest.hasLength(2)); |
| 501 var casted5 = (o["x"]) as core.Map; unittest.expect(casted5, unittest.hasLengt
h(3)); unittest.expect(casted5["list"], unittest.equals([1, 2, 3])); unittest.ex
pect(casted5["bool"], unittest.equals(true)); unittest.expect(casted5["string"],
unittest.equals('foo')); |
| 502 var casted6 = (o["y"]) as core.Map; unittest.expect(casted6, unittest.hasLengt
h(3)); unittest.expect(casted6["list"], unittest.equals([1, 2, 3])); unittest.ex
pect(casted6["bool"], unittest.equals(true)); unittest.expect(casted6["string"],
unittest.equals('foo')); |
| 503 } |
| 504 |
| 505 buildUnnamed2108() { |
| 506 var o = new core.List<core.Map<core.String, core.Object>>(); |
| 507 o.add(buildUnnamed2107()); |
| 508 o.add(buildUnnamed2107()); |
| 509 return o; |
| 510 } |
| 511 |
| 512 checkUnnamed2108(core.List<core.Map<core.String, core.Object>> o) { |
| 513 unittest.expect(o, unittest.hasLength(2)); |
| 514 checkUnnamed2107(o[0]); |
| 515 checkUnnamed2107(o[1]); |
| 516 } |
| 517 |
| 518 core.int buildCounterStatus = 0; |
| 519 buildStatus() { |
| 520 var o = new api.Status(); |
| 521 buildCounterStatus++; |
| 522 if (buildCounterStatus < 3) { |
| 523 o.code = 42; |
| 524 o.details = buildUnnamed2108(); |
| 525 o.message = "foo"; |
| 526 } |
| 527 buildCounterStatus--; |
| 528 return o; |
| 529 } |
| 530 |
| 531 checkStatus(api.Status o) { |
| 532 buildCounterStatus++; |
| 533 if (buildCounterStatus < 3) { |
| 534 unittest.expect(o.code, unittest.equals(42)); |
| 535 checkUnnamed2108(o.details); |
| 536 unittest.expect(o.message, unittest.equals('foo')); |
| 537 } |
| 538 buildCounterStatus--; |
| 539 } |
| 540 |
| 541 core.int buildCounterTimeOfDay = 0; |
| 542 buildTimeOfDay() { |
| 543 var o = new api.TimeOfDay(); |
| 544 buildCounterTimeOfDay++; |
| 545 if (buildCounterTimeOfDay < 3) { |
| 546 o.hours = 42; |
| 547 o.minutes = 42; |
| 548 o.nanos = 42; |
| 549 o.seconds = 42; |
| 550 } |
| 551 buildCounterTimeOfDay--; |
| 552 return o; |
| 553 } |
| 554 |
| 555 checkTimeOfDay(api.TimeOfDay o) { |
| 556 buildCounterTimeOfDay++; |
| 557 if (buildCounterTimeOfDay < 3) { |
| 558 unittest.expect(o.hours, unittest.equals(42)); |
| 559 unittest.expect(o.minutes, unittest.equals(42)); |
| 560 unittest.expect(o.nanos, unittest.equals(42)); |
| 561 unittest.expect(o.seconds, unittest.equals(42)); |
| 562 } |
| 563 buildCounterTimeOfDay--; |
| 564 } |
| 565 |
| 566 core.int buildCounterTransferCounters = 0; |
| 567 buildTransferCounters() { |
| 568 var o = new api.TransferCounters(); |
| 569 buildCounterTransferCounters++; |
| 570 if (buildCounterTransferCounters < 3) { |
| 571 o.bytesCopiedToSink = "foo"; |
| 572 o.bytesDeletedFromSink = "foo"; |
| 573 o.bytesDeletedFromSource = "foo"; |
| 574 o.bytesFailedToDeleteFromSink = "foo"; |
| 575 o.bytesFoundFromSource = "foo"; |
| 576 o.bytesFoundOnlyFromSink = "foo"; |
| 577 o.bytesFromSourceFailed = "foo"; |
| 578 o.bytesFromSourceSkippedBySync = "foo"; |
| 579 o.objectsCopiedToSink = "foo"; |
| 580 o.objectsDeletedFromSink = "foo"; |
| 581 o.objectsDeletedFromSource = "foo"; |
| 582 o.objectsFailedToDeleteFromSink = "foo"; |
| 583 o.objectsFoundFromSource = "foo"; |
| 584 o.objectsFoundOnlyFromSink = "foo"; |
| 585 o.objectsFromSourceFailed = "foo"; |
| 586 o.objectsFromSourceSkippedBySync = "foo"; |
| 587 } |
| 588 buildCounterTransferCounters--; |
| 589 return o; |
| 590 } |
| 591 |
| 592 checkTransferCounters(api.TransferCounters o) { |
| 593 buildCounterTransferCounters++; |
| 594 if (buildCounterTransferCounters < 3) { |
| 595 unittest.expect(o.bytesCopiedToSink, unittest.equals('foo')); |
| 596 unittest.expect(o.bytesDeletedFromSink, unittest.equals('foo')); |
| 597 unittest.expect(o.bytesDeletedFromSource, unittest.equals('foo')); |
| 598 unittest.expect(o.bytesFailedToDeleteFromSink, unittest.equals('foo')); |
| 599 unittest.expect(o.bytesFoundFromSource, unittest.equals('foo')); |
| 600 unittest.expect(o.bytesFoundOnlyFromSink, unittest.equals('foo')); |
| 601 unittest.expect(o.bytesFromSourceFailed, unittest.equals('foo')); |
| 602 unittest.expect(o.bytesFromSourceSkippedBySync, unittest.equals('foo')); |
| 603 unittest.expect(o.objectsCopiedToSink, unittest.equals('foo')); |
| 604 unittest.expect(o.objectsDeletedFromSink, unittest.equals('foo')); |
| 605 unittest.expect(o.objectsDeletedFromSource, unittest.equals('foo')); |
| 606 unittest.expect(o.objectsFailedToDeleteFromSink, unittest.equals('foo')); |
| 607 unittest.expect(o.objectsFoundFromSource, unittest.equals('foo')); |
| 608 unittest.expect(o.objectsFoundOnlyFromSink, unittest.equals('foo')); |
| 609 unittest.expect(o.objectsFromSourceFailed, unittest.equals('foo')); |
| 610 unittest.expect(o.objectsFromSourceSkippedBySync, unittest.equals('foo')); |
| 611 } |
| 612 buildCounterTransferCounters--; |
| 613 } |
| 614 |
| 615 core.int buildCounterTransferJob = 0; |
| 616 buildTransferJob() { |
| 617 var o = new api.TransferJob(); |
| 618 buildCounterTransferJob++; |
| 619 if (buildCounterTransferJob < 3) { |
| 620 o.creationTime = "foo"; |
| 621 o.deletionTime = "foo"; |
| 622 o.description = "foo"; |
| 623 o.lastModificationTime = "foo"; |
| 624 o.name = "foo"; |
| 625 o.projectId = "foo"; |
| 626 o.schedule = buildSchedule(); |
| 627 o.status = "foo"; |
| 628 o.transferSpec = buildTransferSpec(); |
| 629 } |
| 630 buildCounterTransferJob--; |
| 631 return o; |
| 632 } |
| 633 |
| 634 checkTransferJob(api.TransferJob o) { |
| 635 buildCounterTransferJob++; |
| 636 if (buildCounterTransferJob < 3) { |
| 637 unittest.expect(o.creationTime, unittest.equals('foo')); |
| 638 unittest.expect(o.deletionTime, unittest.equals('foo')); |
| 639 unittest.expect(o.description, unittest.equals('foo')); |
| 640 unittest.expect(o.lastModificationTime, unittest.equals('foo')); |
| 641 unittest.expect(o.name, unittest.equals('foo')); |
| 642 unittest.expect(o.projectId, unittest.equals('foo')); |
| 643 checkSchedule(o.schedule); |
| 644 unittest.expect(o.status, unittest.equals('foo')); |
| 645 checkTransferSpec(o.transferSpec); |
| 646 } |
| 647 buildCounterTransferJob--; |
| 648 } |
| 649 |
| 650 buildUnnamed2109() { |
| 651 var o = new core.List<api.ErrorSummary>(); |
| 652 o.add(buildErrorSummary()); |
| 653 o.add(buildErrorSummary()); |
| 654 return o; |
| 655 } |
| 656 |
| 657 checkUnnamed2109(core.List<api.ErrorSummary> o) { |
| 658 unittest.expect(o, unittest.hasLength(2)); |
| 659 checkErrorSummary(o[0]); |
| 660 checkErrorSummary(o[1]); |
| 661 } |
| 662 |
| 663 core.int buildCounterTransferOperation = 0; |
| 664 buildTransferOperation() { |
| 665 var o = new api.TransferOperation(); |
| 666 buildCounterTransferOperation++; |
| 667 if (buildCounterTransferOperation < 3) { |
| 668 o.counters = buildTransferCounters(); |
| 669 o.endTime = "foo"; |
| 670 o.errorBreakdowns = buildUnnamed2109(); |
| 671 o.name = "foo"; |
| 672 o.projectId = "foo"; |
| 673 o.startTime = "foo"; |
| 674 o.status = "foo"; |
| 675 o.transferJobName = "foo"; |
| 676 o.transferSpec = buildTransferSpec(); |
| 677 } |
| 678 buildCounterTransferOperation--; |
| 679 return o; |
| 680 } |
| 681 |
| 682 checkTransferOperation(api.TransferOperation o) { |
| 683 buildCounterTransferOperation++; |
| 684 if (buildCounterTransferOperation < 3) { |
| 685 checkTransferCounters(o.counters); |
| 686 unittest.expect(o.endTime, unittest.equals('foo')); |
| 687 checkUnnamed2109(o.errorBreakdowns); |
| 688 unittest.expect(o.name, unittest.equals('foo')); |
| 689 unittest.expect(o.projectId, unittest.equals('foo')); |
| 690 unittest.expect(o.startTime, unittest.equals('foo')); |
| 691 unittest.expect(o.status, unittest.equals('foo')); |
| 692 unittest.expect(o.transferJobName, unittest.equals('foo')); |
| 693 checkTransferSpec(o.transferSpec); |
| 694 } |
| 695 buildCounterTransferOperation--; |
| 696 } |
| 697 |
| 698 core.int buildCounterTransferOptions = 0; |
| 699 buildTransferOptions() { |
| 700 var o = new api.TransferOptions(); |
| 701 buildCounterTransferOptions++; |
| 702 if (buildCounterTransferOptions < 3) { |
| 703 o.deleteObjectsFromSourceAfterTransfer = true; |
| 704 o.deleteObjectsUniqueInSink = true; |
| 705 o.overwriteObjectsAlreadyExistingInSink = true; |
| 706 } |
| 707 buildCounterTransferOptions--; |
| 708 return o; |
| 709 } |
| 710 |
| 711 checkTransferOptions(api.TransferOptions o) { |
| 712 buildCounterTransferOptions++; |
| 713 if (buildCounterTransferOptions < 3) { |
| 714 unittest.expect(o.deleteObjectsFromSourceAfterTransfer, unittest.isTrue); |
| 715 unittest.expect(o.deleteObjectsUniqueInSink, unittest.isTrue); |
| 716 unittest.expect(o.overwriteObjectsAlreadyExistingInSink, unittest.isTrue); |
| 717 } |
| 718 buildCounterTransferOptions--; |
| 719 } |
| 720 |
| 721 core.int buildCounterTransferSpec = 0; |
| 722 buildTransferSpec() { |
| 723 var o = new api.TransferSpec(); |
| 724 buildCounterTransferSpec++; |
| 725 if (buildCounterTransferSpec < 3) { |
| 726 o.awsS3DataSource = buildAwsS3Data(); |
| 727 o.gcsDataSink = buildGcsData(); |
| 728 o.gcsDataSource = buildGcsData(); |
| 729 o.httpDataSource = buildHttpData(); |
| 730 o.objectConditions = buildObjectConditions(); |
| 731 o.transferOptions = buildTransferOptions(); |
| 732 } |
| 733 buildCounterTransferSpec--; |
| 734 return o; |
| 735 } |
| 736 |
| 737 checkTransferSpec(api.TransferSpec o) { |
| 738 buildCounterTransferSpec++; |
| 739 if (buildCounterTransferSpec < 3) { |
| 740 checkAwsS3Data(o.awsS3DataSource); |
| 741 checkGcsData(o.gcsDataSink); |
| 742 checkGcsData(o.gcsDataSource); |
| 743 checkHttpData(o.httpDataSource); |
| 744 checkObjectConditions(o.objectConditions); |
| 745 checkTransferOptions(o.transferOptions); |
| 746 } |
| 747 buildCounterTransferSpec--; |
| 748 } |
| 749 |
| 750 core.int buildCounterUpdateTransferJobRequest = 0; |
| 751 buildUpdateTransferJobRequest() { |
| 752 var o = new api.UpdateTransferJobRequest(); |
| 753 buildCounterUpdateTransferJobRequest++; |
| 754 if (buildCounterUpdateTransferJobRequest < 3) { |
| 755 o.projectId = "foo"; |
| 756 o.transferJob = buildTransferJob(); |
| 757 o.updateTransferJobFieldMask = "foo"; |
| 758 } |
| 759 buildCounterUpdateTransferJobRequest--; |
| 760 return o; |
| 761 } |
| 762 |
| 763 checkUpdateTransferJobRequest(api.UpdateTransferJobRequest o) { |
| 764 buildCounterUpdateTransferJobRequest++; |
| 765 if (buildCounterUpdateTransferJobRequest < 3) { |
| 766 unittest.expect(o.projectId, unittest.equals('foo')); |
| 767 checkTransferJob(o.transferJob); |
| 768 unittest.expect(o.updateTransferJobFieldMask, unittest.equals('foo')); |
| 769 } |
| 770 buildCounterUpdateTransferJobRequest--; |
| 771 } |
| 772 |
| 773 |
| 774 main() { |
| 775 unittest.group("obj-schema-AwsAccessKey", () { |
| 776 unittest.test("to-json--from-json", () { |
| 777 var o = buildAwsAccessKey(); |
| 778 var od = new api.AwsAccessKey.fromJson(o.toJson()); |
| 779 checkAwsAccessKey(od); |
| 780 }); |
| 781 }); |
| 782 |
| 783 |
| 784 unittest.group("obj-schema-AwsS3Data", () { |
| 785 unittest.test("to-json--from-json", () { |
| 786 var o = buildAwsS3Data(); |
| 787 var od = new api.AwsS3Data.fromJson(o.toJson()); |
| 788 checkAwsS3Data(od); |
| 789 }); |
| 790 }); |
| 791 |
| 792 |
| 793 unittest.group("obj-schema-Date", () { |
| 794 unittest.test("to-json--from-json", () { |
| 795 var o = buildDate(); |
| 796 var od = new api.Date.fromJson(o.toJson()); |
| 797 checkDate(od); |
| 798 }); |
| 799 }); |
| 800 |
| 801 |
| 802 unittest.group("obj-schema-Empty", () { |
| 803 unittest.test("to-json--from-json", () { |
| 804 var o = buildEmpty(); |
| 805 var od = new api.Empty.fromJson(o.toJson()); |
| 806 checkEmpty(od); |
| 807 }); |
| 808 }); |
| 809 |
| 810 |
| 811 unittest.group("obj-schema-ErrorLogEntry", () { |
| 812 unittest.test("to-json--from-json", () { |
| 813 var o = buildErrorLogEntry(); |
| 814 var od = new api.ErrorLogEntry.fromJson(o.toJson()); |
| 815 checkErrorLogEntry(od); |
| 816 }); |
| 817 }); |
| 818 |
| 819 |
| 820 unittest.group("obj-schema-ErrorSummary", () { |
| 821 unittest.test("to-json--from-json", () { |
| 822 var o = buildErrorSummary(); |
| 823 var od = new api.ErrorSummary.fromJson(o.toJson()); |
| 824 checkErrorSummary(od); |
| 825 }); |
| 826 }); |
| 827 |
| 828 |
| 829 unittest.group("obj-schema-GcsData", () { |
| 830 unittest.test("to-json--from-json", () { |
| 831 var o = buildGcsData(); |
| 832 var od = new api.GcsData.fromJson(o.toJson()); |
| 833 checkGcsData(od); |
| 834 }); |
| 835 }); |
| 836 |
| 837 |
| 838 unittest.group("obj-schema-GoogleServiceAccount", () { |
| 839 unittest.test("to-json--from-json", () { |
| 840 var o = buildGoogleServiceAccount(); |
| 841 var od = new api.GoogleServiceAccount.fromJson(o.toJson()); |
| 842 checkGoogleServiceAccount(od); |
| 843 }); |
| 844 }); |
| 845 |
| 846 |
| 847 unittest.group("obj-schema-HttpData", () { |
| 848 unittest.test("to-json--from-json", () { |
| 849 var o = buildHttpData(); |
| 850 var od = new api.HttpData.fromJson(o.toJson()); |
| 851 checkHttpData(od); |
| 852 }); |
| 853 }); |
| 854 |
| 855 |
| 856 unittest.group("obj-schema-ListOperationsResponse", () { |
| 857 unittest.test("to-json--from-json", () { |
| 858 var o = buildListOperationsResponse(); |
| 859 var od = new api.ListOperationsResponse.fromJson(o.toJson()); |
| 860 checkListOperationsResponse(od); |
| 861 }); |
| 862 }); |
| 863 |
| 864 |
| 865 unittest.group("obj-schema-ListTransferJobsResponse", () { |
| 866 unittest.test("to-json--from-json", () { |
| 867 var o = buildListTransferJobsResponse(); |
| 868 var od = new api.ListTransferJobsResponse.fromJson(o.toJson()); |
| 869 checkListTransferJobsResponse(od); |
| 870 }); |
| 871 }); |
| 872 |
| 873 |
| 874 unittest.group("obj-schema-ObjectConditions", () { |
| 875 unittest.test("to-json--from-json", () { |
| 876 var o = buildObjectConditions(); |
| 877 var od = new api.ObjectConditions.fromJson(o.toJson()); |
| 878 checkObjectConditions(od); |
| 879 }); |
| 880 }); |
| 881 |
| 882 |
| 883 unittest.group("obj-schema-Operation", () { |
| 884 unittest.test("to-json--from-json", () { |
| 885 var o = buildOperation(); |
| 886 var od = new api.Operation.fromJson(o.toJson()); |
| 887 checkOperation(od); |
| 888 }); |
| 889 }); |
| 890 |
| 891 |
| 892 unittest.group("obj-schema-PauseTransferOperationRequest", () { |
| 893 unittest.test("to-json--from-json", () { |
| 894 var o = buildPauseTransferOperationRequest(); |
| 895 var od = new api.PauseTransferOperationRequest.fromJson(o.toJson()); |
| 896 checkPauseTransferOperationRequest(od); |
| 897 }); |
| 898 }); |
| 899 |
| 900 |
| 901 unittest.group("obj-schema-ResumeTransferOperationRequest", () { |
| 902 unittest.test("to-json--from-json", () { |
| 903 var o = buildResumeTransferOperationRequest(); |
| 904 var od = new api.ResumeTransferOperationRequest.fromJson(o.toJson()); |
| 905 checkResumeTransferOperationRequest(od); |
| 906 }); |
| 907 }); |
| 908 |
| 909 |
| 910 unittest.group("obj-schema-Schedule", () { |
| 911 unittest.test("to-json--from-json", () { |
| 912 var o = buildSchedule(); |
| 913 var od = new api.Schedule.fromJson(o.toJson()); |
| 914 checkSchedule(od); |
| 915 }); |
| 916 }); |
| 917 |
| 918 |
| 919 unittest.group("obj-schema-Status", () { |
| 920 unittest.test("to-json--from-json", () { |
| 921 var o = buildStatus(); |
| 922 var od = new api.Status.fromJson(o.toJson()); |
| 923 checkStatus(od); |
| 924 }); |
| 925 }); |
| 926 |
| 927 |
| 928 unittest.group("obj-schema-TimeOfDay", () { |
| 929 unittest.test("to-json--from-json", () { |
| 930 var o = buildTimeOfDay(); |
| 931 var od = new api.TimeOfDay.fromJson(o.toJson()); |
| 932 checkTimeOfDay(od); |
| 933 }); |
| 934 }); |
| 935 |
| 936 |
| 937 unittest.group("obj-schema-TransferCounters", () { |
| 938 unittest.test("to-json--from-json", () { |
| 939 var o = buildTransferCounters(); |
| 940 var od = new api.TransferCounters.fromJson(o.toJson()); |
| 941 checkTransferCounters(od); |
| 942 }); |
| 943 }); |
| 944 |
| 945 |
| 946 unittest.group("obj-schema-TransferJob", () { |
| 947 unittest.test("to-json--from-json", () { |
| 948 var o = buildTransferJob(); |
| 949 var od = new api.TransferJob.fromJson(o.toJson()); |
| 950 checkTransferJob(od); |
| 951 }); |
| 952 }); |
| 953 |
| 954 |
| 955 unittest.group("obj-schema-TransferOperation", () { |
| 956 unittest.test("to-json--from-json", () { |
| 957 var o = buildTransferOperation(); |
| 958 var od = new api.TransferOperation.fromJson(o.toJson()); |
| 959 checkTransferOperation(od); |
| 960 }); |
| 961 }); |
| 962 |
| 963 |
| 964 unittest.group("obj-schema-TransferOptions", () { |
| 965 unittest.test("to-json--from-json", () { |
| 966 var o = buildTransferOptions(); |
| 967 var od = new api.TransferOptions.fromJson(o.toJson()); |
| 968 checkTransferOptions(od); |
| 969 }); |
| 970 }); |
| 971 |
| 972 |
| 973 unittest.group("obj-schema-TransferSpec", () { |
| 974 unittest.test("to-json--from-json", () { |
| 975 var o = buildTransferSpec(); |
| 976 var od = new api.TransferSpec.fromJson(o.toJson()); |
| 977 checkTransferSpec(od); |
| 978 }); |
| 979 }); |
| 980 |
| 981 |
| 982 unittest.group("obj-schema-UpdateTransferJobRequest", () { |
| 983 unittest.test("to-json--from-json", () { |
| 984 var o = buildUpdateTransferJobRequest(); |
| 985 var od = new api.UpdateTransferJobRequest.fromJson(o.toJson()); |
| 986 checkUpdateTransferJobRequest(od); |
| 987 }); |
| 988 }); |
| 989 |
| 990 |
| 991 unittest.group("resource-GoogleServiceAccountsResourceApi", () { |
| 992 unittest.test("method--get", () { |
| 993 |
| 994 var mock = new HttpServerMock(); |
| 995 api.GoogleServiceAccountsResourceApi res = new api.StoragetransferApi(mock
).googleServiceAccounts; |
| 996 var arg_projectId = "foo"; |
| 997 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| 998 var path = (req.url).path; |
| 999 var pathOffset = 0; |
| 1000 var index; |
| 1001 var subPart; |
| 1002 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
| 1003 pathOffset += 1; |
| 1004 unittest.expect(path.substring(pathOffset, pathOffset + 25), unittest.eq
uals("v1/googleServiceAccounts/")); |
| 1005 pathOffset += 25; |
| 1006 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); |
| 1007 pathOffset = path.length; |
| 1008 unittest.expect(subPart, unittest.equals("$arg_projectId")); |
| 1009 |
| 1010 var query = (req.url).query; |
| 1011 var queryOffset = 0; |
| 1012 var queryMap = {}; |
| 1013 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 1014 parseBool(n) { |
| 1015 if (n == "true") return true; |
| 1016 if (n == "false") return false; |
| 1017 if (n == null) return null; |
| 1018 throw new core.ArgumentError("Invalid boolean: $n"); |
| 1019 } |
| 1020 if (query.length > 0) { |
| 1021 for (var part in query.split("&")) { |
| 1022 var keyvalue = part.split("="); |
| 1023 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
| 1024 } |
| 1025 } |
| 1026 |
| 1027 |
| 1028 var h = { |
| 1029 "content-type" : "application/json; charset=utf-8", |
| 1030 }; |
| 1031 var resp = convert.JSON.encode(buildGoogleServiceAccount()); |
| 1032 return new async.Future.value(stringResponse(200, h, resp)); |
| 1033 }), true); |
| 1034 res.get(arg_projectId).then(unittest.expectAsync(((api.GoogleServiceAccoun
t response) { |
| 1035 checkGoogleServiceAccount(response); |
| 1036 }))); |
| 1037 }); |
| 1038 |
| 1039 }); |
| 1040 |
| 1041 |
| 1042 unittest.group("resource-TransferJobsResourceApi", () { |
| 1043 unittest.test("method--create", () { |
| 1044 |
| 1045 var mock = new HttpServerMock(); |
| 1046 api.TransferJobsResourceApi res = new api.StoragetransferApi(mock).transfe
rJobs; |
| 1047 var arg_request = buildTransferJob(); |
| 1048 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| 1049 var obj = new api.TransferJob.fromJson(json); |
| 1050 checkTransferJob(obj); |
| 1051 |
| 1052 var path = (req.url).path; |
| 1053 var pathOffset = 0; |
| 1054 var index; |
| 1055 var subPart; |
| 1056 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
| 1057 pathOffset += 1; |
| 1058 unittest.expect(path.substring(pathOffset, pathOffset + 15), unittest.eq
uals("v1/transferJobs")); |
| 1059 pathOffset += 15; |
| 1060 |
| 1061 var query = (req.url).query; |
| 1062 var queryOffset = 0; |
| 1063 var queryMap = {}; |
| 1064 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 1065 parseBool(n) { |
| 1066 if (n == "true") return true; |
| 1067 if (n == "false") return false; |
| 1068 if (n == null) return null; |
| 1069 throw new core.ArgumentError("Invalid boolean: $n"); |
| 1070 } |
| 1071 if (query.length > 0) { |
| 1072 for (var part in query.split("&")) { |
| 1073 var keyvalue = part.split("="); |
| 1074 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
| 1075 } |
| 1076 } |
| 1077 |
| 1078 |
| 1079 var h = { |
| 1080 "content-type" : "application/json; charset=utf-8", |
| 1081 }; |
| 1082 var resp = convert.JSON.encode(buildTransferJob()); |
| 1083 return new async.Future.value(stringResponse(200, h, resp)); |
| 1084 }), true); |
| 1085 res.create(arg_request).then(unittest.expectAsync(((api.TransferJob respon
se) { |
| 1086 checkTransferJob(response); |
| 1087 }))); |
| 1088 }); |
| 1089 |
| 1090 unittest.test("method--get", () { |
| 1091 |
| 1092 var mock = new HttpServerMock(); |
| 1093 api.TransferJobsResourceApi res = new api.StoragetransferApi(mock).transfe
rJobs; |
| 1094 var arg_jobName = "foo"; |
| 1095 var arg_projectId = "foo"; |
| 1096 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| 1097 var path = (req.url).path; |
| 1098 var pathOffset = 0; |
| 1099 var index; |
| 1100 var subPart; |
| 1101 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
| 1102 pathOffset += 1; |
| 1103 unittest.expect(path.substring(pathOffset, pathOffset + 3), unittest.equ
als("v1/")); |
| 1104 pathOffset += 3; |
| 1105 // NOTE: We cannot test reserved expansions due to the inability to reve
rse the operation; |
| 1106 |
| 1107 var query = (req.url).query; |
| 1108 var queryOffset = 0; |
| 1109 var queryMap = {}; |
| 1110 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 1111 parseBool(n) { |
| 1112 if (n == "true") return true; |
| 1113 if (n == "false") return false; |
| 1114 if (n == null) return null; |
| 1115 throw new core.ArgumentError("Invalid boolean: $n"); |
| 1116 } |
| 1117 if (query.length > 0) { |
| 1118 for (var part in query.split("&")) { |
| 1119 var keyvalue = part.split("="); |
| 1120 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
| 1121 } |
| 1122 } |
| 1123 unittest.expect(queryMap["projectId"].first, unittest.equals(arg_project
Id)); |
| 1124 |
| 1125 |
| 1126 var h = { |
| 1127 "content-type" : "application/json; charset=utf-8", |
| 1128 }; |
| 1129 var resp = convert.JSON.encode(buildTransferJob()); |
| 1130 return new async.Future.value(stringResponse(200, h, resp)); |
| 1131 }), true); |
| 1132 res.get(arg_jobName, projectId: arg_projectId).then(unittest.expectAsync((
(api.TransferJob response) { |
| 1133 checkTransferJob(response); |
| 1134 }))); |
| 1135 }); |
| 1136 |
| 1137 unittest.test("method--list", () { |
| 1138 |
| 1139 var mock = new HttpServerMock(); |
| 1140 api.TransferJobsResourceApi res = new api.StoragetransferApi(mock).transfe
rJobs; |
| 1141 var arg_filter = "foo"; |
| 1142 var arg_pageSize = 42; |
| 1143 var arg_pageToken = "foo"; |
| 1144 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| 1145 var path = (req.url).path; |
| 1146 var pathOffset = 0; |
| 1147 var index; |
| 1148 var subPart; |
| 1149 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
| 1150 pathOffset += 1; |
| 1151 unittest.expect(path.substring(pathOffset, pathOffset + 15), unittest.eq
uals("v1/transferJobs")); |
| 1152 pathOffset += 15; |
| 1153 |
| 1154 var query = (req.url).query; |
| 1155 var queryOffset = 0; |
| 1156 var queryMap = {}; |
| 1157 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 1158 parseBool(n) { |
| 1159 if (n == "true") return true; |
| 1160 if (n == "false") return false; |
| 1161 if (n == null) return null; |
| 1162 throw new core.ArgumentError("Invalid boolean: $n"); |
| 1163 } |
| 1164 if (query.length > 0) { |
| 1165 for (var part in query.split("&")) { |
| 1166 var keyvalue = part.split("="); |
| 1167 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
| 1168 } |
| 1169 } |
| 1170 unittest.expect(queryMap["filter"].first, unittest.equals(arg_filter)); |
| 1171 unittest.expect(core.int.parse(queryMap["pageSize"].first), unittest.equ
als(arg_pageSize)); |
| 1172 unittest.expect(queryMap["pageToken"].first, unittest.equals(arg_pageTok
en)); |
| 1173 |
| 1174 |
| 1175 var h = { |
| 1176 "content-type" : "application/json; charset=utf-8", |
| 1177 }; |
| 1178 var resp = convert.JSON.encode(buildListTransferJobsResponse()); |
| 1179 return new async.Future.value(stringResponse(200, h, resp)); |
| 1180 }), true); |
| 1181 res.list(filter: arg_filter, pageSize: arg_pageSize, pageToken: arg_pageTo
ken).then(unittest.expectAsync(((api.ListTransferJobsResponse response) { |
| 1182 checkListTransferJobsResponse(response); |
| 1183 }))); |
| 1184 }); |
| 1185 |
| 1186 unittest.test("method--patch", () { |
| 1187 |
| 1188 var mock = new HttpServerMock(); |
| 1189 api.TransferJobsResourceApi res = new api.StoragetransferApi(mock).transfe
rJobs; |
| 1190 var arg_request = buildUpdateTransferJobRequest(); |
| 1191 var arg_jobName = "foo"; |
| 1192 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| 1193 var obj = new api.UpdateTransferJobRequest.fromJson(json); |
| 1194 checkUpdateTransferJobRequest(obj); |
| 1195 |
| 1196 var path = (req.url).path; |
| 1197 var pathOffset = 0; |
| 1198 var index; |
| 1199 var subPart; |
| 1200 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
| 1201 pathOffset += 1; |
| 1202 unittest.expect(path.substring(pathOffset, pathOffset + 3), unittest.equ
als("v1/")); |
| 1203 pathOffset += 3; |
| 1204 // NOTE: We cannot test reserved expansions due to the inability to reve
rse the operation; |
| 1205 |
| 1206 var query = (req.url).query; |
| 1207 var queryOffset = 0; |
| 1208 var queryMap = {}; |
| 1209 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 1210 parseBool(n) { |
| 1211 if (n == "true") return true; |
| 1212 if (n == "false") return false; |
| 1213 if (n == null) return null; |
| 1214 throw new core.ArgumentError("Invalid boolean: $n"); |
| 1215 } |
| 1216 if (query.length > 0) { |
| 1217 for (var part in query.split("&")) { |
| 1218 var keyvalue = part.split("="); |
| 1219 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
| 1220 } |
| 1221 } |
| 1222 |
| 1223 |
| 1224 var h = { |
| 1225 "content-type" : "application/json; charset=utf-8", |
| 1226 }; |
| 1227 var resp = convert.JSON.encode(buildTransferJob()); |
| 1228 return new async.Future.value(stringResponse(200, h, resp)); |
| 1229 }), true); |
| 1230 res.patch(arg_request, arg_jobName).then(unittest.expectAsync(((api.Transf
erJob response) { |
| 1231 checkTransferJob(response); |
| 1232 }))); |
| 1233 }); |
| 1234 |
| 1235 }); |
| 1236 |
| 1237 |
| 1238 unittest.group("resource-TransferOperationsResourceApi", () { |
| 1239 unittest.test("method--cancel", () { |
| 1240 |
| 1241 var mock = new HttpServerMock(); |
| 1242 api.TransferOperationsResourceApi res = new api.StoragetransferApi(mock).t
ransferOperations; |
| 1243 var arg_name = "foo"; |
| 1244 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| 1245 var path = (req.url).path; |
| 1246 var pathOffset = 0; |
| 1247 var index; |
| 1248 var subPart; |
| 1249 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
| 1250 pathOffset += 1; |
| 1251 unittest.expect(path.substring(pathOffset, pathOffset + 3), unittest.equ
als("v1/")); |
| 1252 pathOffset += 3; |
| 1253 // NOTE: We cannot test reserved expansions due to the inability to reve
rse the operation; |
| 1254 |
| 1255 var query = (req.url).query; |
| 1256 var queryOffset = 0; |
| 1257 var queryMap = {}; |
| 1258 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 1259 parseBool(n) { |
| 1260 if (n == "true") return true; |
| 1261 if (n == "false") return false; |
| 1262 if (n == null) return null; |
| 1263 throw new core.ArgumentError("Invalid boolean: $n"); |
| 1264 } |
| 1265 if (query.length > 0) { |
| 1266 for (var part in query.split("&")) { |
| 1267 var keyvalue = part.split("="); |
| 1268 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
| 1269 } |
| 1270 } |
| 1271 |
| 1272 |
| 1273 var h = { |
| 1274 "content-type" : "application/json; charset=utf-8", |
| 1275 }; |
| 1276 var resp = convert.JSON.encode(buildEmpty()); |
| 1277 return new async.Future.value(stringResponse(200, h, resp)); |
| 1278 }), true); |
| 1279 res.cancel(arg_name).then(unittest.expectAsync(((api.Empty response) { |
| 1280 checkEmpty(response); |
| 1281 }))); |
| 1282 }); |
| 1283 |
| 1284 unittest.test("method--delete", () { |
| 1285 |
| 1286 var mock = new HttpServerMock(); |
| 1287 api.TransferOperationsResourceApi res = new api.StoragetransferApi(mock).t
ransferOperations; |
| 1288 var arg_name = "foo"; |
| 1289 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| 1290 var path = (req.url).path; |
| 1291 var pathOffset = 0; |
| 1292 var index; |
| 1293 var subPart; |
| 1294 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
| 1295 pathOffset += 1; |
| 1296 unittest.expect(path.substring(pathOffset, pathOffset + 3), unittest.equ
als("v1/")); |
| 1297 pathOffset += 3; |
| 1298 // NOTE: We cannot test reserved expansions due to the inability to reve
rse the operation; |
| 1299 |
| 1300 var query = (req.url).query; |
| 1301 var queryOffset = 0; |
| 1302 var queryMap = {}; |
| 1303 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 1304 parseBool(n) { |
| 1305 if (n == "true") return true; |
| 1306 if (n == "false") return false; |
| 1307 if (n == null) return null; |
| 1308 throw new core.ArgumentError("Invalid boolean: $n"); |
| 1309 } |
| 1310 if (query.length > 0) { |
| 1311 for (var part in query.split("&")) { |
| 1312 var keyvalue = part.split("="); |
| 1313 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
| 1314 } |
| 1315 } |
| 1316 |
| 1317 |
| 1318 var h = { |
| 1319 "content-type" : "application/json; charset=utf-8", |
| 1320 }; |
| 1321 var resp = convert.JSON.encode(buildEmpty()); |
| 1322 return new async.Future.value(stringResponse(200, h, resp)); |
| 1323 }), true); |
| 1324 res.delete(arg_name).then(unittest.expectAsync(((api.Empty response) { |
| 1325 checkEmpty(response); |
| 1326 }))); |
| 1327 }); |
| 1328 |
| 1329 unittest.test("method--get", () { |
| 1330 |
| 1331 var mock = new HttpServerMock(); |
| 1332 api.TransferOperationsResourceApi res = new api.StoragetransferApi(mock).t
ransferOperations; |
| 1333 var arg_name = "foo"; |
| 1334 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| 1335 var path = (req.url).path; |
| 1336 var pathOffset = 0; |
| 1337 var index; |
| 1338 var subPart; |
| 1339 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
| 1340 pathOffset += 1; |
| 1341 unittest.expect(path.substring(pathOffset, pathOffset + 3), unittest.equ
als("v1/")); |
| 1342 pathOffset += 3; |
| 1343 // NOTE: We cannot test reserved expansions due to the inability to reve
rse the operation; |
| 1344 |
| 1345 var query = (req.url).query; |
| 1346 var queryOffset = 0; |
| 1347 var queryMap = {}; |
| 1348 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 1349 parseBool(n) { |
| 1350 if (n == "true") return true; |
| 1351 if (n == "false") return false; |
| 1352 if (n == null) return null; |
| 1353 throw new core.ArgumentError("Invalid boolean: $n"); |
| 1354 } |
| 1355 if (query.length > 0) { |
| 1356 for (var part in query.split("&")) { |
| 1357 var keyvalue = part.split("="); |
| 1358 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
| 1359 } |
| 1360 } |
| 1361 |
| 1362 |
| 1363 var h = { |
| 1364 "content-type" : "application/json; charset=utf-8", |
| 1365 }; |
| 1366 var resp = convert.JSON.encode(buildOperation()); |
| 1367 return new async.Future.value(stringResponse(200, h, resp)); |
| 1368 }), true); |
| 1369 res.get(arg_name).then(unittest.expectAsync(((api.Operation response) { |
| 1370 checkOperation(response); |
| 1371 }))); |
| 1372 }); |
| 1373 |
| 1374 unittest.test("method--list", () { |
| 1375 |
| 1376 var mock = new HttpServerMock(); |
| 1377 api.TransferOperationsResourceApi res = new api.StoragetransferApi(mock).t
ransferOperations; |
| 1378 var arg_name = "foo"; |
| 1379 var arg_filter = "foo"; |
| 1380 var arg_pageSize = 42; |
| 1381 var arg_pageToken = "foo"; |
| 1382 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| 1383 var path = (req.url).path; |
| 1384 var pathOffset = 0; |
| 1385 var index; |
| 1386 var subPart; |
| 1387 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
| 1388 pathOffset += 1; |
| 1389 unittest.expect(path.substring(pathOffset, pathOffset + 3), unittest.equ
als("v1/")); |
| 1390 pathOffset += 3; |
| 1391 // NOTE: We cannot test reserved expansions due to the inability to reve
rse the operation; |
| 1392 |
| 1393 var query = (req.url).query; |
| 1394 var queryOffset = 0; |
| 1395 var queryMap = {}; |
| 1396 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 1397 parseBool(n) { |
| 1398 if (n == "true") return true; |
| 1399 if (n == "false") return false; |
| 1400 if (n == null) return null; |
| 1401 throw new core.ArgumentError("Invalid boolean: $n"); |
| 1402 } |
| 1403 if (query.length > 0) { |
| 1404 for (var part in query.split("&")) { |
| 1405 var keyvalue = part.split("="); |
| 1406 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
| 1407 } |
| 1408 } |
| 1409 unittest.expect(queryMap["filter"].first, unittest.equals(arg_filter)); |
| 1410 unittest.expect(core.int.parse(queryMap["pageSize"].first), unittest.equ
als(arg_pageSize)); |
| 1411 unittest.expect(queryMap["pageToken"].first, unittest.equals(arg_pageTok
en)); |
| 1412 |
| 1413 |
| 1414 var h = { |
| 1415 "content-type" : "application/json; charset=utf-8", |
| 1416 }; |
| 1417 var resp = convert.JSON.encode(buildListOperationsResponse()); |
| 1418 return new async.Future.value(stringResponse(200, h, resp)); |
| 1419 }), true); |
| 1420 res.list(arg_name, filter: arg_filter, pageSize: arg_pageSize, pageToken:
arg_pageToken).then(unittest.expectAsync(((api.ListOperationsResponse response)
{ |
| 1421 checkListOperationsResponse(response); |
| 1422 }))); |
| 1423 }); |
| 1424 |
| 1425 unittest.test("method--pause", () { |
| 1426 |
| 1427 var mock = new HttpServerMock(); |
| 1428 api.TransferOperationsResourceApi res = new api.StoragetransferApi(mock).t
ransferOperations; |
| 1429 var arg_request = buildPauseTransferOperationRequest(); |
| 1430 var arg_name = "foo"; |
| 1431 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| 1432 var obj = new api.PauseTransferOperationRequest.fromJson(json); |
| 1433 checkPauseTransferOperationRequest(obj); |
| 1434 |
| 1435 var path = (req.url).path; |
| 1436 var pathOffset = 0; |
| 1437 var index; |
| 1438 var subPart; |
| 1439 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
| 1440 pathOffset += 1; |
| 1441 unittest.expect(path.substring(pathOffset, pathOffset + 3), unittest.equ
als("v1/")); |
| 1442 pathOffset += 3; |
| 1443 // NOTE: We cannot test reserved expansions due to the inability to reve
rse the operation; |
| 1444 |
| 1445 var query = (req.url).query; |
| 1446 var queryOffset = 0; |
| 1447 var queryMap = {}; |
| 1448 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 1449 parseBool(n) { |
| 1450 if (n == "true") return true; |
| 1451 if (n == "false") return false; |
| 1452 if (n == null) return null; |
| 1453 throw new core.ArgumentError("Invalid boolean: $n"); |
| 1454 } |
| 1455 if (query.length > 0) { |
| 1456 for (var part in query.split("&")) { |
| 1457 var keyvalue = part.split("="); |
| 1458 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
| 1459 } |
| 1460 } |
| 1461 |
| 1462 |
| 1463 var h = { |
| 1464 "content-type" : "application/json; charset=utf-8", |
| 1465 }; |
| 1466 var resp = convert.JSON.encode(buildEmpty()); |
| 1467 return new async.Future.value(stringResponse(200, h, resp)); |
| 1468 }), true); |
| 1469 res.pause(arg_request, arg_name).then(unittest.expectAsync(((api.Empty res
ponse) { |
| 1470 checkEmpty(response); |
| 1471 }))); |
| 1472 }); |
| 1473 |
| 1474 unittest.test("method--resume", () { |
| 1475 |
| 1476 var mock = new HttpServerMock(); |
| 1477 api.TransferOperationsResourceApi res = new api.StoragetransferApi(mock).t
ransferOperations; |
| 1478 var arg_request = buildResumeTransferOperationRequest(); |
| 1479 var arg_name = "foo"; |
| 1480 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| 1481 var obj = new api.ResumeTransferOperationRequest.fromJson(json); |
| 1482 checkResumeTransferOperationRequest(obj); |
| 1483 |
| 1484 var path = (req.url).path; |
| 1485 var pathOffset = 0; |
| 1486 var index; |
| 1487 var subPart; |
| 1488 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
| 1489 pathOffset += 1; |
| 1490 unittest.expect(path.substring(pathOffset, pathOffset + 3), unittest.equ
als("v1/")); |
| 1491 pathOffset += 3; |
| 1492 // NOTE: We cannot test reserved expansions due to the inability to reve
rse the operation; |
| 1493 |
| 1494 var query = (req.url).query; |
| 1495 var queryOffset = 0; |
| 1496 var queryMap = {}; |
| 1497 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 1498 parseBool(n) { |
| 1499 if (n == "true") return true; |
| 1500 if (n == "false") return false; |
| 1501 if (n == null) return null; |
| 1502 throw new core.ArgumentError("Invalid boolean: $n"); |
| 1503 } |
| 1504 if (query.length > 0) { |
| 1505 for (var part in query.split("&")) { |
| 1506 var keyvalue = part.split("="); |
| 1507 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
| 1508 } |
| 1509 } |
| 1510 |
| 1511 |
| 1512 var h = { |
| 1513 "content-type" : "application/json; charset=utf-8", |
| 1514 }; |
| 1515 var resp = convert.JSON.encode(buildEmpty()); |
| 1516 return new async.Future.value(stringResponse(200, h, resp)); |
| 1517 }), true); |
| 1518 res.resume(arg_request, arg_name).then(unittest.expectAsync(((api.Empty re
sponse) { |
| 1519 checkEmpty(response); |
| 1520 }))); |
| 1521 }); |
| 1522 |
| 1523 }); |
| 1524 |
| 1525 |
| 1526 unittest.group("resource-V1ResourceApi", () { |
| 1527 unittest.test("method--getGoogleServiceAccount", () { |
| 1528 |
| 1529 var mock = new HttpServerMock(); |
| 1530 api.V1ResourceApi res = new api.StoragetransferApi(mock).v1; |
| 1531 var arg_projectId = "foo"; |
| 1532 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| 1533 var path = (req.url).path; |
| 1534 var pathOffset = 0; |
| 1535 var index; |
| 1536 var subPart; |
| 1537 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
| 1538 pathOffset += 1; |
| 1539 unittest.expect(path.substring(pathOffset, pathOffset + 26), unittest.eq
uals("v1:getGoogleServiceAccount")); |
| 1540 pathOffset += 26; |
| 1541 |
| 1542 var query = (req.url).query; |
| 1543 var queryOffset = 0; |
| 1544 var queryMap = {}; |
| 1545 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 1546 parseBool(n) { |
| 1547 if (n == "true") return true; |
| 1548 if (n == "false") return false; |
| 1549 if (n == null) return null; |
| 1550 throw new core.ArgumentError("Invalid boolean: $n"); |
| 1551 } |
| 1552 if (query.length > 0) { |
| 1553 for (var part in query.split("&")) { |
| 1554 var keyvalue = part.split("="); |
| 1555 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
| 1556 } |
| 1557 } |
| 1558 unittest.expect(queryMap["projectId"].first, unittest.equals(arg_project
Id)); |
| 1559 |
| 1560 |
| 1561 var h = { |
| 1562 "content-type" : "application/json; charset=utf-8", |
| 1563 }; |
| 1564 var resp = convert.JSON.encode(buildGoogleServiceAccount()); |
| 1565 return new async.Future.value(stringResponse(200, h, resp)); |
| 1566 }), true); |
| 1567 res.getGoogleServiceAccount(projectId: arg_projectId).then(unittest.expect
Async(((api.GoogleServiceAccount response) { |
| 1568 checkGoogleServiceAccount(response); |
| 1569 }))); |
| 1570 }); |
| 1571 |
| 1572 }); |
| 1573 |
| 1574 |
| 1575 } |
| 1576 |
OLD | NEW |