Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(562)

Side by Side Diff: generated/googleapis/test/tracing/v2_test.dart

Issue 2824163002: Api-roll 48: 2017-04-18 (Closed)
Patch Set: Revert changes to pubspecs Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 library googleapis.tracing.v2.test;
2
3 import "dart:core" as core;
4 import "dart:collection" as collection;
5 import "dart:async" as async;
6 import "dart:convert" as convert;
7
8 import 'package:http/http.dart' as http;
9 import 'package:http/testing.dart' as http_testing;
10 import 'package:unittest/unittest.dart' as unittest;
11
12 import 'package:googleapis/tracing/v2.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 buildUnnamed1656() {
55 var o = new core.Map<core.String, api.AttributeValue>();
56 o["x"] = buildAttributeValue();
57 o["y"] = buildAttributeValue();
58 return o;
59 }
60
61 checkUnnamed1656(core.Map<core.String, api.AttributeValue> o) {
62 unittest.expect(o, unittest.hasLength(2));
63 checkAttributeValue(o["x"]);
64 checkAttributeValue(o["y"]);
65 }
66
67 core.int buildCounterAnnotation = 0;
68 buildAnnotation() {
69 var o = new api.Annotation();
70 buildCounterAnnotation++;
71 if (buildCounterAnnotation < 3) {
72 o.attributes = buildUnnamed1656();
73 o.description = "foo";
74 }
75 buildCounterAnnotation--;
76 return o;
77 }
78
79 checkAnnotation(api.Annotation o) {
80 buildCounterAnnotation++;
81 if (buildCounterAnnotation < 3) {
82 checkUnnamed1656(o.attributes);
83 unittest.expect(o.description, unittest.equals('foo'));
84 }
85 buildCounterAnnotation--;
86 }
87
88 core.int buildCounterAttributeValue = 0;
89 buildAttributeValue() {
90 var o = new api.AttributeValue();
91 buildCounterAttributeValue++;
92 if (buildCounterAttributeValue < 3) {
93 o.boolValue = true;
94 o.intValue = "foo";
95 o.stringValue = "foo";
96 }
97 buildCounterAttributeValue--;
98 return o;
99 }
100
101 checkAttributeValue(api.AttributeValue o) {
102 buildCounterAttributeValue++;
103 if (buildCounterAttributeValue < 3) {
104 unittest.expect(o.boolValue, unittest.isTrue);
105 unittest.expect(o.intValue, unittest.equals('foo'));
106 unittest.expect(o.stringValue, unittest.equals('foo'));
107 }
108 buildCounterAttributeValue--;
109 }
110
111 buildUnnamed1657() {
112 var o = new core.List<api.Span>();
113 o.add(buildSpan());
114 o.add(buildSpan());
115 return o;
116 }
117
118 checkUnnamed1657(core.List<api.Span> o) {
119 unittest.expect(o, unittest.hasLength(2));
120 checkSpan(o[0]);
121 checkSpan(o[1]);
122 }
123
124 core.int buildCounterBatchWriteSpansRequest = 0;
125 buildBatchWriteSpansRequest() {
126 var o = new api.BatchWriteSpansRequest();
127 buildCounterBatchWriteSpansRequest++;
128 if (buildCounterBatchWriteSpansRequest < 3) {
129 o.spans = buildUnnamed1657();
130 }
131 buildCounterBatchWriteSpansRequest--;
132 return o;
133 }
134
135 checkBatchWriteSpansRequest(api.BatchWriteSpansRequest o) {
136 buildCounterBatchWriteSpansRequest++;
137 if (buildCounterBatchWriteSpansRequest < 3) {
138 checkUnnamed1657(o.spans);
139 }
140 buildCounterBatchWriteSpansRequest--;
141 }
142
143 core.int buildCounterEmpty = 0;
144 buildEmpty() {
145 var o = new api.Empty();
146 buildCounterEmpty++;
147 if (buildCounterEmpty < 3) {
148 }
149 buildCounterEmpty--;
150 return o;
151 }
152
153 checkEmpty(api.Empty o) {
154 buildCounterEmpty++;
155 if (buildCounterEmpty < 3) {
156 }
157 buildCounterEmpty--;
158 }
159
160 core.int buildCounterLink = 0;
161 buildLink() {
162 var o = new api.Link();
163 buildCounterLink++;
164 if (buildCounterLink < 3) {
165 o.spanId = "foo";
166 o.traceId = "foo";
167 o.type = "foo";
168 }
169 buildCounterLink--;
170 return o;
171 }
172
173 checkLink(api.Link o) {
174 buildCounterLink++;
175 if (buildCounterLink < 3) {
176 unittest.expect(o.spanId, unittest.equals('foo'));
177 unittest.expect(o.traceId, unittest.equals('foo'));
178 unittest.expect(o.type, unittest.equals('foo'));
179 }
180 buildCounterLink--;
181 }
182
183 buildUnnamed1658() {
184 var o = new core.List<api.Span>();
185 o.add(buildSpan());
186 o.add(buildSpan());
187 return o;
188 }
189
190 checkUnnamed1658(core.List<api.Span> o) {
191 unittest.expect(o, unittest.hasLength(2));
192 checkSpan(o[0]);
193 checkSpan(o[1]);
194 }
195
196 core.int buildCounterListSpansResponse = 0;
197 buildListSpansResponse() {
198 var o = new api.ListSpansResponse();
199 buildCounterListSpansResponse++;
200 if (buildCounterListSpansResponse < 3) {
201 o.nextPageToken = "foo";
202 o.spans = buildUnnamed1658();
203 }
204 buildCounterListSpansResponse--;
205 return o;
206 }
207
208 checkListSpansResponse(api.ListSpansResponse o) {
209 buildCounterListSpansResponse++;
210 if (buildCounterListSpansResponse < 3) {
211 unittest.expect(o.nextPageToken, unittest.equals('foo'));
212 checkUnnamed1658(o.spans);
213 }
214 buildCounterListSpansResponse--;
215 }
216
217 buildUnnamed1659() {
218 var o = new core.List<api.Trace>();
219 o.add(buildTrace());
220 o.add(buildTrace());
221 return o;
222 }
223
224 checkUnnamed1659(core.List<api.Trace> o) {
225 unittest.expect(o, unittest.hasLength(2));
226 checkTrace(o[0]);
227 checkTrace(o[1]);
228 }
229
230 core.int buildCounterListTracesResponse = 0;
231 buildListTracesResponse() {
232 var o = new api.ListTracesResponse();
233 buildCounterListTracesResponse++;
234 if (buildCounterListTracesResponse < 3) {
235 o.nextPageToken = "foo";
236 o.traces = buildUnnamed1659();
237 }
238 buildCounterListTracesResponse--;
239 return o;
240 }
241
242 checkListTracesResponse(api.ListTracesResponse o) {
243 buildCounterListTracesResponse++;
244 if (buildCounterListTracesResponse < 3) {
245 unittest.expect(o.nextPageToken, unittest.equals('foo'));
246 checkUnnamed1659(o.traces);
247 }
248 buildCounterListTracesResponse--;
249 }
250
251 core.int buildCounterModule = 0;
252 buildModule() {
253 var o = new api.Module();
254 buildCounterModule++;
255 if (buildCounterModule < 3) {
256 o.buildId = "foo";
257 o.module = "foo";
258 }
259 buildCounterModule--;
260 return o;
261 }
262
263 checkModule(api.Module o) {
264 buildCounterModule++;
265 if (buildCounterModule < 3) {
266 unittest.expect(o.buildId, unittest.equals('foo'));
267 unittest.expect(o.module, unittest.equals('foo'));
268 }
269 buildCounterModule--;
270 }
271
272 core.int buildCounterNetworkEvent = 0;
273 buildNetworkEvent() {
274 var o = new api.NetworkEvent();
275 buildCounterNetworkEvent++;
276 if (buildCounterNetworkEvent < 3) {
277 o.messageId = "foo";
278 o.messageSize = "foo";
279 o.time = "foo";
280 o.type = "foo";
281 }
282 buildCounterNetworkEvent--;
283 return o;
284 }
285
286 checkNetworkEvent(api.NetworkEvent o) {
287 buildCounterNetworkEvent++;
288 if (buildCounterNetworkEvent < 3) {
289 unittest.expect(o.messageId, unittest.equals('foo'));
290 unittest.expect(o.messageSize, unittest.equals('foo'));
291 unittest.expect(o.time, unittest.equals('foo'));
292 unittest.expect(o.type, unittest.equals('foo'));
293 }
294 buildCounterNetworkEvent--;
295 }
296
297 buildUnnamed1660() {
298 var o = new core.Map<core.String, api.AttributeValue>();
299 o["x"] = buildAttributeValue();
300 o["y"] = buildAttributeValue();
301 return o;
302 }
303
304 checkUnnamed1660(core.Map<core.String, api.AttributeValue> o) {
305 unittest.expect(o, unittest.hasLength(2));
306 checkAttributeValue(o["x"]);
307 checkAttributeValue(o["y"]);
308 }
309
310 buildUnnamed1661() {
311 var o = new core.List<api.Link>();
312 o.add(buildLink());
313 o.add(buildLink());
314 return o;
315 }
316
317 checkUnnamed1661(core.List<api.Link> o) {
318 unittest.expect(o, unittest.hasLength(2));
319 checkLink(o[0]);
320 checkLink(o[1]);
321 }
322
323 buildUnnamed1662() {
324 var o = new core.List<api.TimeEvent>();
325 o.add(buildTimeEvent());
326 o.add(buildTimeEvent());
327 return o;
328 }
329
330 checkUnnamed1662(core.List<api.TimeEvent> o) {
331 unittest.expect(o, unittest.hasLength(2));
332 checkTimeEvent(o[0]);
333 checkTimeEvent(o[1]);
334 }
335
336 core.int buildCounterSpan = 0;
337 buildSpan() {
338 var o = new api.Span();
339 buildCounterSpan++;
340 if (buildCounterSpan < 3) {
341 o.attributes = buildUnnamed1660();
342 o.displayName = "foo";
343 o.endTime = "foo";
344 o.links = buildUnnamed1661();
345 o.name = "foo";
346 o.parentSpanId = "foo";
347 o.spanId = "foo";
348 o.stackTrace = buildStackTrace();
349 o.startTime = "foo";
350 o.status = buildStatus();
351 o.timeEvents = buildUnnamed1662();
352 }
353 buildCounterSpan--;
354 return o;
355 }
356
357 checkSpan(api.Span o) {
358 buildCounterSpan++;
359 if (buildCounterSpan < 3) {
360 checkUnnamed1660(o.attributes);
361 unittest.expect(o.displayName, unittest.equals('foo'));
362 unittest.expect(o.endTime, unittest.equals('foo'));
363 checkUnnamed1661(o.links);
364 unittest.expect(o.name, unittest.equals('foo'));
365 unittest.expect(o.parentSpanId, unittest.equals('foo'));
366 unittest.expect(o.spanId, unittest.equals('foo'));
367 checkStackTrace(o.stackTrace);
368 unittest.expect(o.startTime, unittest.equals('foo'));
369 checkStatus(o.status);
370 checkUnnamed1662(o.timeEvents);
371 }
372 buildCounterSpan--;
373 }
374
375 core.int buildCounterStackFrame = 0;
376 buildStackFrame() {
377 var o = new api.StackFrame();
378 buildCounterStackFrame++;
379 if (buildCounterStackFrame < 3) {
380 o.columnNumber = "foo";
381 o.fileName = "foo";
382 o.functionName = "foo";
383 o.lineNumber = "foo";
384 o.loadModule = buildModule();
385 o.originalFunctionName = "foo";
386 o.sourceVersion = "foo";
387 }
388 buildCounterStackFrame--;
389 return o;
390 }
391
392 checkStackFrame(api.StackFrame o) {
393 buildCounterStackFrame++;
394 if (buildCounterStackFrame < 3) {
395 unittest.expect(o.columnNumber, unittest.equals('foo'));
396 unittest.expect(o.fileName, unittest.equals('foo'));
397 unittest.expect(o.functionName, unittest.equals('foo'));
398 unittest.expect(o.lineNumber, unittest.equals('foo'));
399 checkModule(o.loadModule);
400 unittest.expect(o.originalFunctionName, unittest.equals('foo'));
401 unittest.expect(o.sourceVersion, unittest.equals('foo'));
402 }
403 buildCounterStackFrame--;
404 }
405
406 buildUnnamed1663() {
407 var o = new core.List<api.StackFrame>();
408 o.add(buildStackFrame());
409 o.add(buildStackFrame());
410 return o;
411 }
412
413 checkUnnamed1663(core.List<api.StackFrame> o) {
414 unittest.expect(o, unittest.hasLength(2));
415 checkStackFrame(o[0]);
416 checkStackFrame(o[1]);
417 }
418
419 core.int buildCounterStackTrace = 0;
420 buildStackTrace() {
421 var o = new api.StackTrace();
422 buildCounterStackTrace++;
423 if (buildCounterStackTrace < 3) {
424 o.stackFrame = buildUnnamed1663();
425 o.stackTraceHashId = "foo";
426 }
427 buildCounterStackTrace--;
428 return o;
429 }
430
431 checkStackTrace(api.StackTrace o) {
432 buildCounterStackTrace++;
433 if (buildCounterStackTrace < 3) {
434 checkUnnamed1663(o.stackFrame);
435 unittest.expect(o.stackTraceHashId, unittest.equals('foo'));
436 }
437 buildCounterStackTrace--;
438 }
439
440 buildUnnamed1664() {
441 var o = new core.Map<core.String, core.Object>();
442 o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'};
443 o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'};
444 return o;
445 }
446
447 checkUnnamed1664(core.Map<core.String, core.Object> o) {
448 unittest.expect(o, unittest.hasLength(2));
449 var casted1 = (o["x"]) as core.Map; unittest.expect(casted1, unittest.hasLengt h(3)); unittest.expect(casted1["list"], unittest.equals([1, 2, 3])); unittest.ex pect(casted1["bool"], unittest.equals(true)); unittest.expect(casted1["string"], unittest.equals('foo'));
450 var casted2 = (o["y"]) as core.Map; unittest.expect(casted2, unittest.hasLengt h(3)); unittest.expect(casted2["list"], unittest.equals([1, 2, 3])); unittest.ex pect(casted2["bool"], unittest.equals(true)); unittest.expect(casted2["string"], unittest.equals('foo'));
451 }
452
453 buildUnnamed1665() {
454 var o = new core.List<core.Map<core.String, core.Object>>();
455 o.add(buildUnnamed1664());
456 o.add(buildUnnamed1664());
457 return o;
458 }
459
460 checkUnnamed1665(core.List<core.Map<core.String, core.Object>> o) {
461 unittest.expect(o, unittest.hasLength(2));
462 checkUnnamed1664(o[0]);
463 checkUnnamed1664(o[1]);
464 }
465
466 core.int buildCounterStatus = 0;
467 buildStatus() {
468 var o = new api.Status();
469 buildCounterStatus++;
470 if (buildCounterStatus < 3) {
471 o.code = 42;
472 o.details = buildUnnamed1665();
473 o.message = "foo";
474 }
475 buildCounterStatus--;
476 return o;
477 }
478
479 checkStatus(api.Status o) {
480 buildCounterStatus++;
481 if (buildCounterStatus < 3) {
482 unittest.expect(o.code, unittest.equals(42));
483 checkUnnamed1665(o.details);
484 unittest.expect(o.message, unittest.equals('foo'));
485 }
486 buildCounterStatus--;
487 }
488
489 core.int buildCounterTimeEvent = 0;
490 buildTimeEvent() {
491 var o = new api.TimeEvent();
492 buildCounterTimeEvent++;
493 if (buildCounterTimeEvent < 3) {
494 o.annotation = buildAnnotation();
495 o.networkEvent = buildNetworkEvent();
496 o.time = "foo";
497 }
498 buildCounterTimeEvent--;
499 return o;
500 }
501
502 checkTimeEvent(api.TimeEvent o) {
503 buildCounterTimeEvent++;
504 if (buildCounterTimeEvent < 3) {
505 checkAnnotation(o.annotation);
506 checkNetworkEvent(o.networkEvent);
507 unittest.expect(o.time, unittest.equals('foo'));
508 }
509 buildCounterTimeEvent--;
510 }
511
512 core.int buildCounterTrace = 0;
513 buildTrace() {
514 var o = new api.Trace();
515 buildCounterTrace++;
516 if (buildCounterTrace < 3) {
517 o.name = "foo";
518 }
519 buildCounterTrace--;
520 return o;
521 }
522
523 checkTrace(api.Trace o) {
524 buildCounterTrace++;
525 if (buildCounterTrace < 3) {
526 unittest.expect(o.name, unittest.equals('foo'));
527 }
528 buildCounterTrace--;
529 }
530
531
532 main() {
533 unittest.group("obj-schema-Annotation", () {
534 unittest.test("to-json--from-json", () {
535 var o = buildAnnotation();
536 var od = new api.Annotation.fromJson(o.toJson());
537 checkAnnotation(od);
538 });
539 });
540
541
542 unittest.group("obj-schema-AttributeValue", () {
543 unittest.test("to-json--from-json", () {
544 var o = buildAttributeValue();
545 var od = new api.AttributeValue.fromJson(o.toJson());
546 checkAttributeValue(od);
547 });
548 });
549
550
551 unittest.group("obj-schema-BatchWriteSpansRequest", () {
552 unittest.test("to-json--from-json", () {
553 var o = buildBatchWriteSpansRequest();
554 var od = new api.BatchWriteSpansRequest.fromJson(o.toJson());
555 checkBatchWriteSpansRequest(od);
556 });
557 });
558
559
560 unittest.group("obj-schema-Empty", () {
561 unittest.test("to-json--from-json", () {
562 var o = buildEmpty();
563 var od = new api.Empty.fromJson(o.toJson());
564 checkEmpty(od);
565 });
566 });
567
568
569 unittest.group("obj-schema-Link", () {
570 unittest.test("to-json--from-json", () {
571 var o = buildLink();
572 var od = new api.Link.fromJson(o.toJson());
573 checkLink(od);
574 });
575 });
576
577
578 unittest.group("obj-schema-ListSpansResponse", () {
579 unittest.test("to-json--from-json", () {
580 var o = buildListSpansResponse();
581 var od = new api.ListSpansResponse.fromJson(o.toJson());
582 checkListSpansResponse(od);
583 });
584 });
585
586
587 unittest.group("obj-schema-ListTracesResponse", () {
588 unittest.test("to-json--from-json", () {
589 var o = buildListTracesResponse();
590 var od = new api.ListTracesResponse.fromJson(o.toJson());
591 checkListTracesResponse(od);
592 });
593 });
594
595
596 unittest.group("obj-schema-Module", () {
597 unittest.test("to-json--from-json", () {
598 var o = buildModule();
599 var od = new api.Module.fromJson(o.toJson());
600 checkModule(od);
601 });
602 });
603
604
605 unittest.group("obj-schema-NetworkEvent", () {
606 unittest.test("to-json--from-json", () {
607 var o = buildNetworkEvent();
608 var od = new api.NetworkEvent.fromJson(o.toJson());
609 checkNetworkEvent(od);
610 });
611 });
612
613
614 unittest.group("obj-schema-Span", () {
615 unittest.test("to-json--from-json", () {
616 var o = buildSpan();
617 var od = new api.Span.fromJson(o.toJson());
618 checkSpan(od);
619 });
620 });
621
622
623 unittest.group("obj-schema-StackFrame", () {
624 unittest.test("to-json--from-json", () {
625 var o = buildStackFrame();
626 var od = new api.StackFrame.fromJson(o.toJson());
627 checkStackFrame(od);
628 });
629 });
630
631
632 unittest.group("obj-schema-StackTrace", () {
633 unittest.test("to-json--from-json", () {
634 var o = buildStackTrace();
635 var od = new api.StackTrace.fromJson(o.toJson());
636 checkStackTrace(od);
637 });
638 });
639
640
641 unittest.group("obj-schema-Status", () {
642 unittest.test("to-json--from-json", () {
643 var o = buildStatus();
644 var od = new api.Status.fromJson(o.toJson());
645 checkStatus(od);
646 });
647 });
648
649
650 unittest.group("obj-schema-TimeEvent", () {
651 unittest.test("to-json--from-json", () {
652 var o = buildTimeEvent();
653 var od = new api.TimeEvent.fromJson(o.toJson());
654 checkTimeEvent(od);
655 });
656 });
657
658
659 unittest.group("obj-schema-Trace", () {
660 unittest.test("to-json--from-json", () {
661 var o = buildTrace();
662 var od = new api.Trace.fromJson(o.toJson());
663 checkTrace(od);
664 });
665 });
666
667
668 unittest.group("resource-ProjectsTracesResourceApi", () {
669 unittest.test("method--batchWrite", () {
670
671 var mock = new HttpServerMock();
672 api.ProjectsTracesResourceApi res = new api.TracingApi(mock).projects.trac es;
673 var arg_request = buildBatchWriteSpansRequest();
674 var arg_name = "foo";
675 mock.register(unittest.expectAsync((http.BaseRequest req, json) {
676 var obj = new api.BatchWriteSpansRequest.fromJson(json);
677 checkBatchWriteSpansRequest(obj);
678
679 var path = (req.url).path;
680 var pathOffset = 0;
681 var index;
682 var subPart;
683 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ als("/"));
684 pathOffset += 1;
685 unittest.expect(path.substring(pathOffset, pathOffset + 3), unittest.equ als("v2/"));
686 pathOffset += 3;
687 // NOTE: We cannot test reserved expansions due to the inability to reve rse the operation;
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(buildEmpty());
711 return new async.Future.value(stringResponse(200, h, resp));
712 }), true);
713 res.batchWrite(arg_request, arg_name).then(unittest.expectAsync(((api.Empt y response) {
714 checkEmpty(response);
715 })));
716 });
717
718 unittest.test("method--list", () {
719
720 var mock = new HttpServerMock();
721 api.ProjectsTracesResourceApi res = new api.TracingApi(mock).projects.trac es;
722 var arg_parent = "foo";
723 var arg_startTime = "foo";
724 var arg_pageToken = "foo";
725 var arg_pageSize = 42;
726 var arg_orderBy = "foo";
727 var arg_filter = "foo";
728 var arg_endTime = "foo";
729 mock.register(unittest.expectAsync((http.BaseRequest req, json) {
730 var path = (req.url).path;
731 var pathOffset = 0;
732 var index;
733 var subPart;
734 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ als("/"));
735 pathOffset += 1;
736 unittest.expect(path.substring(pathOffset, pathOffset + 3), unittest.equ als("v2/"));
737 pathOffset += 3;
738 // NOTE: We cannot test reserved expansions due to the inability to reve rse the operation;
739
740 var query = (req.url).query;
741 var queryOffset = 0;
742 var queryMap = {};
743 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
744 parseBool(n) {
745 if (n == "true") return true;
746 if (n == "false") return false;
747 if (n == null) return null;
748 throw new core.ArgumentError("Invalid boolean: $n");
749 }
750 if (query.length > 0) {
751 for (var part in query.split("&")) {
752 var keyvalue = part.split("=");
753 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
754 }
755 }
756 unittest.expect(queryMap["startTime"].first, unittest.equals(arg_startTi me));
757 unittest.expect(queryMap["pageToken"].first, unittest.equals(arg_pageTok en));
758 unittest.expect(core.int.parse(queryMap["pageSize"].first), unittest.equ als(arg_pageSize));
759 unittest.expect(queryMap["orderBy"].first, unittest.equals(arg_orderBy)) ;
760 unittest.expect(queryMap["filter"].first, unittest.equals(arg_filter));
761 unittest.expect(queryMap["endTime"].first, unittest.equals(arg_endTime)) ;
762
763
764 var h = {
765 "content-type" : "application/json; charset=utf-8",
766 };
767 var resp = convert.JSON.encode(buildListTracesResponse());
768 return new async.Future.value(stringResponse(200, h, resp));
769 }), true);
770 res.list(arg_parent, startTime: arg_startTime, pageToken: arg_pageToken, p ageSize: arg_pageSize, orderBy: arg_orderBy, filter: arg_filter, endTime: arg_en dTime).then(unittest.expectAsync(((api.ListTracesResponse response) {
771 checkListTracesResponse(response);
772 })));
773 });
774
775 unittest.test("method--listSpans", () {
776
777 var mock = new HttpServerMock();
778 api.ProjectsTracesResourceApi res = new api.TracingApi(mock).projects.trac es;
779 var arg_parent = "foo";
780 var arg_pageToken = "foo";
781 mock.register(unittest.expectAsync((http.BaseRequest req, json) {
782 var path = (req.url).path;
783 var pathOffset = 0;
784 var index;
785 var subPart;
786 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ als("/"));
787 pathOffset += 1;
788 unittest.expect(path.substring(pathOffset, pathOffset + 3), unittest.equ als("v2/"));
789 pathOffset += 3;
790 // NOTE: We cannot test reserved expansions due to the inability to reve rse the operation;
791
792 var query = (req.url).query;
793 var queryOffset = 0;
794 var queryMap = {};
795 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
796 parseBool(n) {
797 if (n == "true") return true;
798 if (n == "false") return false;
799 if (n == null) return null;
800 throw new core.ArgumentError("Invalid boolean: $n");
801 }
802 if (query.length > 0) {
803 for (var part in query.split("&")) {
804 var keyvalue = part.split("=");
805 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
806 }
807 }
808 unittest.expect(queryMap["pageToken"].first, unittest.equals(arg_pageTok en));
809
810
811 var h = {
812 "content-type" : "application/json; charset=utf-8",
813 };
814 var resp = convert.JSON.encode(buildListSpansResponse());
815 return new async.Future.value(stringResponse(200, h, resp));
816 }), true);
817 res.listSpans(arg_parent, pageToken: arg_pageToken).then(unittest.expectAs ync(((api.ListSpansResponse response) {
818 checkListSpansResponse(response);
819 })));
820 });
821
822 });
823
824
825 unittest.group("resource-ProjectsTracesSpansResourceApi", () {
826 unittest.test("method--create", () {
827
828 var mock = new HttpServerMock();
829 api.ProjectsTracesSpansResourceApi res = new api.TracingApi(mock).projects .traces.spans;
830 var arg_request = buildSpan();
831 var arg_name = "foo";
832 mock.register(unittest.expectAsync((http.BaseRequest req, json) {
833 var obj = new api.Span.fromJson(json);
834 checkSpan(obj);
835
836 var path = (req.url).path;
837 var pathOffset = 0;
838 var index;
839 var subPart;
840 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ als("/"));
841 pathOffset += 1;
842 unittest.expect(path.substring(pathOffset, pathOffset + 3), unittest.equ als("v2/"));
843 pathOffset += 3;
844 // NOTE: We cannot test reserved expansions due to the inability to reve rse the operation;
845
846 var query = (req.url).query;
847 var queryOffset = 0;
848 var queryMap = {};
849 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
850 parseBool(n) {
851 if (n == "true") return true;
852 if (n == "false") return false;
853 if (n == null) return null;
854 throw new core.ArgumentError("Invalid boolean: $n");
855 }
856 if (query.length > 0) {
857 for (var part in query.split("&")) {
858 var keyvalue = part.split("=");
859 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
860 }
861 }
862
863
864 var h = {
865 "content-type" : "application/json; charset=utf-8",
866 };
867 var resp = convert.JSON.encode(buildSpan());
868 return new async.Future.value(stringResponse(200, h, resp));
869 }), true);
870 res.create(arg_request, arg_name).then(unittest.expectAsync(((api.Span res ponse) {
871 checkSpan(response);
872 })));
873 });
874
875 });
876
877
878 }
879
OLDNEW
« no previous file with comments | « generated/googleapis/test/tracing/v1_test.dart ('k') | generated/googleapis/test/translate/v2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698