Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 1 | library googleapis.manufacturers.v1.test; |
| 2 | |
| 3 | import "dart:core" as core; |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 4 | import "dart:async" as async; |
| 5 | import "dart:convert" as convert; |
| 6 | |
| 7 | import 'package:http/http.dart' as http; |
Martin Kustermann | 3953f0d | 2017-06-12 16:59:53 +0200 | [diff] [blame] | 8 | import 'package:test/test.dart' as unittest; |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 9 | |
| 10 | import 'package:googleapis/manufacturers/v1.dart' as api; |
| 11 | |
| 12 | class HttpServerMock extends http.BaseClient { |
| 13 | core.Function _callback; |
| 14 | core.bool _expectJson; |
| 15 | |
| 16 | void register(core.Function callback, core.bool expectJson) { |
| 17 | _callback = callback; |
| 18 | _expectJson = expectJson; |
| 19 | } |
| 20 | |
| 21 | async.Future<http.StreamedResponse> send(http.BaseRequest request) { |
| 22 | if (_expectJson) { |
Martin Kustermann | 5eb85c1 | 2017-09-11 12:35:54 +0200 | [diff] [blame] | 23 | return request |
| 24 | .finalize() |
Jakob Andersen | 52715df | 2018-05-01 13:58:48 +0200 | [diff] [blame] | 25 | .transform(convert.utf8.decoder) |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 26 | .join('') |
| 27 | .then((core.String jsonString) { |
| 28 | if (jsonString.isEmpty) { |
| 29 | return _callback(request, null); |
| 30 | } else { |
Jakob Andersen | 52715df | 2018-05-01 13:58:48 +0200 | [diff] [blame] | 31 | return _callback(request, convert.json.decode(jsonString)); |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 32 | } |
| 33 | }); |
| 34 | } else { |
| 35 | var stream = request.finalize(); |
| 36 | if (stream == null) { |
| 37 | return _callback(request, []); |
| 38 | } else { |
| 39 | return stream.toBytes().then((data) { |
| 40 | return _callback(request, data); |
| 41 | }); |
| 42 | } |
| 43 | } |
| 44 | } |
| 45 | } |
| 46 | |
Martin Kustermann | 5eb85c1 | 2017-09-11 12:35:54 +0200 | [diff] [blame] | 47 | http.StreamedResponse stringResponse(core.int status, |
| 48 | core.Map<core.String, core.String> headers, core.String body) { |
Jakob Andersen | 52715df | 2018-05-01 13:58:48 +0200 | [diff] [blame] | 49 | var stream = new async.Stream.fromIterable([convert.utf8.encode(body)]); |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 50 | return new http.StreamedResponse(stream, status, headers: headers); |
| 51 | } |
| 52 | |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 53 | buildUnnamed4111() { |
Martin Kustermann | a6d0a32 | 2017-03-27 13:52:31 +0200 | [diff] [blame] | 54 | var o = new core.List<api.Image>(); |
| 55 | o.add(buildImage()); |
| 56 | o.add(buildImage()); |
| 57 | return o; |
| 58 | } |
| 59 | |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 60 | checkUnnamed4111(core.List<api.Image> o) { |
Martin Kustermann | a6d0a32 | 2017-03-27 13:52:31 +0200 | [diff] [blame] | 61 | unittest.expect(o, unittest.hasLength(2)); |
| 62 | checkImage(o[0]); |
| 63 | checkImage(o[1]); |
| 64 | } |
| 65 | |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 66 | buildUnnamed4112() { |
Martin Kustermann | 81eb88b | 2018-06-04 12:02:00 +0200 | [diff] [blame] | 67 | var o = new core.List<core.String>(); |
| 68 | o.add("foo"); |
| 69 | o.add("foo"); |
| 70 | return o; |
| 71 | } |
| 72 | |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 73 | checkUnnamed4112(core.List<core.String> o) { |
Martin Kustermann | 81eb88b | 2018-06-04 12:02:00 +0200 | [diff] [blame] | 74 | unittest.expect(o, unittest.hasLength(2)); |
| 75 | unittest.expect(o[0], unittest.equals('foo')); |
| 76 | unittest.expect(o[1], unittest.equals('foo')); |
| 77 | } |
| 78 | |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 79 | buildUnnamed4113() { |
Martin Kustermann | a6d0a32 | 2017-03-27 13:52:31 +0200 | [diff] [blame] | 80 | var o = new core.List<api.FeatureDescription>(); |
| 81 | o.add(buildFeatureDescription()); |
| 82 | o.add(buildFeatureDescription()); |
| 83 | return o; |
| 84 | } |
| 85 | |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 86 | checkUnnamed4113(core.List<api.FeatureDescription> o) { |
Martin Kustermann | a6d0a32 | 2017-03-27 13:52:31 +0200 | [diff] [blame] | 87 | unittest.expect(o, unittest.hasLength(2)); |
| 88 | checkFeatureDescription(o[0]); |
| 89 | checkFeatureDescription(o[1]); |
| 90 | } |
| 91 | |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 92 | buildUnnamed4114() { |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 93 | var o = new core.List<core.String>(); |
| 94 | o.add("foo"); |
| 95 | o.add("foo"); |
| 96 | return o; |
| 97 | } |
| 98 | |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 99 | checkUnnamed4114(core.List<core.String> o) { |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 100 | unittest.expect(o, unittest.hasLength(2)); |
| 101 | unittest.expect(o[0], unittest.equals('foo')); |
| 102 | unittest.expect(o[1], unittest.equals('foo')); |
| 103 | } |
| 104 | |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 105 | buildUnnamed4115() { |
Martin Kustermann | 81eb88b | 2018-06-04 12:02:00 +0200 | [diff] [blame] | 106 | var o = new core.List<core.String>(); |
| 107 | o.add("foo"); |
| 108 | o.add("foo"); |
| 109 | return o; |
| 110 | } |
| 111 | |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 112 | checkUnnamed4115(core.List<core.String> o) { |
Martin Kustermann | 81eb88b | 2018-06-04 12:02:00 +0200 | [diff] [blame] | 113 | unittest.expect(o, unittest.hasLength(2)); |
| 114 | unittest.expect(o[0], unittest.equals('foo')); |
| 115 | unittest.expect(o[1], unittest.equals('foo')); |
| 116 | } |
| 117 | |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 118 | buildUnnamed4116() { |
Martin Kustermann | a6d0a32 | 2017-03-27 13:52:31 +0200 | [diff] [blame] | 119 | var o = new core.List<api.ProductDetail>(); |
| 120 | o.add(buildProductDetail()); |
| 121 | o.add(buildProductDetail()); |
| 122 | return o; |
| 123 | } |
| 124 | |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 125 | checkUnnamed4116(core.List<api.ProductDetail> o) { |
Martin Kustermann | a6d0a32 | 2017-03-27 13:52:31 +0200 | [diff] [blame] | 126 | unittest.expect(o, unittest.hasLength(2)); |
| 127 | checkProductDetail(o[0]); |
| 128 | checkProductDetail(o[1]); |
| 129 | } |
| 130 | |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 131 | buildUnnamed4117() { |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 132 | var o = new core.List<core.String>(); |
| 133 | o.add("foo"); |
| 134 | o.add("foo"); |
| 135 | return o; |
| 136 | } |
| 137 | |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 138 | checkUnnamed4117(core.List<core.String> o) { |
Martin Kustermann | a6d0a32 | 2017-03-27 13:52:31 +0200 | [diff] [blame] | 139 | unittest.expect(o, unittest.hasLength(2)); |
| 140 | unittest.expect(o[0], unittest.equals('foo')); |
| 141 | unittest.expect(o[1], unittest.equals('foo')); |
| 142 | } |
| 143 | |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 144 | buildUnnamed4118() { |
Martin Kustermann | a6d0a32 | 2017-03-27 13:52:31 +0200 | [diff] [blame] | 145 | var o = new core.List<core.String>(); |
| 146 | o.add("foo"); |
| 147 | o.add("foo"); |
| 148 | return o; |
| 149 | } |
| 150 | |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 151 | checkUnnamed4118(core.List<core.String> o) { |
Jonas Finnemann Jensen | 94d5b4d | 2020-05-07 12:00:14 +0200 | [diff] [blame] | 152 | unittest.expect(o, unittest.hasLength(2)); |
| 153 | unittest.expect(o[0], unittest.equals('foo')); |
| 154 | unittest.expect(o[1], unittest.equals('foo')); |
| 155 | } |
| 156 | |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 157 | buildUnnamed4119() { |
Jonas Finnemann Jensen | 94d5b4d | 2020-05-07 12:00:14 +0200 | [diff] [blame] | 158 | var o = new core.List<core.String>(); |
| 159 | o.add("foo"); |
| 160 | o.add("foo"); |
| 161 | return o; |
| 162 | } |
| 163 | |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 164 | checkUnnamed4119(core.List<core.String> o) { |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 165 | unittest.expect(o, unittest.hasLength(2)); |
| 166 | unittest.expect(o[0], unittest.equals('foo')); |
| 167 | unittest.expect(o[1], unittest.equals('foo')); |
| 168 | } |
| 169 | |
| 170 | core.int buildCounterAttributes = 0; |
| 171 | buildAttributes() { |
| 172 | var o = new api.Attributes(); |
| 173 | buildCounterAttributes++; |
| 174 | if (buildCounterAttributes < 3) { |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 175 | o.additionalImageLink = buildUnnamed4111(); |
Martin Kustermann | a6d0a32 | 2017-03-27 13:52:31 +0200 | [diff] [blame] | 176 | o.ageGroup = "foo"; |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 177 | o.brand = "foo"; |
Martin Kustermann | a6d0a32 | 2017-03-27 13:52:31 +0200 | [diff] [blame] | 178 | o.capacity = buildCapacity(); |
| 179 | o.color = "foo"; |
| 180 | o.count = buildCount(); |
| 181 | o.description = "foo"; |
| 182 | o.disclosureDate = "foo"; |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 183 | o.excludedDestination = buildUnnamed4112(); |
| 184 | o.featureDescription = buildUnnamed4113(); |
Martin Kustermann | a6d0a32 | 2017-03-27 13:52:31 +0200 | [diff] [blame] | 185 | o.flavor = "foo"; |
| 186 | o.format = "foo"; |
| 187 | o.gender = "foo"; |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 188 | o.gtin = buildUnnamed4114(); |
Martin Kustermann | a6d0a32 | 2017-03-27 13:52:31 +0200 | [diff] [blame] | 189 | o.imageLink = buildImage(); |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 190 | o.includedDestination = buildUnnamed4115(); |
Martin Kustermann | a6d0a32 | 2017-03-27 13:52:31 +0200 | [diff] [blame] | 191 | o.itemGroupId = "foo"; |
| 192 | o.material = "foo"; |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 193 | o.mpn = "foo"; |
Martin Kustermann | a6d0a32 | 2017-03-27 13:52:31 +0200 | [diff] [blame] | 194 | o.pattern = "foo"; |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 195 | o.productDetail = buildUnnamed4116(); |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 196 | o.productLine = "foo"; |
| 197 | o.productName = "foo"; |
| 198 | o.productPageUrl = "foo"; |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 199 | o.productType = buildUnnamed4117(); |
Martin Kustermann | a6d0a32 | 2017-03-27 13:52:31 +0200 | [diff] [blame] | 200 | o.releaseDate = "foo"; |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 201 | o.richProductContent = buildUnnamed4118(); |
Martin Kustermann | a6d0a32 | 2017-03-27 13:52:31 +0200 | [diff] [blame] | 202 | o.scent = "foo"; |
| 203 | o.size = "foo"; |
| 204 | o.sizeSystem = "foo"; |
| 205 | o.sizeType = "foo"; |
| 206 | o.suggestedRetailPrice = buildPrice(); |
Martin Kustermann | 7a3b5f5 | 2017-10-23 11:34:19 +0200 | [diff] [blame] | 207 | o.targetClientId = "foo"; |
Martin Kustermann | a6d0a32 | 2017-03-27 13:52:31 +0200 | [diff] [blame] | 208 | o.theme = "foo"; |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 209 | o.title = "foo"; |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 210 | o.videoLink = buildUnnamed4119(); |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 211 | } |
| 212 | buildCounterAttributes--; |
| 213 | return o; |
| 214 | } |
| 215 | |
| 216 | checkAttributes(api.Attributes o) { |
| 217 | buildCounterAttributes++; |
| 218 | if (buildCounterAttributes < 3) { |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 219 | checkUnnamed4111(o.additionalImageLink); |
Martin Kustermann | a6d0a32 | 2017-03-27 13:52:31 +0200 | [diff] [blame] | 220 | unittest.expect(o.ageGroup, unittest.equals('foo')); |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 221 | unittest.expect(o.brand, unittest.equals('foo')); |
Martin Kustermann | a6d0a32 | 2017-03-27 13:52:31 +0200 | [diff] [blame] | 222 | checkCapacity(o.capacity); |
| 223 | unittest.expect(o.color, unittest.equals('foo')); |
| 224 | checkCount(o.count); |
| 225 | unittest.expect(o.description, unittest.equals('foo')); |
| 226 | unittest.expect(o.disclosureDate, unittest.equals('foo')); |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 227 | checkUnnamed4112(o.excludedDestination); |
| 228 | checkUnnamed4113(o.featureDescription); |
Martin Kustermann | a6d0a32 | 2017-03-27 13:52:31 +0200 | [diff] [blame] | 229 | unittest.expect(o.flavor, unittest.equals('foo')); |
| 230 | unittest.expect(o.format, unittest.equals('foo')); |
| 231 | unittest.expect(o.gender, unittest.equals('foo')); |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 232 | checkUnnamed4114(o.gtin); |
Martin Kustermann | a6d0a32 | 2017-03-27 13:52:31 +0200 | [diff] [blame] | 233 | checkImage(o.imageLink); |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 234 | checkUnnamed4115(o.includedDestination); |
Martin Kustermann | a6d0a32 | 2017-03-27 13:52:31 +0200 | [diff] [blame] | 235 | unittest.expect(o.itemGroupId, unittest.equals('foo')); |
| 236 | unittest.expect(o.material, unittest.equals('foo')); |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 237 | unittest.expect(o.mpn, unittest.equals('foo')); |
Martin Kustermann | a6d0a32 | 2017-03-27 13:52:31 +0200 | [diff] [blame] | 238 | unittest.expect(o.pattern, unittest.equals('foo')); |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 239 | checkUnnamed4116(o.productDetail); |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 240 | unittest.expect(o.productLine, unittest.equals('foo')); |
| 241 | unittest.expect(o.productName, unittest.equals('foo')); |
| 242 | unittest.expect(o.productPageUrl, unittest.equals('foo')); |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 243 | checkUnnamed4117(o.productType); |
Martin Kustermann | a6d0a32 | 2017-03-27 13:52:31 +0200 | [diff] [blame] | 244 | unittest.expect(o.releaseDate, unittest.equals('foo')); |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 245 | checkUnnamed4118(o.richProductContent); |
Martin Kustermann | a6d0a32 | 2017-03-27 13:52:31 +0200 | [diff] [blame] | 246 | unittest.expect(o.scent, unittest.equals('foo')); |
| 247 | unittest.expect(o.size, unittest.equals('foo')); |
| 248 | unittest.expect(o.sizeSystem, unittest.equals('foo')); |
| 249 | unittest.expect(o.sizeType, unittest.equals('foo')); |
| 250 | checkPrice(o.suggestedRetailPrice); |
Martin Kustermann | 7a3b5f5 | 2017-10-23 11:34:19 +0200 | [diff] [blame] | 251 | unittest.expect(o.targetClientId, unittest.equals('foo')); |
Martin Kustermann | a6d0a32 | 2017-03-27 13:52:31 +0200 | [diff] [blame] | 252 | unittest.expect(o.theme, unittest.equals('foo')); |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 253 | unittest.expect(o.title, unittest.equals('foo')); |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 254 | checkUnnamed4119(o.videoLink); |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 255 | } |
| 256 | buildCounterAttributes--; |
| 257 | } |
| 258 | |
Martin Kustermann | a6d0a32 | 2017-03-27 13:52:31 +0200 | [diff] [blame] | 259 | core.int buildCounterCapacity = 0; |
| 260 | buildCapacity() { |
| 261 | var o = new api.Capacity(); |
| 262 | buildCounterCapacity++; |
| 263 | if (buildCounterCapacity < 3) { |
| 264 | o.unit = "foo"; |
| 265 | o.value = "foo"; |
| 266 | } |
| 267 | buildCounterCapacity--; |
| 268 | return o; |
| 269 | } |
| 270 | |
| 271 | checkCapacity(api.Capacity o) { |
| 272 | buildCounterCapacity++; |
| 273 | if (buildCounterCapacity < 3) { |
| 274 | unittest.expect(o.unit, unittest.equals('foo')); |
| 275 | unittest.expect(o.value, unittest.equals('foo')); |
| 276 | } |
| 277 | buildCounterCapacity--; |
| 278 | } |
| 279 | |
| 280 | core.int buildCounterCount = 0; |
| 281 | buildCount() { |
| 282 | var o = new api.Count(); |
| 283 | buildCounterCount++; |
| 284 | if (buildCounterCount < 3) { |
| 285 | o.unit = "foo"; |
| 286 | o.value = "foo"; |
| 287 | } |
| 288 | buildCounterCount--; |
| 289 | return o; |
| 290 | } |
| 291 | |
| 292 | checkCount(api.Count o) { |
| 293 | buildCounterCount++; |
| 294 | if (buildCounterCount < 3) { |
| 295 | unittest.expect(o.unit, unittest.equals('foo')); |
| 296 | unittest.expect(o.value, unittest.equals('foo')); |
| 297 | } |
| 298 | buildCounterCount--; |
| 299 | } |
| 300 | |
Martin Kustermann | 81eb88b | 2018-06-04 12:02:00 +0200 | [diff] [blame] | 301 | core.int buildCounterDestinationStatus = 0; |
| 302 | buildDestinationStatus() { |
| 303 | var o = new api.DestinationStatus(); |
| 304 | buildCounterDestinationStatus++; |
| 305 | if (buildCounterDestinationStatus < 3) { |
| 306 | o.destination = "foo"; |
| 307 | o.status = "foo"; |
| 308 | } |
| 309 | buildCounterDestinationStatus--; |
| 310 | return o; |
| 311 | } |
| 312 | |
| 313 | checkDestinationStatus(api.DestinationStatus o) { |
| 314 | buildCounterDestinationStatus++; |
| 315 | if (buildCounterDestinationStatus < 3) { |
| 316 | unittest.expect(o.destination, unittest.equals('foo')); |
| 317 | unittest.expect(o.status, unittest.equals('foo')); |
| 318 | } |
| 319 | buildCounterDestinationStatus--; |
| 320 | } |
| 321 | |
Martin Kustermann | 8c5bbda | 2017-07-10 13:23:47 +0200 | [diff] [blame] | 322 | core.int buildCounterEmpty = 0; |
| 323 | buildEmpty() { |
| 324 | var o = new api.Empty(); |
| 325 | buildCounterEmpty++; |
Martin Kustermann | 5eb85c1 | 2017-09-11 12:35:54 +0200 | [diff] [blame] | 326 | if (buildCounterEmpty < 3) {} |
Martin Kustermann | 8c5bbda | 2017-07-10 13:23:47 +0200 | [diff] [blame] | 327 | buildCounterEmpty--; |
| 328 | return o; |
| 329 | } |
| 330 | |
| 331 | checkEmpty(api.Empty o) { |
| 332 | buildCounterEmpty++; |
Martin Kustermann | 5eb85c1 | 2017-09-11 12:35:54 +0200 | [diff] [blame] | 333 | if (buildCounterEmpty < 3) {} |
Martin Kustermann | 8c5bbda | 2017-07-10 13:23:47 +0200 | [diff] [blame] | 334 | buildCounterEmpty--; |
| 335 | } |
| 336 | |
Martin Kustermann | a6d0a32 | 2017-03-27 13:52:31 +0200 | [diff] [blame] | 337 | core.int buildCounterFeatureDescription = 0; |
| 338 | buildFeatureDescription() { |
| 339 | var o = new api.FeatureDescription(); |
| 340 | buildCounterFeatureDescription++; |
| 341 | if (buildCounterFeatureDescription < 3) { |
| 342 | o.headline = "foo"; |
| 343 | o.image = buildImage(); |
| 344 | o.text = "foo"; |
| 345 | } |
| 346 | buildCounterFeatureDescription--; |
| 347 | return o; |
| 348 | } |
| 349 | |
| 350 | checkFeatureDescription(api.FeatureDescription o) { |
| 351 | buildCounterFeatureDescription++; |
| 352 | if (buildCounterFeatureDescription < 3) { |
| 353 | unittest.expect(o.headline, unittest.equals('foo')); |
| 354 | checkImage(o.image); |
| 355 | unittest.expect(o.text, unittest.equals('foo')); |
| 356 | } |
| 357 | buildCounterFeatureDescription--; |
| 358 | } |
| 359 | |
| 360 | core.int buildCounterImage = 0; |
| 361 | buildImage() { |
| 362 | var o = new api.Image(); |
| 363 | buildCounterImage++; |
| 364 | if (buildCounterImage < 3) { |
| 365 | o.imageUrl = "foo"; |
| 366 | o.status = "foo"; |
| 367 | o.type = "foo"; |
| 368 | } |
| 369 | buildCounterImage--; |
| 370 | return o; |
| 371 | } |
| 372 | |
| 373 | checkImage(api.Image o) { |
| 374 | buildCounterImage++; |
| 375 | if (buildCounterImage < 3) { |
| 376 | unittest.expect(o.imageUrl, unittest.equals('foo')); |
| 377 | unittest.expect(o.status, unittest.equals('foo')); |
| 378 | unittest.expect(o.type, unittest.equals('foo')); |
| 379 | } |
| 380 | buildCounterImage--; |
| 381 | } |
| 382 | |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 383 | core.int buildCounterIssue = 0; |
| 384 | buildIssue() { |
| 385 | var o = new api.Issue(); |
| 386 | buildCounterIssue++; |
| 387 | if (buildCounterIssue < 3) { |
| 388 | o.attribute = "foo"; |
| 389 | o.description = "foo"; |
Martin Kustermann | 81eb88b | 2018-06-04 12:02:00 +0200 | [diff] [blame] | 390 | o.destination = "foo"; |
| 391 | o.resolution = "foo"; |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 392 | o.severity = "foo"; |
Martin Kustermann | a6d0a32 | 2017-03-27 13:52:31 +0200 | [diff] [blame] | 393 | o.timestamp = "foo"; |
Martin Kustermann | 81eb88b | 2018-06-04 12:02:00 +0200 | [diff] [blame] | 394 | o.title = "foo"; |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 395 | o.type = "foo"; |
| 396 | } |
| 397 | buildCounterIssue--; |
| 398 | return o; |
| 399 | } |
| 400 | |
| 401 | checkIssue(api.Issue o) { |
| 402 | buildCounterIssue++; |
| 403 | if (buildCounterIssue < 3) { |
| 404 | unittest.expect(o.attribute, unittest.equals('foo')); |
| 405 | unittest.expect(o.description, unittest.equals('foo')); |
Martin Kustermann | 81eb88b | 2018-06-04 12:02:00 +0200 | [diff] [blame] | 406 | unittest.expect(o.destination, unittest.equals('foo')); |
| 407 | unittest.expect(o.resolution, unittest.equals('foo')); |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 408 | unittest.expect(o.severity, unittest.equals('foo')); |
Martin Kustermann | a6d0a32 | 2017-03-27 13:52:31 +0200 | [diff] [blame] | 409 | unittest.expect(o.timestamp, unittest.equals('foo')); |
Martin Kustermann | 81eb88b | 2018-06-04 12:02:00 +0200 | [diff] [blame] | 410 | unittest.expect(o.title, unittest.equals('foo')); |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 411 | unittest.expect(o.type, unittest.equals('foo')); |
| 412 | } |
| 413 | buildCounterIssue--; |
| 414 | } |
| 415 | |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 416 | buildUnnamed4120() { |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 417 | var o = new core.List<api.Product>(); |
| 418 | o.add(buildProduct()); |
| 419 | o.add(buildProduct()); |
| 420 | return o; |
| 421 | } |
| 422 | |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 423 | checkUnnamed4120(core.List<api.Product> o) { |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 424 | unittest.expect(o, unittest.hasLength(2)); |
| 425 | checkProduct(o[0]); |
| 426 | checkProduct(o[1]); |
| 427 | } |
| 428 | |
| 429 | core.int buildCounterListProductsResponse = 0; |
| 430 | buildListProductsResponse() { |
| 431 | var o = new api.ListProductsResponse(); |
| 432 | buildCounterListProductsResponse++; |
| 433 | if (buildCounterListProductsResponse < 3) { |
| 434 | o.nextPageToken = "foo"; |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 435 | o.products = buildUnnamed4120(); |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 436 | } |
| 437 | buildCounterListProductsResponse--; |
| 438 | return o; |
| 439 | } |
| 440 | |
| 441 | checkListProductsResponse(api.ListProductsResponse o) { |
| 442 | buildCounterListProductsResponse++; |
| 443 | if (buildCounterListProductsResponse < 3) { |
| 444 | unittest.expect(o.nextPageToken, unittest.equals('foo')); |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 445 | checkUnnamed4120(o.products); |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 446 | } |
| 447 | buildCounterListProductsResponse--; |
| 448 | } |
| 449 | |
Martin Kustermann | a6d0a32 | 2017-03-27 13:52:31 +0200 | [diff] [blame] | 450 | core.int buildCounterPrice = 0; |
| 451 | buildPrice() { |
| 452 | var o = new api.Price(); |
| 453 | buildCounterPrice++; |
| 454 | if (buildCounterPrice < 3) { |
| 455 | o.amount = "foo"; |
| 456 | o.currency = "foo"; |
| 457 | } |
| 458 | buildCounterPrice--; |
| 459 | return o; |
| 460 | } |
| 461 | |
| 462 | checkPrice(api.Price o) { |
| 463 | buildCounterPrice++; |
| 464 | if (buildCounterPrice < 3) { |
| 465 | unittest.expect(o.amount, unittest.equals('foo')); |
| 466 | unittest.expect(o.currency, unittest.equals('foo')); |
| 467 | } |
| 468 | buildCounterPrice--; |
| 469 | } |
| 470 | |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 471 | buildUnnamed4121() { |
Martin Kustermann | 81eb88b | 2018-06-04 12:02:00 +0200 | [diff] [blame] | 472 | var o = new core.List<api.DestinationStatus>(); |
| 473 | o.add(buildDestinationStatus()); |
| 474 | o.add(buildDestinationStatus()); |
| 475 | return o; |
| 476 | } |
| 477 | |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 478 | checkUnnamed4121(core.List<api.DestinationStatus> o) { |
Martin Kustermann | 81eb88b | 2018-06-04 12:02:00 +0200 | [diff] [blame] | 479 | unittest.expect(o, unittest.hasLength(2)); |
| 480 | checkDestinationStatus(o[0]); |
| 481 | checkDestinationStatus(o[1]); |
| 482 | } |
| 483 | |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 484 | buildUnnamed4122() { |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 485 | var o = new core.List<api.Issue>(); |
| 486 | o.add(buildIssue()); |
| 487 | o.add(buildIssue()); |
| 488 | return o; |
| 489 | } |
| 490 | |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 491 | checkUnnamed4122(core.List<api.Issue> o) { |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 492 | unittest.expect(o, unittest.hasLength(2)); |
| 493 | checkIssue(o[0]); |
| 494 | checkIssue(o[1]); |
| 495 | } |
| 496 | |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 497 | core.int buildCounterProduct = 0; |
| 498 | buildProduct() { |
| 499 | var o = new api.Product(); |
| 500 | buildCounterProduct++; |
| 501 | if (buildCounterProduct < 3) { |
Martin Kustermann | 81eb88b | 2018-06-04 12:02:00 +0200 | [diff] [blame] | 502 | o.attributes = buildAttributes(); |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 503 | o.contentLanguage = "foo"; |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 504 | o.destinationStatuses = buildUnnamed4121(); |
| 505 | o.issues = buildUnnamed4122(); |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 506 | o.name = "foo"; |
| 507 | o.parent = "foo"; |
| 508 | o.productId = "foo"; |
| 509 | o.targetCountry = "foo"; |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 510 | } |
| 511 | buildCounterProduct--; |
| 512 | return o; |
| 513 | } |
| 514 | |
| 515 | checkProduct(api.Product o) { |
| 516 | buildCounterProduct++; |
| 517 | if (buildCounterProduct < 3) { |
Martin Kustermann | 81eb88b | 2018-06-04 12:02:00 +0200 | [diff] [blame] | 518 | checkAttributes(o.attributes); |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 519 | unittest.expect(o.contentLanguage, unittest.equals('foo')); |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 520 | checkUnnamed4121(o.destinationStatuses); |
| 521 | checkUnnamed4122(o.issues); |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 522 | unittest.expect(o.name, unittest.equals('foo')); |
| 523 | unittest.expect(o.parent, unittest.equals('foo')); |
| 524 | unittest.expect(o.productId, unittest.equals('foo')); |
| 525 | unittest.expect(o.targetCountry, unittest.equals('foo')); |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 526 | } |
| 527 | buildCounterProduct--; |
| 528 | } |
| 529 | |
Martin Kustermann | a6d0a32 | 2017-03-27 13:52:31 +0200 | [diff] [blame] | 530 | core.int buildCounterProductDetail = 0; |
| 531 | buildProductDetail() { |
| 532 | var o = new api.ProductDetail(); |
| 533 | buildCounterProductDetail++; |
| 534 | if (buildCounterProductDetail < 3) { |
| 535 | o.attributeName = "foo"; |
| 536 | o.attributeValue = "foo"; |
| 537 | o.sectionName = "foo"; |
| 538 | } |
| 539 | buildCounterProductDetail--; |
| 540 | return o; |
| 541 | } |
| 542 | |
| 543 | checkProductDetail(api.ProductDetail o) { |
| 544 | buildCounterProductDetail++; |
| 545 | if (buildCounterProductDetail < 3) { |
| 546 | unittest.expect(o.attributeName, unittest.equals('foo')); |
| 547 | unittest.expect(o.attributeValue, unittest.equals('foo')); |
| 548 | unittest.expect(o.sectionName, unittest.equals('foo')); |
| 549 | } |
| 550 | buildCounterProductDetail--; |
| 551 | } |
| 552 | |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 553 | buildUnnamed4123() { |
Martin Kustermann | 81eb88b | 2018-06-04 12:02:00 +0200 | [diff] [blame] | 554 | var o = new core.List<core.String>(); |
| 555 | o.add("foo"); |
| 556 | o.add("foo"); |
| 557 | return o; |
| 558 | } |
| 559 | |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 560 | checkUnnamed4123(core.List<core.String> o) { |
Martin Kustermann | 81eb88b | 2018-06-04 12:02:00 +0200 | [diff] [blame] | 561 | unittest.expect(o, unittest.hasLength(2)); |
| 562 | unittest.expect(o[0], unittest.equals('foo')); |
| 563 | unittest.expect(o[1], unittest.equals('foo')); |
| 564 | } |
| 565 | |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 566 | buildUnnamed4124() { |
Martin Kustermann | 81eb88b | 2018-06-04 12:02:00 +0200 | [diff] [blame] | 567 | var o = new core.List<core.String>(); |
| 568 | o.add("foo"); |
| 569 | o.add("foo"); |
| 570 | return o; |
| 571 | } |
| 572 | |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 573 | checkUnnamed4124(core.List<core.String> o) { |
Martin Kustermann | 81eb88b | 2018-06-04 12:02:00 +0200 | [diff] [blame] | 574 | unittest.expect(o, unittest.hasLength(2)); |
| 575 | unittest.expect(o[0], unittest.equals('foo')); |
| 576 | unittest.expect(o[1], unittest.equals('foo')); |
| 577 | } |
| 578 | |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 579 | main() { |
| 580 | unittest.group("obj-schema-Attributes", () { |
| 581 | unittest.test("to-json--from-json", () { |
| 582 | var o = buildAttributes(); |
| 583 | var od = new api.Attributes.fromJson(o.toJson()); |
| 584 | checkAttributes(od); |
| 585 | }); |
| 586 | }); |
| 587 | |
Martin Kustermann | a6d0a32 | 2017-03-27 13:52:31 +0200 | [diff] [blame] | 588 | unittest.group("obj-schema-Capacity", () { |
| 589 | unittest.test("to-json--from-json", () { |
| 590 | var o = buildCapacity(); |
| 591 | var od = new api.Capacity.fromJson(o.toJson()); |
| 592 | checkCapacity(od); |
| 593 | }); |
| 594 | }); |
| 595 | |
Martin Kustermann | a6d0a32 | 2017-03-27 13:52:31 +0200 | [diff] [blame] | 596 | unittest.group("obj-schema-Count", () { |
| 597 | unittest.test("to-json--from-json", () { |
| 598 | var o = buildCount(); |
| 599 | var od = new api.Count.fromJson(o.toJson()); |
| 600 | checkCount(od); |
| 601 | }); |
| 602 | }); |
| 603 | |
Martin Kustermann | 81eb88b | 2018-06-04 12:02:00 +0200 | [diff] [blame] | 604 | unittest.group("obj-schema-DestinationStatus", () { |
| 605 | unittest.test("to-json--from-json", () { |
| 606 | var o = buildDestinationStatus(); |
| 607 | var od = new api.DestinationStatus.fromJson(o.toJson()); |
| 608 | checkDestinationStatus(od); |
| 609 | }); |
| 610 | }); |
| 611 | |
Martin Kustermann | 8c5bbda | 2017-07-10 13:23:47 +0200 | [diff] [blame] | 612 | unittest.group("obj-schema-Empty", () { |
| 613 | unittest.test("to-json--from-json", () { |
| 614 | var o = buildEmpty(); |
| 615 | var od = new api.Empty.fromJson(o.toJson()); |
| 616 | checkEmpty(od); |
| 617 | }); |
| 618 | }); |
| 619 | |
Martin Kustermann | a6d0a32 | 2017-03-27 13:52:31 +0200 | [diff] [blame] | 620 | unittest.group("obj-schema-FeatureDescription", () { |
| 621 | unittest.test("to-json--from-json", () { |
| 622 | var o = buildFeatureDescription(); |
| 623 | var od = new api.FeatureDescription.fromJson(o.toJson()); |
| 624 | checkFeatureDescription(od); |
| 625 | }); |
| 626 | }); |
| 627 | |
Martin Kustermann | a6d0a32 | 2017-03-27 13:52:31 +0200 | [diff] [blame] | 628 | unittest.group("obj-schema-Image", () { |
| 629 | unittest.test("to-json--from-json", () { |
| 630 | var o = buildImage(); |
| 631 | var od = new api.Image.fromJson(o.toJson()); |
| 632 | checkImage(od); |
| 633 | }); |
| 634 | }); |
| 635 | |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 636 | unittest.group("obj-schema-Issue", () { |
| 637 | unittest.test("to-json--from-json", () { |
| 638 | var o = buildIssue(); |
| 639 | var od = new api.Issue.fromJson(o.toJson()); |
| 640 | checkIssue(od); |
| 641 | }); |
| 642 | }); |
| 643 | |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 644 | unittest.group("obj-schema-ListProductsResponse", () { |
| 645 | unittest.test("to-json--from-json", () { |
| 646 | var o = buildListProductsResponse(); |
| 647 | var od = new api.ListProductsResponse.fromJson(o.toJson()); |
| 648 | checkListProductsResponse(od); |
| 649 | }); |
| 650 | }); |
| 651 | |
Martin Kustermann | a6d0a32 | 2017-03-27 13:52:31 +0200 | [diff] [blame] | 652 | unittest.group("obj-schema-Price", () { |
| 653 | unittest.test("to-json--from-json", () { |
| 654 | var o = buildPrice(); |
| 655 | var od = new api.Price.fromJson(o.toJson()); |
| 656 | checkPrice(od); |
| 657 | }); |
| 658 | }); |
| 659 | |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 660 | unittest.group("obj-schema-Product", () { |
| 661 | unittest.test("to-json--from-json", () { |
| 662 | var o = buildProduct(); |
| 663 | var od = new api.Product.fromJson(o.toJson()); |
| 664 | checkProduct(od); |
| 665 | }); |
| 666 | }); |
| 667 | |
Martin Kustermann | a6d0a32 | 2017-03-27 13:52:31 +0200 | [diff] [blame] | 668 | unittest.group("obj-schema-ProductDetail", () { |
| 669 | unittest.test("to-json--from-json", () { |
| 670 | var o = buildProductDetail(); |
| 671 | var od = new api.ProductDetail.fromJson(o.toJson()); |
| 672 | checkProductDetail(od); |
| 673 | }); |
| 674 | }); |
| 675 | |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 676 | unittest.group("resource-AccountsProductsResourceApi", () { |
Martin Kustermann | 8c5bbda | 2017-07-10 13:23:47 +0200 | [diff] [blame] | 677 | unittest.test("method--delete", () { |
Martin Kustermann | 8c5bbda | 2017-07-10 13:23:47 +0200 | [diff] [blame] | 678 | var mock = new HttpServerMock(); |
Martin Kustermann | 5eb85c1 | 2017-09-11 12:35:54 +0200 | [diff] [blame] | 679 | api.AccountsProductsResourceApi res = |
| 680 | new api.ManufacturersApi(mock).accounts.products; |
Martin Kustermann | 8c5bbda | 2017-07-10 13:23:47 +0200 | [diff] [blame] | 681 | var arg_parent = "foo"; |
| 682 | var arg_name = "foo"; |
Martin Kustermann | 7a3b5f5 | 2017-10-23 11:34:19 +0200 | [diff] [blame] | 683 | var arg_$fields = "foo"; |
Martin Kustermann | 8c5bbda | 2017-07-10 13:23:47 +0200 | [diff] [blame] | 684 | mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| 685 | var path = (req.url).path; |
| 686 | var pathOffset = 0; |
| 687 | var index; |
| 688 | var subPart; |
Martin Kustermann | 5eb85c1 | 2017-09-11 12:35:54 +0200 | [diff] [blame] | 689 | unittest.expect( |
| 690 | path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
Martin Kustermann | 8c5bbda | 2017-07-10 13:23:47 +0200 | [diff] [blame] | 691 | pathOffset += 1; |
Martin Kustermann | 5eb85c1 | 2017-09-11 12:35:54 +0200 | [diff] [blame] | 692 | unittest.expect( |
| 693 | path.substring(pathOffset, pathOffset + 3), unittest.equals("v1/")); |
Martin Kustermann | 8c5bbda | 2017-07-10 13:23:47 +0200 | [diff] [blame] | 694 | pathOffset += 3; |
| 695 | // NOTE: We cannot test reserved expansions due to the inability to reverse the operation; |
| 696 | |
| 697 | var query = (req.url).query; |
| 698 | var queryOffset = 0; |
Jakob Andersen | 52715df | 2018-05-01 13:58:48 +0200 | [diff] [blame] | 699 | var queryMap = <core.String, core.List<core.String>>{}; |
Martin Kustermann | 8c5bbda | 2017-07-10 13:23:47 +0200 | [diff] [blame] | 700 | addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 701 | parseBool(n) { |
| 702 | if (n == "true") return true; |
| 703 | if (n == "false") return false; |
| 704 | if (n == null) return null; |
| 705 | throw new core.ArgumentError("Invalid boolean: $n"); |
| 706 | } |
Martin Kustermann | 5eb85c1 | 2017-09-11 12:35:54 +0200 | [diff] [blame] | 707 | |
Martin Kustermann | 8c5bbda | 2017-07-10 13:23:47 +0200 | [diff] [blame] | 708 | if (query.length > 0) { |
| 709 | for (var part in query.split("&")) { |
| 710 | var keyvalue = part.split("="); |
Martin Kustermann | 5eb85c1 | 2017-09-11 12:35:54 +0200 | [diff] [blame] | 711 | addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 712 | core.Uri.decodeQueryComponent(keyvalue[1])); |
Martin Kustermann | 8c5bbda | 2017-07-10 13:23:47 +0200 | [diff] [blame] | 713 | } |
| 714 | } |
Martin Kustermann | 7a3b5f5 | 2017-10-23 11:34:19 +0200 | [diff] [blame] | 715 | unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields)); |
Martin Kustermann | 8c5bbda | 2017-07-10 13:23:47 +0200 | [diff] [blame] | 716 | |
Martin Kustermann | 8c5bbda | 2017-07-10 13:23:47 +0200 | [diff] [blame] | 717 | var h = { |
Martin Kustermann | 5eb85c1 | 2017-09-11 12:35:54 +0200 | [diff] [blame] | 718 | "content-type": "application/json; charset=utf-8", |
Martin Kustermann | 8c5bbda | 2017-07-10 13:23:47 +0200 | [diff] [blame] | 719 | }; |
Jakob Andersen | 52715df | 2018-05-01 13:58:48 +0200 | [diff] [blame] | 720 | var resp = convert.json.encode(buildEmpty()); |
Martin Kustermann | 8c5bbda | 2017-07-10 13:23:47 +0200 | [diff] [blame] | 721 | return new async.Future.value(stringResponse(200, h, resp)); |
| 722 | }), true); |
Martin Kustermann | 5eb85c1 | 2017-09-11 12:35:54 +0200 | [diff] [blame] | 723 | res |
Martin Kustermann | 7a3b5f5 | 2017-10-23 11:34:19 +0200 | [diff] [blame] | 724 | .delete(arg_parent, arg_name, $fields: arg_$fields) |
Jakob Andersen | 4ce761d | 2018-04-19 11:19:11 +0200 | [diff] [blame] | 725 | .then(unittest.expectAsync1(((response) { |
Martin Kustermann | 8c5bbda | 2017-07-10 13:23:47 +0200 | [diff] [blame] | 726 | checkEmpty(response); |
| 727 | }))); |
| 728 | }); |
| 729 | |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 730 | unittest.test("method--get", () { |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 731 | var mock = new HttpServerMock(); |
Martin Kustermann | 5eb85c1 | 2017-09-11 12:35:54 +0200 | [diff] [blame] | 732 | api.AccountsProductsResourceApi res = |
| 733 | new api.ManufacturersApi(mock).accounts.products; |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 734 | var arg_parent = "foo"; |
| 735 | var arg_name = "foo"; |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 736 | var arg_include = buildUnnamed4123(); |
Martin Kustermann | 7a3b5f5 | 2017-10-23 11:34:19 +0200 | [diff] [blame] | 737 | var arg_$fields = "foo"; |
Martin Kustermann | 3953f0d | 2017-06-12 16:59:53 +0200 | [diff] [blame] | 738 | mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 739 | var path = (req.url).path; |
| 740 | var pathOffset = 0; |
| 741 | var index; |
| 742 | var subPart; |
Martin Kustermann | 5eb85c1 | 2017-09-11 12:35:54 +0200 | [diff] [blame] | 743 | unittest.expect( |
| 744 | path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 745 | pathOffset += 1; |
Martin Kustermann | 5eb85c1 | 2017-09-11 12:35:54 +0200 | [diff] [blame] | 746 | unittest.expect( |
| 747 | path.substring(pathOffset, pathOffset + 3), unittest.equals("v1/")); |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 748 | pathOffset += 3; |
| 749 | // NOTE: We cannot test reserved expansions due to the inability to reverse the operation; |
| 750 | |
| 751 | var query = (req.url).query; |
| 752 | var queryOffset = 0; |
Jakob Andersen | 52715df | 2018-05-01 13:58:48 +0200 | [diff] [blame] | 753 | var queryMap = <core.String, core.List<core.String>>{}; |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 754 | addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 755 | parseBool(n) { |
| 756 | if (n == "true") return true; |
| 757 | if (n == "false") return false; |
| 758 | if (n == null) return null; |
| 759 | throw new core.ArgumentError("Invalid boolean: $n"); |
| 760 | } |
Martin Kustermann | 5eb85c1 | 2017-09-11 12:35:54 +0200 | [diff] [blame] | 761 | |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 762 | if (query.length > 0) { |
| 763 | for (var part in query.split("&")) { |
| 764 | var keyvalue = part.split("="); |
Martin Kustermann | 5eb85c1 | 2017-09-11 12:35:54 +0200 | [diff] [blame] | 765 | addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 766 | core.Uri.decodeQueryComponent(keyvalue[1])); |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 767 | } |
| 768 | } |
Martin Kustermann | 81eb88b | 2018-06-04 12:02:00 +0200 | [diff] [blame] | 769 | unittest.expect(queryMap["include"], unittest.equals(arg_include)); |
Martin Kustermann | 7a3b5f5 | 2017-10-23 11:34:19 +0200 | [diff] [blame] | 770 | unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields)); |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 771 | |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 772 | var h = { |
Martin Kustermann | 5eb85c1 | 2017-09-11 12:35:54 +0200 | [diff] [blame] | 773 | "content-type": "application/json; charset=utf-8", |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 774 | }; |
Jakob Andersen | 52715df | 2018-05-01 13:58:48 +0200 | [diff] [blame] | 775 | var resp = convert.json.encode(buildProduct()); |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 776 | return new async.Future.value(stringResponse(200, h, resp)); |
| 777 | }), true); |
Martin Kustermann | 5eb85c1 | 2017-09-11 12:35:54 +0200 | [diff] [blame] | 778 | res |
Martin Kustermann | 81eb88b | 2018-06-04 12:02:00 +0200 | [diff] [blame] | 779 | .get(arg_parent, arg_name, include: arg_include, $fields: arg_$fields) |
Jakob Andersen | 4ce761d | 2018-04-19 11:19:11 +0200 | [diff] [blame] | 780 | .then(unittest.expectAsync1(((response) { |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 781 | checkProduct(response); |
| 782 | }))); |
| 783 | }); |
| 784 | |
| 785 | unittest.test("method--list", () { |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 786 | var mock = new HttpServerMock(); |
Martin Kustermann | 5eb85c1 | 2017-09-11 12:35:54 +0200 | [diff] [blame] | 787 | api.AccountsProductsResourceApi res = |
| 788 | new api.ManufacturersApi(mock).accounts.products; |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 789 | var arg_parent = "foo"; |
Jonas Finnemann Jensen | ef0c8a3 | 2020-10-07 20:58:20 +0200 | [diff] [blame] | 790 | var arg_include = buildUnnamed4124(); |
Martin Kustermann | 7a3b5f5 | 2017-10-23 11:34:19 +0200 | [diff] [blame] | 791 | var arg_pageToken = "foo"; |
Martin Kustermann | 2a13118 | 2017-11-13 13:50:07 +0100 | [diff] [blame] | 792 | var arg_pageSize = 42; |
Martin Kustermann | 7a3b5f5 | 2017-10-23 11:34:19 +0200 | [diff] [blame] | 793 | var arg_$fields = "foo"; |
Martin Kustermann | 3953f0d | 2017-06-12 16:59:53 +0200 | [diff] [blame] | 794 | mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 795 | var path = (req.url).path; |
| 796 | var pathOffset = 0; |
| 797 | var index; |
| 798 | var subPart; |
Martin Kustermann | 5eb85c1 | 2017-09-11 12:35:54 +0200 | [diff] [blame] | 799 | unittest.expect( |
| 800 | path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 801 | pathOffset += 1; |
Martin Kustermann | 5eb85c1 | 2017-09-11 12:35:54 +0200 | [diff] [blame] | 802 | unittest.expect( |
| 803 | path.substring(pathOffset, pathOffset + 3), unittest.equals("v1/")); |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 804 | pathOffset += 3; |
| 805 | // NOTE: We cannot test reserved expansions due to the inability to reverse the operation; |
| 806 | |
| 807 | var query = (req.url).query; |
| 808 | var queryOffset = 0; |
Jakob Andersen | 52715df | 2018-05-01 13:58:48 +0200 | [diff] [blame] | 809 | var queryMap = <core.String, core.List<core.String>>{}; |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 810 | addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 811 | parseBool(n) { |
| 812 | if (n == "true") return true; |
| 813 | if (n == "false") return false; |
| 814 | if (n == null) return null; |
| 815 | throw new core.ArgumentError("Invalid boolean: $n"); |
| 816 | } |
Martin Kustermann | 5eb85c1 | 2017-09-11 12:35:54 +0200 | [diff] [blame] | 817 | |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 818 | if (query.length > 0) { |
| 819 | for (var part in query.split("&")) { |
| 820 | var keyvalue = part.split("="); |
Martin Kustermann | 5eb85c1 | 2017-09-11 12:35:54 +0200 | [diff] [blame] | 821 | addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 822 | core.Uri.decodeQueryComponent(keyvalue[1])); |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 823 | } |
| 824 | } |
Martin Kustermann | 12cdd52 | 2018-08-27 10:46:50 +0200 | [diff] [blame] | 825 | unittest.expect(queryMap["include"], unittest.equals(arg_include)); |
Martin Kustermann | 7a3b5f5 | 2017-10-23 11:34:19 +0200 | [diff] [blame] | 826 | unittest.expect( |
| 827 | queryMap["pageToken"].first, unittest.equals(arg_pageToken)); |
Martin Kustermann | 2a13118 | 2017-11-13 13:50:07 +0100 | [diff] [blame] | 828 | unittest.expect(core.int.parse(queryMap["pageSize"].first), |
| 829 | unittest.equals(arg_pageSize)); |
Martin Kustermann | 7a3b5f5 | 2017-10-23 11:34:19 +0200 | [diff] [blame] | 830 | unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields)); |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 831 | |
| 832 | var h = { |
Martin Kustermann | 5eb85c1 | 2017-09-11 12:35:54 +0200 | [diff] [blame] | 833 | "content-type": "application/json; charset=utf-8", |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 834 | }; |
Jakob Andersen | 52715df | 2018-05-01 13:58:48 +0200 | [diff] [blame] | 835 | var resp = convert.json.encode(buildListProductsResponse()); |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 836 | return new async.Future.value(stringResponse(200, h, resp)); |
| 837 | }), true); |
Martin Kustermann | 5eb85c1 | 2017-09-11 12:35:54 +0200 | [diff] [blame] | 838 | res |
Martin Kustermann | 7a3b5f5 | 2017-10-23 11:34:19 +0200 | [diff] [blame] | 839 | .list(arg_parent, |
Martin Kustermann | 12cdd52 | 2018-08-27 10:46:50 +0200 | [diff] [blame] | 840 | include: arg_include, |
Martin Kustermann | 7a3b5f5 | 2017-10-23 11:34:19 +0200 | [diff] [blame] | 841 | pageToken: arg_pageToken, |
Martin Kustermann | 2a13118 | 2017-11-13 13:50:07 +0100 | [diff] [blame] | 842 | pageSize: arg_pageSize, |
Martin Kustermann | 7a3b5f5 | 2017-10-23 11:34:19 +0200 | [diff] [blame] | 843 | $fields: arg_$fields) |
Jakob Andersen | 4ce761d | 2018-04-19 11:19:11 +0200 | [diff] [blame] | 844 | .then(unittest.expectAsync1(((response) { |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 845 | checkListProductsResponse(response); |
| 846 | }))); |
| 847 | }); |
| 848 | |
Martin Kustermann | 81eb88b | 2018-06-04 12:02:00 +0200 | [diff] [blame] | 849 | unittest.test("method--update", () { |
Martin Kustermann | 8c5bbda | 2017-07-10 13:23:47 +0200 | [diff] [blame] | 850 | var mock = new HttpServerMock(); |
Martin Kustermann | 5eb85c1 | 2017-09-11 12:35:54 +0200 | [diff] [blame] | 851 | api.AccountsProductsResourceApi res = |
| 852 | new api.ManufacturersApi(mock).accounts.products; |
Martin Kustermann | a525076 | 2018-02-19 12:56:45 +0100 | [diff] [blame] | 853 | var arg_request = buildAttributes(); |
Martin Kustermann | 8c5bbda | 2017-07-10 13:23:47 +0200 | [diff] [blame] | 854 | var arg_parent = "foo"; |
| 855 | var arg_name = "foo"; |
Martin Kustermann | 7a3b5f5 | 2017-10-23 11:34:19 +0200 | [diff] [blame] | 856 | var arg_$fields = "foo"; |
Martin Kustermann | 8c5bbda | 2017-07-10 13:23:47 +0200 | [diff] [blame] | 857 | mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
Martin Kustermann | a525076 | 2018-02-19 12:56:45 +0100 | [diff] [blame] | 858 | var obj = new api.Attributes.fromJson(json); |
| 859 | checkAttributes(obj); |
Martin Kustermann | 8c5bbda | 2017-07-10 13:23:47 +0200 | [diff] [blame] | 860 | |
| 861 | var path = (req.url).path; |
| 862 | var pathOffset = 0; |
| 863 | var index; |
| 864 | var subPart; |
Martin Kustermann | 5eb85c1 | 2017-09-11 12:35:54 +0200 | [diff] [blame] | 865 | unittest.expect( |
| 866 | path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
Martin Kustermann | 8c5bbda | 2017-07-10 13:23:47 +0200 | [diff] [blame] | 867 | pathOffset += 1; |
Martin Kustermann | 5eb85c1 | 2017-09-11 12:35:54 +0200 | [diff] [blame] | 868 | unittest.expect( |
| 869 | path.substring(pathOffset, pathOffset + 3), unittest.equals("v1/")); |
Martin Kustermann | 8c5bbda | 2017-07-10 13:23:47 +0200 | [diff] [blame] | 870 | pathOffset += 3; |
| 871 | // NOTE: We cannot test reserved expansions due to the inability to reverse the operation; |
| 872 | |
| 873 | var query = (req.url).query; |
| 874 | var queryOffset = 0; |
Jakob Andersen | 52715df | 2018-05-01 13:58:48 +0200 | [diff] [blame] | 875 | var queryMap = <core.String, core.List<core.String>>{}; |
Martin Kustermann | 8c5bbda | 2017-07-10 13:23:47 +0200 | [diff] [blame] | 876 | addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 877 | parseBool(n) { |
| 878 | if (n == "true") return true; |
| 879 | if (n == "false") return false; |
| 880 | if (n == null) return null; |
| 881 | throw new core.ArgumentError("Invalid boolean: $n"); |
| 882 | } |
Martin Kustermann | 5eb85c1 | 2017-09-11 12:35:54 +0200 | [diff] [blame] | 883 | |
Martin Kustermann | 8c5bbda | 2017-07-10 13:23:47 +0200 | [diff] [blame] | 884 | if (query.length > 0) { |
| 885 | for (var part in query.split("&")) { |
| 886 | var keyvalue = part.split("="); |
Martin Kustermann | 5eb85c1 | 2017-09-11 12:35:54 +0200 | [diff] [blame] | 887 | addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 888 | core.Uri.decodeQueryComponent(keyvalue[1])); |
Martin Kustermann | 8c5bbda | 2017-07-10 13:23:47 +0200 | [diff] [blame] | 889 | } |
| 890 | } |
Martin Kustermann | 7a3b5f5 | 2017-10-23 11:34:19 +0200 | [diff] [blame] | 891 | unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields)); |
Martin Kustermann | 8c5bbda | 2017-07-10 13:23:47 +0200 | [diff] [blame] | 892 | |
Martin Kustermann | 8c5bbda | 2017-07-10 13:23:47 +0200 | [diff] [blame] | 893 | var h = { |
Martin Kustermann | 5eb85c1 | 2017-09-11 12:35:54 +0200 | [diff] [blame] | 894 | "content-type": "application/json; charset=utf-8", |
Martin Kustermann | 8c5bbda | 2017-07-10 13:23:47 +0200 | [diff] [blame] | 895 | }; |
Jakob Andersen | 52715df | 2018-05-01 13:58:48 +0200 | [diff] [blame] | 896 | var resp = convert.json.encode(buildEmpty()); |
Martin Kustermann | 8c5bbda | 2017-07-10 13:23:47 +0200 | [diff] [blame] | 897 | return new async.Future.value(stringResponse(200, h, resp)); |
| 898 | }), true); |
Martin Kustermann | 5eb85c1 | 2017-09-11 12:35:54 +0200 | [diff] [blame] | 899 | res |
Martin Kustermann | 81eb88b | 2018-06-04 12:02:00 +0200 | [diff] [blame] | 900 | .update(arg_request, arg_parent, arg_name, $fields: arg_$fields) |
Jakob Andersen | 4ce761d | 2018-04-19 11:19:11 +0200 | [diff] [blame] | 901 | .then(unittest.expectAsync1(((response) { |
Martin Kustermann | a525076 | 2018-02-19 12:56:45 +0100 | [diff] [blame] | 902 | checkEmpty(response); |
Martin Kustermann | 8c5bbda | 2017-07-10 13:23:47 +0200 | [diff] [blame] | 903 | }))); |
| 904 | }); |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 905 | }); |
Martin Kustermann | 4ff71db | 2016-11-09 10:46:40 +0100 | [diff] [blame] | 906 | } |