OLD | NEW |
| (Empty) |
1 library googleapis_beta.datastore.v1beta3.test; | |
2 | |
3 import "dart:core" as core; | |
4 import "dart:collection" as collection; | |
5 import "dart:async" as async; | |
6 import "dart:convert" as convert; | |
7 | |
8 import 'package:http/http.dart' as http; | |
9 import 'package:http/testing.dart' as http_testing; | |
10 import 'package:unittest/unittest.dart' as unittest; | |
11 | |
12 import 'package:googleapis_beta/datastore/v1beta3.dart' as api; | |
13 | |
14 class HttpServerMock extends http.BaseClient { | |
15 core.Function _callback; | |
16 core.bool _expectJson; | |
17 | |
18 void register(core.Function callback, core.bool expectJson) { | |
19 _callback = callback; | |
20 _expectJson = expectJson; | |
21 } | |
22 | |
23 async.Future<http.StreamedResponse> send(http.BaseRequest request) { | |
24 if (_expectJson) { | |
25 return request.finalize() | |
26 .transform(convert.UTF8.decoder) | |
27 .join('') | |
28 .then((core.String jsonString) { | |
29 if (jsonString.isEmpty) { | |
30 return _callback(request, null); | |
31 } else { | |
32 return _callback(request, convert.JSON.decode(jsonString)); | |
33 } | |
34 }); | |
35 } else { | |
36 var stream = request.finalize(); | |
37 if (stream == null) { | |
38 return _callback(request, []); | |
39 } else { | |
40 return stream.toBytes().then((data) { | |
41 return _callback(request, data); | |
42 }); | |
43 } | |
44 } | |
45 } | |
46 } | |
47 | |
48 http.StreamedResponse stringResponse( | |
49 core.int status, core.Map headers, core.String body) { | |
50 var stream = new async.Stream.fromIterable([convert.UTF8.encode(body)]); | |
51 return new http.StreamedResponse(stream, status, headers: headers); | |
52 } | |
53 | |
54 buildUnnamed3395() { | |
55 var o = new core.List<api.Key>(); | |
56 o.add(buildKey()); | |
57 o.add(buildKey()); | |
58 return o; | |
59 } | |
60 | |
61 checkUnnamed3395(core.List<api.Key> o) { | |
62 unittest.expect(o, unittest.hasLength(2)); | |
63 checkKey(o[0]); | |
64 checkKey(o[1]); | |
65 } | |
66 | |
67 core.int buildCounterAllocateIdsRequest = 0; | |
68 buildAllocateIdsRequest() { | |
69 var o = new api.AllocateIdsRequest(); | |
70 buildCounterAllocateIdsRequest++; | |
71 if (buildCounterAllocateIdsRequest < 3) { | |
72 o.keys = buildUnnamed3395(); | |
73 } | |
74 buildCounterAllocateIdsRequest--; | |
75 return o; | |
76 } | |
77 | |
78 checkAllocateIdsRequest(api.AllocateIdsRequest o) { | |
79 buildCounterAllocateIdsRequest++; | |
80 if (buildCounterAllocateIdsRequest < 3) { | |
81 checkUnnamed3395(o.keys); | |
82 } | |
83 buildCounterAllocateIdsRequest--; | |
84 } | |
85 | |
86 buildUnnamed3396() { | |
87 var o = new core.List<api.Key>(); | |
88 o.add(buildKey()); | |
89 o.add(buildKey()); | |
90 return o; | |
91 } | |
92 | |
93 checkUnnamed3396(core.List<api.Key> o) { | |
94 unittest.expect(o, unittest.hasLength(2)); | |
95 checkKey(o[0]); | |
96 checkKey(o[1]); | |
97 } | |
98 | |
99 core.int buildCounterAllocateIdsResponse = 0; | |
100 buildAllocateIdsResponse() { | |
101 var o = new api.AllocateIdsResponse(); | |
102 buildCounterAllocateIdsResponse++; | |
103 if (buildCounterAllocateIdsResponse < 3) { | |
104 o.keys = buildUnnamed3396(); | |
105 } | |
106 buildCounterAllocateIdsResponse--; | |
107 return o; | |
108 } | |
109 | |
110 checkAllocateIdsResponse(api.AllocateIdsResponse o) { | |
111 buildCounterAllocateIdsResponse++; | |
112 if (buildCounterAllocateIdsResponse < 3) { | |
113 checkUnnamed3396(o.keys); | |
114 } | |
115 buildCounterAllocateIdsResponse--; | |
116 } | |
117 | |
118 buildUnnamed3397() { | |
119 var o = new core.List<api.Value>(); | |
120 o.add(buildValue()); | |
121 o.add(buildValue()); | |
122 return o; | |
123 } | |
124 | |
125 checkUnnamed3397(core.List<api.Value> o) { | |
126 unittest.expect(o, unittest.hasLength(2)); | |
127 checkValue(o[0]); | |
128 checkValue(o[1]); | |
129 } | |
130 | |
131 core.int buildCounterArrayValue = 0; | |
132 buildArrayValue() { | |
133 var o = new api.ArrayValue(); | |
134 buildCounterArrayValue++; | |
135 if (buildCounterArrayValue < 3) { | |
136 o.values = buildUnnamed3397(); | |
137 } | |
138 buildCounterArrayValue--; | |
139 return o; | |
140 } | |
141 | |
142 checkArrayValue(api.ArrayValue o) { | |
143 buildCounterArrayValue++; | |
144 if (buildCounterArrayValue < 3) { | |
145 checkUnnamed3397(o.values); | |
146 } | |
147 buildCounterArrayValue--; | |
148 } | |
149 | |
150 core.int buildCounterBeginTransactionRequest = 0; | |
151 buildBeginTransactionRequest() { | |
152 var o = new api.BeginTransactionRequest(); | |
153 buildCounterBeginTransactionRequest++; | |
154 if (buildCounterBeginTransactionRequest < 3) { | |
155 } | |
156 buildCounterBeginTransactionRequest--; | |
157 return o; | |
158 } | |
159 | |
160 checkBeginTransactionRequest(api.BeginTransactionRequest o) { | |
161 buildCounterBeginTransactionRequest++; | |
162 if (buildCounterBeginTransactionRequest < 3) { | |
163 } | |
164 buildCounterBeginTransactionRequest--; | |
165 } | |
166 | |
167 core.int buildCounterBeginTransactionResponse = 0; | |
168 buildBeginTransactionResponse() { | |
169 var o = new api.BeginTransactionResponse(); | |
170 buildCounterBeginTransactionResponse++; | |
171 if (buildCounterBeginTransactionResponse < 3) { | |
172 o.transaction = "foo"; | |
173 } | |
174 buildCounterBeginTransactionResponse--; | |
175 return o; | |
176 } | |
177 | |
178 checkBeginTransactionResponse(api.BeginTransactionResponse o) { | |
179 buildCounterBeginTransactionResponse++; | |
180 if (buildCounterBeginTransactionResponse < 3) { | |
181 unittest.expect(o.transaction, unittest.equals('foo')); | |
182 } | |
183 buildCounterBeginTransactionResponse--; | |
184 } | |
185 | |
186 buildUnnamed3398() { | |
187 var o = new core.List<api.Mutation>(); | |
188 o.add(buildMutation()); | |
189 o.add(buildMutation()); | |
190 return o; | |
191 } | |
192 | |
193 checkUnnamed3398(core.List<api.Mutation> o) { | |
194 unittest.expect(o, unittest.hasLength(2)); | |
195 checkMutation(o[0]); | |
196 checkMutation(o[1]); | |
197 } | |
198 | |
199 core.int buildCounterCommitRequest = 0; | |
200 buildCommitRequest() { | |
201 var o = new api.CommitRequest(); | |
202 buildCounterCommitRequest++; | |
203 if (buildCounterCommitRequest < 3) { | |
204 o.mode = "foo"; | |
205 o.mutations = buildUnnamed3398(); | |
206 o.transaction = "foo"; | |
207 } | |
208 buildCounterCommitRequest--; | |
209 return o; | |
210 } | |
211 | |
212 checkCommitRequest(api.CommitRequest o) { | |
213 buildCounterCommitRequest++; | |
214 if (buildCounterCommitRequest < 3) { | |
215 unittest.expect(o.mode, unittest.equals('foo')); | |
216 checkUnnamed3398(o.mutations); | |
217 unittest.expect(o.transaction, unittest.equals('foo')); | |
218 } | |
219 buildCounterCommitRequest--; | |
220 } | |
221 | |
222 buildUnnamed3399() { | |
223 var o = new core.List<api.MutationResult>(); | |
224 o.add(buildMutationResult()); | |
225 o.add(buildMutationResult()); | |
226 return o; | |
227 } | |
228 | |
229 checkUnnamed3399(core.List<api.MutationResult> o) { | |
230 unittest.expect(o, unittest.hasLength(2)); | |
231 checkMutationResult(o[0]); | |
232 checkMutationResult(o[1]); | |
233 } | |
234 | |
235 core.int buildCounterCommitResponse = 0; | |
236 buildCommitResponse() { | |
237 var o = new api.CommitResponse(); | |
238 buildCounterCommitResponse++; | |
239 if (buildCounterCommitResponse < 3) { | |
240 o.indexUpdates = 42; | |
241 o.mutationResults = buildUnnamed3399(); | |
242 } | |
243 buildCounterCommitResponse--; | |
244 return o; | |
245 } | |
246 | |
247 checkCommitResponse(api.CommitResponse o) { | |
248 buildCounterCommitResponse++; | |
249 if (buildCounterCommitResponse < 3) { | |
250 unittest.expect(o.indexUpdates, unittest.equals(42)); | |
251 checkUnnamed3399(o.mutationResults); | |
252 } | |
253 buildCounterCommitResponse--; | |
254 } | |
255 | |
256 buildUnnamed3400() { | |
257 var o = new core.List<api.Filter>(); | |
258 o.add(buildFilter()); | |
259 o.add(buildFilter()); | |
260 return o; | |
261 } | |
262 | |
263 checkUnnamed3400(core.List<api.Filter> o) { | |
264 unittest.expect(o, unittest.hasLength(2)); | |
265 checkFilter(o[0]); | |
266 checkFilter(o[1]); | |
267 } | |
268 | |
269 core.int buildCounterCompositeFilter = 0; | |
270 buildCompositeFilter() { | |
271 var o = new api.CompositeFilter(); | |
272 buildCounterCompositeFilter++; | |
273 if (buildCounterCompositeFilter < 3) { | |
274 o.filters = buildUnnamed3400(); | |
275 o.op = "foo"; | |
276 } | |
277 buildCounterCompositeFilter--; | |
278 return o; | |
279 } | |
280 | |
281 checkCompositeFilter(api.CompositeFilter o) { | |
282 buildCounterCompositeFilter++; | |
283 if (buildCounterCompositeFilter < 3) { | |
284 checkUnnamed3400(o.filters); | |
285 unittest.expect(o.op, unittest.equals('foo')); | |
286 } | |
287 buildCounterCompositeFilter--; | |
288 } | |
289 | |
290 buildUnnamed3401() { | |
291 var o = new core.Map<core.String, api.Value>(); | |
292 o["x"] = buildValue(); | |
293 o["y"] = buildValue(); | |
294 return o; | |
295 } | |
296 | |
297 checkUnnamed3401(core.Map<core.String, api.Value> o) { | |
298 unittest.expect(o, unittest.hasLength(2)); | |
299 checkValue(o["x"]); | |
300 checkValue(o["y"]); | |
301 } | |
302 | |
303 core.int buildCounterEntity = 0; | |
304 buildEntity() { | |
305 var o = new api.Entity(); | |
306 buildCounterEntity++; | |
307 if (buildCounterEntity < 3) { | |
308 o.key = buildKey(); | |
309 o.properties = buildUnnamed3401(); | |
310 } | |
311 buildCounterEntity--; | |
312 return o; | |
313 } | |
314 | |
315 checkEntity(api.Entity o) { | |
316 buildCounterEntity++; | |
317 if (buildCounterEntity < 3) { | |
318 checkKey(o.key); | |
319 checkUnnamed3401(o.properties); | |
320 } | |
321 buildCounterEntity--; | |
322 } | |
323 | |
324 core.int buildCounterEntityResult = 0; | |
325 buildEntityResult() { | |
326 var o = new api.EntityResult(); | |
327 buildCounterEntityResult++; | |
328 if (buildCounterEntityResult < 3) { | |
329 o.cursor = "foo"; | |
330 o.entity = buildEntity(); | |
331 o.version = "foo"; | |
332 } | |
333 buildCounterEntityResult--; | |
334 return o; | |
335 } | |
336 | |
337 checkEntityResult(api.EntityResult o) { | |
338 buildCounterEntityResult++; | |
339 if (buildCounterEntityResult < 3) { | |
340 unittest.expect(o.cursor, unittest.equals('foo')); | |
341 checkEntity(o.entity); | |
342 unittest.expect(o.version, unittest.equals('foo')); | |
343 } | |
344 buildCounterEntityResult--; | |
345 } | |
346 | |
347 core.int buildCounterFilter = 0; | |
348 buildFilter() { | |
349 var o = new api.Filter(); | |
350 buildCounterFilter++; | |
351 if (buildCounterFilter < 3) { | |
352 o.compositeFilter = buildCompositeFilter(); | |
353 o.propertyFilter = buildPropertyFilter(); | |
354 } | |
355 buildCounterFilter--; | |
356 return o; | |
357 } | |
358 | |
359 checkFilter(api.Filter o) { | |
360 buildCounterFilter++; | |
361 if (buildCounterFilter < 3) { | |
362 checkCompositeFilter(o.compositeFilter); | |
363 checkPropertyFilter(o.propertyFilter); | |
364 } | |
365 buildCounterFilter--; | |
366 } | |
367 | |
368 buildUnnamed3402() { | |
369 var o = new core.Map<core.String, api.GqlQueryParameter>(); | |
370 o["x"] = buildGqlQueryParameter(); | |
371 o["y"] = buildGqlQueryParameter(); | |
372 return o; | |
373 } | |
374 | |
375 checkUnnamed3402(core.Map<core.String, api.GqlQueryParameter> o) { | |
376 unittest.expect(o, unittest.hasLength(2)); | |
377 checkGqlQueryParameter(o["x"]); | |
378 checkGqlQueryParameter(o["y"]); | |
379 } | |
380 | |
381 buildUnnamed3403() { | |
382 var o = new core.List<api.GqlQueryParameter>(); | |
383 o.add(buildGqlQueryParameter()); | |
384 o.add(buildGqlQueryParameter()); | |
385 return o; | |
386 } | |
387 | |
388 checkUnnamed3403(core.List<api.GqlQueryParameter> o) { | |
389 unittest.expect(o, unittest.hasLength(2)); | |
390 checkGqlQueryParameter(o[0]); | |
391 checkGqlQueryParameter(o[1]); | |
392 } | |
393 | |
394 core.int buildCounterGqlQuery = 0; | |
395 buildGqlQuery() { | |
396 var o = new api.GqlQuery(); | |
397 buildCounterGqlQuery++; | |
398 if (buildCounterGqlQuery < 3) { | |
399 o.allowLiterals = true; | |
400 o.namedBindings = buildUnnamed3402(); | |
401 o.positionalBindings = buildUnnamed3403(); | |
402 o.queryString = "foo"; | |
403 } | |
404 buildCounterGqlQuery--; | |
405 return o; | |
406 } | |
407 | |
408 checkGqlQuery(api.GqlQuery o) { | |
409 buildCounterGqlQuery++; | |
410 if (buildCounterGqlQuery < 3) { | |
411 unittest.expect(o.allowLiterals, unittest.isTrue); | |
412 checkUnnamed3402(o.namedBindings); | |
413 checkUnnamed3403(o.positionalBindings); | |
414 unittest.expect(o.queryString, unittest.equals('foo')); | |
415 } | |
416 buildCounterGqlQuery--; | |
417 } | |
418 | |
419 core.int buildCounterGqlQueryParameter = 0; | |
420 buildGqlQueryParameter() { | |
421 var o = new api.GqlQueryParameter(); | |
422 buildCounterGqlQueryParameter++; | |
423 if (buildCounterGqlQueryParameter < 3) { | |
424 o.cursor = "foo"; | |
425 o.value = buildValue(); | |
426 } | |
427 buildCounterGqlQueryParameter--; | |
428 return o; | |
429 } | |
430 | |
431 checkGqlQueryParameter(api.GqlQueryParameter o) { | |
432 buildCounterGqlQueryParameter++; | |
433 if (buildCounterGqlQueryParameter < 3) { | |
434 unittest.expect(o.cursor, unittest.equals('foo')); | |
435 checkValue(o.value); | |
436 } | |
437 buildCounterGqlQueryParameter--; | |
438 } | |
439 | |
440 buildUnnamed3404() { | |
441 var o = new core.List<api.PathElement>(); | |
442 o.add(buildPathElement()); | |
443 o.add(buildPathElement()); | |
444 return o; | |
445 } | |
446 | |
447 checkUnnamed3404(core.List<api.PathElement> o) { | |
448 unittest.expect(o, unittest.hasLength(2)); | |
449 checkPathElement(o[0]); | |
450 checkPathElement(o[1]); | |
451 } | |
452 | |
453 core.int buildCounterKey = 0; | |
454 buildKey() { | |
455 var o = new api.Key(); | |
456 buildCounterKey++; | |
457 if (buildCounterKey < 3) { | |
458 o.partitionId = buildPartitionId(); | |
459 o.path = buildUnnamed3404(); | |
460 } | |
461 buildCounterKey--; | |
462 return o; | |
463 } | |
464 | |
465 checkKey(api.Key o) { | |
466 buildCounterKey++; | |
467 if (buildCounterKey < 3) { | |
468 checkPartitionId(o.partitionId); | |
469 checkUnnamed3404(o.path); | |
470 } | |
471 buildCounterKey--; | |
472 } | |
473 | |
474 core.int buildCounterKindExpression = 0; | |
475 buildKindExpression() { | |
476 var o = new api.KindExpression(); | |
477 buildCounterKindExpression++; | |
478 if (buildCounterKindExpression < 3) { | |
479 o.name = "foo"; | |
480 } | |
481 buildCounterKindExpression--; | |
482 return o; | |
483 } | |
484 | |
485 checkKindExpression(api.KindExpression o) { | |
486 buildCounterKindExpression++; | |
487 if (buildCounterKindExpression < 3) { | |
488 unittest.expect(o.name, unittest.equals('foo')); | |
489 } | |
490 buildCounterKindExpression--; | |
491 } | |
492 | |
493 core.int buildCounterLatLng = 0; | |
494 buildLatLng() { | |
495 var o = new api.LatLng(); | |
496 buildCounterLatLng++; | |
497 if (buildCounterLatLng < 3) { | |
498 o.latitude = 42.0; | |
499 o.longitude = 42.0; | |
500 } | |
501 buildCounterLatLng--; | |
502 return o; | |
503 } | |
504 | |
505 checkLatLng(api.LatLng o) { | |
506 buildCounterLatLng++; | |
507 if (buildCounterLatLng < 3) { | |
508 unittest.expect(o.latitude, unittest.equals(42.0)); | |
509 unittest.expect(o.longitude, unittest.equals(42.0)); | |
510 } | |
511 buildCounterLatLng--; | |
512 } | |
513 | |
514 buildUnnamed3405() { | |
515 var o = new core.List<api.Key>(); | |
516 o.add(buildKey()); | |
517 o.add(buildKey()); | |
518 return o; | |
519 } | |
520 | |
521 checkUnnamed3405(core.List<api.Key> o) { | |
522 unittest.expect(o, unittest.hasLength(2)); | |
523 checkKey(o[0]); | |
524 checkKey(o[1]); | |
525 } | |
526 | |
527 core.int buildCounterLookupRequest = 0; | |
528 buildLookupRequest() { | |
529 var o = new api.LookupRequest(); | |
530 buildCounterLookupRequest++; | |
531 if (buildCounterLookupRequest < 3) { | |
532 o.keys = buildUnnamed3405(); | |
533 o.readOptions = buildReadOptions(); | |
534 } | |
535 buildCounterLookupRequest--; | |
536 return o; | |
537 } | |
538 | |
539 checkLookupRequest(api.LookupRequest o) { | |
540 buildCounterLookupRequest++; | |
541 if (buildCounterLookupRequest < 3) { | |
542 checkUnnamed3405(o.keys); | |
543 checkReadOptions(o.readOptions); | |
544 } | |
545 buildCounterLookupRequest--; | |
546 } | |
547 | |
548 buildUnnamed3406() { | |
549 var o = new core.List<api.Key>(); | |
550 o.add(buildKey()); | |
551 o.add(buildKey()); | |
552 return o; | |
553 } | |
554 | |
555 checkUnnamed3406(core.List<api.Key> o) { | |
556 unittest.expect(o, unittest.hasLength(2)); | |
557 checkKey(o[0]); | |
558 checkKey(o[1]); | |
559 } | |
560 | |
561 buildUnnamed3407() { | |
562 var o = new core.List<api.EntityResult>(); | |
563 o.add(buildEntityResult()); | |
564 o.add(buildEntityResult()); | |
565 return o; | |
566 } | |
567 | |
568 checkUnnamed3407(core.List<api.EntityResult> o) { | |
569 unittest.expect(o, unittest.hasLength(2)); | |
570 checkEntityResult(o[0]); | |
571 checkEntityResult(o[1]); | |
572 } | |
573 | |
574 buildUnnamed3408() { | |
575 var o = new core.List<api.EntityResult>(); | |
576 o.add(buildEntityResult()); | |
577 o.add(buildEntityResult()); | |
578 return o; | |
579 } | |
580 | |
581 checkUnnamed3408(core.List<api.EntityResult> o) { | |
582 unittest.expect(o, unittest.hasLength(2)); | |
583 checkEntityResult(o[0]); | |
584 checkEntityResult(o[1]); | |
585 } | |
586 | |
587 core.int buildCounterLookupResponse = 0; | |
588 buildLookupResponse() { | |
589 var o = new api.LookupResponse(); | |
590 buildCounterLookupResponse++; | |
591 if (buildCounterLookupResponse < 3) { | |
592 o.deferred = buildUnnamed3406(); | |
593 o.found = buildUnnamed3407(); | |
594 o.missing = buildUnnamed3408(); | |
595 } | |
596 buildCounterLookupResponse--; | |
597 return o; | |
598 } | |
599 | |
600 checkLookupResponse(api.LookupResponse o) { | |
601 buildCounterLookupResponse++; | |
602 if (buildCounterLookupResponse < 3) { | |
603 checkUnnamed3406(o.deferred); | |
604 checkUnnamed3407(o.found); | |
605 checkUnnamed3408(o.missing); | |
606 } | |
607 buildCounterLookupResponse--; | |
608 } | |
609 | |
610 core.int buildCounterMutation = 0; | |
611 buildMutation() { | |
612 var o = new api.Mutation(); | |
613 buildCounterMutation++; | |
614 if (buildCounterMutation < 3) { | |
615 o.baseVersion = "foo"; | |
616 o.delete = buildKey(); | |
617 o.insert = buildEntity(); | |
618 o.update = buildEntity(); | |
619 o.upsert = buildEntity(); | |
620 } | |
621 buildCounterMutation--; | |
622 return o; | |
623 } | |
624 | |
625 checkMutation(api.Mutation o) { | |
626 buildCounterMutation++; | |
627 if (buildCounterMutation < 3) { | |
628 unittest.expect(o.baseVersion, unittest.equals('foo')); | |
629 checkKey(o.delete); | |
630 checkEntity(o.insert); | |
631 checkEntity(o.update); | |
632 checkEntity(o.upsert); | |
633 } | |
634 buildCounterMutation--; | |
635 } | |
636 | |
637 core.int buildCounterMutationResult = 0; | |
638 buildMutationResult() { | |
639 var o = new api.MutationResult(); | |
640 buildCounterMutationResult++; | |
641 if (buildCounterMutationResult < 3) { | |
642 o.conflictDetected = true; | |
643 o.key = buildKey(); | |
644 o.version = "foo"; | |
645 } | |
646 buildCounterMutationResult--; | |
647 return o; | |
648 } | |
649 | |
650 checkMutationResult(api.MutationResult o) { | |
651 buildCounterMutationResult++; | |
652 if (buildCounterMutationResult < 3) { | |
653 unittest.expect(o.conflictDetected, unittest.isTrue); | |
654 checkKey(o.key); | |
655 unittest.expect(o.version, unittest.equals('foo')); | |
656 } | |
657 buildCounterMutationResult--; | |
658 } | |
659 | |
660 core.int buildCounterPartitionId = 0; | |
661 buildPartitionId() { | |
662 var o = new api.PartitionId(); | |
663 buildCounterPartitionId++; | |
664 if (buildCounterPartitionId < 3) { | |
665 o.namespaceId = "foo"; | |
666 o.projectId = "foo"; | |
667 } | |
668 buildCounterPartitionId--; | |
669 return o; | |
670 } | |
671 | |
672 checkPartitionId(api.PartitionId o) { | |
673 buildCounterPartitionId++; | |
674 if (buildCounterPartitionId < 3) { | |
675 unittest.expect(o.namespaceId, unittest.equals('foo')); | |
676 unittest.expect(o.projectId, unittest.equals('foo')); | |
677 } | |
678 buildCounterPartitionId--; | |
679 } | |
680 | |
681 core.int buildCounterPathElement = 0; | |
682 buildPathElement() { | |
683 var o = new api.PathElement(); | |
684 buildCounterPathElement++; | |
685 if (buildCounterPathElement < 3) { | |
686 o.id = "foo"; | |
687 o.kind = "foo"; | |
688 o.name = "foo"; | |
689 } | |
690 buildCounterPathElement--; | |
691 return o; | |
692 } | |
693 | |
694 checkPathElement(api.PathElement o) { | |
695 buildCounterPathElement++; | |
696 if (buildCounterPathElement < 3) { | |
697 unittest.expect(o.id, unittest.equals('foo')); | |
698 unittest.expect(o.kind, unittest.equals('foo')); | |
699 unittest.expect(o.name, unittest.equals('foo')); | |
700 } | |
701 buildCounterPathElement--; | |
702 } | |
703 | |
704 core.int buildCounterProjection = 0; | |
705 buildProjection() { | |
706 var o = new api.Projection(); | |
707 buildCounterProjection++; | |
708 if (buildCounterProjection < 3) { | |
709 o.property = buildPropertyReference(); | |
710 } | |
711 buildCounterProjection--; | |
712 return o; | |
713 } | |
714 | |
715 checkProjection(api.Projection o) { | |
716 buildCounterProjection++; | |
717 if (buildCounterProjection < 3) { | |
718 checkPropertyReference(o.property); | |
719 } | |
720 buildCounterProjection--; | |
721 } | |
722 | |
723 core.int buildCounterPropertyFilter = 0; | |
724 buildPropertyFilter() { | |
725 var o = new api.PropertyFilter(); | |
726 buildCounterPropertyFilter++; | |
727 if (buildCounterPropertyFilter < 3) { | |
728 o.op = "foo"; | |
729 o.property = buildPropertyReference(); | |
730 o.value = buildValue(); | |
731 } | |
732 buildCounterPropertyFilter--; | |
733 return o; | |
734 } | |
735 | |
736 checkPropertyFilter(api.PropertyFilter o) { | |
737 buildCounterPropertyFilter++; | |
738 if (buildCounterPropertyFilter < 3) { | |
739 unittest.expect(o.op, unittest.equals('foo')); | |
740 checkPropertyReference(o.property); | |
741 checkValue(o.value); | |
742 } | |
743 buildCounterPropertyFilter--; | |
744 } | |
745 | |
746 core.int buildCounterPropertyOrder = 0; | |
747 buildPropertyOrder() { | |
748 var o = new api.PropertyOrder(); | |
749 buildCounterPropertyOrder++; | |
750 if (buildCounterPropertyOrder < 3) { | |
751 o.direction = "foo"; | |
752 o.property = buildPropertyReference(); | |
753 } | |
754 buildCounterPropertyOrder--; | |
755 return o; | |
756 } | |
757 | |
758 checkPropertyOrder(api.PropertyOrder o) { | |
759 buildCounterPropertyOrder++; | |
760 if (buildCounterPropertyOrder < 3) { | |
761 unittest.expect(o.direction, unittest.equals('foo')); | |
762 checkPropertyReference(o.property); | |
763 } | |
764 buildCounterPropertyOrder--; | |
765 } | |
766 | |
767 core.int buildCounterPropertyReference = 0; | |
768 buildPropertyReference() { | |
769 var o = new api.PropertyReference(); | |
770 buildCounterPropertyReference++; | |
771 if (buildCounterPropertyReference < 3) { | |
772 o.name = "foo"; | |
773 } | |
774 buildCounterPropertyReference--; | |
775 return o; | |
776 } | |
777 | |
778 checkPropertyReference(api.PropertyReference o) { | |
779 buildCounterPropertyReference++; | |
780 if (buildCounterPropertyReference < 3) { | |
781 unittest.expect(o.name, unittest.equals('foo')); | |
782 } | |
783 buildCounterPropertyReference--; | |
784 } | |
785 | |
786 buildUnnamed3409() { | |
787 var o = new core.List<api.PropertyReference>(); | |
788 o.add(buildPropertyReference()); | |
789 o.add(buildPropertyReference()); | |
790 return o; | |
791 } | |
792 | |
793 checkUnnamed3409(core.List<api.PropertyReference> o) { | |
794 unittest.expect(o, unittest.hasLength(2)); | |
795 checkPropertyReference(o[0]); | |
796 checkPropertyReference(o[1]); | |
797 } | |
798 | |
799 buildUnnamed3410() { | |
800 var o = new core.List<api.KindExpression>(); | |
801 o.add(buildKindExpression()); | |
802 o.add(buildKindExpression()); | |
803 return o; | |
804 } | |
805 | |
806 checkUnnamed3410(core.List<api.KindExpression> o) { | |
807 unittest.expect(o, unittest.hasLength(2)); | |
808 checkKindExpression(o[0]); | |
809 checkKindExpression(o[1]); | |
810 } | |
811 | |
812 buildUnnamed3411() { | |
813 var o = new core.List<api.PropertyOrder>(); | |
814 o.add(buildPropertyOrder()); | |
815 o.add(buildPropertyOrder()); | |
816 return o; | |
817 } | |
818 | |
819 checkUnnamed3411(core.List<api.PropertyOrder> o) { | |
820 unittest.expect(o, unittest.hasLength(2)); | |
821 checkPropertyOrder(o[0]); | |
822 checkPropertyOrder(o[1]); | |
823 } | |
824 | |
825 buildUnnamed3412() { | |
826 var o = new core.List<api.Projection>(); | |
827 o.add(buildProjection()); | |
828 o.add(buildProjection()); | |
829 return o; | |
830 } | |
831 | |
832 checkUnnamed3412(core.List<api.Projection> o) { | |
833 unittest.expect(o, unittest.hasLength(2)); | |
834 checkProjection(o[0]); | |
835 checkProjection(o[1]); | |
836 } | |
837 | |
838 core.int buildCounterQuery = 0; | |
839 buildQuery() { | |
840 var o = new api.Query(); | |
841 buildCounterQuery++; | |
842 if (buildCounterQuery < 3) { | |
843 o.distinctOn = buildUnnamed3409(); | |
844 o.endCursor = "foo"; | |
845 o.filter = buildFilter(); | |
846 o.kind = buildUnnamed3410(); | |
847 o.limit = 42; | |
848 o.offset = 42; | |
849 o.order = buildUnnamed3411(); | |
850 o.projection = buildUnnamed3412(); | |
851 o.startCursor = "foo"; | |
852 } | |
853 buildCounterQuery--; | |
854 return o; | |
855 } | |
856 | |
857 checkQuery(api.Query o) { | |
858 buildCounterQuery++; | |
859 if (buildCounterQuery < 3) { | |
860 checkUnnamed3409(o.distinctOn); | |
861 unittest.expect(o.endCursor, unittest.equals('foo')); | |
862 checkFilter(o.filter); | |
863 checkUnnamed3410(o.kind); | |
864 unittest.expect(o.limit, unittest.equals(42)); | |
865 unittest.expect(o.offset, unittest.equals(42)); | |
866 checkUnnamed3411(o.order); | |
867 checkUnnamed3412(o.projection); | |
868 unittest.expect(o.startCursor, unittest.equals('foo')); | |
869 } | |
870 buildCounterQuery--; | |
871 } | |
872 | |
873 buildUnnamed3413() { | |
874 var o = new core.List<api.EntityResult>(); | |
875 o.add(buildEntityResult()); | |
876 o.add(buildEntityResult()); | |
877 return o; | |
878 } | |
879 | |
880 checkUnnamed3413(core.List<api.EntityResult> o) { | |
881 unittest.expect(o, unittest.hasLength(2)); | |
882 checkEntityResult(o[0]); | |
883 checkEntityResult(o[1]); | |
884 } | |
885 | |
886 core.int buildCounterQueryResultBatch = 0; | |
887 buildQueryResultBatch() { | |
888 var o = new api.QueryResultBatch(); | |
889 buildCounterQueryResultBatch++; | |
890 if (buildCounterQueryResultBatch < 3) { | |
891 o.endCursor = "foo"; | |
892 o.entityResultType = "foo"; | |
893 o.entityResults = buildUnnamed3413(); | |
894 o.moreResults = "foo"; | |
895 o.skippedCursor = "foo"; | |
896 o.skippedResults = 42; | |
897 o.snapshotVersion = "foo"; | |
898 } | |
899 buildCounterQueryResultBatch--; | |
900 return o; | |
901 } | |
902 | |
903 checkQueryResultBatch(api.QueryResultBatch o) { | |
904 buildCounterQueryResultBatch++; | |
905 if (buildCounterQueryResultBatch < 3) { | |
906 unittest.expect(o.endCursor, unittest.equals('foo')); | |
907 unittest.expect(o.entityResultType, unittest.equals('foo')); | |
908 checkUnnamed3413(o.entityResults); | |
909 unittest.expect(o.moreResults, unittest.equals('foo')); | |
910 unittest.expect(o.skippedCursor, unittest.equals('foo')); | |
911 unittest.expect(o.skippedResults, unittest.equals(42)); | |
912 unittest.expect(o.snapshotVersion, unittest.equals('foo')); | |
913 } | |
914 buildCounterQueryResultBatch--; | |
915 } | |
916 | |
917 core.int buildCounterReadOptions = 0; | |
918 buildReadOptions() { | |
919 var o = new api.ReadOptions(); | |
920 buildCounterReadOptions++; | |
921 if (buildCounterReadOptions < 3) { | |
922 o.readConsistency = "foo"; | |
923 o.transaction = "foo"; | |
924 } | |
925 buildCounterReadOptions--; | |
926 return o; | |
927 } | |
928 | |
929 checkReadOptions(api.ReadOptions o) { | |
930 buildCounterReadOptions++; | |
931 if (buildCounterReadOptions < 3) { | |
932 unittest.expect(o.readConsistency, unittest.equals('foo')); | |
933 unittest.expect(o.transaction, unittest.equals('foo')); | |
934 } | |
935 buildCounterReadOptions--; | |
936 } | |
937 | |
938 core.int buildCounterRollbackRequest = 0; | |
939 buildRollbackRequest() { | |
940 var o = new api.RollbackRequest(); | |
941 buildCounterRollbackRequest++; | |
942 if (buildCounterRollbackRequest < 3) { | |
943 o.transaction = "foo"; | |
944 } | |
945 buildCounterRollbackRequest--; | |
946 return o; | |
947 } | |
948 | |
949 checkRollbackRequest(api.RollbackRequest o) { | |
950 buildCounterRollbackRequest++; | |
951 if (buildCounterRollbackRequest < 3) { | |
952 unittest.expect(o.transaction, unittest.equals('foo')); | |
953 } | |
954 buildCounterRollbackRequest--; | |
955 } | |
956 | |
957 core.int buildCounterRollbackResponse = 0; | |
958 buildRollbackResponse() { | |
959 var o = new api.RollbackResponse(); | |
960 buildCounterRollbackResponse++; | |
961 if (buildCounterRollbackResponse < 3) { | |
962 } | |
963 buildCounterRollbackResponse--; | |
964 return o; | |
965 } | |
966 | |
967 checkRollbackResponse(api.RollbackResponse o) { | |
968 buildCounterRollbackResponse++; | |
969 if (buildCounterRollbackResponse < 3) { | |
970 } | |
971 buildCounterRollbackResponse--; | |
972 } | |
973 | |
974 core.int buildCounterRunQueryRequest = 0; | |
975 buildRunQueryRequest() { | |
976 var o = new api.RunQueryRequest(); | |
977 buildCounterRunQueryRequest++; | |
978 if (buildCounterRunQueryRequest < 3) { | |
979 o.gqlQuery = buildGqlQuery(); | |
980 o.partitionId = buildPartitionId(); | |
981 o.query = buildQuery(); | |
982 o.readOptions = buildReadOptions(); | |
983 } | |
984 buildCounterRunQueryRequest--; | |
985 return o; | |
986 } | |
987 | |
988 checkRunQueryRequest(api.RunQueryRequest o) { | |
989 buildCounterRunQueryRequest++; | |
990 if (buildCounterRunQueryRequest < 3) { | |
991 checkGqlQuery(o.gqlQuery); | |
992 checkPartitionId(o.partitionId); | |
993 checkQuery(o.query); | |
994 checkReadOptions(o.readOptions); | |
995 } | |
996 buildCounterRunQueryRequest--; | |
997 } | |
998 | |
999 core.int buildCounterRunQueryResponse = 0; | |
1000 buildRunQueryResponse() { | |
1001 var o = new api.RunQueryResponse(); | |
1002 buildCounterRunQueryResponse++; | |
1003 if (buildCounterRunQueryResponse < 3) { | |
1004 o.batch = buildQueryResultBatch(); | |
1005 o.query = buildQuery(); | |
1006 } | |
1007 buildCounterRunQueryResponse--; | |
1008 return o; | |
1009 } | |
1010 | |
1011 checkRunQueryResponse(api.RunQueryResponse o) { | |
1012 buildCounterRunQueryResponse++; | |
1013 if (buildCounterRunQueryResponse < 3) { | |
1014 checkQueryResultBatch(o.batch); | |
1015 checkQuery(o.query); | |
1016 } | |
1017 buildCounterRunQueryResponse--; | |
1018 } | |
1019 | |
1020 core.int buildCounterValue = 0; | |
1021 buildValue() { | |
1022 var o = new api.Value(); | |
1023 buildCounterValue++; | |
1024 if (buildCounterValue < 3) { | |
1025 o.arrayValue = buildArrayValue(); | |
1026 o.blobValue = "foo"; | |
1027 o.booleanValue = true; | |
1028 o.doubleValue = 42.0; | |
1029 o.entityValue = buildEntity(); | |
1030 o.excludeFromIndexes = true; | |
1031 o.geoPointValue = buildLatLng(); | |
1032 o.integerValue = "foo"; | |
1033 o.keyValue = buildKey(); | |
1034 o.meaning = 42; | |
1035 o.nullValue = "foo"; | |
1036 o.stringValue = "foo"; | |
1037 o.timestampValue = "foo"; | |
1038 } | |
1039 buildCounterValue--; | |
1040 return o; | |
1041 } | |
1042 | |
1043 checkValue(api.Value o) { | |
1044 buildCounterValue++; | |
1045 if (buildCounterValue < 3) { | |
1046 checkArrayValue(o.arrayValue); | |
1047 unittest.expect(o.blobValue, unittest.equals('foo')); | |
1048 unittest.expect(o.booleanValue, unittest.isTrue); | |
1049 unittest.expect(o.doubleValue, unittest.equals(42.0)); | |
1050 checkEntity(o.entityValue); | |
1051 unittest.expect(o.excludeFromIndexes, unittest.isTrue); | |
1052 checkLatLng(o.geoPointValue); | |
1053 unittest.expect(o.integerValue, unittest.equals('foo')); | |
1054 checkKey(o.keyValue); | |
1055 unittest.expect(o.meaning, unittest.equals(42)); | |
1056 unittest.expect(o.nullValue, unittest.equals('foo')); | |
1057 unittest.expect(o.stringValue, unittest.equals('foo')); | |
1058 unittest.expect(o.timestampValue, unittest.equals('foo')); | |
1059 } | |
1060 buildCounterValue--; | |
1061 } | |
1062 | |
1063 | |
1064 main() { | |
1065 unittest.group("obj-schema-AllocateIdsRequest", () { | |
1066 unittest.test("to-json--from-json", () { | |
1067 var o = buildAllocateIdsRequest(); | |
1068 var od = new api.AllocateIdsRequest.fromJson(o.toJson()); | |
1069 checkAllocateIdsRequest(od); | |
1070 }); | |
1071 }); | |
1072 | |
1073 | |
1074 unittest.group("obj-schema-AllocateIdsResponse", () { | |
1075 unittest.test("to-json--from-json", () { | |
1076 var o = buildAllocateIdsResponse(); | |
1077 var od = new api.AllocateIdsResponse.fromJson(o.toJson()); | |
1078 checkAllocateIdsResponse(od); | |
1079 }); | |
1080 }); | |
1081 | |
1082 | |
1083 unittest.group("obj-schema-ArrayValue", () { | |
1084 unittest.test("to-json--from-json", () { | |
1085 var o = buildArrayValue(); | |
1086 var od = new api.ArrayValue.fromJson(o.toJson()); | |
1087 checkArrayValue(od); | |
1088 }); | |
1089 }); | |
1090 | |
1091 | |
1092 unittest.group("obj-schema-BeginTransactionRequest", () { | |
1093 unittest.test("to-json--from-json", () { | |
1094 var o = buildBeginTransactionRequest(); | |
1095 var od = new api.BeginTransactionRequest.fromJson(o.toJson()); | |
1096 checkBeginTransactionRequest(od); | |
1097 }); | |
1098 }); | |
1099 | |
1100 | |
1101 unittest.group("obj-schema-BeginTransactionResponse", () { | |
1102 unittest.test("to-json--from-json", () { | |
1103 var o = buildBeginTransactionResponse(); | |
1104 var od = new api.BeginTransactionResponse.fromJson(o.toJson()); | |
1105 checkBeginTransactionResponse(od); | |
1106 }); | |
1107 }); | |
1108 | |
1109 | |
1110 unittest.group("obj-schema-CommitRequest", () { | |
1111 unittest.test("to-json--from-json", () { | |
1112 var o = buildCommitRequest(); | |
1113 var od = new api.CommitRequest.fromJson(o.toJson()); | |
1114 checkCommitRequest(od); | |
1115 }); | |
1116 }); | |
1117 | |
1118 | |
1119 unittest.group("obj-schema-CommitResponse", () { | |
1120 unittest.test("to-json--from-json", () { | |
1121 var o = buildCommitResponse(); | |
1122 var od = new api.CommitResponse.fromJson(o.toJson()); | |
1123 checkCommitResponse(od); | |
1124 }); | |
1125 }); | |
1126 | |
1127 | |
1128 unittest.group("obj-schema-CompositeFilter", () { | |
1129 unittest.test("to-json--from-json", () { | |
1130 var o = buildCompositeFilter(); | |
1131 var od = new api.CompositeFilter.fromJson(o.toJson()); | |
1132 checkCompositeFilter(od); | |
1133 }); | |
1134 }); | |
1135 | |
1136 | |
1137 unittest.group("obj-schema-Entity", () { | |
1138 unittest.test("to-json--from-json", () { | |
1139 var o = buildEntity(); | |
1140 var od = new api.Entity.fromJson(o.toJson()); | |
1141 checkEntity(od); | |
1142 }); | |
1143 }); | |
1144 | |
1145 | |
1146 unittest.group("obj-schema-EntityResult", () { | |
1147 unittest.test("to-json--from-json", () { | |
1148 var o = buildEntityResult(); | |
1149 var od = new api.EntityResult.fromJson(o.toJson()); | |
1150 checkEntityResult(od); | |
1151 }); | |
1152 }); | |
1153 | |
1154 | |
1155 unittest.group("obj-schema-Filter", () { | |
1156 unittest.test("to-json--from-json", () { | |
1157 var o = buildFilter(); | |
1158 var od = new api.Filter.fromJson(o.toJson()); | |
1159 checkFilter(od); | |
1160 }); | |
1161 }); | |
1162 | |
1163 | |
1164 unittest.group("obj-schema-GqlQuery", () { | |
1165 unittest.test("to-json--from-json", () { | |
1166 var o = buildGqlQuery(); | |
1167 var od = new api.GqlQuery.fromJson(o.toJson()); | |
1168 checkGqlQuery(od); | |
1169 }); | |
1170 }); | |
1171 | |
1172 | |
1173 unittest.group("obj-schema-GqlQueryParameter", () { | |
1174 unittest.test("to-json--from-json", () { | |
1175 var o = buildGqlQueryParameter(); | |
1176 var od = new api.GqlQueryParameter.fromJson(o.toJson()); | |
1177 checkGqlQueryParameter(od); | |
1178 }); | |
1179 }); | |
1180 | |
1181 | |
1182 unittest.group("obj-schema-Key", () { | |
1183 unittest.test("to-json--from-json", () { | |
1184 var o = buildKey(); | |
1185 var od = new api.Key.fromJson(o.toJson()); | |
1186 checkKey(od); | |
1187 }); | |
1188 }); | |
1189 | |
1190 | |
1191 unittest.group("obj-schema-KindExpression", () { | |
1192 unittest.test("to-json--from-json", () { | |
1193 var o = buildKindExpression(); | |
1194 var od = new api.KindExpression.fromJson(o.toJson()); | |
1195 checkKindExpression(od); | |
1196 }); | |
1197 }); | |
1198 | |
1199 | |
1200 unittest.group("obj-schema-LatLng", () { | |
1201 unittest.test("to-json--from-json", () { | |
1202 var o = buildLatLng(); | |
1203 var od = new api.LatLng.fromJson(o.toJson()); | |
1204 checkLatLng(od); | |
1205 }); | |
1206 }); | |
1207 | |
1208 | |
1209 unittest.group("obj-schema-LookupRequest", () { | |
1210 unittest.test("to-json--from-json", () { | |
1211 var o = buildLookupRequest(); | |
1212 var od = new api.LookupRequest.fromJson(o.toJson()); | |
1213 checkLookupRequest(od); | |
1214 }); | |
1215 }); | |
1216 | |
1217 | |
1218 unittest.group("obj-schema-LookupResponse", () { | |
1219 unittest.test("to-json--from-json", () { | |
1220 var o = buildLookupResponse(); | |
1221 var od = new api.LookupResponse.fromJson(o.toJson()); | |
1222 checkLookupResponse(od); | |
1223 }); | |
1224 }); | |
1225 | |
1226 | |
1227 unittest.group("obj-schema-Mutation", () { | |
1228 unittest.test("to-json--from-json", () { | |
1229 var o = buildMutation(); | |
1230 var od = new api.Mutation.fromJson(o.toJson()); | |
1231 checkMutation(od); | |
1232 }); | |
1233 }); | |
1234 | |
1235 | |
1236 unittest.group("obj-schema-MutationResult", () { | |
1237 unittest.test("to-json--from-json", () { | |
1238 var o = buildMutationResult(); | |
1239 var od = new api.MutationResult.fromJson(o.toJson()); | |
1240 checkMutationResult(od); | |
1241 }); | |
1242 }); | |
1243 | |
1244 | |
1245 unittest.group("obj-schema-PartitionId", () { | |
1246 unittest.test("to-json--from-json", () { | |
1247 var o = buildPartitionId(); | |
1248 var od = new api.PartitionId.fromJson(o.toJson()); | |
1249 checkPartitionId(od); | |
1250 }); | |
1251 }); | |
1252 | |
1253 | |
1254 unittest.group("obj-schema-PathElement", () { | |
1255 unittest.test("to-json--from-json", () { | |
1256 var o = buildPathElement(); | |
1257 var od = new api.PathElement.fromJson(o.toJson()); | |
1258 checkPathElement(od); | |
1259 }); | |
1260 }); | |
1261 | |
1262 | |
1263 unittest.group("obj-schema-Projection", () { | |
1264 unittest.test("to-json--from-json", () { | |
1265 var o = buildProjection(); | |
1266 var od = new api.Projection.fromJson(o.toJson()); | |
1267 checkProjection(od); | |
1268 }); | |
1269 }); | |
1270 | |
1271 | |
1272 unittest.group("obj-schema-PropertyFilter", () { | |
1273 unittest.test("to-json--from-json", () { | |
1274 var o = buildPropertyFilter(); | |
1275 var od = new api.PropertyFilter.fromJson(o.toJson()); | |
1276 checkPropertyFilter(od); | |
1277 }); | |
1278 }); | |
1279 | |
1280 | |
1281 unittest.group("obj-schema-PropertyOrder", () { | |
1282 unittest.test("to-json--from-json", () { | |
1283 var o = buildPropertyOrder(); | |
1284 var od = new api.PropertyOrder.fromJson(o.toJson()); | |
1285 checkPropertyOrder(od); | |
1286 }); | |
1287 }); | |
1288 | |
1289 | |
1290 unittest.group("obj-schema-PropertyReference", () { | |
1291 unittest.test("to-json--from-json", () { | |
1292 var o = buildPropertyReference(); | |
1293 var od = new api.PropertyReference.fromJson(o.toJson()); | |
1294 checkPropertyReference(od); | |
1295 }); | |
1296 }); | |
1297 | |
1298 | |
1299 unittest.group("obj-schema-Query", () { | |
1300 unittest.test("to-json--from-json", () { | |
1301 var o = buildQuery(); | |
1302 var od = new api.Query.fromJson(o.toJson()); | |
1303 checkQuery(od); | |
1304 }); | |
1305 }); | |
1306 | |
1307 | |
1308 unittest.group("obj-schema-QueryResultBatch", () { | |
1309 unittest.test("to-json--from-json", () { | |
1310 var o = buildQueryResultBatch(); | |
1311 var od = new api.QueryResultBatch.fromJson(o.toJson()); | |
1312 checkQueryResultBatch(od); | |
1313 }); | |
1314 }); | |
1315 | |
1316 | |
1317 unittest.group("obj-schema-ReadOptions", () { | |
1318 unittest.test("to-json--from-json", () { | |
1319 var o = buildReadOptions(); | |
1320 var od = new api.ReadOptions.fromJson(o.toJson()); | |
1321 checkReadOptions(od); | |
1322 }); | |
1323 }); | |
1324 | |
1325 | |
1326 unittest.group("obj-schema-RollbackRequest", () { | |
1327 unittest.test("to-json--from-json", () { | |
1328 var o = buildRollbackRequest(); | |
1329 var od = new api.RollbackRequest.fromJson(o.toJson()); | |
1330 checkRollbackRequest(od); | |
1331 }); | |
1332 }); | |
1333 | |
1334 | |
1335 unittest.group("obj-schema-RollbackResponse", () { | |
1336 unittest.test("to-json--from-json", () { | |
1337 var o = buildRollbackResponse(); | |
1338 var od = new api.RollbackResponse.fromJson(o.toJson()); | |
1339 checkRollbackResponse(od); | |
1340 }); | |
1341 }); | |
1342 | |
1343 | |
1344 unittest.group("obj-schema-RunQueryRequest", () { | |
1345 unittest.test("to-json--from-json", () { | |
1346 var o = buildRunQueryRequest(); | |
1347 var od = new api.RunQueryRequest.fromJson(o.toJson()); | |
1348 checkRunQueryRequest(od); | |
1349 }); | |
1350 }); | |
1351 | |
1352 | |
1353 unittest.group("obj-schema-RunQueryResponse", () { | |
1354 unittest.test("to-json--from-json", () { | |
1355 var o = buildRunQueryResponse(); | |
1356 var od = new api.RunQueryResponse.fromJson(o.toJson()); | |
1357 checkRunQueryResponse(od); | |
1358 }); | |
1359 }); | |
1360 | |
1361 | |
1362 unittest.group("obj-schema-Value", () { | |
1363 unittest.test("to-json--from-json", () { | |
1364 var o = buildValue(); | |
1365 var od = new api.Value.fromJson(o.toJson()); | |
1366 checkValue(od); | |
1367 }); | |
1368 }); | |
1369 | |
1370 | |
1371 unittest.group("resource-ProjectsResourceApi", () { | |
1372 unittest.test("method--allocateIds", () { | |
1373 | |
1374 var mock = new HttpServerMock(); | |
1375 api.ProjectsResourceApi res = new api.DatastoreApi(mock).projects; | |
1376 var arg_request = buildAllocateIdsRequest(); | |
1377 var arg_projectId = "foo"; | |
1378 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
1379 var obj = new api.AllocateIdsRequest.fromJson(json); | |
1380 checkAllocateIdsRequest(obj); | |
1381 | |
1382 var path = (req.url).path; | |
1383 var pathOffset = 0; | |
1384 var index; | |
1385 var subPart; | |
1386 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | |
1387 pathOffset += 1; | |
1388 unittest.expect(path.substring(pathOffset, pathOffset + 17), unittest.eq
uals("v1beta3/projects/")); | |
1389 pathOffset += 17; | |
1390 index = path.indexOf(":allocateIds", pathOffset); | |
1391 unittest.expect(index >= 0, unittest.isTrue); | |
1392 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1393 pathOffset = index; | |
1394 unittest.expect(subPart, unittest.equals("$arg_projectId")); | |
1395 unittest.expect(path.substring(pathOffset, pathOffset + 12), unittest.eq
uals(":allocateIds")); | |
1396 pathOffset += 12; | |
1397 | |
1398 var query = (req.url).query; | |
1399 var queryOffset = 0; | |
1400 var queryMap = {}; | |
1401 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
1402 parseBool(n) { | |
1403 if (n == "true") return true; | |
1404 if (n == "false") return false; | |
1405 if (n == null) return null; | |
1406 throw new core.ArgumentError("Invalid boolean: $n"); | |
1407 } | |
1408 if (query.length > 0) { | |
1409 for (var part in query.split("&")) { | |
1410 var keyvalue = part.split("="); | |
1411 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
1412 } | |
1413 } | |
1414 | |
1415 | |
1416 var h = { | |
1417 "content-type" : "application/json; charset=utf-8", | |
1418 }; | |
1419 var resp = convert.JSON.encode(buildAllocateIdsResponse()); | |
1420 return new async.Future.value(stringResponse(200, h, resp)); | |
1421 }), true); | |
1422 res.allocateIds(arg_request, arg_projectId).then(unittest.expectAsync(((ap
i.AllocateIdsResponse response) { | |
1423 checkAllocateIdsResponse(response); | |
1424 }))); | |
1425 }); | |
1426 | |
1427 unittest.test("method--beginTransaction", () { | |
1428 | |
1429 var mock = new HttpServerMock(); | |
1430 api.ProjectsResourceApi res = new api.DatastoreApi(mock).projects; | |
1431 var arg_request = buildBeginTransactionRequest(); | |
1432 var arg_projectId = "foo"; | |
1433 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
1434 var obj = new api.BeginTransactionRequest.fromJson(json); | |
1435 checkBeginTransactionRequest(obj); | |
1436 | |
1437 var path = (req.url).path; | |
1438 var pathOffset = 0; | |
1439 var index; | |
1440 var subPart; | |
1441 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | |
1442 pathOffset += 1; | |
1443 unittest.expect(path.substring(pathOffset, pathOffset + 17), unittest.eq
uals("v1beta3/projects/")); | |
1444 pathOffset += 17; | |
1445 index = path.indexOf(":beginTransaction", pathOffset); | |
1446 unittest.expect(index >= 0, unittest.isTrue); | |
1447 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1448 pathOffset = index; | |
1449 unittest.expect(subPart, unittest.equals("$arg_projectId")); | |
1450 unittest.expect(path.substring(pathOffset, pathOffset + 17), unittest.eq
uals(":beginTransaction")); | |
1451 pathOffset += 17; | |
1452 | |
1453 var query = (req.url).query; | |
1454 var queryOffset = 0; | |
1455 var queryMap = {}; | |
1456 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
1457 parseBool(n) { | |
1458 if (n == "true") return true; | |
1459 if (n == "false") return false; | |
1460 if (n == null) return null; | |
1461 throw new core.ArgumentError("Invalid boolean: $n"); | |
1462 } | |
1463 if (query.length > 0) { | |
1464 for (var part in query.split("&")) { | |
1465 var keyvalue = part.split("="); | |
1466 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
1467 } | |
1468 } | |
1469 | |
1470 | |
1471 var h = { | |
1472 "content-type" : "application/json; charset=utf-8", | |
1473 }; | |
1474 var resp = convert.JSON.encode(buildBeginTransactionResponse()); | |
1475 return new async.Future.value(stringResponse(200, h, resp)); | |
1476 }), true); | |
1477 res.beginTransaction(arg_request, arg_projectId).then(unittest.expectAsync
(((api.BeginTransactionResponse response) { | |
1478 checkBeginTransactionResponse(response); | |
1479 }))); | |
1480 }); | |
1481 | |
1482 unittest.test("method--commit", () { | |
1483 | |
1484 var mock = new HttpServerMock(); | |
1485 api.ProjectsResourceApi res = new api.DatastoreApi(mock).projects; | |
1486 var arg_request = buildCommitRequest(); | |
1487 var arg_projectId = "foo"; | |
1488 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
1489 var obj = new api.CommitRequest.fromJson(json); | |
1490 checkCommitRequest(obj); | |
1491 | |
1492 var path = (req.url).path; | |
1493 var pathOffset = 0; | |
1494 var index; | |
1495 var subPart; | |
1496 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | |
1497 pathOffset += 1; | |
1498 unittest.expect(path.substring(pathOffset, pathOffset + 17), unittest.eq
uals("v1beta3/projects/")); | |
1499 pathOffset += 17; | |
1500 index = path.indexOf(":commit", pathOffset); | |
1501 unittest.expect(index >= 0, unittest.isTrue); | |
1502 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1503 pathOffset = index; | |
1504 unittest.expect(subPart, unittest.equals("$arg_projectId")); | |
1505 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ
als(":commit")); | |
1506 pathOffset += 7; | |
1507 | |
1508 var query = (req.url).query; | |
1509 var queryOffset = 0; | |
1510 var queryMap = {}; | |
1511 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
1512 parseBool(n) { | |
1513 if (n == "true") return true; | |
1514 if (n == "false") return false; | |
1515 if (n == null) return null; | |
1516 throw new core.ArgumentError("Invalid boolean: $n"); | |
1517 } | |
1518 if (query.length > 0) { | |
1519 for (var part in query.split("&")) { | |
1520 var keyvalue = part.split("="); | |
1521 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
1522 } | |
1523 } | |
1524 | |
1525 | |
1526 var h = { | |
1527 "content-type" : "application/json; charset=utf-8", | |
1528 }; | |
1529 var resp = convert.JSON.encode(buildCommitResponse()); | |
1530 return new async.Future.value(stringResponse(200, h, resp)); | |
1531 }), true); | |
1532 res.commit(arg_request, arg_projectId).then(unittest.expectAsync(((api.Com
mitResponse response) { | |
1533 checkCommitResponse(response); | |
1534 }))); | |
1535 }); | |
1536 | |
1537 unittest.test("method--lookup", () { | |
1538 | |
1539 var mock = new HttpServerMock(); | |
1540 api.ProjectsResourceApi res = new api.DatastoreApi(mock).projects; | |
1541 var arg_request = buildLookupRequest(); | |
1542 var arg_projectId = "foo"; | |
1543 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
1544 var obj = new api.LookupRequest.fromJson(json); | |
1545 checkLookupRequest(obj); | |
1546 | |
1547 var path = (req.url).path; | |
1548 var pathOffset = 0; | |
1549 var index; | |
1550 var subPart; | |
1551 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | |
1552 pathOffset += 1; | |
1553 unittest.expect(path.substring(pathOffset, pathOffset + 17), unittest.eq
uals("v1beta3/projects/")); | |
1554 pathOffset += 17; | |
1555 index = path.indexOf(":lookup", pathOffset); | |
1556 unittest.expect(index >= 0, unittest.isTrue); | |
1557 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1558 pathOffset = index; | |
1559 unittest.expect(subPart, unittest.equals("$arg_projectId")); | |
1560 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ
als(":lookup")); | |
1561 pathOffset += 7; | |
1562 | |
1563 var query = (req.url).query; | |
1564 var queryOffset = 0; | |
1565 var queryMap = {}; | |
1566 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
1567 parseBool(n) { | |
1568 if (n == "true") return true; | |
1569 if (n == "false") return false; | |
1570 if (n == null) return null; | |
1571 throw new core.ArgumentError("Invalid boolean: $n"); | |
1572 } | |
1573 if (query.length > 0) { | |
1574 for (var part in query.split("&")) { | |
1575 var keyvalue = part.split("="); | |
1576 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
1577 } | |
1578 } | |
1579 | |
1580 | |
1581 var h = { | |
1582 "content-type" : "application/json; charset=utf-8", | |
1583 }; | |
1584 var resp = convert.JSON.encode(buildLookupResponse()); | |
1585 return new async.Future.value(stringResponse(200, h, resp)); | |
1586 }), true); | |
1587 res.lookup(arg_request, arg_projectId).then(unittest.expectAsync(((api.Loo
kupResponse response) { | |
1588 checkLookupResponse(response); | |
1589 }))); | |
1590 }); | |
1591 | |
1592 unittest.test("method--rollback", () { | |
1593 | |
1594 var mock = new HttpServerMock(); | |
1595 api.ProjectsResourceApi res = new api.DatastoreApi(mock).projects; | |
1596 var arg_request = buildRollbackRequest(); | |
1597 var arg_projectId = "foo"; | |
1598 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
1599 var obj = new api.RollbackRequest.fromJson(json); | |
1600 checkRollbackRequest(obj); | |
1601 | |
1602 var path = (req.url).path; | |
1603 var pathOffset = 0; | |
1604 var index; | |
1605 var subPart; | |
1606 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | |
1607 pathOffset += 1; | |
1608 unittest.expect(path.substring(pathOffset, pathOffset + 17), unittest.eq
uals("v1beta3/projects/")); | |
1609 pathOffset += 17; | |
1610 index = path.indexOf(":rollback", pathOffset); | |
1611 unittest.expect(index >= 0, unittest.isTrue); | |
1612 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1613 pathOffset = index; | |
1614 unittest.expect(subPart, unittest.equals("$arg_projectId")); | |
1615 unittest.expect(path.substring(pathOffset, pathOffset + 9), unittest.equ
als(":rollback")); | |
1616 pathOffset += 9; | |
1617 | |
1618 var query = (req.url).query; | |
1619 var queryOffset = 0; | |
1620 var queryMap = {}; | |
1621 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
1622 parseBool(n) { | |
1623 if (n == "true") return true; | |
1624 if (n == "false") return false; | |
1625 if (n == null) return null; | |
1626 throw new core.ArgumentError("Invalid boolean: $n"); | |
1627 } | |
1628 if (query.length > 0) { | |
1629 for (var part in query.split("&")) { | |
1630 var keyvalue = part.split("="); | |
1631 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
1632 } | |
1633 } | |
1634 | |
1635 | |
1636 var h = { | |
1637 "content-type" : "application/json; charset=utf-8", | |
1638 }; | |
1639 var resp = convert.JSON.encode(buildRollbackResponse()); | |
1640 return new async.Future.value(stringResponse(200, h, resp)); | |
1641 }), true); | |
1642 res.rollback(arg_request, arg_projectId).then(unittest.expectAsync(((api.R
ollbackResponse response) { | |
1643 checkRollbackResponse(response); | |
1644 }))); | |
1645 }); | |
1646 | |
1647 unittest.test("method--runQuery", () { | |
1648 | |
1649 var mock = new HttpServerMock(); | |
1650 api.ProjectsResourceApi res = new api.DatastoreApi(mock).projects; | |
1651 var arg_request = buildRunQueryRequest(); | |
1652 var arg_projectId = "foo"; | |
1653 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
1654 var obj = new api.RunQueryRequest.fromJson(json); | |
1655 checkRunQueryRequest(obj); | |
1656 | |
1657 var path = (req.url).path; | |
1658 var pathOffset = 0; | |
1659 var index; | |
1660 var subPart; | |
1661 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | |
1662 pathOffset += 1; | |
1663 unittest.expect(path.substring(pathOffset, pathOffset + 17), unittest.eq
uals("v1beta3/projects/")); | |
1664 pathOffset += 17; | |
1665 index = path.indexOf(":runQuery", pathOffset); | |
1666 unittest.expect(index >= 0, unittest.isTrue); | |
1667 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1668 pathOffset = index; | |
1669 unittest.expect(subPart, unittest.equals("$arg_projectId")); | |
1670 unittest.expect(path.substring(pathOffset, pathOffset + 9), unittest.equ
als(":runQuery")); | |
1671 pathOffset += 9; | |
1672 | |
1673 var query = (req.url).query; | |
1674 var queryOffset = 0; | |
1675 var queryMap = {}; | |
1676 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
1677 parseBool(n) { | |
1678 if (n == "true") return true; | |
1679 if (n == "false") return false; | |
1680 if (n == null) return null; | |
1681 throw new core.ArgumentError("Invalid boolean: $n"); | |
1682 } | |
1683 if (query.length > 0) { | |
1684 for (var part in query.split("&")) { | |
1685 var keyvalue = part.split("="); | |
1686 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
1687 } | |
1688 } | |
1689 | |
1690 | |
1691 var h = { | |
1692 "content-type" : "application/json; charset=utf-8", | |
1693 }; | |
1694 var resp = convert.JSON.encode(buildRunQueryResponse()); | |
1695 return new async.Future.value(stringResponse(200, h, resp)); | |
1696 }), true); | |
1697 res.runQuery(arg_request, arg_projectId).then(unittest.expectAsync(((api.R
unQueryResponse response) { | |
1698 checkRunQueryResponse(response); | |
1699 }))); | |
1700 }); | |
1701 | |
1702 }); | |
1703 | |
1704 | |
1705 } | |
1706 | |
OLD | NEW |