| OLD | NEW |
| 1 library googleapis.manufacturers.v1.test; | 1 library googleapis.manufacturers.v1.test; |
| 2 | 2 |
| 3 import "dart:core" as core; | 3 import "dart:core" as core; |
| 4 import "dart:collection" as collection; | 4 import "dart:collection" as collection; |
| 5 import "dart:async" as async; | 5 import "dart:async" as async; |
| 6 import "dart:convert" as convert; | 6 import "dart:convert" as convert; |
| 7 | 7 |
| 8 import 'package:http/http.dart' as http; | 8 import 'package:http/http.dart' as http; |
| 9 import 'package:http/testing.dart' as http_testing; | 9 import 'package:http/testing.dart' as http_testing; |
| 10 import 'package:unittest/unittest.dart' as unittest; | 10 import 'package:unittest/unittest.dart' as unittest; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 } | 44 } |
| 45 } | 45 } |
| 46 } | 46 } |
| 47 | 47 |
| 48 http.StreamedResponse stringResponse( | 48 http.StreamedResponse stringResponse( |
| 49 core.int status, core.Map headers, core.String body) { | 49 core.int status, core.Map headers, core.String body) { |
| 50 var stream = new async.Stream.fromIterable([convert.UTF8.encode(body)]); | 50 var stream = new async.Stream.fromIterable([convert.UTF8.encode(body)]); |
| 51 return new http.StreamedResponse(stream, status, headers: headers); | 51 return new http.StreamedResponse(stream, status, headers: headers); |
| 52 } | 52 } |
| 53 | 53 |
| 54 buildUnnamed1564() { | 54 buildUnnamed1576() { |
| 55 var o = new core.List<core.String>(); | 55 var o = new core.List<core.String>(); |
| 56 o.add("foo"); | 56 o.add("foo"); |
| 57 o.add("foo"); | 57 o.add("foo"); |
| 58 return o; | 58 return o; |
| 59 } | 59 } |
| 60 | 60 |
| 61 checkUnnamed1564(core.List<core.String> o) { | 61 checkUnnamed1576(core.List<core.String> o) { |
| 62 unittest.expect(o, unittest.hasLength(2)); | 62 unittest.expect(o, unittest.hasLength(2)); |
| 63 unittest.expect(o[0], unittest.equals('foo')); | 63 unittest.expect(o[0], unittest.equals('foo')); |
| 64 unittest.expect(o[1], unittest.equals('foo')); | 64 unittest.expect(o[1], unittest.equals('foo')); |
| 65 } | 65 } |
| 66 | 66 |
| 67 buildUnnamed1565() { | 67 buildUnnamed1577() { |
| 68 var o = new core.List<core.String>(); | 68 var o = new core.List<core.String>(); |
| 69 o.add("foo"); | 69 o.add("foo"); |
| 70 o.add("foo"); | 70 o.add("foo"); |
| 71 return o; | 71 return o; |
| 72 } | 72 } |
| 73 | 73 |
| 74 checkUnnamed1565(core.List<core.String> o) { | 74 checkUnnamed1577(core.List<core.String> o) { |
| 75 unittest.expect(o, unittest.hasLength(2)); | 75 unittest.expect(o, unittest.hasLength(2)); |
| 76 unittest.expect(o[0], unittest.equals('foo')); | 76 unittest.expect(o[0], unittest.equals('foo')); |
| 77 unittest.expect(o[1], unittest.equals('foo')); | 77 unittest.expect(o[1], unittest.equals('foo')); |
| 78 } | 78 } |
| 79 | 79 |
| 80 core.int buildCounterAttributes = 0; | 80 core.int buildCounterAttributes = 0; |
| 81 buildAttributes() { | 81 buildAttributes() { |
| 82 var o = new api.Attributes(); | 82 var o = new api.Attributes(); |
| 83 buildCounterAttributes++; | 83 buildCounterAttributes++; |
| 84 if (buildCounterAttributes < 3) { | 84 if (buildCounterAttributes < 3) { |
| 85 o.brand = "foo"; | 85 o.brand = "foo"; |
| 86 o.gtin = buildUnnamed1564(); | 86 o.gtin = buildUnnamed1576(); |
| 87 o.mpn = "foo"; | 87 o.mpn = "foo"; |
| 88 o.productLine = "foo"; | 88 o.productLine = "foo"; |
| 89 o.productName = "foo"; | 89 o.productName = "foo"; |
| 90 o.productPageUrl = "foo"; | 90 o.productPageUrl = "foo"; |
| 91 o.productType = buildUnnamed1565(); | 91 o.productType = buildUnnamed1577(); |
| 92 o.title = "foo"; | 92 o.title = "foo"; |
| 93 } | 93 } |
| 94 buildCounterAttributes--; | 94 buildCounterAttributes--; |
| 95 return o; | 95 return o; |
| 96 } | 96 } |
| 97 | 97 |
| 98 checkAttributes(api.Attributes o) { | 98 checkAttributes(api.Attributes o) { |
| 99 buildCounterAttributes++; | 99 buildCounterAttributes++; |
| 100 if (buildCounterAttributes < 3) { | 100 if (buildCounterAttributes < 3) { |
| 101 unittest.expect(o.brand, unittest.equals('foo')); | 101 unittest.expect(o.brand, unittest.equals('foo')); |
| 102 checkUnnamed1564(o.gtin); | 102 checkUnnamed1576(o.gtin); |
| 103 unittest.expect(o.mpn, unittest.equals('foo')); | 103 unittest.expect(o.mpn, unittest.equals('foo')); |
| 104 unittest.expect(o.productLine, unittest.equals('foo')); | 104 unittest.expect(o.productLine, unittest.equals('foo')); |
| 105 unittest.expect(o.productName, unittest.equals('foo')); | 105 unittest.expect(o.productName, unittest.equals('foo')); |
| 106 unittest.expect(o.productPageUrl, unittest.equals('foo')); | 106 unittest.expect(o.productPageUrl, unittest.equals('foo')); |
| 107 checkUnnamed1565(o.productType); | 107 checkUnnamed1577(o.productType); |
| 108 unittest.expect(o.title, unittest.equals('foo')); | 108 unittest.expect(o.title, unittest.equals('foo')); |
| 109 } | 109 } |
| 110 buildCounterAttributes--; | 110 buildCounterAttributes--; |
| 111 } | 111 } |
| 112 | 112 |
| 113 core.int buildCounterIssue = 0; | 113 core.int buildCounterIssue = 0; |
| 114 buildIssue() { | 114 buildIssue() { |
| 115 var o = new api.Issue(); | 115 var o = new api.Issue(); |
| 116 buildCounterIssue++; | 116 buildCounterIssue++; |
| 117 if (buildCounterIssue < 3) { | 117 if (buildCounterIssue < 3) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 128 buildCounterIssue++; | 128 buildCounterIssue++; |
| 129 if (buildCounterIssue < 3) { | 129 if (buildCounterIssue < 3) { |
| 130 unittest.expect(o.attribute, unittest.equals('foo')); | 130 unittest.expect(o.attribute, unittest.equals('foo')); |
| 131 unittest.expect(o.description, unittest.equals('foo')); | 131 unittest.expect(o.description, unittest.equals('foo')); |
| 132 unittest.expect(o.severity, unittest.equals('foo')); | 132 unittest.expect(o.severity, unittest.equals('foo')); |
| 133 unittest.expect(o.type, unittest.equals('foo')); | 133 unittest.expect(o.type, unittest.equals('foo')); |
| 134 } | 134 } |
| 135 buildCounterIssue--; | 135 buildCounterIssue--; |
| 136 } | 136 } |
| 137 | 137 |
| 138 buildUnnamed1566() { | 138 buildUnnamed1578() { |
| 139 var o = new core.List<api.Product>(); | 139 var o = new core.List<api.Product>(); |
| 140 o.add(buildProduct()); | 140 o.add(buildProduct()); |
| 141 o.add(buildProduct()); | 141 o.add(buildProduct()); |
| 142 return o; | 142 return o; |
| 143 } | 143 } |
| 144 | 144 |
| 145 checkUnnamed1566(core.List<api.Product> o) { | 145 checkUnnamed1578(core.List<api.Product> o) { |
| 146 unittest.expect(o, unittest.hasLength(2)); | 146 unittest.expect(o, unittest.hasLength(2)); |
| 147 checkProduct(o[0]); | 147 checkProduct(o[0]); |
| 148 checkProduct(o[1]); | 148 checkProduct(o[1]); |
| 149 } | 149 } |
| 150 | 150 |
| 151 core.int buildCounterListProductsResponse = 0; | 151 core.int buildCounterListProductsResponse = 0; |
| 152 buildListProductsResponse() { | 152 buildListProductsResponse() { |
| 153 var o = new api.ListProductsResponse(); | 153 var o = new api.ListProductsResponse(); |
| 154 buildCounterListProductsResponse++; | 154 buildCounterListProductsResponse++; |
| 155 if (buildCounterListProductsResponse < 3) { | 155 if (buildCounterListProductsResponse < 3) { |
| 156 o.nextPageToken = "foo"; | 156 o.nextPageToken = "foo"; |
| 157 o.products = buildUnnamed1566(); | 157 o.products = buildUnnamed1578(); |
| 158 } | 158 } |
| 159 buildCounterListProductsResponse--; | 159 buildCounterListProductsResponse--; |
| 160 return o; | 160 return o; |
| 161 } | 161 } |
| 162 | 162 |
| 163 checkListProductsResponse(api.ListProductsResponse o) { | 163 checkListProductsResponse(api.ListProductsResponse o) { |
| 164 buildCounterListProductsResponse++; | 164 buildCounterListProductsResponse++; |
| 165 if (buildCounterListProductsResponse < 3) { | 165 if (buildCounterListProductsResponse < 3) { |
| 166 unittest.expect(o.nextPageToken, unittest.equals('foo')); | 166 unittest.expect(o.nextPageToken, unittest.equals('foo')); |
| 167 checkUnnamed1566(o.products); | 167 checkUnnamed1578(o.products); |
| 168 } | 168 } |
| 169 buildCounterListProductsResponse--; | 169 buildCounterListProductsResponse--; |
| 170 } | 170 } |
| 171 | 171 |
| 172 buildUnnamed1567() { | 172 buildUnnamed1579() { |
| 173 var o = new core.List<api.Issue>(); | 173 var o = new core.List<api.Issue>(); |
| 174 o.add(buildIssue()); | 174 o.add(buildIssue()); |
| 175 o.add(buildIssue()); | 175 o.add(buildIssue()); |
| 176 return o; | 176 return o; |
| 177 } | 177 } |
| 178 | 178 |
| 179 checkUnnamed1567(core.List<api.Issue> o) { | 179 checkUnnamed1579(core.List<api.Issue> o) { |
| 180 unittest.expect(o, unittest.hasLength(2)); | 180 unittest.expect(o, unittest.hasLength(2)); |
| 181 checkIssue(o[0]); | 181 checkIssue(o[0]); |
| 182 checkIssue(o[1]); | 182 checkIssue(o[1]); |
| 183 } | 183 } |
| 184 | 184 |
| 185 buildUnnamed1568() { | 185 buildUnnamed1580() { |
| 186 var o = new core.List<core.String>(); | 186 var o = new core.List<core.String>(); |
| 187 o.add("foo"); | 187 o.add("foo"); |
| 188 o.add("foo"); | 188 o.add("foo"); |
| 189 return o; | 189 return o; |
| 190 } | 190 } |
| 191 | 191 |
| 192 checkUnnamed1568(core.List<core.String> o) { | 192 checkUnnamed1580(core.List<core.String> o) { |
| 193 unittest.expect(o, unittest.hasLength(2)); | 193 unittest.expect(o, unittest.hasLength(2)); |
| 194 unittest.expect(o[0], unittest.equals('foo')); | 194 unittest.expect(o[0], unittest.equals('foo')); |
| 195 unittest.expect(o[1], unittest.equals('foo')); | 195 unittest.expect(o[1], unittest.equals('foo')); |
| 196 } | 196 } |
| 197 | 197 |
| 198 core.int buildCounterProduct = 0; | 198 core.int buildCounterProduct = 0; |
| 199 buildProduct() { | 199 buildProduct() { |
| 200 var o = new api.Product(); | 200 var o = new api.Product(); |
| 201 buildCounterProduct++; | 201 buildCounterProduct++; |
| 202 if (buildCounterProduct < 3) { | 202 if (buildCounterProduct < 3) { |
| 203 o.contentLanguage = "foo"; | 203 o.contentLanguage = "foo"; |
| 204 o.finalAttributes = buildAttributes(); | 204 o.finalAttributes = buildAttributes(); |
| 205 o.issues = buildUnnamed1567(); | 205 o.issues = buildUnnamed1579(); |
| 206 o.manuallyDeletedAttributes = buildUnnamed1568(); | 206 o.manuallyDeletedAttributes = buildUnnamed1580(); |
| 207 o.manuallyProvidedAttributes = buildAttributes(); | 207 o.manuallyProvidedAttributes = buildAttributes(); |
| 208 o.name = "foo"; | 208 o.name = "foo"; |
| 209 o.parent = "foo"; | 209 o.parent = "foo"; |
| 210 o.productId = "foo"; | 210 o.productId = "foo"; |
| 211 o.targetCountry = "foo"; | 211 o.targetCountry = "foo"; |
| 212 o.uploadedAttributes = buildAttributes(); | 212 o.uploadedAttributes = buildAttributes(); |
| 213 } | 213 } |
| 214 buildCounterProduct--; | 214 buildCounterProduct--; |
| 215 return o; | 215 return o; |
| 216 } | 216 } |
| 217 | 217 |
| 218 checkProduct(api.Product o) { | 218 checkProduct(api.Product o) { |
| 219 buildCounterProduct++; | 219 buildCounterProduct++; |
| 220 if (buildCounterProduct < 3) { | 220 if (buildCounterProduct < 3) { |
| 221 unittest.expect(o.contentLanguage, unittest.equals('foo')); | 221 unittest.expect(o.contentLanguage, unittest.equals('foo')); |
| 222 checkAttributes(o.finalAttributes); | 222 checkAttributes(o.finalAttributes); |
| 223 checkUnnamed1567(o.issues); | 223 checkUnnamed1579(o.issues); |
| 224 checkUnnamed1568(o.manuallyDeletedAttributes); | 224 checkUnnamed1580(o.manuallyDeletedAttributes); |
| 225 checkAttributes(o.manuallyProvidedAttributes); | 225 checkAttributes(o.manuallyProvidedAttributes); |
| 226 unittest.expect(o.name, unittest.equals('foo')); | 226 unittest.expect(o.name, unittest.equals('foo')); |
| 227 unittest.expect(o.parent, unittest.equals('foo')); | 227 unittest.expect(o.parent, unittest.equals('foo')); |
| 228 unittest.expect(o.productId, unittest.equals('foo')); | 228 unittest.expect(o.productId, unittest.equals('foo')); |
| 229 unittest.expect(o.targetCountry, unittest.equals('foo')); | 229 unittest.expect(o.targetCountry, unittest.equals('foo')); |
| 230 checkAttributes(o.uploadedAttributes); | 230 checkAttributes(o.uploadedAttributes); |
| 231 } | 231 } |
| 232 buildCounterProduct--; | 232 buildCounterProduct--; |
| 233 } | 233 } |
| 234 | 234 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 res.get(arg_parent, arg_name).then(unittest.expectAsync(((api.Product resp
onse) { | 315 res.get(arg_parent, arg_name).then(unittest.expectAsync(((api.Product resp
onse) { |
| 316 checkProduct(response); | 316 checkProduct(response); |
| 317 }))); | 317 }))); |
| 318 }); | 318 }); |
| 319 | 319 |
| 320 unittest.test("method--list", () { | 320 unittest.test("method--list", () { |
| 321 | 321 |
| 322 var mock = new HttpServerMock(); | 322 var mock = new HttpServerMock(); |
| 323 api.AccountsProductsResourceApi res = new api.ManufacturersApi(mock).accou
nts.products; | 323 api.AccountsProductsResourceApi res = new api.ManufacturersApi(mock).accou
nts.products; |
| 324 var arg_parent = "foo"; | 324 var arg_parent = "foo"; |
| 325 var arg_pageToken = "foo"; |
| 325 var arg_pageSize = 42; | 326 var arg_pageSize = 42; |
| 326 var arg_pageToken = "foo"; | |
| 327 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | 327 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| 328 var path = (req.url).path; | 328 var path = (req.url).path; |
| 329 var pathOffset = 0; | 329 var pathOffset = 0; |
| 330 var index; | 330 var index; |
| 331 var subPart; | 331 var subPart; |
| 332 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 332 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
| 333 pathOffset += 1; | 333 pathOffset += 1; |
| 334 unittest.expect(path.substring(pathOffset, pathOffset + 3), unittest.equ
als("v1/")); | 334 unittest.expect(path.substring(pathOffset, pathOffset + 3), unittest.equ
als("v1/")); |
| 335 pathOffset += 3; | 335 pathOffset += 3; |
| 336 // NOTE: We cannot test reserved expansions due to the inability to reve
rse the operation; | 336 // NOTE: We cannot test reserved expansions due to the inability to reve
rse the operation; |
| 337 | 337 |
| 338 var query = (req.url).query; | 338 var query = (req.url).query; |
| 339 var queryOffset = 0; | 339 var queryOffset = 0; |
| 340 var queryMap = {}; | 340 var queryMap = {}; |
| 341 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 341 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 342 parseBool(n) { | 342 parseBool(n) { |
| 343 if (n == "true") return true; | 343 if (n == "true") return true; |
| 344 if (n == "false") return false; | 344 if (n == "false") return false; |
| 345 if (n == null) return null; | 345 if (n == null) return null; |
| 346 throw new core.ArgumentError("Invalid boolean: $n"); | 346 throw new core.ArgumentError("Invalid boolean: $n"); |
| 347 } | 347 } |
| 348 if (query.length > 0) { | 348 if (query.length > 0) { |
| 349 for (var part in query.split("&")) { | 349 for (var part in query.split("&")) { |
| 350 var keyvalue = part.split("="); | 350 var keyvalue = part.split("="); |
| 351 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 351 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
| 352 } | 352 } |
| 353 } | 353 } |
| 354 unittest.expect(queryMap["pageToken"].first, unittest.equals(arg_pageTok
en)); |
| 354 unittest.expect(core.int.parse(queryMap["pageSize"].first), unittest.equ
als(arg_pageSize)); | 355 unittest.expect(core.int.parse(queryMap["pageSize"].first), unittest.equ
als(arg_pageSize)); |
| 355 unittest.expect(queryMap["pageToken"].first, unittest.equals(arg_pageTok
en)); | |
| 356 | 356 |
| 357 | 357 |
| 358 var h = { | 358 var h = { |
| 359 "content-type" : "application/json; charset=utf-8", | 359 "content-type" : "application/json; charset=utf-8", |
| 360 }; | 360 }; |
| 361 var resp = convert.JSON.encode(buildListProductsResponse()); | 361 var resp = convert.JSON.encode(buildListProductsResponse()); |
| 362 return new async.Future.value(stringResponse(200, h, resp)); | 362 return new async.Future.value(stringResponse(200, h, resp)); |
| 363 }), true); | 363 }), true); |
| 364 res.list(arg_parent, pageSize: arg_pageSize, pageToken: arg_pageToken).the
n(unittest.expectAsync(((api.ListProductsResponse response) { | 364 res.list(arg_parent, pageToken: arg_pageToken, pageSize: arg_pageSize).the
n(unittest.expectAsync(((api.ListProductsResponse response) { |
| 365 checkListProductsResponse(response); | 365 checkListProductsResponse(response); |
| 366 }))); | 366 }))); |
| 367 }); | 367 }); |
| 368 | 368 |
| 369 }); | 369 }); |
| 370 | 370 |
| 371 | 371 |
| 372 } | 372 } |
| 373 | 373 |
| OLD | NEW |