OLD | NEW |
| (Empty) |
1 library googleapis.doubleclicksearch.v2.test; | |
2 | |
3 import "dart:core" as core; | |
4 import "dart:collection" as collection; | |
5 import "dart:async" as async; | |
6 import "dart:convert" as convert; | |
7 | |
8 import 'package:http/http.dart' as http; | |
9 import 'package:http/testing.dart' as http_testing; | |
10 import 'package:unittest/unittest.dart' as unittest; | |
11 import 'package:googleapis/common/common.dart' as common; | |
12 import 'package:googleapis/src/common_internal.dart' as common_internal; | |
13 import '../common/common_internal_test.dart' as common_test; | |
14 | |
15 import 'package:googleapis/doubleclicksearch/v2.dart' as api; | |
16 | |
17 | |
18 | |
19 core.int buildCounterAvailability = 0; | |
20 buildAvailability() { | |
21 var o = new api.Availability(); | |
22 buildCounterAvailability++; | |
23 if (buildCounterAvailability < 3) { | |
24 o.advertiserId = "foo"; | |
25 o.agencyId = "foo"; | |
26 o.availabilityTimestamp = "foo"; | |
27 o.segmentationId = "foo"; | |
28 o.segmentationName = "foo"; | |
29 o.segmentationType = "foo"; | |
30 } | |
31 buildCounterAvailability--; | |
32 return o; | |
33 } | |
34 | |
35 checkAvailability(api.Availability o) { | |
36 buildCounterAvailability++; | |
37 if (buildCounterAvailability < 3) { | |
38 unittest.expect(o.advertiserId, unittest.equals('foo')); | |
39 unittest.expect(o.agencyId, unittest.equals('foo')); | |
40 unittest.expect(o.availabilityTimestamp, unittest.equals('foo')); | |
41 unittest.expect(o.segmentationId, unittest.equals('foo')); | |
42 unittest.expect(o.segmentationName, unittest.equals('foo')); | |
43 unittest.expect(o.segmentationType, unittest.equals('foo')); | |
44 } | |
45 buildCounterAvailability--; | |
46 } | |
47 | |
48 buildUnnamed731() { | |
49 var o = new core.List<api.CustomDimension>(); | |
50 o.add(buildCustomDimension()); | |
51 o.add(buildCustomDimension()); | |
52 return o; | |
53 } | |
54 | |
55 checkUnnamed731(core.List<api.CustomDimension> o) { | |
56 unittest.expect(o, unittest.hasLength(2)); | |
57 checkCustomDimension(o[0]); | |
58 checkCustomDimension(o[1]); | |
59 } | |
60 | |
61 buildUnnamed732() { | |
62 var o = new core.List<api.CustomMetric>(); | |
63 o.add(buildCustomMetric()); | |
64 o.add(buildCustomMetric()); | |
65 return o; | |
66 } | |
67 | |
68 checkUnnamed732(core.List<api.CustomMetric> o) { | |
69 unittest.expect(o, unittest.hasLength(2)); | |
70 checkCustomMetric(o[0]); | |
71 checkCustomMetric(o[1]); | |
72 } | |
73 | |
74 core.int buildCounterConversion = 0; | |
75 buildConversion() { | |
76 var o = new api.Conversion(); | |
77 buildCounterConversion++; | |
78 if (buildCounterConversion < 3) { | |
79 o.adGroupId = "foo"; | |
80 o.adId = "foo"; | |
81 o.advertiserId = "foo"; | |
82 o.agencyId = "foo"; | |
83 o.campaignId = "foo"; | |
84 o.clickId = "foo"; | |
85 o.conversionId = "foo"; | |
86 o.conversionModifiedTimestamp = "foo"; | |
87 o.conversionTimestamp = "foo"; | |
88 o.criterionId = "foo"; | |
89 o.currencyCode = "foo"; | |
90 o.customDimension = buildUnnamed731(); | |
91 o.customMetric = buildUnnamed732(); | |
92 o.dsConversionId = "foo"; | |
93 o.engineAccountId = "foo"; | |
94 o.floodlightOrderId = "foo"; | |
95 o.quantityMillis = "foo"; | |
96 o.revenueMicros = "foo"; | |
97 o.segmentationId = "foo"; | |
98 o.segmentationName = "foo"; | |
99 o.segmentationType = "foo"; | |
100 o.state = "foo"; | |
101 o.type = "foo"; | |
102 } | |
103 buildCounterConversion--; | |
104 return o; | |
105 } | |
106 | |
107 checkConversion(api.Conversion o) { | |
108 buildCounterConversion++; | |
109 if (buildCounterConversion < 3) { | |
110 unittest.expect(o.adGroupId, unittest.equals('foo')); | |
111 unittest.expect(o.adId, unittest.equals('foo')); | |
112 unittest.expect(o.advertiserId, unittest.equals('foo')); | |
113 unittest.expect(o.agencyId, unittest.equals('foo')); | |
114 unittest.expect(o.campaignId, unittest.equals('foo')); | |
115 unittest.expect(o.clickId, unittest.equals('foo')); | |
116 unittest.expect(o.conversionId, unittest.equals('foo')); | |
117 unittest.expect(o.conversionModifiedTimestamp, unittest.equals('foo')); | |
118 unittest.expect(o.conversionTimestamp, unittest.equals('foo')); | |
119 unittest.expect(o.criterionId, unittest.equals('foo')); | |
120 unittest.expect(o.currencyCode, unittest.equals('foo')); | |
121 checkUnnamed731(o.customDimension); | |
122 checkUnnamed732(o.customMetric); | |
123 unittest.expect(o.dsConversionId, unittest.equals('foo')); | |
124 unittest.expect(o.engineAccountId, unittest.equals('foo')); | |
125 unittest.expect(o.floodlightOrderId, unittest.equals('foo')); | |
126 unittest.expect(o.quantityMillis, unittest.equals('foo')); | |
127 unittest.expect(o.revenueMicros, unittest.equals('foo')); | |
128 unittest.expect(o.segmentationId, unittest.equals('foo')); | |
129 unittest.expect(o.segmentationName, unittest.equals('foo')); | |
130 unittest.expect(o.segmentationType, unittest.equals('foo')); | |
131 unittest.expect(o.state, unittest.equals('foo')); | |
132 unittest.expect(o.type, unittest.equals('foo')); | |
133 } | |
134 buildCounterConversion--; | |
135 } | |
136 | |
137 buildUnnamed733() { | |
138 var o = new core.List<api.Conversion>(); | |
139 o.add(buildConversion()); | |
140 o.add(buildConversion()); | |
141 return o; | |
142 } | |
143 | |
144 checkUnnamed733(core.List<api.Conversion> o) { | |
145 unittest.expect(o, unittest.hasLength(2)); | |
146 checkConversion(o[0]); | |
147 checkConversion(o[1]); | |
148 } | |
149 | |
150 core.int buildCounterConversionList = 0; | |
151 buildConversionList() { | |
152 var o = new api.ConversionList(); | |
153 buildCounterConversionList++; | |
154 if (buildCounterConversionList < 3) { | |
155 o.conversion = buildUnnamed733(); | |
156 o.kind = "foo"; | |
157 } | |
158 buildCounterConversionList--; | |
159 return o; | |
160 } | |
161 | |
162 checkConversionList(api.ConversionList o) { | |
163 buildCounterConversionList++; | |
164 if (buildCounterConversionList < 3) { | |
165 checkUnnamed733(o.conversion); | |
166 unittest.expect(o.kind, unittest.equals('foo')); | |
167 } | |
168 buildCounterConversionList--; | |
169 } | |
170 | |
171 core.int buildCounterCustomDimension = 0; | |
172 buildCustomDimension() { | |
173 var o = new api.CustomDimension(); | |
174 buildCounterCustomDimension++; | |
175 if (buildCounterCustomDimension < 3) { | |
176 o.name = "foo"; | |
177 o.value = "foo"; | |
178 } | |
179 buildCounterCustomDimension--; | |
180 return o; | |
181 } | |
182 | |
183 checkCustomDimension(api.CustomDimension o) { | |
184 buildCounterCustomDimension++; | |
185 if (buildCounterCustomDimension < 3) { | |
186 unittest.expect(o.name, unittest.equals('foo')); | |
187 unittest.expect(o.value, unittest.equals('foo')); | |
188 } | |
189 buildCounterCustomDimension--; | |
190 } | |
191 | |
192 core.int buildCounterCustomMetric = 0; | |
193 buildCustomMetric() { | |
194 var o = new api.CustomMetric(); | |
195 buildCounterCustomMetric++; | |
196 if (buildCounterCustomMetric < 3) { | |
197 o.name = "foo"; | |
198 o.value = 42.0; | |
199 } | |
200 buildCounterCustomMetric--; | |
201 return o; | |
202 } | |
203 | |
204 checkCustomMetric(api.CustomMetric o) { | |
205 buildCounterCustomMetric++; | |
206 if (buildCounterCustomMetric < 3) { | |
207 unittest.expect(o.name, unittest.equals('foo')); | |
208 unittest.expect(o.value, unittest.equals(42.0)); | |
209 } | |
210 buildCounterCustomMetric--; | |
211 } | |
212 | |
213 core.int buildCounterReportFiles = 0; | |
214 buildReportFiles() { | |
215 var o = new api.ReportFiles(); | |
216 buildCounterReportFiles++; | |
217 if (buildCounterReportFiles < 3) { | |
218 o.byteCount = "foo"; | |
219 o.url = "foo"; | |
220 } | |
221 buildCounterReportFiles--; | |
222 return o; | |
223 } | |
224 | |
225 checkReportFiles(api.ReportFiles o) { | |
226 buildCounterReportFiles++; | |
227 if (buildCounterReportFiles < 3) { | |
228 unittest.expect(o.byteCount, unittest.equals('foo')); | |
229 unittest.expect(o.url, unittest.equals('foo')); | |
230 } | |
231 buildCounterReportFiles--; | |
232 } | |
233 | |
234 buildUnnamed734() { | |
235 var o = new core.List<api.ReportFiles>(); | |
236 o.add(buildReportFiles()); | |
237 o.add(buildReportFiles()); | |
238 return o; | |
239 } | |
240 | |
241 checkUnnamed734(core.List<api.ReportFiles> o) { | |
242 unittest.expect(o, unittest.hasLength(2)); | |
243 checkReportFiles(o[0]); | |
244 checkReportFiles(o[1]); | |
245 } | |
246 | |
247 buildUnnamed735() { | |
248 var o = new core.List<api.ReportRow>(); | |
249 o.add(buildReportRow()); | |
250 o.add(buildReportRow()); | |
251 return o; | |
252 } | |
253 | |
254 checkUnnamed735(core.List<api.ReportRow> o) { | |
255 unittest.expect(o, unittest.hasLength(2)); | |
256 checkReportRow(o[0]); | |
257 checkReportRow(o[1]); | |
258 } | |
259 | |
260 core.int buildCounterReport = 0; | |
261 buildReport() { | |
262 var o = new api.Report(); | |
263 buildCounterReport++; | |
264 if (buildCounterReport < 3) { | |
265 o.files = buildUnnamed734(); | |
266 o.id = "foo"; | |
267 o.isReportReady = true; | |
268 o.kind = "foo"; | |
269 o.request = buildReportRequest(); | |
270 o.rowCount = 42; | |
271 o.rows = buildUnnamed735(); | |
272 o.statisticsCurrencyCode = "foo"; | |
273 o.statisticsTimeZone = "foo"; | |
274 } | |
275 buildCounterReport--; | |
276 return o; | |
277 } | |
278 | |
279 checkReport(api.Report o) { | |
280 buildCounterReport++; | |
281 if (buildCounterReport < 3) { | |
282 checkUnnamed734(o.files); | |
283 unittest.expect(o.id, unittest.equals('foo')); | |
284 unittest.expect(o.isReportReady, unittest.isTrue); | |
285 unittest.expect(o.kind, unittest.equals('foo')); | |
286 checkReportRequest(o.request); | |
287 unittest.expect(o.rowCount, unittest.equals(42)); | |
288 checkUnnamed735(o.rows); | |
289 unittest.expect(o.statisticsCurrencyCode, unittest.equals('foo')); | |
290 unittest.expect(o.statisticsTimeZone, unittest.equals('foo')); | |
291 } | |
292 buildCounterReport--; | |
293 } | |
294 | |
295 core.int buildCounterReportApiColumnSpec = 0; | |
296 buildReportApiColumnSpec() { | |
297 var o = new api.ReportApiColumnSpec(); | |
298 buildCounterReportApiColumnSpec++; | |
299 if (buildCounterReportApiColumnSpec < 3) { | |
300 o.columnName = "foo"; | |
301 o.customDimensionName = "foo"; | |
302 o.endDate = "foo"; | |
303 o.groupByColumn = true; | |
304 o.headerText = "foo"; | |
305 o.platformSource = "foo"; | |
306 o.savedColumnName = "foo"; | |
307 o.startDate = "foo"; | |
308 } | |
309 buildCounterReportApiColumnSpec--; | |
310 return o; | |
311 } | |
312 | |
313 checkReportApiColumnSpec(api.ReportApiColumnSpec o) { | |
314 buildCounterReportApiColumnSpec++; | |
315 if (buildCounterReportApiColumnSpec < 3) { | |
316 unittest.expect(o.columnName, unittest.equals('foo')); | |
317 unittest.expect(o.customDimensionName, unittest.equals('foo')); | |
318 unittest.expect(o.endDate, unittest.equals('foo')); | |
319 unittest.expect(o.groupByColumn, unittest.isTrue); | |
320 unittest.expect(o.headerText, unittest.equals('foo')); | |
321 unittest.expect(o.platformSource, unittest.equals('foo')); | |
322 unittest.expect(o.savedColumnName, unittest.equals('foo')); | |
323 unittest.expect(o.startDate, unittest.equals('foo')); | |
324 } | |
325 buildCounterReportApiColumnSpec--; | |
326 } | |
327 | |
328 buildUnnamed736() { | |
329 var o = new core.List<api.ReportApiColumnSpec>(); | |
330 o.add(buildReportApiColumnSpec()); | |
331 o.add(buildReportApiColumnSpec()); | |
332 return o; | |
333 } | |
334 | |
335 checkUnnamed736(core.List<api.ReportApiColumnSpec> o) { | |
336 unittest.expect(o, unittest.hasLength(2)); | |
337 checkReportApiColumnSpec(o[0]); | |
338 checkReportApiColumnSpec(o[1]); | |
339 } | |
340 | |
341 buildUnnamed737() { | |
342 var o = new core.List<core.Object>(); | |
343 o.add({'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}); | |
344 o.add({'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}); | |
345 return o; | |
346 } | |
347 | |
348 checkUnnamed737(core.List<core.Object> o) { | |
349 unittest.expect(o, unittest.hasLength(2)); | |
350 var casted1 = (o[0]) as core.Map; unittest.expect(casted1, unittest.hasLength(
3)); unittest.expect(casted1["list"], unittest.equals([1, 2, 3])); unittest.expe
ct(casted1["bool"], unittest.equals(true)); unittest.expect(casted1["string"], u
nittest.equals('foo')); | |
351 var casted2 = (o[1]) as core.Map; unittest.expect(casted2, unittest.hasLength(
3)); unittest.expect(casted2["list"], unittest.equals([1, 2, 3])); unittest.expe
ct(casted2["bool"], unittest.equals(true)); unittest.expect(casted2["string"], u
nittest.equals('foo')); | |
352 } | |
353 | |
354 core.int buildCounterReportRequestFilters = 0; | |
355 buildReportRequestFilters() { | |
356 var o = new api.ReportRequestFilters(); | |
357 buildCounterReportRequestFilters++; | |
358 if (buildCounterReportRequestFilters < 3) { | |
359 o.column = buildReportApiColumnSpec(); | |
360 o.operator = "foo"; | |
361 o.values = buildUnnamed737(); | |
362 } | |
363 buildCounterReportRequestFilters--; | |
364 return o; | |
365 } | |
366 | |
367 checkReportRequestFilters(api.ReportRequestFilters o) { | |
368 buildCounterReportRequestFilters++; | |
369 if (buildCounterReportRequestFilters < 3) { | |
370 checkReportApiColumnSpec(o.column); | |
371 unittest.expect(o.operator, unittest.equals('foo')); | |
372 checkUnnamed737(o.values); | |
373 } | |
374 buildCounterReportRequestFilters--; | |
375 } | |
376 | |
377 buildUnnamed738() { | |
378 var o = new core.List<api.ReportRequestFilters>(); | |
379 o.add(buildReportRequestFilters()); | |
380 o.add(buildReportRequestFilters()); | |
381 return o; | |
382 } | |
383 | |
384 checkUnnamed738(core.List<api.ReportRequestFilters> o) { | |
385 unittest.expect(o, unittest.hasLength(2)); | |
386 checkReportRequestFilters(o[0]); | |
387 checkReportRequestFilters(o[1]); | |
388 } | |
389 | |
390 core.int buildCounterReportRequestOrderBy = 0; | |
391 buildReportRequestOrderBy() { | |
392 var o = new api.ReportRequestOrderBy(); | |
393 buildCounterReportRequestOrderBy++; | |
394 if (buildCounterReportRequestOrderBy < 3) { | |
395 o.column = buildReportApiColumnSpec(); | |
396 o.sortOrder = "foo"; | |
397 } | |
398 buildCounterReportRequestOrderBy--; | |
399 return o; | |
400 } | |
401 | |
402 checkReportRequestOrderBy(api.ReportRequestOrderBy o) { | |
403 buildCounterReportRequestOrderBy++; | |
404 if (buildCounterReportRequestOrderBy < 3) { | |
405 checkReportApiColumnSpec(o.column); | |
406 unittest.expect(o.sortOrder, unittest.equals('foo')); | |
407 } | |
408 buildCounterReportRequestOrderBy--; | |
409 } | |
410 | |
411 buildUnnamed739() { | |
412 var o = new core.List<api.ReportRequestOrderBy>(); | |
413 o.add(buildReportRequestOrderBy()); | |
414 o.add(buildReportRequestOrderBy()); | |
415 return o; | |
416 } | |
417 | |
418 checkUnnamed739(core.List<api.ReportRequestOrderBy> o) { | |
419 unittest.expect(o, unittest.hasLength(2)); | |
420 checkReportRequestOrderBy(o[0]); | |
421 checkReportRequestOrderBy(o[1]); | |
422 } | |
423 | |
424 core.int buildCounterReportRequestReportScope = 0; | |
425 buildReportRequestReportScope() { | |
426 var o = new api.ReportRequestReportScope(); | |
427 buildCounterReportRequestReportScope++; | |
428 if (buildCounterReportRequestReportScope < 3) { | |
429 o.adGroupId = "foo"; | |
430 o.adId = "foo"; | |
431 o.advertiserId = "foo"; | |
432 o.agencyId = "foo"; | |
433 o.campaignId = "foo"; | |
434 o.engineAccountId = "foo"; | |
435 o.keywordId = "foo"; | |
436 } | |
437 buildCounterReportRequestReportScope--; | |
438 return o; | |
439 } | |
440 | |
441 checkReportRequestReportScope(api.ReportRequestReportScope o) { | |
442 buildCounterReportRequestReportScope++; | |
443 if (buildCounterReportRequestReportScope < 3) { | |
444 unittest.expect(o.adGroupId, unittest.equals('foo')); | |
445 unittest.expect(o.adId, unittest.equals('foo')); | |
446 unittest.expect(o.advertiserId, unittest.equals('foo')); | |
447 unittest.expect(o.agencyId, unittest.equals('foo')); | |
448 unittest.expect(o.campaignId, unittest.equals('foo')); | |
449 unittest.expect(o.engineAccountId, unittest.equals('foo')); | |
450 unittest.expect(o.keywordId, unittest.equals('foo')); | |
451 } | |
452 buildCounterReportRequestReportScope--; | |
453 } | |
454 | |
455 core.int buildCounterReportRequestTimeRange = 0; | |
456 buildReportRequestTimeRange() { | |
457 var o = new api.ReportRequestTimeRange(); | |
458 buildCounterReportRequestTimeRange++; | |
459 if (buildCounterReportRequestTimeRange < 3) { | |
460 o.changedAttributesSinceTimestamp = core.DateTime.parse("2002-02-27T14:01:02
"); | |
461 o.changedMetricsSinceTimestamp = core.DateTime.parse("2002-02-27T14:01:02"); | |
462 o.endDate = "foo"; | |
463 o.startDate = "foo"; | |
464 } | |
465 buildCounterReportRequestTimeRange--; | |
466 return o; | |
467 } | |
468 | |
469 checkReportRequestTimeRange(api.ReportRequestTimeRange o) { | |
470 buildCounterReportRequestTimeRange++; | |
471 if (buildCounterReportRequestTimeRange < 3) { | |
472 unittest.expect(o.changedAttributesSinceTimestamp, unittest.equals(core.Date
Time.parse("2002-02-27T14:01:02"))); | |
473 unittest.expect(o.changedMetricsSinceTimestamp, unittest.equals(core.DateTim
e.parse("2002-02-27T14:01:02"))); | |
474 unittest.expect(o.endDate, unittest.equals('foo')); | |
475 unittest.expect(o.startDate, unittest.equals('foo')); | |
476 } | |
477 buildCounterReportRequestTimeRange--; | |
478 } | |
479 | |
480 core.int buildCounterReportRequest = 0; | |
481 buildReportRequest() { | |
482 var o = new api.ReportRequest(); | |
483 buildCounterReportRequest++; | |
484 if (buildCounterReportRequest < 3) { | |
485 o.columns = buildUnnamed736(); | |
486 o.downloadFormat = "foo"; | |
487 o.filters = buildUnnamed738(); | |
488 o.includeDeletedEntities = true; | |
489 o.includeRemovedEntities = true; | |
490 o.maxRowsPerFile = 42; | |
491 o.orderBy = buildUnnamed739(); | |
492 o.reportScope = buildReportRequestReportScope(); | |
493 o.reportType = "foo"; | |
494 o.rowCount = 42; | |
495 o.startRow = 42; | |
496 o.statisticsCurrency = "foo"; | |
497 o.timeRange = buildReportRequestTimeRange(); | |
498 o.verifySingleTimeZone = true; | |
499 } | |
500 buildCounterReportRequest--; | |
501 return o; | |
502 } | |
503 | |
504 checkReportRequest(api.ReportRequest o) { | |
505 buildCounterReportRequest++; | |
506 if (buildCounterReportRequest < 3) { | |
507 checkUnnamed736(o.columns); | |
508 unittest.expect(o.downloadFormat, unittest.equals('foo')); | |
509 checkUnnamed738(o.filters); | |
510 unittest.expect(o.includeDeletedEntities, unittest.isTrue); | |
511 unittest.expect(o.includeRemovedEntities, unittest.isTrue); | |
512 unittest.expect(o.maxRowsPerFile, unittest.equals(42)); | |
513 checkUnnamed739(o.orderBy); | |
514 checkReportRequestReportScope(o.reportScope); | |
515 unittest.expect(o.reportType, unittest.equals('foo')); | |
516 unittest.expect(o.rowCount, unittest.equals(42)); | |
517 unittest.expect(o.startRow, unittest.equals(42)); | |
518 unittest.expect(o.statisticsCurrency, unittest.equals('foo')); | |
519 checkReportRequestTimeRange(o.timeRange); | |
520 unittest.expect(o.verifySingleTimeZone, unittest.isTrue); | |
521 } | |
522 buildCounterReportRequest--; | |
523 } | |
524 | |
525 buildReportRow() { | |
526 var o = new api.ReportRow(); | |
527 o["a"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; | |
528 o["b"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; | |
529 return o; | |
530 } | |
531 | |
532 checkReportRow(api.ReportRow o) { | |
533 unittest.expect(o, unittest.hasLength(2)); | |
534 var casted3 = (o["a"]) 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')); | |
535 var casted4 = (o["b"]) 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')); | |
536 } | |
537 | |
538 core.int buildCounterSavedColumn = 0; | |
539 buildSavedColumn() { | |
540 var o = new api.SavedColumn(); | |
541 buildCounterSavedColumn++; | |
542 if (buildCounterSavedColumn < 3) { | |
543 o.kind = "foo"; | |
544 o.savedColumnName = "foo"; | |
545 o.type = "foo"; | |
546 } | |
547 buildCounterSavedColumn--; | |
548 return o; | |
549 } | |
550 | |
551 checkSavedColumn(api.SavedColumn o) { | |
552 buildCounterSavedColumn++; | |
553 if (buildCounterSavedColumn < 3) { | |
554 unittest.expect(o.kind, unittest.equals('foo')); | |
555 unittest.expect(o.savedColumnName, unittest.equals('foo')); | |
556 unittest.expect(o.type, unittest.equals('foo')); | |
557 } | |
558 buildCounterSavedColumn--; | |
559 } | |
560 | |
561 buildUnnamed740() { | |
562 var o = new core.List<api.SavedColumn>(); | |
563 o.add(buildSavedColumn()); | |
564 o.add(buildSavedColumn()); | |
565 return o; | |
566 } | |
567 | |
568 checkUnnamed740(core.List<api.SavedColumn> o) { | |
569 unittest.expect(o, unittest.hasLength(2)); | |
570 checkSavedColumn(o[0]); | |
571 checkSavedColumn(o[1]); | |
572 } | |
573 | |
574 core.int buildCounterSavedColumnList = 0; | |
575 buildSavedColumnList() { | |
576 var o = new api.SavedColumnList(); | |
577 buildCounterSavedColumnList++; | |
578 if (buildCounterSavedColumnList < 3) { | |
579 o.items = buildUnnamed740(); | |
580 o.kind = "foo"; | |
581 } | |
582 buildCounterSavedColumnList--; | |
583 return o; | |
584 } | |
585 | |
586 checkSavedColumnList(api.SavedColumnList o) { | |
587 buildCounterSavedColumnList++; | |
588 if (buildCounterSavedColumnList < 3) { | |
589 checkUnnamed740(o.items); | |
590 unittest.expect(o.kind, unittest.equals('foo')); | |
591 } | |
592 buildCounterSavedColumnList--; | |
593 } | |
594 | |
595 buildUnnamed741() { | |
596 var o = new core.List<api.Availability>(); | |
597 o.add(buildAvailability()); | |
598 o.add(buildAvailability()); | |
599 return o; | |
600 } | |
601 | |
602 checkUnnamed741(core.List<api.Availability> o) { | |
603 unittest.expect(o, unittest.hasLength(2)); | |
604 checkAvailability(o[0]); | |
605 checkAvailability(o[1]); | |
606 } | |
607 | |
608 core.int buildCounterUpdateAvailabilityRequest = 0; | |
609 buildUpdateAvailabilityRequest() { | |
610 var o = new api.UpdateAvailabilityRequest(); | |
611 buildCounterUpdateAvailabilityRequest++; | |
612 if (buildCounterUpdateAvailabilityRequest < 3) { | |
613 o.availabilities = buildUnnamed741(); | |
614 } | |
615 buildCounterUpdateAvailabilityRequest--; | |
616 return o; | |
617 } | |
618 | |
619 checkUpdateAvailabilityRequest(api.UpdateAvailabilityRequest o) { | |
620 buildCounterUpdateAvailabilityRequest++; | |
621 if (buildCounterUpdateAvailabilityRequest < 3) { | |
622 checkUnnamed741(o.availabilities); | |
623 } | |
624 buildCounterUpdateAvailabilityRequest--; | |
625 } | |
626 | |
627 buildUnnamed742() { | |
628 var o = new core.List<api.Availability>(); | |
629 o.add(buildAvailability()); | |
630 o.add(buildAvailability()); | |
631 return o; | |
632 } | |
633 | |
634 checkUnnamed742(core.List<api.Availability> o) { | |
635 unittest.expect(o, unittest.hasLength(2)); | |
636 checkAvailability(o[0]); | |
637 checkAvailability(o[1]); | |
638 } | |
639 | |
640 core.int buildCounterUpdateAvailabilityResponse = 0; | |
641 buildUpdateAvailabilityResponse() { | |
642 var o = new api.UpdateAvailabilityResponse(); | |
643 buildCounterUpdateAvailabilityResponse++; | |
644 if (buildCounterUpdateAvailabilityResponse < 3) { | |
645 o.availabilities = buildUnnamed742(); | |
646 } | |
647 buildCounterUpdateAvailabilityResponse--; | |
648 return o; | |
649 } | |
650 | |
651 checkUpdateAvailabilityResponse(api.UpdateAvailabilityResponse o) { | |
652 buildCounterUpdateAvailabilityResponse++; | |
653 if (buildCounterUpdateAvailabilityResponse < 3) { | |
654 checkUnnamed742(o.availabilities); | |
655 } | |
656 buildCounterUpdateAvailabilityResponse--; | |
657 } | |
658 | |
659 | |
660 main() { | |
661 unittest.group("obj-schema-Availability", () { | |
662 unittest.test("to-json--from-json", () { | |
663 var o = buildAvailability(); | |
664 var od = new api.Availability.fromJson(o.toJson()); | |
665 checkAvailability(od); | |
666 }); | |
667 }); | |
668 | |
669 | |
670 unittest.group("obj-schema-Conversion", () { | |
671 unittest.test("to-json--from-json", () { | |
672 var o = buildConversion(); | |
673 var od = new api.Conversion.fromJson(o.toJson()); | |
674 checkConversion(od); | |
675 }); | |
676 }); | |
677 | |
678 | |
679 unittest.group("obj-schema-ConversionList", () { | |
680 unittest.test("to-json--from-json", () { | |
681 var o = buildConversionList(); | |
682 var od = new api.ConversionList.fromJson(o.toJson()); | |
683 checkConversionList(od); | |
684 }); | |
685 }); | |
686 | |
687 | |
688 unittest.group("obj-schema-CustomDimension", () { | |
689 unittest.test("to-json--from-json", () { | |
690 var o = buildCustomDimension(); | |
691 var od = new api.CustomDimension.fromJson(o.toJson()); | |
692 checkCustomDimension(od); | |
693 }); | |
694 }); | |
695 | |
696 | |
697 unittest.group("obj-schema-CustomMetric", () { | |
698 unittest.test("to-json--from-json", () { | |
699 var o = buildCustomMetric(); | |
700 var od = new api.CustomMetric.fromJson(o.toJson()); | |
701 checkCustomMetric(od); | |
702 }); | |
703 }); | |
704 | |
705 | |
706 unittest.group("obj-schema-ReportFiles", () { | |
707 unittest.test("to-json--from-json", () { | |
708 var o = buildReportFiles(); | |
709 var od = new api.ReportFiles.fromJson(o.toJson()); | |
710 checkReportFiles(od); | |
711 }); | |
712 }); | |
713 | |
714 | |
715 unittest.group("obj-schema-Report", () { | |
716 unittest.test("to-json--from-json", () { | |
717 var o = buildReport(); | |
718 var od = new api.Report.fromJson(o.toJson()); | |
719 checkReport(od); | |
720 }); | |
721 }); | |
722 | |
723 | |
724 unittest.group("obj-schema-ReportApiColumnSpec", () { | |
725 unittest.test("to-json--from-json", () { | |
726 var o = buildReportApiColumnSpec(); | |
727 var od = new api.ReportApiColumnSpec.fromJson(o.toJson()); | |
728 checkReportApiColumnSpec(od); | |
729 }); | |
730 }); | |
731 | |
732 | |
733 unittest.group("obj-schema-ReportRequestFilters", () { | |
734 unittest.test("to-json--from-json", () { | |
735 var o = buildReportRequestFilters(); | |
736 var od = new api.ReportRequestFilters.fromJson(o.toJson()); | |
737 checkReportRequestFilters(od); | |
738 }); | |
739 }); | |
740 | |
741 | |
742 unittest.group("obj-schema-ReportRequestOrderBy", () { | |
743 unittest.test("to-json--from-json", () { | |
744 var o = buildReportRequestOrderBy(); | |
745 var od = new api.ReportRequestOrderBy.fromJson(o.toJson()); | |
746 checkReportRequestOrderBy(od); | |
747 }); | |
748 }); | |
749 | |
750 | |
751 unittest.group("obj-schema-ReportRequestReportScope", () { | |
752 unittest.test("to-json--from-json", () { | |
753 var o = buildReportRequestReportScope(); | |
754 var od = new api.ReportRequestReportScope.fromJson(o.toJson()); | |
755 checkReportRequestReportScope(od); | |
756 }); | |
757 }); | |
758 | |
759 | |
760 unittest.group("obj-schema-ReportRequestTimeRange", () { | |
761 unittest.test("to-json--from-json", () { | |
762 var o = buildReportRequestTimeRange(); | |
763 var od = new api.ReportRequestTimeRange.fromJson(o.toJson()); | |
764 checkReportRequestTimeRange(od); | |
765 }); | |
766 }); | |
767 | |
768 | |
769 unittest.group("obj-schema-ReportRequest", () { | |
770 unittest.test("to-json--from-json", () { | |
771 var o = buildReportRequest(); | |
772 var od = new api.ReportRequest.fromJson(o.toJson()); | |
773 checkReportRequest(od); | |
774 }); | |
775 }); | |
776 | |
777 | |
778 unittest.group("obj-schema-ReportRow", () { | |
779 unittest.test("to-json--from-json", () { | |
780 var o = buildReportRow(); | |
781 var od = new api.ReportRow.fromJson(o.toJson()); | |
782 checkReportRow(od); | |
783 }); | |
784 }); | |
785 | |
786 | |
787 unittest.group("obj-schema-SavedColumn", () { | |
788 unittest.test("to-json--from-json", () { | |
789 var o = buildSavedColumn(); | |
790 var od = new api.SavedColumn.fromJson(o.toJson()); | |
791 checkSavedColumn(od); | |
792 }); | |
793 }); | |
794 | |
795 | |
796 unittest.group("obj-schema-SavedColumnList", () { | |
797 unittest.test("to-json--from-json", () { | |
798 var o = buildSavedColumnList(); | |
799 var od = new api.SavedColumnList.fromJson(o.toJson()); | |
800 checkSavedColumnList(od); | |
801 }); | |
802 }); | |
803 | |
804 | |
805 unittest.group("obj-schema-UpdateAvailabilityRequest", () { | |
806 unittest.test("to-json--from-json", () { | |
807 var o = buildUpdateAvailabilityRequest(); | |
808 var od = new api.UpdateAvailabilityRequest.fromJson(o.toJson()); | |
809 checkUpdateAvailabilityRequest(od); | |
810 }); | |
811 }); | |
812 | |
813 | |
814 unittest.group("obj-schema-UpdateAvailabilityResponse", () { | |
815 unittest.test("to-json--from-json", () { | |
816 var o = buildUpdateAvailabilityResponse(); | |
817 var od = new api.UpdateAvailabilityResponse.fromJson(o.toJson()); | |
818 checkUpdateAvailabilityResponse(od); | |
819 }); | |
820 }); | |
821 | |
822 | |
823 unittest.group("resource-ConversionResourceApi", () { | |
824 unittest.test("method--get", () { | |
825 | |
826 var mock = new common_test.HttpServerMock(); | |
827 api.ConversionResourceApi res = new api.DoubleclicksearchApi(mock).convers
ion; | |
828 var arg_agencyId = "foo"; | |
829 var arg_advertiserId = "foo"; | |
830 var arg_engineAccountId = "foo"; | |
831 var arg_endDate = 42; | |
832 var arg_rowCount = 42; | |
833 var arg_startDate = 42; | |
834 var arg_startRow = 42; | |
835 var arg_adGroupId = "foo"; | |
836 var arg_adId = "foo"; | |
837 var arg_campaignId = "foo"; | |
838 var arg_criterionId = "foo"; | |
839 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
840 var path = (req.url).path; | |
841 var pathOffset = 0; | |
842 var index; | |
843 var subPart; | |
844 unittest.expect(path.substring(pathOffset, pathOffset + 22), unittest.eq
uals("/doubleclicksearch/v2/")); | |
845 pathOffset += 22; | |
846 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ
als("agency/")); | |
847 pathOffset += 7; | |
848 index = path.indexOf("/advertiser/", pathOffset); | |
849 unittest.expect(index >= 0, unittest.isTrue); | |
850 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
851 pathOffset = index; | |
852 unittest.expect(subPart, unittest.equals("$arg_agencyId")); | |
853 unittest.expect(path.substring(pathOffset, pathOffset + 12), unittest.eq
uals("/advertiser/")); | |
854 pathOffset += 12; | |
855 index = path.indexOf("/engine/", pathOffset); | |
856 unittest.expect(index >= 0, unittest.isTrue); | |
857 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
858 pathOffset = index; | |
859 unittest.expect(subPart, unittest.equals("$arg_advertiserId")); | |
860 unittest.expect(path.substring(pathOffset, pathOffset + 8), unittest.equ
als("/engine/")); | |
861 pathOffset += 8; | |
862 index = path.indexOf("/conversion", pathOffset); | |
863 unittest.expect(index >= 0, unittest.isTrue); | |
864 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
865 pathOffset = index; | |
866 unittest.expect(subPart, unittest.equals("$arg_engineAccountId")); | |
867 unittest.expect(path.substring(pathOffset, pathOffset + 11), unittest.eq
uals("/conversion")); | |
868 pathOffset += 11; | |
869 | |
870 var query = (req.url).query; | |
871 var queryOffset = 0; | |
872 var queryMap = {}; | |
873 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
874 parseBool(n) { | |
875 if (n == "true") return true; | |
876 if (n == "false") return false; | |
877 if (n == null) return null; | |
878 throw new core.ArgumentError("Invalid boolean: $n"); | |
879 } | |
880 if (query.length > 0) { | |
881 for (var part in query.split("&")) { | |
882 var keyvalue = part.split("="); | |
883 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
884 } | |
885 } | |
886 unittest.expect(core.int.parse(queryMap["endDate"].first), unittest.equa
ls(arg_endDate)); | |
887 unittest.expect(core.int.parse(queryMap["rowCount"].first), unittest.equ
als(arg_rowCount)); | |
888 unittest.expect(core.int.parse(queryMap["startDate"].first), unittest.eq
uals(arg_startDate)); | |
889 unittest.expect(core.int.parse(queryMap["startRow"].first), unittest.equ
als(arg_startRow)); | |
890 unittest.expect(queryMap["adGroupId"].first, unittest.equals(arg_adGroup
Id)); | |
891 unittest.expect(queryMap["adId"].first, unittest.equals(arg_adId)); | |
892 unittest.expect(queryMap["campaignId"].first, unittest.equals(arg_campai
gnId)); | |
893 unittest.expect(queryMap["criterionId"].first, unittest.equals(arg_crite
rionId)); | |
894 | |
895 | |
896 var h = { | |
897 "content-type" : "application/json; charset=utf-8", | |
898 }; | |
899 var resp = convert.JSON.encode(buildConversionList()); | |
900 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
901 }), true); | |
902 res.get(arg_agencyId, arg_advertiserId, arg_engineAccountId, arg_endDate,
arg_rowCount, arg_startDate, arg_startRow, adGroupId: arg_adGroupId, adId: arg_a
dId, campaignId: arg_campaignId, criterionId: arg_criterionId).then(unittest.exp
ectAsync(((api.ConversionList response) { | |
903 checkConversionList(response); | |
904 }))); | |
905 }); | |
906 | |
907 unittest.test("method--insert", () { | |
908 | |
909 var mock = new common_test.HttpServerMock(); | |
910 api.ConversionResourceApi res = new api.DoubleclicksearchApi(mock).convers
ion; | |
911 var arg_request = buildConversionList(); | |
912 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
913 var obj = new api.ConversionList.fromJson(json); | |
914 checkConversionList(obj); | |
915 | |
916 var path = (req.url).path; | |
917 var pathOffset = 0; | |
918 var index; | |
919 var subPart; | |
920 unittest.expect(path.substring(pathOffset, pathOffset + 22), unittest.eq
uals("/doubleclicksearch/v2/")); | |
921 pathOffset += 22; | |
922 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("conversion")); | |
923 pathOffset += 10; | |
924 | |
925 var query = (req.url).query; | |
926 var queryOffset = 0; | |
927 var queryMap = {}; | |
928 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
929 parseBool(n) { | |
930 if (n == "true") return true; | |
931 if (n == "false") return false; | |
932 if (n == null) return null; | |
933 throw new core.ArgumentError("Invalid boolean: $n"); | |
934 } | |
935 if (query.length > 0) { | |
936 for (var part in query.split("&")) { | |
937 var keyvalue = part.split("="); | |
938 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
939 } | |
940 } | |
941 | |
942 | |
943 var h = { | |
944 "content-type" : "application/json; charset=utf-8", | |
945 }; | |
946 var resp = convert.JSON.encode(buildConversionList()); | |
947 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
948 }), true); | |
949 res.insert(arg_request).then(unittest.expectAsync(((api.ConversionList res
ponse) { | |
950 checkConversionList(response); | |
951 }))); | |
952 }); | |
953 | |
954 unittest.test("method--patch", () { | |
955 | |
956 var mock = new common_test.HttpServerMock(); | |
957 api.ConversionResourceApi res = new api.DoubleclicksearchApi(mock).convers
ion; | |
958 var arg_request = buildConversionList(); | |
959 var arg_advertiserId = "foo"; | |
960 var arg_agencyId = "foo"; | |
961 var arg_endDate = 42; | |
962 var arg_engineAccountId = "foo"; | |
963 var arg_rowCount = 42; | |
964 var arg_startDate = 42; | |
965 var arg_startRow = 42; | |
966 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
967 var obj = new api.ConversionList.fromJson(json); | |
968 checkConversionList(obj); | |
969 | |
970 var path = (req.url).path; | |
971 var pathOffset = 0; | |
972 var index; | |
973 var subPart; | |
974 unittest.expect(path.substring(pathOffset, pathOffset + 22), unittest.eq
uals("/doubleclicksearch/v2/")); | |
975 pathOffset += 22; | |
976 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("conversion")); | |
977 pathOffset += 10; | |
978 | |
979 var query = (req.url).query; | |
980 var queryOffset = 0; | |
981 var queryMap = {}; | |
982 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
983 parseBool(n) { | |
984 if (n == "true") return true; | |
985 if (n == "false") return false; | |
986 if (n == null) return null; | |
987 throw new core.ArgumentError("Invalid boolean: $n"); | |
988 } | |
989 if (query.length > 0) { | |
990 for (var part in query.split("&")) { | |
991 var keyvalue = part.split("="); | |
992 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
993 } | |
994 } | |
995 unittest.expect(queryMap["advertiserId"].first, unittest.equals(arg_adve
rtiserId)); | |
996 unittest.expect(queryMap["agencyId"].first, unittest.equals(arg_agencyId
)); | |
997 unittest.expect(core.int.parse(queryMap["endDate"].first), unittest.equa
ls(arg_endDate)); | |
998 unittest.expect(queryMap["engineAccountId"].first, unittest.equals(arg_e
ngineAccountId)); | |
999 unittest.expect(core.int.parse(queryMap["rowCount"].first), unittest.equ
als(arg_rowCount)); | |
1000 unittest.expect(core.int.parse(queryMap["startDate"].first), unittest.eq
uals(arg_startDate)); | |
1001 unittest.expect(core.int.parse(queryMap["startRow"].first), unittest.equ
als(arg_startRow)); | |
1002 | |
1003 | |
1004 var h = { | |
1005 "content-type" : "application/json; charset=utf-8", | |
1006 }; | |
1007 var resp = convert.JSON.encode(buildConversionList()); | |
1008 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
1009 }), true); | |
1010 res.patch(arg_request, arg_advertiserId, arg_agencyId, arg_endDate, arg_en
gineAccountId, arg_rowCount, arg_startDate, arg_startRow).then(unittest.expectAs
ync(((api.ConversionList response) { | |
1011 checkConversionList(response); | |
1012 }))); | |
1013 }); | |
1014 | |
1015 unittest.test("method--update", () { | |
1016 | |
1017 var mock = new common_test.HttpServerMock(); | |
1018 api.ConversionResourceApi res = new api.DoubleclicksearchApi(mock).convers
ion; | |
1019 var arg_request = buildConversionList(); | |
1020 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
1021 var obj = new api.ConversionList.fromJson(json); | |
1022 checkConversionList(obj); | |
1023 | |
1024 var path = (req.url).path; | |
1025 var pathOffset = 0; | |
1026 var index; | |
1027 var subPart; | |
1028 unittest.expect(path.substring(pathOffset, pathOffset + 22), unittest.eq
uals("/doubleclicksearch/v2/")); | |
1029 pathOffset += 22; | |
1030 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("conversion")); | |
1031 pathOffset += 10; | |
1032 | |
1033 var query = (req.url).query; | |
1034 var queryOffset = 0; | |
1035 var queryMap = {}; | |
1036 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
1037 parseBool(n) { | |
1038 if (n == "true") return true; | |
1039 if (n == "false") return false; | |
1040 if (n == null) return null; | |
1041 throw new core.ArgumentError("Invalid boolean: $n"); | |
1042 } | |
1043 if (query.length > 0) { | |
1044 for (var part in query.split("&")) { | |
1045 var keyvalue = part.split("="); | |
1046 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
1047 } | |
1048 } | |
1049 | |
1050 | |
1051 var h = { | |
1052 "content-type" : "application/json; charset=utf-8", | |
1053 }; | |
1054 var resp = convert.JSON.encode(buildConversionList()); | |
1055 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
1056 }), true); | |
1057 res.update(arg_request).then(unittest.expectAsync(((api.ConversionList res
ponse) { | |
1058 checkConversionList(response); | |
1059 }))); | |
1060 }); | |
1061 | |
1062 unittest.test("method--updateAvailability", () { | |
1063 | |
1064 var mock = new common_test.HttpServerMock(); | |
1065 api.ConversionResourceApi res = new api.DoubleclicksearchApi(mock).convers
ion; | |
1066 var arg_request = buildUpdateAvailabilityRequest(); | |
1067 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
1068 var obj = new api.UpdateAvailabilityRequest.fromJson(json); | |
1069 checkUpdateAvailabilityRequest(obj); | |
1070 | |
1071 var path = (req.url).path; | |
1072 var pathOffset = 0; | |
1073 var index; | |
1074 var subPart; | |
1075 unittest.expect(path.substring(pathOffset, pathOffset + 22), unittest.eq
uals("/doubleclicksearch/v2/")); | |
1076 pathOffset += 22; | |
1077 unittest.expect(path.substring(pathOffset, pathOffset + 29), unittest.eq
uals("conversion/updateAvailability")); | |
1078 pathOffset += 29; | |
1079 | |
1080 var query = (req.url).query; | |
1081 var queryOffset = 0; | |
1082 var queryMap = {}; | |
1083 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
1084 parseBool(n) { | |
1085 if (n == "true") return true; | |
1086 if (n == "false") return false; | |
1087 if (n == null) return null; | |
1088 throw new core.ArgumentError("Invalid boolean: $n"); | |
1089 } | |
1090 if (query.length > 0) { | |
1091 for (var part in query.split("&")) { | |
1092 var keyvalue = part.split("="); | |
1093 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
1094 } | |
1095 } | |
1096 | |
1097 | |
1098 var h = { | |
1099 "content-type" : "application/json; charset=utf-8", | |
1100 }; | |
1101 var resp = convert.JSON.encode(buildUpdateAvailabilityResponse()); | |
1102 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
1103 }), true); | |
1104 res.updateAvailability(arg_request).then(unittest.expectAsync(((api.Update
AvailabilityResponse response) { | |
1105 checkUpdateAvailabilityResponse(response); | |
1106 }))); | |
1107 }); | |
1108 | |
1109 }); | |
1110 | |
1111 | |
1112 unittest.group("resource-ReportsResourceApi", () { | |
1113 unittest.test("method--generate", () { | |
1114 | |
1115 var mock = new common_test.HttpServerMock(); | |
1116 api.ReportsResourceApi res = new api.DoubleclicksearchApi(mock).reports; | |
1117 var arg_request_1 = buildReportRequest(); | |
1118 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
1119 var obj = new api.ReportRequest.fromJson(json); | |
1120 checkReportRequest(obj); | |
1121 | |
1122 var path = (req.url).path; | |
1123 var pathOffset = 0; | |
1124 var index; | |
1125 var subPart; | |
1126 unittest.expect(path.substring(pathOffset, pathOffset + 22), unittest.eq
uals("/doubleclicksearch/v2/")); | |
1127 pathOffset += 22; | |
1128 unittest.expect(path.substring(pathOffset, pathOffset + 16), unittest.eq
uals("reports/generate")); | |
1129 pathOffset += 16; | |
1130 | |
1131 var query = (req.url).query; | |
1132 var queryOffset = 0; | |
1133 var queryMap = {}; | |
1134 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
1135 parseBool(n) { | |
1136 if (n == "true") return true; | |
1137 if (n == "false") return false; | |
1138 if (n == null) return null; | |
1139 throw new core.ArgumentError("Invalid boolean: $n"); | |
1140 } | |
1141 if (query.length > 0) { | |
1142 for (var part in query.split("&")) { | |
1143 var keyvalue = part.split("="); | |
1144 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
1145 } | |
1146 } | |
1147 | |
1148 | |
1149 var h = { | |
1150 "content-type" : "application/json; charset=utf-8", | |
1151 }; | |
1152 var resp = convert.JSON.encode(buildReport()); | |
1153 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
1154 }), true); | |
1155 res.generate(arg_request_1).then(unittest.expectAsync(((api.Report respons
e) { | |
1156 checkReport(response); | |
1157 }))); | |
1158 }); | |
1159 | |
1160 unittest.test("method--get", () { | |
1161 | |
1162 var mock = new common_test.HttpServerMock(); | |
1163 api.ReportsResourceApi res = new api.DoubleclicksearchApi(mock).reports; | |
1164 var arg_reportId = "foo"; | |
1165 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
1166 var path = (req.url).path; | |
1167 var pathOffset = 0; | |
1168 var index; | |
1169 var subPart; | |
1170 unittest.expect(path.substring(pathOffset, pathOffset + 22), unittest.eq
uals("/doubleclicksearch/v2/")); | |
1171 pathOffset += 22; | |
1172 unittest.expect(path.substring(pathOffset, pathOffset + 8), unittest.equ
als("reports/")); | |
1173 pathOffset += 8; | |
1174 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); | |
1175 pathOffset = path.length; | |
1176 unittest.expect(subPart, unittest.equals("$arg_reportId")); | |
1177 | |
1178 var query = (req.url).query; | |
1179 var queryOffset = 0; | |
1180 var queryMap = {}; | |
1181 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
1182 parseBool(n) { | |
1183 if (n == "true") return true; | |
1184 if (n == "false") return false; | |
1185 if (n == null) return null; | |
1186 throw new core.ArgumentError("Invalid boolean: $n"); | |
1187 } | |
1188 if (query.length > 0) { | |
1189 for (var part in query.split("&")) { | |
1190 var keyvalue = part.split("="); | |
1191 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
1192 } | |
1193 } | |
1194 | |
1195 | |
1196 var h = { | |
1197 "content-type" : "application/json; charset=utf-8", | |
1198 }; | |
1199 var resp = convert.JSON.encode(buildReport()); | |
1200 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
1201 }), true); | |
1202 res.get(arg_reportId).then(unittest.expectAsync(((api.Report response) { | |
1203 checkReport(response); | |
1204 }))); | |
1205 }); | |
1206 | |
1207 unittest.test("method--getFile", () { | |
1208 // TODO: Implement tests for media upload; | |
1209 // TODO: Implement tests for media download; | |
1210 | |
1211 var mock = new common_test.HttpServerMock(); | |
1212 api.ReportsResourceApi res = new api.DoubleclicksearchApi(mock).reports; | |
1213 var arg_reportId = "foo"; | |
1214 var arg_reportFragment = 42; | |
1215 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
1216 var path = (req.url).path; | |
1217 var pathOffset = 0; | |
1218 var index; | |
1219 var subPart; | |
1220 unittest.expect(path.substring(pathOffset, pathOffset + 22), unittest.eq
uals("/doubleclicksearch/v2/")); | |
1221 pathOffset += 22; | |
1222 unittest.expect(path.substring(pathOffset, pathOffset + 8), unittest.equ
als("reports/")); | |
1223 pathOffset += 8; | |
1224 index = path.indexOf("/files/", pathOffset); | |
1225 unittest.expect(index >= 0, unittest.isTrue); | |
1226 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1227 pathOffset = index; | |
1228 unittest.expect(subPart, unittest.equals("$arg_reportId")); | |
1229 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ
als("/files/")); | |
1230 pathOffset += 7; | |
1231 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); | |
1232 pathOffset = path.length; | |
1233 unittest.expect(subPart, unittest.equals("$arg_reportFragment")); | |
1234 | |
1235 var query = (req.url).query; | |
1236 var queryOffset = 0; | |
1237 var queryMap = {}; | |
1238 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
1239 parseBool(n) { | |
1240 if (n == "true") return true; | |
1241 if (n == "false") return false; | |
1242 if (n == null) return null; | |
1243 throw new core.ArgumentError("Invalid boolean: $n"); | |
1244 } | |
1245 if (query.length > 0) { | |
1246 for (var part in query.split("&")) { | |
1247 var keyvalue = part.split("="); | |
1248 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
1249 } | |
1250 } | |
1251 | |
1252 | |
1253 var h = { | |
1254 "content-type" : "application/json; charset=utf-8", | |
1255 }; | |
1256 var resp = ""; | |
1257 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
1258 }), true); | |
1259 res.getFile(arg_reportId, arg_reportFragment).then(unittest.expectAsync((_
) {})); | |
1260 }); | |
1261 | |
1262 unittest.test("method--request", () { | |
1263 | |
1264 var mock = new common_test.HttpServerMock(); | |
1265 api.ReportsResourceApi res = new api.DoubleclicksearchApi(mock).reports; | |
1266 var arg_request_1 = buildReportRequest(); | |
1267 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
1268 var obj = new api.ReportRequest.fromJson(json); | |
1269 checkReportRequest(obj); | |
1270 | |
1271 var path = (req.url).path; | |
1272 var pathOffset = 0; | |
1273 var index; | |
1274 var subPart; | |
1275 unittest.expect(path.substring(pathOffset, pathOffset + 22), unittest.eq
uals("/doubleclicksearch/v2/")); | |
1276 pathOffset += 22; | |
1277 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ
als("reports")); | |
1278 pathOffset += 7; | |
1279 | |
1280 var query = (req.url).query; | |
1281 var queryOffset = 0; | |
1282 var queryMap = {}; | |
1283 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
1284 parseBool(n) { | |
1285 if (n == "true") return true; | |
1286 if (n == "false") return false; | |
1287 if (n == null) return null; | |
1288 throw new core.ArgumentError("Invalid boolean: $n"); | |
1289 } | |
1290 if (query.length > 0) { | |
1291 for (var part in query.split("&")) { | |
1292 var keyvalue = part.split("="); | |
1293 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
1294 } | |
1295 } | |
1296 | |
1297 | |
1298 var h = { | |
1299 "content-type" : "application/json; charset=utf-8", | |
1300 }; | |
1301 var resp = convert.JSON.encode(buildReport()); | |
1302 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
1303 }), true); | |
1304 res.request(arg_request_1).then(unittest.expectAsync(((api.Report response
) { | |
1305 checkReport(response); | |
1306 }))); | |
1307 }); | |
1308 | |
1309 }); | |
1310 | |
1311 | |
1312 unittest.group("resource-SavedColumnsResourceApi", () { | |
1313 unittest.test("method--list", () { | |
1314 | |
1315 var mock = new common_test.HttpServerMock(); | |
1316 api.SavedColumnsResourceApi res = new api.DoubleclicksearchApi(mock).saved
Columns; | |
1317 var arg_agencyId = "foo"; | |
1318 var arg_advertiserId = "foo"; | |
1319 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
1320 var path = (req.url).path; | |
1321 var pathOffset = 0; | |
1322 var index; | |
1323 var subPart; | |
1324 unittest.expect(path.substring(pathOffset, pathOffset + 22), unittest.eq
uals("/doubleclicksearch/v2/")); | |
1325 pathOffset += 22; | |
1326 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ
als("agency/")); | |
1327 pathOffset += 7; | |
1328 index = path.indexOf("/advertiser/", pathOffset); | |
1329 unittest.expect(index >= 0, unittest.isTrue); | |
1330 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1331 pathOffset = index; | |
1332 unittest.expect(subPart, unittest.equals("$arg_agencyId")); | |
1333 unittest.expect(path.substring(pathOffset, pathOffset + 12), unittest.eq
uals("/advertiser/")); | |
1334 pathOffset += 12; | |
1335 index = path.indexOf("/savedcolumns", pathOffset); | |
1336 unittest.expect(index >= 0, unittest.isTrue); | |
1337 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1338 pathOffset = index; | |
1339 unittest.expect(subPart, unittest.equals("$arg_advertiserId")); | |
1340 unittest.expect(path.substring(pathOffset, pathOffset + 13), unittest.eq
uals("/savedcolumns")); | |
1341 pathOffset += 13; | |
1342 | |
1343 var query = (req.url).query; | |
1344 var queryOffset = 0; | |
1345 var queryMap = {}; | |
1346 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
1347 parseBool(n) { | |
1348 if (n == "true") return true; | |
1349 if (n == "false") return false; | |
1350 if (n == null) return null; | |
1351 throw new core.ArgumentError("Invalid boolean: $n"); | |
1352 } | |
1353 if (query.length > 0) { | |
1354 for (var part in query.split("&")) { | |
1355 var keyvalue = part.split("="); | |
1356 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
1357 } | |
1358 } | |
1359 | |
1360 | |
1361 var h = { | |
1362 "content-type" : "application/json; charset=utf-8", | |
1363 }; | |
1364 var resp = convert.JSON.encode(buildSavedColumnList()); | |
1365 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
1366 }), true); | |
1367 res.list(arg_agencyId, arg_advertiserId).then(unittest.expectAsync(((api.S
avedColumnList response) { | |
1368 checkSavedColumnList(response); | |
1369 }))); | |
1370 }); | |
1371 | |
1372 }); | |
1373 | |
1374 | |
1375 } | |
1376 | |
OLD | NEW |