OLD | NEW |
| (Empty) |
1 library googleapis.coordinate.v1.test; | |
2 | |
3 import "dart:core" as core; | |
4 import "dart:collection" as collection; | |
5 import "dart:async" as async; | |
6 import "dart:convert" as convert; | |
7 | |
8 import 'package:http/http.dart' as http; | |
9 import 'package:http/testing.dart' as http_testing; | |
10 import 'package:unittest/unittest.dart' as unittest; | |
11 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/coordinate/v1.dart' as api; | |
16 | |
17 | |
18 | |
19 core.int buildCounterCustomField = 0; | |
20 buildCustomField() { | |
21 var o = new api.CustomField(); | |
22 buildCounterCustomField++; | |
23 if (buildCounterCustomField < 3) { | |
24 o.customFieldId = "foo"; | |
25 o.kind = "foo"; | |
26 o.value = "foo"; | |
27 } | |
28 buildCounterCustomField--; | |
29 return o; | |
30 } | |
31 | |
32 checkCustomField(api.CustomField o) { | |
33 buildCounterCustomField++; | |
34 if (buildCounterCustomField < 3) { | |
35 unittest.expect(o.customFieldId, unittest.equals('foo')); | |
36 unittest.expect(o.kind, unittest.equals('foo')); | |
37 unittest.expect(o.value, unittest.equals('foo')); | |
38 } | |
39 buildCounterCustomField--; | |
40 } | |
41 | |
42 core.int buildCounterCustomFieldDef = 0; | |
43 buildCustomFieldDef() { | |
44 var o = new api.CustomFieldDef(); | |
45 buildCounterCustomFieldDef++; | |
46 if (buildCounterCustomFieldDef < 3) { | |
47 o.enabled = true; | |
48 o.id = "foo"; | |
49 o.kind = "foo"; | |
50 o.name = "foo"; | |
51 o.requiredForCheckout = true; | |
52 o.type = "foo"; | |
53 } | |
54 buildCounterCustomFieldDef--; | |
55 return o; | |
56 } | |
57 | |
58 checkCustomFieldDef(api.CustomFieldDef o) { | |
59 buildCounterCustomFieldDef++; | |
60 if (buildCounterCustomFieldDef < 3) { | |
61 unittest.expect(o.enabled, unittest.isTrue); | |
62 unittest.expect(o.id, unittest.equals('foo')); | |
63 unittest.expect(o.kind, unittest.equals('foo')); | |
64 unittest.expect(o.name, unittest.equals('foo')); | |
65 unittest.expect(o.requiredForCheckout, unittest.isTrue); | |
66 unittest.expect(o.type, unittest.equals('foo')); | |
67 } | |
68 buildCounterCustomFieldDef--; | |
69 } | |
70 | |
71 buildUnnamed445() { | |
72 var o = new core.List<api.CustomFieldDef>(); | |
73 o.add(buildCustomFieldDef()); | |
74 o.add(buildCustomFieldDef()); | |
75 return o; | |
76 } | |
77 | |
78 checkUnnamed445(core.List<api.CustomFieldDef> o) { | |
79 unittest.expect(o, unittest.hasLength(2)); | |
80 checkCustomFieldDef(o[0]); | |
81 checkCustomFieldDef(o[1]); | |
82 } | |
83 | |
84 core.int buildCounterCustomFieldDefListResponse = 0; | |
85 buildCustomFieldDefListResponse() { | |
86 var o = new api.CustomFieldDefListResponse(); | |
87 buildCounterCustomFieldDefListResponse++; | |
88 if (buildCounterCustomFieldDefListResponse < 3) { | |
89 o.items = buildUnnamed445(); | |
90 o.kind = "foo"; | |
91 } | |
92 buildCounterCustomFieldDefListResponse--; | |
93 return o; | |
94 } | |
95 | |
96 checkCustomFieldDefListResponse(api.CustomFieldDefListResponse o) { | |
97 buildCounterCustomFieldDefListResponse++; | |
98 if (buildCounterCustomFieldDefListResponse < 3) { | |
99 checkUnnamed445(o.items); | |
100 unittest.expect(o.kind, unittest.equals('foo')); | |
101 } | |
102 buildCounterCustomFieldDefListResponse--; | |
103 } | |
104 | |
105 buildUnnamed446() { | |
106 var o = new core.List<api.CustomField>(); | |
107 o.add(buildCustomField()); | |
108 o.add(buildCustomField()); | |
109 return o; | |
110 } | |
111 | |
112 checkUnnamed446(core.List<api.CustomField> o) { | |
113 unittest.expect(o, unittest.hasLength(2)); | |
114 checkCustomField(o[0]); | |
115 checkCustomField(o[1]); | |
116 } | |
117 | |
118 core.int buildCounterCustomFields = 0; | |
119 buildCustomFields() { | |
120 var o = new api.CustomFields(); | |
121 buildCounterCustomFields++; | |
122 if (buildCounterCustomFields < 3) { | |
123 o.customField = buildUnnamed446(); | |
124 o.kind = "foo"; | |
125 } | |
126 buildCounterCustomFields--; | |
127 return o; | |
128 } | |
129 | |
130 checkCustomFields(api.CustomFields o) { | |
131 buildCounterCustomFields++; | |
132 if (buildCounterCustomFields < 3) { | |
133 checkUnnamed446(o.customField); | |
134 unittest.expect(o.kind, unittest.equals('foo')); | |
135 } | |
136 buildCounterCustomFields--; | |
137 } | |
138 | |
139 buildUnnamed447() { | |
140 var o = new core.List<api.JobChange>(); | |
141 o.add(buildJobChange()); | |
142 o.add(buildJobChange()); | |
143 return o; | |
144 } | |
145 | |
146 checkUnnamed447(core.List<api.JobChange> o) { | |
147 unittest.expect(o, unittest.hasLength(2)); | |
148 checkJobChange(o[0]); | |
149 checkJobChange(o[1]); | |
150 } | |
151 | |
152 core.int buildCounterJob = 0; | |
153 buildJob() { | |
154 var o = new api.Job(); | |
155 buildCounterJob++; | |
156 if (buildCounterJob < 3) { | |
157 o.id = "foo"; | |
158 o.jobChange = buildUnnamed447(); | |
159 o.kind = "foo"; | |
160 o.state = buildJobState(); | |
161 } | |
162 buildCounterJob--; | |
163 return o; | |
164 } | |
165 | |
166 checkJob(api.Job o) { | |
167 buildCounterJob++; | |
168 if (buildCounterJob < 3) { | |
169 unittest.expect(o.id, unittest.equals('foo')); | |
170 checkUnnamed447(o.jobChange); | |
171 unittest.expect(o.kind, unittest.equals('foo')); | |
172 checkJobState(o.state); | |
173 } | |
174 buildCounterJob--; | |
175 } | |
176 | |
177 core.int buildCounterJobChange = 0; | |
178 buildJobChange() { | |
179 var o = new api.JobChange(); | |
180 buildCounterJobChange++; | |
181 if (buildCounterJobChange < 3) { | |
182 o.kind = "foo"; | |
183 o.state = buildJobState(); | |
184 o.timestamp = "foo"; | |
185 } | |
186 buildCounterJobChange--; | |
187 return o; | |
188 } | |
189 | |
190 checkJobChange(api.JobChange o) { | |
191 buildCounterJobChange++; | |
192 if (buildCounterJobChange < 3) { | |
193 unittest.expect(o.kind, unittest.equals('foo')); | |
194 checkJobState(o.state); | |
195 unittest.expect(o.timestamp, unittest.equals('foo')); | |
196 } | |
197 buildCounterJobChange--; | |
198 } | |
199 | |
200 buildUnnamed448() { | |
201 var o = new core.List<api.Job>(); | |
202 o.add(buildJob()); | |
203 o.add(buildJob()); | |
204 return o; | |
205 } | |
206 | |
207 checkUnnamed448(core.List<api.Job> o) { | |
208 unittest.expect(o, unittest.hasLength(2)); | |
209 checkJob(o[0]); | |
210 checkJob(o[1]); | |
211 } | |
212 | |
213 core.int buildCounterJobListResponse = 0; | |
214 buildJobListResponse() { | |
215 var o = new api.JobListResponse(); | |
216 buildCounterJobListResponse++; | |
217 if (buildCounterJobListResponse < 3) { | |
218 o.items = buildUnnamed448(); | |
219 o.kind = "foo"; | |
220 o.nextPageToken = "foo"; | |
221 } | |
222 buildCounterJobListResponse--; | |
223 return o; | |
224 } | |
225 | |
226 checkJobListResponse(api.JobListResponse o) { | |
227 buildCounterJobListResponse++; | |
228 if (buildCounterJobListResponse < 3) { | |
229 checkUnnamed448(o.items); | |
230 unittest.expect(o.kind, unittest.equals('foo')); | |
231 unittest.expect(o.nextPageToken, unittest.equals('foo')); | |
232 } | |
233 buildCounterJobListResponse--; | |
234 } | |
235 | |
236 buildUnnamed449() { | |
237 var o = new core.List<core.String>(); | |
238 o.add("foo"); | |
239 o.add("foo"); | |
240 return o; | |
241 } | |
242 | |
243 checkUnnamed449(core.List<core.String> o) { | |
244 unittest.expect(o, unittest.hasLength(2)); | |
245 unittest.expect(o[0], unittest.equals('foo')); | |
246 unittest.expect(o[1], unittest.equals('foo')); | |
247 } | |
248 | |
249 core.int buildCounterJobState = 0; | |
250 buildJobState() { | |
251 var o = new api.JobState(); | |
252 buildCounterJobState++; | |
253 if (buildCounterJobState < 3) { | |
254 o.assignee = "foo"; | |
255 o.customFields = buildCustomFields(); | |
256 o.customerName = "foo"; | |
257 o.customerPhoneNumber = "foo"; | |
258 o.kind = "foo"; | |
259 o.location = buildLocation(); | |
260 o.note = buildUnnamed449(); | |
261 o.progress = "foo"; | |
262 o.title = "foo"; | |
263 } | |
264 buildCounterJobState--; | |
265 return o; | |
266 } | |
267 | |
268 checkJobState(api.JobState o) { | |
269 buildCounterJobState++; | |
270 if (buildCounterJobState < 3) { | |
271 unittest.expect(o.assignee, unittest.equals('foo')); | |
272 checkCustomFields(o.customFields); | |
273 unittest.expect(o.customerName, unittest.equals('foo')); | |
274 unittest.expect(o.customerPhoneNumber, unittest.equals('foo')); | |
275 unittest.expect(o.kind, unittest.equals('foo')); | |
276 checkLocation(o.location); | |
277 checkUnnamed449(o.note); | |
278 unittest.expect(o.progress, unittest.equals('foo')); | |
279 unittest.expect(o.title, unittest.equals('foo')); | |
280 } | |
281 buildCounterJobState--; | |
282 } | |
283 | |
284 buildUnnamed450() { | |
285 var o = new core.List<core.String>(); | |
286 o.add("foo"); | |
287 o.add("foo"); | |
288 return o; | |
289 } | |
290 | |
291 checkUnnamed450(core.List<core.String> o) { | |
292 unittest.expect(o, unittest.hasLength(2)); | |
293 unittest.expect(o[0], unittest.equals('foo')); | |
294 unittest.expect(o[1], unittest.equals('foo')); | |
295 } | |
296 | |
297 core.int buildCounterLocation = 0; | |
298 buildLocation() { | |
299 var o = new api.Location(); | |
300 buildCounterLocation++; | |
301 if (buildCounterLocation < 3) { | |
302 o.addressLine = buildUnnamed450(); | |
303 o.kind = "foo"; | |
304 o.lat = 42.0; | |
305 o.lng = 42.0; | |
306 } | |
307 buildCounterLocation--; | |
308 return o; | |
309 } | |
310 | |
311 checkLocation(api.Location o) { | |
312 buildCounterLocation++; | |
313 if (buildCounterLocation < 3) { | |
314 checkUnnamed450(o.addressLine); | |
315 unittest.expect(o.kind, unittest.equals('foo')); | |
316 unittest.expect(o.lat, unittest.equals(42.0)); | |
317 unittest.expect(o.lng, unittest.equals(42.0)); | |
318 } | |
319 buildCounterLocation--; | |
320 } | |
321 | |
322 buildUnnamed451() { | |
323 var o = new core.List<api.LocationRecord>(); | |
324 o.add(buildLocationRecord()); | |
325 o.add(buildLocationRecord()); | |
326 return o; | |
327 } | |
328 | |
329 checkUnnamed451(core.List<api.LocationRecord> o) { | |
330 unittest.expect(o, unittest.hasLength(2)); | |
331 checkLocationRecord(o[0]); | |
332 checkLocationRecord(o[1]); | |
333 } | |
334 | |
335 core.int buildCounterLocationListResponse = 0; | |
336 buildLocationListResponse() { | |
337 var o = new api.LocationListResponse(); | |
338 buildCounterLocationListResponse++; | |
339 if (buildCounterLocationListResponse < 3) { | |
340 o.items = buildUnnamed451(); | |
341 o.kind = "foo"; | |
342 o.nextPageToken = "foo"; | |
343 o.tokenPagination = buildTokenPagination(); | |
344 } | |
345 buildCounterLocationListResponse--; | |
346 return o; | |
347 } | |
348 | |
349 checkLocationListResponse(api.LocationListResponse o) { | |
350 buildCounterLocationListResponse++; | |
351 if (buildCounterLocationListResponse < 3) { | |
352 checkUnnamed451(o.items); | |
353 unittest.expect(o.kind, unittest.equals('foo')); | |
354 unittest.expect(o.nextPageToken, unittest.equals('foo')); | |
355 checkTokenPagination(o.tokenPagination); | |
356 } | |
357 buildCounterLocationListResponse--; | |
358 } | |
359 | |
360 core.int buildCounterLocationRecord = 0; | |
361 buildLocationRecord() { | |
362 var o = new api.LocationRecord(); | |
363 buildCounterLocationRecord++; | |
364 if (buildCounterLocationRecord < 3) { | |
365 o.collectionTime = "foo"; | |
366 o.confidenceRadius = 42.0; | |
367 o.kind = "foo"; | |
368 o.latitude = 42.0; | |
369 o.longitude = 42.0; | |
370 } | |
371 buildCounterLocationRecord--; | |
372 return o; | |
373 } | |
374 | |
375 checkLocationRecord(api.LocationRecord o) { | |
376 buildCounterLocationRecord++; | |
377 if (buildCounterLocationRecord < 3) { | |
378 unittest.expect(o.collectionTime, unittest.equals('foo')); | |
379 unittest.expect(o.confidenceRadius, unittest.equals(42.0)); | |
380 unittest.expect(o.kind, unittest.equals('foo')); | |
381 unittest.expect(o.latitude, unittest.equals(42.0)); | |
382 unittest.expect(o.longitude, unittest.equals(42.0)); | |
383 } | |
384 buildCounterLocationRecord--; | |
385 } | |
386 | |
387 core.int buildCounterSchedule = 0; | |
388 buildSchedule() { | |
389 var o = new api.Schedule(); | |
390 buildCounterSchedule++; | |
391 if (buildCounterSchedule < 3) { | |
392 o.allDay = true; | |
393 o.duration = "foo"; | |
394 o.endTime = "foo"; | |
395 o.kind = "foo"; | |
396 o.startTime = "foo"; | |
397 } | |
398 buildCounterSchedule--; | |
399 return o; | |
400 } | |
401 | |
402 checkSchedule(api.Schedule o) { | |
403 buildCounterSchedule++; | |
404 if (buildCounterSchedule < 3) { | |
405 unittest.expect(o.allDay, unittest.isTrue); | |
406 unittest.expect(o.duration, unittest.equals('foo')); | |
407 unittest.expect(o.endTime, unittest.equals('foo')); | |
408 unittest.expect(o.kind, unittest.equals('foo')); | |
409 unittest.expect(o.startTime, unittest.equals('foo')); | |
410 } | |
411 buildCounterSchedule--; | |
412 } | |
413 | |
414 core.int buildCounterTokenPagination = 0; | |
415 buildTokenPagination() { | |
416 var o = new api.TokenPagination(); | |
417 buildCounterTokenPagination++; | |
418 if (buildCounterTokenPagination < 3) { | |
419 o.kind = "foo"; | |
420 o.nextPageToken = "foo"; | |
421 o.previousPageToken = "foo"; | |
422 } | |
423 buildCounterTokenPagination--; | |
424 return o; | |
425 } | |
426 | |
427 checkTokenPagination(api.TokenPagination o) { | |
428 buildCounterTokenPagination++; | |
429 if (buildCounterTokenPagination < 3) { | |
430 unittest.expect(o.kind, unittest.equals('foo')); | |
431 unittest.expect(o.nextPageToken, unittest.equals('foo')); | |
432 unittest.expect(o.previousPageToken, unittest.equals('foo')); | |
433 } | |
434 buildCounterTokenPagination--; | |
435 } | |
436 | |
437 core.int buildCounterWorker = 0; | |
438 buildWorker() { | |
439 var o = new api.Worker(); | |
440 buildCounterWorker++; | |
441 if (buildCounterWorker < 3) { | |
442 o.id = "foo"; | |
443 o.kind = "foo"; | |
444 } | |
445 buildCounterWorker--; | |
446 return o; | |
447 } | |
448 | |
449 checkWorker(api.Worker o) { | |
450 buildCounterWorker++; | |
451 if (buildCounterWorker < 3) { | |
452 unittest.expect(o.id, unittest.equals('foo')); | |
453 unittest.expect(o.kind, unittest.equals('foo')); | |
454 } | |
455 buildCounterWorker--; | |
456 } | |
457 | |
458 buildUnnamed452() { | |
459 var o = new core.List<api.Worker>(); | |
460 o.add(buildWorker()); | |
461 o.add(buildWorker()); | |
462 return o; | |
463 } | |
464 | |
465 checkUnnamed452(core.List<api.Worker> o) { | |
466 unittest.expect(o, unittest.hasLength(2)); | |
467 checkWorker(o[0]); | |
468 checkWorker(o[1]); | |
469 } | |
470 | |
471 core.int buildCounterWorkerListResponse = 0; | |
472 buildWorkerListResponse() { | |
473 var o = new api.WorkerListResponse(); | |
474 buildCounterWorkerListResponse++; | |
475 if (buildCounterWorkerListResponse < 3) { | |
476 o.items = buildUnnamed452(); | |
477 o.kind = "foo"; | |
478 } | |
479 buildCounterWorkerListResponse--; | |
480 return o; | |
481 } | |
482 | |
483 checkWorkerListResponse(api.WorkerListResponse o) { | |
484 buildCounterWorkerListResponse++; | |
485 if (buildCounterWorkerListResponse < 3) { | |
486 checkUnnamed452(o.items); | |
487 unittest.expect(o.kind, unittest.equals('foo')); | |
488 } | |
489 buildCounterWorkerListResponse--; | |
490 } | |
491 | |
492 buildUnnamed453() { | |
493 var o = new core.List<core.String>(); | |
494 o.add("foo"); | |
495 o.add("foo"); | |
496 return o; | |
497 } | |
498 | |
499 checkUnnamed453(core.List<core.String> o) { | |
500 unittest.expect(o, unittest.hasLength(2)); | |
501 unittest.expect(o[0], unittest.equals('foo')); | |
502 unittest.expect(o[1], unittest.equals('foo')); | |
503 } | |
504 | |
505 buildUnnamed454() { | |
506 var o = new core.List<core.String>(); | |
507 o.add("foo"); | |
508 o.add("foo"); | |
509 return o; | |
510 } | |
511 | |
512 checkUnnamed454(core.List<core.String> o) { | |
513 unittest.expect(o, unittest.hasLength(2)); | |
514 unittest.expect(o[0], unittest.equals('foo')); | |
515 unittest.expect(o[1], unittest.equals('foo')); | |
516 } | |
517 | |
518 buildUnnamed455() { | |
519 var o = new core.List<core.String>(); | |
520 o.add("foo"); | |
521 o.add("foo"); | |
522 return o; | |
523 } | |
524 | |
525 checkUnnamed455(core.List<core.String> o) { | |
526 unittest.expect(o, unittest.hasLength(2)); | |
527 unittest.expect(o[0], unittest.equals('foo')); | |
528 unittest.expect(o[1], unittest.equals('foo')); | |
529 } | |
530 | |
531 | |
532 main() { | |
533 unittest.group("obj-schema-CustomField", () { | |
534 unittest.test("to-json--from-json", () { | |
535 var o = buildCustomField(); | |
536 var od = new api.CustomField.fromJson(o.toJson()); | |
537 checkCustomField(od); | |
538 }); | |
539 }); | |
540 | |
541 | |
542 unittest.group("obj-schema-CustomFieldDef", () { | |
543 unittest.test("to-json--from-json", () { | |
544 var o = buildCustomFieldDef(); | |
545 var od = new api.CustomFieldDef.fromJson(o.toJson()); | |
546 checkCustomFieldDef(od); | |
547 }); | |
548 }); | |
549 | |
550 | |
551 unittest.group("obj-schema-CustomFieldDefListResponse", () { | |
552 unittest.test("to-json--from-json", () { | |
553 var o = buildCustomFieldDefListResponse(); | |
554 var od = new api.CustomFieldDefListResponse.fromJson(o.toJson()); | |
555 checkCustomFieldDefListResponse(od); | |
556 }); | |
557 }); | |
558 | |
559 | |
560 unittest.group("obj-schema-CustomFields", () { | |
561 unittest.test("to-json--from-json", () { | |
562 var o = buildCustomFields(); | |
563 var od = new api.CustomFields.fromJson(o.toJson()); | |
564 checkCustomFields(od); | |
565 }); | |
566 }); | |
567 | |
568 | |
569 unittest.group("obj-schema-Job", () { | |
570 unittest.test("to-json--from-json", () { | |
571 var o = buildJob(); | |
572 var od = new api.Job.fromJson(o.toJson()); | |
573 checkJob(od); | |
574 }); | |
575 }); | |
576 | |
577 | |
578 unittest.group("obj-schema-JobChange", () { | |
579 unittest.test("to-json--from-json", () { | |
580 var o = buildJobChange(); | |
581 var od = new api.JobChange.fromJson(o.toJson()); | |
582 checkJobChange(od); | |
583 }); | |
584 }); | |
585 | |
586 | |
587 unittest.group("obj-schema-JobListResponse", () { | |
588 unittest.test("to-json--from-json", () { | |
589 var o = buildJobListResponse(); | |
590 var od = new api.JobListResponse.fromJson(o.toJson()); | |
591 checkJobListResponse(od); | |
592 }); | |
593 }); | |
594 | |
595 | |
596 unittest.group("obj-schema-JobState", () { | |
597 unittest.test("to-json--from-json", () { | |
598 var o = buildJobState(); | |
599 var od = new api.JobState.fromJson(o.toJson()); | |
600 checkJobState(od); | |
601 }); | |
602 }); | |
603 | |
604 | |
605 unittest.group("obj-schema-Location", () { | |
606 unittest.test("to-json--from-json", () { | |
607 var o = buildLocation(); | |
608 var od = new api.Location.fromJson(o.toJson()); | |
609 checkLocation(od); | |
610 }); | |
611 }); | |
612 | |
613 | |
614 unittest.group("obj-schema-LocationListResponse", () { | |
615 unittest.test("to-json--from-json", () { | |
616 var o = buildLocationListResponse(); | |
617 var od = new api.LocationListResponse.fromJson(o.toJson()); | |
618 checkLocationListResponse(od); | |
619 }); | |
620 }); | |
621 | |
622 | |
623 unittest.group("obj-schema-LocationRecord", () { | |
624 unittest.test("to-json--from-json", () { | |
625 var o = buildLocationRecord(); | |
626 var od = new api.LocationRecord.fromJson(o.toJson()); | |
627 checkLocationRecord(od); | |
628 }); | |
629 }); | |
630 | |
631 | |
632 unittest.group("obj-schema-Schedule", () { | |
633 unittest.test("to-json--from-json", () { | |
634 var o = buildSchedule(); | |
635 var od = new api.Schedule.fromJson(o.toJson()); | |
636 checkSchedule(od); | |
637 }); | |
638 }); | |
639 | |
640 | |
641 unittest.group("obj-schema-TokenPagination", () { | |
642 unittest.test("to-json--from-json", () { | |
643 var o = buildTokenPagination(); | |
644 var od = new api.TokenPagination.fromJson(o.toJson()); | |
645 checkTokenPagination(od); | |
646 }); | |
647 }); | |
648 | |
649 | |
650 unittest.group("obj-schema-Worker", () { | |
651 unittest.test("to-json--from-json", () { | |
652 var o = buildWorker(); | |
653 var od = new api.Worker.fromJson(o.toJson()); | |
654 checkWorker(od); | |
655 }); | |
656 }); | |
657 | |
658 | |
659 unittest.group("obj-schema-WorkerListResponse", () { | |
660 unittest.test("to-json--from-json", () { | |
661 var o = buildWorkerListResponse(); | |
662 var od = new api.WorkerListResponse.fromJson(o.toJson()); | |
663 checkWorkerListResponse(od); | |
664 }); | |
665 }); | |
666 | |
667 | |
668 unittest.group("resource-CustomFieldDefResourceApi", () { | |
669 unittest.test("method--list", () { | |
670 | |
671 var mock = new common_test.HttpServerMock(); | |
672 api.CustomFieldDefResourceApi res = new api.CoordinateApi(mock).customFiel
dDef; | |
673 var arg_teamId = "foo"; | |
674 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
675 var path = (req.url).path; | |
676 var pathOffset = 0; | |
677 var index; | |
678 var subPart; | |
679 unittest.expect(path.substring(pathOffset, pathOffset + 21), unittest.eq
uals("/coordinate/v1/teams/")); | |
680 pathOffset += 21; | |
681 index = path.indexOf("/custom_fields", pathOffset); | |
682 unittest.expect(index >= 0, unittest.isTrue); | |
683 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
684 pathOffset = index; | |
685 unittest.expect(subPart, unittest.equals("$arg_teamId")); | |
686 unittest.expect(path.substring(pathOffset, pathOffset + 14), unittest.eq
uals("/custom_fields")); | |
687 pathOffset += 14; | |
688 | |
689 var query = (req.url).query; | |
690 var queryOffset = 0; | |
691 var queryMap = {}; | |
692 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
693 parseBool(n) { | |
694 if (n == "true") return true; | |
695 if (n == "false") return false; | |
696 if (n == null) return null; | |
697 throw new core.ArgumentError("Invalid boolean: $n"); | |
698 } | |
699 if (query.length > 0) { | |
700 for (var part in query.split("&")) { | |
701 var keyvalue = part.split("="); | |
702 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
703 } | |
704 } | |
705 | |
706 | |
707 var h = { | |
708 "content-type" : "application/json; charset=utf-8", | |
709 }; | |
710 var resp = convert.JSON.encode(buildCustomFieldDefListResponse()); | |
711 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
712 }), true); | |
713 res.list(arg_teamId).then(unittest.expectAsync(((api.CustomFieldDefListRes
ponse response) { | |
714 checkCustomFieldDefListResponse(response); | |
715 }))); | |
716 }); | |
717 | |
718 }); | |
719 | |
720 | |
721 unittest.group("resource-JobsResourceApi", () { | |
722 unittest.test("method--get", () { | |
723 | |
724 var mock = new common_test.HttpServerMock(); | |
725 api.JobsResourceApi res = new api.CoordinateApi(mock).jobs; | |
726 var arg_teamId = "foo"; | |
727 var arg_jobId = "foo"; | |
728 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
729 var path = (req.url).path; | |
730 var pathOffset = 0; | |
731 var index; | |
732 var subPart; | |
733 unittest.expect(path.substring(pathOffset, pathOffset + 21), unittest.eq
uals("/coordinate/v1/teams/")); | |
734 pathOffset += 21; | |
735 index = path.indexOf("/jobs/", pathOffset); | |
736 unittest.expect(index >= 0, unittest.isTrue); | |
737 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
738 pathOffset = index; | |
739 unittest.expect(subPart, unittest.equals("$arg_teamId")); | |
740 unittest.expect(path.substring(pathOffset, pathOffset + 6), unittest.equ
als("/jobs/")); | |
741 pathOffset += 6; | |
742 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); | |
743 pathOffset = path.length; | |
744 unittest.expect(subPart, unittest.equals("$arg_jobId")); | |
745 | |
746 var query = (req.url).query; | |
747 var queryOffset = 0; | |
748 var queryMap = {}; | |
749 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
750 parseBool(n) { | |
751 if (n == "true") return true; | |
752 if (n == "false") return false; | |
753 if (n == null) return null; | |
754 throw new core.ArgumentError("Invalid boolean: $n"); | |
755 } | |
756 if (query.length > 0) { | |
757 for (var part in query.split("&")) { | |
758 var keyvalue = part.split("="); | |
759 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
760 } | |
761 } | |
762 | |
763 | |
764 var h = { | |
765 "content-type" : "application/json; charset=utf-8", | |
766 }; | |
767 var resp = convert.JSON.encode(buildJob()); | |
768 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
769 }), true); | |
770 res.get(arg_teamId, arg_jobId).then(unittest.expectAsync(((api.Job respons
e) { | |
771 checkJob(response); | |
772 }))); | |
773 }); | |
774 | |
775 unittest.test("method--insert", () { | |
776 | |
777 var mock = new common_test.HttpServerMock(); | |
778 api.JobsResourceApi res = new api.CoordinateApi(mock).jobs; | |
779 var arg_request = buildJob(); | |
780 var arg_teamId = "foo"; | |
781 var arg_address = "foo"; | |
782 var arg_lat = 42.0; | |
783 var arg_lng = 42.0; | |
784 var arg_title = "foo"; | |
785 var arg_assignee = "foo"; | |
786 var arg_customField = buildUnnamed453(); | |
787 var arg_customerName = "foo"; | |
788 var arg_customerPhoneNumber = "foo"; | |
789 var arg_note = "foo"; | |
790 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
791 var obj = new api.Job.fromJson(json); | |
792 checkJob(obj); | |
793 | |
794 var path = (req.url).path; | |
795 var pathOffset = 0; | |
796 var index; | |
797 var subPart; | |
798 unittest.expect(path.substring(pathOffset, pathOffset + 21), unittest.eq
uals("/coordinate/v1/teams/")); | |
799 pathOffset += 21; | |
800 index = path.indexOf("/jobs", pathOffset); | |
801 unittest.expect(index >= 0, unittest.isTrue); | |
802 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
803 pathOffset = index; | |
804 unittest.expect(subPart, unittest.equals("$arg_teamId")); | |
805 unittest.expect(path.substring(pathOffset, pathOffset + 5), unittest.equ
als("/jobs")); | |
806 pathOffset += 5; | |
807 | |
808 var query = (req.url).query; | |
809 var queryOffset = 0; | |
810 var queryMap = {}; | |
811 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
812 parseBool(n) { | |
813 if (n == "true") return true; | |
814 if (n == "false") return false; | |
815 if (n == null) return null; | |
816 throw new core.ArgumentError("Invalid boolean: $n"); | |
817 } | |
818 if (query.length > 0) { | |
819 for (var part in query.split("&")) { | |
820 var keyvalue = part.split("="); | |
821 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
822 } | |
823 } | |
824 unittest.expect(queryMap["address"].first, unittest.equals(arg_address))
; | |
825 unittest.expect(core.num.parse(queryMap["lat"].first), unittest.equals(a
rg_lat)); | |
826 unittest.expect(core.num.parse(queryMap["lng"].first), unittest.equals(a
rg_lng)); | |
827 unittest.expect(queryMap["title"].first, unittest.equals(arg_title)); | |
828 unittest.expect(queryMap["assignee"].first, unittest.equals(arg_assignee
)); | |
829 unittest.expect(queryMap["customField"], unittest.equals(arg_customField
)); | |
830 unittest.expect(queryMap["customerName"].first, unittest.equals(arg_cust
omerName)); | |
831 unittest.expect(queryMap["customerPhoneNumber"].first, unittest.equals(a
rg_customerPhoneNumber)); | |
832 unittest.expect(queryMap["note"].first, unittest.equals(arg_note)); | |
833 | |
834 | |
835 var h = { | |
836 "content-type" : "application/json; charset=utf-8", | |
837 }; | |
838 var resp = convert.JSON.encode(buildJob()); | |
839 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
840 }), true); | |
841 res.insert(arg_request, arg_teamId, arg_address, arg_lat, arg_lng, arg_tit
le, assignee: arg_assignee, customField: arg_customField, customerName: arg_cust
omerName, customerPhoneNumber: arg_customerPhoneNumber, note: arg_note).then(uni
ttest.expectAsync(((api.Job response) { | |
842 checkJob(response); | |
843 }))); | |
844 }); | |
845 | |
846 unittest.test("method--list", () { | |
847 | |
848 var mock = new common_test.HttpServerMock(); | |
849 api.JobsResourceApi res = new api.CoordinateApi(mock).jobs; | |
850 var arg_teamId = "foo"; | |
851 var arg_maxResults = 42; | |
852 var arg_minModifiedTimestampMs = "foo"; | |
853 var arg_pageToken = "foo"; | |
854 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
855 var path = (req.url).path; | |
856 var pathOffset = 0; | |
857 var index; | |
858 var subPart; | |
859 unittest.expect(path.substring(pathOffset, pathOffset + 21), unittest.eq
uals("/coordinate/v1/teams/")); | |
860 pathOffset += 21; | |
861 index = path.indexOf("/jobs", pathOffset); | |
862 unittest.expect(index >= 0, unittest.isTrue); | |
863 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
864 pathOffset = index; | |
865 unittest.expect(subPart, unittest.equals("$arg_teamId")); | |
866 unittest.expect(path.substring(pathOffset, pathOffset + 5), unittest.equ
als("/jobs")); | |
867 pathOffset += 5; | |
868 | |
869 var query = (req.url).query; | |
870 var queryOffset = 0; | |
871 var queryMap = {}; | |
872 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
873 parseBool(n) { | |
874 if (n == "true") return true; | |
875 if (n == "false") return false; | |
876 if (n == null) return null; | |
877 throw new core.ArgumentError("Invalid boolean: $n"); | |
878 } | |
879 if (query.length > 0) { | |
880 for (var part in query.split("&")) { | |
881 var keyvalue = part.split("="); | |
882 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
883 } | |
884 } | |
885 unittest.expect(core.int.parse(queryMap["maxResults"].first), unittest.e
quals(arg_maxResults)); | |
886 unittest.expect(queryMap["minModifiedTimestampMs"].first, unittest.equal
s(arg_minModifiedTimestampMs)); | |
887 unittest.expect(queryMap["pageToken"].first, unittest.equals(arg_pageTok
en)); | |
888 | |
889 | |
890 var h = { | |
891 "content-type" : "application/json; charset=utf-8", | |
892 }; | |
893 var resp = convert.JSON.encode(buildJobListResponse()); | |
894 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
895 }), true); | |
896 res.list(arg_teamId, maxResults: arg_maxResults, minModifiedTimestampMs: a
rg_minModifiedTimestampMs, pageToken: arg_pageToken).then(unittest.expectAsync((
(api.JobListResponse response) { | |
897 checkJobListResponse(response); | |
898 }))); | |
899 }); | |
900 | |
901 unittest.test("method--patch", () { | |
902 | |
903 var mock = new common_test.HttpServerMock(); | |
904 api.JobsResourceApi res = new api.CoordinateApi(mock).jobs; | |
905 var arg_request = buildJob(); | |
906 var arg_teamId = "foo"; | |
907 var arg_jobId = "foo"; | |
908 var arg_address = "foo"; | |
909 var arg_assignee = "foo"; | |
910 var arg_customField = buildUnnamed454(); | |
911 var arg_customerName = "foo"; | |
912 var arg_customerPhoneNumber = "foo"; | |
913 var arg_lat = 42.0; | |
914 var arg_lng = 42.0; | |
915 var arg_note = "foo"; | |
916 var arg_progress = "foo"; | |
917 var arg_title = "foo"; | |
918 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
919 var obj = new api.Job.fromJson(json); | |
920 checkJob(obj); | |
921 | |
922 var path = (req.url).path; | |
923 var pathOffset = 0; | |
924 var index; | |
925 var subPart; | |
926 unittest.expect(path.substring(pathOffset, pathOffset + 21), unittest.eq
uals("/coordinate/v1/teams/")); | |
927 pathOffset += 21; | |
928 index = path.indexOf("/jobs/", pathOffset); | |
929 unittest.expect(index >= 0, unittest.isTrue); | |
930 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
931 pathOffset = index; | |
932 unittest.expect(subPart, unittest.equals("$arg_teamId")); | |
933 unittest.expect(path.substring(pathOffset, pathOffset + 6), unittest.equ
als("/jobs/")); | |
934 pathOffset += 6; | |
935 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); | |
936 pathOffset = path.length; | |
937 unittest.expect(subPart, unittest.equals("$arg_jobId")); | |
938 | |
939 var query = (req.url).query; | |
940 var queryOffset = 0; | |
941 var queryMap = {}; | |
942 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
943 parseBool(n) { | |
944 if (n == "true") return true; | |
945 if (n == "false") return false; | |
946 if (n == null) return null; | |
947 throw new core.ArgumentError("Invalid boolean: $n"); | |
948 } | |
949 if (query.length > 0) { | |
950 for (var part in query.split("&")) { | |
951 var keyvalue = part.split("="); | |
952 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
953 } | |
954 } | |
955 unittest.expect(queryMap["address"].first, unittest.equals(arg_address))
; | |
956 unittest.expect(queryMap["assignee"].first, unittest.equals(arg_assignee
)); | |
957 unittest.expect(queryMap["customField"], unittest.equals(arg_customField
)); | |
958 unittest.expect(queryMap["customerName"].first, unittest.equals(arg_cust
omerName)); | |
959 unittest.expect(queryMap["customerPhoneNumber"].first, unittest.equals(a
rg_customerPhoneNumber)); | |
960 unittest.expect(core.num.parse(queryMap["lat"].first), unittest.equals(a
rg_lat)); | |
961 unittest.expect(core.num.parse(queryMap["lng"].first), unittest.equals(a
rg_lng)); | |
962 unittest.expect(queryMap["note"].first, unittest.equals(arg_note)); | |
963 unittest.expect(queryMap["progress"].first, unittest.equals(arg_progress
)); | |
964 unittest.expect(queryMap["title"].first, unittest.equals(arg_title)); | |
965 | |
966 | |
967 var h = { | |
968 "content-type" : "application/json; charset=utf-8", | |
969 }; | |
970 var resp = convert.JSON.encode(buildJob()); | |
971 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
972 }), true); | |
973 res.patch(arg_request, arg_teamId, arg_jobId, address: arg_address, assign
ee: arg_assignee, customField: arg_customField, customerName: arg_customerName,
customerPhoneNumber: arg_customerPhoneNumber, lat: arg_lat, lng: arg_lng, note:
arg_note, progress: arg_progress, title: arg_title).then(unittest.expectAsync(((
api.Job response) { | |
974 checkJob(response); | |
975 }))); | |
976 }); | |
977 | |
978 unittest.test("method--update", () { | |
979 | |
980 var mock = new common_test.HttpServerMock(); | |
981 api.JobsResourceApi res = new api.CoordinateApi(mock).jobs; | |
982 var arg_request = buildJob(); | |
983 var arg_teamId = "foo"; | |
984 var arg_jobId = "foo"; | |
985 var arg_address = "foo"; | |
986 var arg_assignee = "foo"; | |
987 var arg_customField = buildUnnamed455(); | |
988 var arg_customerName = "foo"; | |
989 var arg_customerPhoneNumber = "foo"; | |
990 var arg_lat = 42.0; | |
991 var arg_lng = 42.0; | |
992 var arg_note = "foo"; | |
993 var arg_progress = "foo"; | |
994 var arg_title = "foo"; | |
995 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
996 var obj = new api.Job.fromJson(json); | |
997 checkJob(obj); | |
998 | |
999 var path = (req.url).path; | |
1000 var pathOffset = 0; | |
1001 var index; | |
1002 var subPart; | |
1003 unittest.expect(path.substring(pathOffset, pathOffset + 21), unittest.eq
uals("/coordinate/v1/teams/")); | |
1004 pathOffset += 21; | |
1005 index = path.indexOf("/jobs/", pathOffset); | |
1006 unittest.expect(index >= 0, unittest.isTrue); | |
1007 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1008 pathOffset = index; | |
1009 unittest.expect(subPart, unittest.equals("$arg_teamId")); | |
1010 unittest.expect(path.substring(pathOffset, pathOffset + 6), unittest.equ
als("/jobs/")); | |
1011 pathOffset += 6; | |
1012 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); | |
1013 pathOffset = path.length; | |
1014 unittest.expect(subPart, unittest.equals("$arg_jobId")); | |
1015 | |
1016 var query = (req.url).query; | |
1017 var queryOffset = 0; | |
1018 var queryMap = {}; | |
1019 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
1020 parseBool(n) { | |
1021 if (n == "true") return true; | |
1022 if (n == "false") return false; | |
1023 if (n == null) return null; | |
1024 throw new core.ArgumentError("Invalid boolean: $n"); | |
1025 } | |
1026 if (query.length > 0) { | |
1027 for (var part in query.split("&")) { | |
1028 var keyvalue = part.split("="); | |
1029 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
1030 } | |
1031 } | |
1032 unittest.expect(queryMap["address"].first, unittest.equals(arg_address))
; | |
1033 unittest.expect(queryMap["assignee"].first, unittest.equals(arg_assignee
)); | |
1034 unittest.expect(queryMap["customField"], unittest.equals(arg_customField
)); | |
1035 unittest.expect(queryMap["customerName"].first, unittest.equals(arg_cust
omerName)); | |
1036 unittest.expect(queryMap["customerPhoneNumber"].first, unittest.equals(a
rg_customerPhoneNumber)); | |
1037 unittest.expect(core.num.parse(queryMap["lat"].first), unittest.equals(a
rg_lat)); | |
1038 unittest.expect(core.num.parse(queryMap["lng"].first), unittest.equals(a
rg_lng)); | |
1039 unittest.expect(queryMap["note"].first, unittest.equals(arg_note)); | |
1040 unittest.expect(queryMap["progress"].first, unittest.equals(arg_progress
)); | |
1041 unittest.expect(queryMap["title"].first, unittest.equals(arg_title)); | |
1042 | |
1043 | |
1044 var h = { | |
1045 "content-type" : "application/json; charset=utf-8", | |
1046 }; | |
1047 var resp = convert.JSON.encode(buildJob()); | |
1048 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
1049 }), true); | |
1050 res.update(arg_request, arg_teamId, arg_jobId, address: arg_address, assig
nee: arg_assignee, customField: arg_customField, customerName: arg_customerName,
customerPhoneNumber: arg_customerPhoneNumber, lat: arg_lat, lng: arg_lng, note:
arg_note, progress: arg_progress, title: arg_title).then(unittest.expectAsync((
(api.Job response) { | |
1051 checkJob(response); | |
1052 }))); | |
1053 }); | |
1054 | |
1055 }); | |
1056 | |
1057 | |
1058 unittest.group("resource-LocationResourceApi", () { | |
1059 unittest.test("method--list", () { | |
1060 | |
1061 var mock = new common_test.HttpServerMock(); | |
1062 api.LocationResourceApi res = new api.CoordinateApi(mock).location; | |
1063 var arg_teamId = "foo"; | |
1064 var arg_workerEmail = "foo"; | |
1065 var arg_startTimestampMs = "foo"; | |
1066 var arg_maxResults = 42; | |
1067 var arg_pageToken = "foo"; | |
1068 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
1069 var path = (req.url).path; | |
1070 var pathOffset = 0; | |
1071 var index; | |
1072 var subPart; | |
1073 unittest.expect(path.substring(pathOffset, pathOffset + 21), unittest.eq
uals("/coordinate/v1/teams/")); | |
1074 pathOffset += 21; | |
1075 index = path.indexOf("/workers/", pathOffset); | |
1076 unittest.expect(index >= 0, unittest.isTrue); | |
1077 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1078 pathOffset = index; | |
1079 unittest.expect(subPart, unittest.equals("$arg_teamId")); | |
1080 unittest.expect(path.substring(pathOffset, pathOffset + 9), unittest.equ
als("/workers/")); | |
1081 pathOffset += 9; | |
1082 index = path.indexOf("/locations", pathOffset); | |
1083 unittest.expect(index >= 0, unittest.isTrue); | |
1084 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1085 pathOffset = index; | |
1086 unittest.expect(subPart, unittest.equals("$arg_workerEmail")); | |
1087 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("/locations")); | |
1088 pathOffset += 10; | |
1089 | |
1090 var query = (req.url).query; | |
1091 var queryOffset = 0; | |
1092 var queryMap = {}; | |
1093 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
1094 parseBool(n) { | |
1095 if (n == "true") return true; | |
1096 if (n == "false") return false; | |
1097 if (n == null) return null; | |
1098 throw new core.ArgumentError("Invalid boolean: $n"); | |
1099 } | |
1100 if (query.length > 0) { | |
1101 for (var part in query.split("&")) { | |
1102 var keyvalue = part.split("="); | |
1103 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
1104 } | |
1105 } | |
1106 unittest.expect(queryMap["startTimestampMs"].first, unittest.equals(arg_
startTimestampMs)); | |
1107 unittest.expect(core.int.parse(queryMap["maxResults"].first), unittest.e
quals(arg_maxResults)); | |
1108 unittest.expect(queryMap["pageToken"].first, unittest.equals(arg_pageTok
en)); | |
1109 | |
1110 | |
1111 var h = { | |
1112 "content-type" : "application/json; charset=utf-8", | |
1113 }; | |
1114 var resp = convert.JSON.encode(buildLocationListResponse()); | |
1115 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
1116 }), true); | |
1117 res.list(arg_teamId, arg_workerEmail, arg_startTimestampMs, maxResults: ar
g_maxResults, pageToken: arg_pageToken).then(unittest.expectAsync(((api.Location
ListResponse response) { | |
1118 checkLocationListResponse(response); | |
1119 }))); | |
1120 }); | |
1121 | |
1122 }); | |
1123 | |
1124 | |
1125 unittest.group("resource-ScheduleResourceApi", () { | |
1126 unittest.test("method--get", () { | |
1127 | |
1128 var mock = new common_test.HttpServerMock(); | |
1129 api.ScheduleResourceApi res = new api.CoordinateApi(mock).schedule; | |
1130 var arg_teamId = "foo"; | |
1131 var arg_jobId = "foo"; | |
1132 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
1133 var path = (req.url).path; | |
1134 var pathOffset = 0; | |
1135 var index; | |
1136 var subPart; | |
1137 unittest.expect(path.substring(pathOffset, pathOffset + 21), unittest.eq
uals("/coordinate/v1/teams/")); | |
1138 pathOffset += 21; | |
1139 index = path.indexOf("/jobs/", pathOffset); | |
1140 unittest.expect(index >= 0, unittest.isTrue); | |
1141 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1142 pathOffset = index; | |
1143 unittest.expect(subPart, unittest.equals("$arg_teamId")); | |
1144 unittest.expect(path.substring(pathOffset, pathOffset + 6), unittest.equ
als("/jobs/")); | |
1145 pathOffset += 6; | |
1146 index = path.indexOf("/schedule", pathOffset); | |
1147 unittest.expect(index >= 0, unittest.isTrue); | |
1148 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1149 pathOffset = index; | |
1150 unittest.expect(subPart, unittest.equals("$arg_jobId")); | |
1151 unittest.expect(path.substring(pathOffset, pathOffset + 9), unittest.equ
als("/schedule")); | |
1152 pathOffset += 9; | |
1153 | |
1154 var query = (req.url).query; | |
1155 var queryOffset = 0; | |
1156 var queryMap = {}; | |
1157 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
1158 parseBool(n) { | |
1159 if (n == "true") return true; | |
1160 if (n == "false") return false; | |
1161 if (n == null) return null; | |
1162 throw new core.ArgumentError("Invalid boolean: $n"); | |
1163 } | |
1164 if (query.length > 0) { | |
1165 for (var part in query.split("&")) { | |
1166 var keyvalue = part.split("="); | |
1167 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
1168 } | |
1169 } | |
1170 | |
1171 | |
1172 var h = { | |
1173 "content-type" : "application/json; charset=utf-8", | |
1174 }; | |
1175 var resp = convert.JSON.encode(buildSchedule()); | |
1176 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
1177 }), true); | |
1178 res.get(arg_teamId, arg_jobId).then(unittest.expectAsync(((api.Schedule re
sponse) { | |
1179 checkSchedule(response); | |
1180 }))); | |
1181 }); | |
1182 | |
1183 unittest.test("method--patch", () { | |
1184 | |
1185 var mock = new common_test.HttpServerMock(); | |
1186 api.ScheduleResourceApi res = new api.CoordinateApi(mock).schedule; | |
1187 var arg_request = buildSchedule(); | |
1188 var arg_teamId = "foo"; | |
1189 var arg_jobId = "foo"; | |
1190 var arg_allDay = true; | |
1191 var arg_duration = "foo"; | |
1192 var arg_endTime = "foo"; | |
1193 var arg_startTime = "foo"; | |
1194 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
1195 var obj = new api.Schedule.fromJson(json); | |
1196 checkSchedule(obj); | |
1197 | |
1198 var path = (req.url).path; | |
1199 var pathOffset = 0; | |
1200 var index; | |
1201 var subPart; | |
1202 unittest.expect(path.substring(pathOffset, pathOffset + 21), unittest.eq
uals("/coordinate/v1/teams/")); | |
1203 pathOffset += 21; | |
1204 index = path.indexOf("/jobs/", pathOffset); | |
1205 unittest.expect(index >= 0, unittest.isTrue); | |
1206 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1207 pathOffset = index; | |
1208 unittest.expect(subPart, unittest.equals("$arg_teamId")); | |
1209 unittest.expect(path.substring(pathOffset, pathOffset + 6), unittest.equ
als("/jobs/")); | |
1210 pathOffset += 6; | |
1211 index = path.indexOf("/schedule", pathOffset); | |
1212 unittest.expect(index >= 0, unittest.isTrue); | |
1213 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1214 pathOffset = index; | |
1215 unittest.expect(subPart, unittest.equals("$arg_jobId")); | |
1216 unittest.expect(path.substring(pathOffset, pathOffset + 9), unittest.equ
als("/schedule")); | |
1217 pathOffset += 9; | |
1218 | |
1219 var query = (req.url).query; | |
1220 var queryOffset = 0; | |
1221 var queryMap = {}; | |
1222 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
1223 parseBool(n) { | |
1224 if (n == "true") return true; | |
1225 if (n == "false") return false; | |
1226 if (n == null) return null; | |
1227 throw new core.ArgumentError("Invalid boolean: $n"); | |
1228 } | |
1229 if (query.length > 0) { | |
1230 for (var part in query.split("&")) { | |
1231 var keyvalue = part.split("="); | |
1232 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
1233 } | |
1234 } | |
1235 unittest.expect(queryMap["allDay"].first, unittest.equals("$arg_allDay")
); | |
1236 unittest.expect(queryMap["duration"].first, unittest.equals(arg_duration
)); | |
1237 unittest.expect(queryMap["endTime"].first, unittest.equals(arg_endTime))
; | |
1238 unittest.expect(queryMap["startTime"].first, unittest.equals(arg_startTi
me)); | |
1239 | |
1240 | |
1241 var h = { | |
1242 "content-type" : "application/json; charset=utf-8", | |
1243 }; | |
1244 var resp = convert.JSON.encode(buildSchedule()); | |
1245 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
1246 }), true); | |
1247 res.patch(arg_request, arg_teamId, arg_jobId, allDay: arg_allDay, duration
: arg_duration, endTime: arg_endTime, startTime: arg_startTime).then(unittest.ex
pectAsync(((api.Schedule response) { | |
1248 checkSchedule(response); | |
1249 }))); | |
1250 }); | |
1251 | |
1252 unittest.test("method--update", () { | |
1253 | |
1254 var mock = new common_test.HttpServerMock(); | |
1255 api.ScheduleResourceApi res = new api.CoordinateApi(mock).schedule; | |
1256 var arg_request = buildSchedule(); | |
1257 var arg_teamId = "foo"; | |
1258 var arg_jobId = "foo"; | |
1259 var arg_allDay = true; | |
1260 var arg_duration = "foo"; | |
1261 var arg_endTime = "foo"; | |
1262 var arg_startTime = "foo"; | |
1263 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
1264 var obj = new api.Schedule.fromJson(json); | |
1265 checkSchedule(obj); | |
1266 | |
1267 var path = (req.url).path; | |
1268 var pathOffset = 0; | |
1269 var index; | |
1270 var subPart; | |
1271 unittest.expect(path.substring(pathOffset, pathOffset + 21), unittest.eq
uals("/coordinate/v1/teams/")); | |
1272 pathOffset += 21; | |
1273 index = path.indexOf("/jobs/", pathOffset); | |
1274 unittest.expect(index >= 0, unittest.isTrue); | |
1275 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1276 pathOffset = index; | |
1277 unittest.expect(subPart, unittest.equals("$arg_teamId")); | |
1278 unittest.expect(path.substring(pathOffset, pathOffset + 6), unittest.equ
als("/jobs/")); | |
1279 pathOffset += 6; | |
1280 index = path.indexOf("/schedule", pathOffset); | |
1281 unittest.expect(index >= 0, unittest.isTrue); | |
1282 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1283 pathOffset = index; | |
1284 unittest.expect(subPart, unittest.equals("$arg_jobId")); | |
1285 unittest.expect(path.substring(pathOffset, pathOffset + 9), unittest.equ
als("/schedule")); | |
1286 pathOffset += 9; | |
1287 | |
1288 var query = (req.url).query; | |
1289 var queryOffset = 0; | |
1290 var queryMap = {}; | |
1291 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
1292 parseBool(n) { | |
1293 if (n == "true") return true; | |
1294 if (n == "false") return false; | |
1295 if (n == null) return null; | |
1296 throw new core.ArgumentError("Invalid boolean: $n"); | |
1297 } | |
1298 if (query.length > 0) { | |
1299 for (var part in query.split("&")) { | |
1300 var keyvalue = part.split("="); | |
1301 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
1302 } | |
1303 } | |
1304 unittest.expect(queryMap["allDay"].first, unittest.equals("$arg_allDay")
); | |
1305 unittest.expect(queryMap["duration"].first, unittest.equals(arg_duration
)); | |
1306 unittest.expect(queryMap["endTime"].first, unittest.equals(arg_endTime))
; | |
1307 unittest.expect(queryMap["startTime"].first, unittest.equals(arg_startTi
me)); | |
1308 | |
1309 | |
1310 var h = { | |
1311 "content-type" : "application/json; charset=utf-8", | |
1312 }; | |
1313 var resp = convert.JSON.encode(buildSchedule()); | |
1314 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
1315 }), true); | |
1316 res.update(arg_request, arg_teamId, arg_jobId, allDay: arg_allDay, duratio
n: arg_duration, endTime: arg_endTime, startTime: arg_startTime).then(unittest.e
xpectAsync(((api.Schedule response) { | |
1317 checkSchedule(response); | |
1318 }))); | |
1319 }); | |
1320 | |
1321 }); | |
1322 | |
1323 | |
1324 unittest.group("resource-WorkerResourceApi", () { | |
1325 unittest.test("method--list", () { | |
1326 | |
1327 var mock = new common_test.HttpServerMock(); | |
1328 api.WorkerResourceApi res = new api.CoordinateApi(mock).worker; | |
1329 var arg_teamId = "foo"; | |
1330 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
1331 var path = (req.url).path; | |
1332 var pathOffset = 0; | |
1333 var index; | |
1334 var subPart; | |
1335 unittest.expect(path.substring(pathOffset, pathOffset + 21), unittest.eq
uals("/coordinate/v1/teams/")); | |
1336 pathOffset += 21; | |
1337 index = path.indexOf("/workers", pathOffset); | |
1338 unittest.expect(index >= 0, unittest.isTrue); | |
1339 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1340 pathOffset = index; | |
1341 unittest.expect(subPart, unittest.equals("$arg_teamId")); | |
1342 unittest.expect(path.substring(pathOffset, pathOffset + 8), unittest.equ
als("/workers")); | |
1343 pathOffset += 8; | |
1344 | |
1345 var query = (req.url).query; | |
1346 var queryOffset = 0; | |
1347 var queryMap = {}; | |
1348 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
1349 parseBool(n) { | |
1350 if (n == "true") return true; | |
1351 if (n == "false") return false; | |
1352 if (n == null) return null; | |
1353 throw new core.ArgumentError("Invalid boolean: $n"); | |
1354 } | |
1355 if (query.length > 0) { | |
1356 for (var part in query.split("&")) { | |
1357 var keyvalue = part.split("="); | |
1358 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
1359 } | |
1360 } | |
1361 | |
1362 | |
1363 var h = { | |
1364 "content-type" : "application/json; charset=utf-8", | |
1365 }; | |
1366 var resp = convert.JSON.encode(buildWorkerListResponse()); | |
1367 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
1368 }), true); | |
1369 res.list(arg_teamId).then(unittest.expectAsync(((api.WorkerListResponse re
sponse) { | |
1370 checkWorkerListResponse(response); | |
1371 }))); | |
1372 }); | |
1373 | |
1374 }); | |
1375 | |
1376 | |
1377 } | |
1378 | |
OLD | NEW |