OLD | NEW |
| (Empty) |
1 library googleapis.tracing.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 | |
12 import 'package:googleapis/tracing/v1.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 buildUnnamed3064() { | |
55 var o = new core.Map<core.String, api.AttributeValue>(); | |
56 o["x"] = buildAttributeValue(); | |
57 o["y"] = buildAttributeValue(); | |
58 return o; | |
59 } | |
60 | |
61 checkUnnamed3064(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 = buildUnnamed3064(); | |
73 o.description = "foo"; | |
74 } | |
75 buildCounterAnnotation--; | |
76 return o; | |
77 } | |
78 | |
79 checkAnnotation(api.Annotation o) { | |
80 buildCounterAnnotation++; | |
81 if (buildCounterAnnotation < 3) { | |
82 checkUnnamed3064(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 buildUnnamed3065() { | |
112 var o = new core.Map<core.String, api.SpanUpdates>(); | |
113 o["x"] = buildSpanUpdates(); | |
114 o["y"] = buildSpanUpdates(); | |
115 return o; | |
116 } | |
117 | |
118 checkUnnamed3065(core.Map<core.String, api.SpanUpdates> o) { | |
119 unittest.expect(o, unittest.hasLength(2)); | |
120 checkSpanUpdates(o["x"]); | |
121 checkSpanUpdates(o["y"]); | |
122 } | |
123 | |
124 core.int buildCounterBatchUpdateSpansRequest = 0; | |
125 buildBatchUpdateSpansRequest() { | |
126 var o = new api.BatchUpdateSpansRequest(); | |
127 buildCounterBatchUpdateSpansRequest++; | |
128 if (buildCounterBatchUpdateSpansRequest < 3) { | |
129 o.spanUpdates = buildUnnamed3065(); | |
130 } | |
131 buildCounterBatchUpdateSpansRequest--; | |
132 return o; | |
133 } | |
134 | |
135 checkBatchUpdateSpansRequest(api.BatchUpdateSpansRequest o) { | |
136 buildCounterBatchUpdateSpansRequest++; | |
137 if (buildCounterBatchUpdateSpansRequest < 3) { | |
138 checkUnnamed3065(o.spanUpdates); | |
139 } | |
140 buildCounterBatchUpdateSpansRequest--; | |
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 buildUnnamed3066() { | |
184 var o = new core.List<api.Span>(); | |
185 o.add(buildSpan()); | |
186 o.add(buildSpan()); | |
187 return o; | |
188 } | |
189 | |
190 checkUnnamed3066(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 = buildUnnamed3066(); | |
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 checkUnnamed3066(o.spans); | |
213 } | |
214 buildCounterListSpansResponse--; | |
215 } | |
216 | |
217 buildUnnamed3067() { | |
218 var o = new core.List<api.Trace>(); | |
219 o.add(buildTrace()); | |
220 o.add(buildTrace()); | |
221 return o; | |
222 } | |
223 | |
224 checkUnnamed3067(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 = buildUnnamed3067(); | |
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 checkUnnamed3067(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.kernelTime = "foo"; | |
278 o.messageId = "foo"; | |
279 o.messageSize = "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.kernelTime, unittest.equals('foo')); | |
290 unittest.expect(o.messageId, unittest.equals('foo')); | |
291 unittest.expect(o.messageSize, unittest.equals('foo')); | |
292 unittest.expect(o.type, unittest.equals('foo')); | |
293 } | |
294 buildCounterNetworkEvent--; | |
295 } | |
296 | |
297 buildUnnamed3068() { | |
298 var o = new core.Map<core.String, api.AttributeValue>(); | |
299 o["x"] = buildAttributeValue(); | |
300 o["y"] = buildAttributeValue(); | |
301 return o; | |
302 } | |
303 | |
304 checkUnnamed3068(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 buildUnnamed3069() { | |
311 var o = new core.List<api.Link>(); | |
312 o.add(buildLink()); | |
313 o.add(buildLink()); | |
314 return o; | |
315 } | |
316 | |
317 checkUnnamed3069(core.List<api.Link> o) { | |
318 unittest.expect(o, unittest.hasLength(2)); | |
319 checkLink(o[0]); | |
320 checkLink(o[1]); | |
321 } | |
322 | |
323 buildUnnamed3070() { | |
324 var o = new core.List<api.TimeEvent>(); | |
325 o.add(buildTimeEvent()); | |
326 o.add(buildTimeEvent()); | |
327 return o; | |
328 } | |
329 | |
330 checkUnnamed3070(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 = buildUnnamed3068(); | |
342 o.hasRemoteParent = true; | |
343 o.id = "foo"; | |
344 o.links = buildUnnamed3069(); | |
345 o.localEndTime = "foo"; | |
346 o.localStartTime = "foo"; | |
347 o.name = "foo"; | |
348 o.parentId = "foo"; | |
349 o.stackTrace = buildStackTrace(); | |
350 o.status = buildStatus(); | |
351 o.timeEvents = buildUnnamed3070(); | |
352 } | |
353 buildCounterSpan--; | |
354 return o; | |
355 } | |
356 | |
357 checkSpan(api.Span o) { | |
358 buildCounterSpan++; | |
359 if (buildCounterSpan < 3) { | |
360 checkUnnamed3068(o.attributes); | |
361 unittest.expect(o.hasRemoteParent, unittest.isTrue); | |
362 unittest.expect(o.id, unittest.equals('foo')); | |
363 checkUnnamed3069(o.links); | |
364 unittest.expect(o.localEndTime, unittest.equals('foo')); | |
365 unittest.expect(o.localStartTime, unittest.equals('foo')); | |
366 unittest.expect(o.name, unittest.equals('foo')); | |
367 unittest.expect(o.parentId, unittest.equals('foo')); | |
368 checkStackTrace(o.stackTrace); | |
369 checkStatus(o.status); | |
370 checkUnnamed3070(o.timeEvents); | |
371 } | |
372 buildCounterSpan--; | |
373 } | |
374 | |
375 buildUnnamed3071() { | |
376 var o = new core.List<api.Span>(); | |
377 o.add(buildSpan()); | |
378 o.add(buildSpan()); | |
379 return o; | |
380 } | |
381 | |
382 checkUnnamed3071(core.List<api.Span> o) { | |
383 unittest.expect(o, unittest.hasLength(2)); | |
384 checkSpan(o[0]); | |
385 checkSpan(o[1]); | |
386 } | |
387 | |
388 core.int buildCounterSpanUpdates = 0; | |
389 buildSpanUpdates() { | |
390 var o = new api.SpanUpdates(); | |
391 buildCounterSpanUpdates++; | |
392 if (buildCounterSpanUpdates < 3) { | |
393 o.spans = buildUnnamed3071(); | |
394 } | |
395 buildCounterSpanUpdates--; | |
396 return o; | |
397 } | |
398 | |
399 checkSpanUpdates(api.SpanUpdates o) { | |
400 buildCounterSpanUpdates++; | |
401 if (buildCounterSpanUpdates < 3) { | |
402 checkUnnamed3071(o.spans); | |
403 } | |
404 buildCounterSpanUpdates--; | |
405 } | |
406 | |
407 core.int buildCounterStackFrame = 0; | |
408 buildStackFrame() { | |
409 var o = new api.StackFrame(); | |
410 buildCounterStackFrame++; | |
411 if (buildCounterStackFrame < 3) { | |
412 o.columnNumber = "foo"; | |
413 o.fileName = "foo"; | |
414 o.functionName = "foo"; | |
415 o.lineNumber = "foo"; | |
416 o.loadModule = buildModule(); | |
417 o.originalFunctionName = "foo"; | |
418 o.sourceVersion = "foo"; | |
419 } | |
420 buildCounterStackFrame--; | |
421 return o; | |
422 } | |
423 | |
424 checkStackFrame(api.StackFrame o) { | |
425 buildCounterStackFrame++; | |
426 if (buildCounterStackFrame < 3) { | |
427 unittest.expect(o.columnNumber, unittest.equals('foo')); | |
428 unittest.expect(o.fileName, unittest.equals('foo')); | |
429 unittest.expect(o.functionName, unittest.equals('foo')); | |
430 unittest.expect(o.lineNumber, unittest.equals('foo')); | |
431 checkModule(o.loadModule); | |
432 unittest.expect(o.originalFunctionName, unittest.equals('foo')); | |
433 unittest.expect(o.sourceVersion, unittest.equals('foo')); | |
434 } | |
435 buildCounterStackFrame--; | |
436 } | |
437 | |
438 buildUnnamed3072() { | |
439 var o = new core.List<api.StackFrame>(); | |
440 o.add(buildStackFrame()); | |
441 o.add(buildStackFrame()); | |
442 return o; | |
443 } | |
444 | |
445 checkUnnamed3072(core.List<api.StackFrame> o) { | |
446 unittest.expect(o, unittest.hasLength(2)); | |
447 checkStackFrame(o[0]); | |
448 checkStackFrame(o[1]); | |
449 } | |
450 | |
451 core.int buildCounterStackTrace = 0; | |
452 buildStackTrace() { | |
453 var o = new api.StackTrace(); | |
454 buildCounterStackTrace++; | |
455 if (buildCounterStackTrace < 3) { | |
456 o.stackFrame = buildUnnamed3072(); | |
457 o.stackTraceHashId = "foo"; | |
458 } | |
459 buildCounterStackTrace--; | |
460 return o; | |
461 } | |
462 | |
463 checkStackTrace(api.StackTrace o) { | |
464 buildCounterStackTrace++; | |
465 if (buildCounterStackTrace < 3) { | |
466 checkUnnamed3072(o.stackFrame); | |
467 unittest.expect(o.stackTraceHashId, unittest.equals('foo')); | |
468 } | |
469 buildCounterStackTrace--; | |
470 } | |
471 | |
472 buildUnnamed3073() { | |
473 var o = new core.Map<core.String, core.Object>(); | |
474 o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; | |
475 o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; | |
476 return o; | |
477 } | |
478 | |
479 checkUnnamed3073(core.Map<core.String, core.Object> o) { | |
480 unittest.expect(o, unittest.hasLength(2)); | |
481 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')); | |
482 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')); | |
483 } | |
484 | |
485 buildUnnamed3074() { | |
486 var o = new core.List<core.Map<core.String, core.Object>>(); | |
487 o.add(buildUnnamed3073()); | |
488 o.add(buildUnnamed3073()); | |
489 return o; | |
490 } | |
491 | |
492 checkUnnamed3074(core.List<core.Map<core.String, core.Object>> o) { | |
493 unittest.expect(o, unittest.hasLength(2)); | |
494 checkUnnamed3073(o[0]); | |
495 checkUnnamed3073(o[1]); | |
496 } | |
497 | |
498 core.int buildCounterStatus = 0; | |
499 buildStatus() { | |
500 var o = new api.Status(); | |
501 buildCounterStatus++; | |
502 if (buildCounterStatus < 3) { | |
503 o.code = 42; | |
504 o.details = buildUnnamed3074(); | |
505 o.message = "foo"; | |
506 } | |
507 buildCounterStatus--; | |
508 return o; | |
509 } | |
510 | |
511 checkStatus(api.Status o) { | |
512 buildCounterStatus++; | |
513 if (buildCounterStatus < 3) { | |
514 unittest.expect(o.code, unittest.equals(42)); | |
515 checkUnnamed3074(o.details); | |
516 unittest.expect(o.message, unittest.equals('foo')); | |
517 } | |
518 buildCounterStatus--; | |
519 } | |
520 | |
521 core.int buildCounterTimeEvent = 0; | |
522 buildTimeEvent() { | |
523 var o = new api.TimeEvent(); | |
524 buildCounterTimeEvent++; | |
525 if (buildCounterTimeEvent < 3) { | |
526 o.annotation = buildAnnotation(); | |
527 o.localTime = "foo"; | |
528 o.networkEvent = buildNetworkEvent(); | |
529 } | |
530 buildCounterTimeEvent--; | |
531 return o; | |
532 } | |
533 | |
534 checkTimeEvent(api.TimeEvent o) { | |
535 buildCounterTimeEvent++; | |
536 if (buildCounterTimeEvent < 3) { | |
537 checkAnnotation(o.annotation); | |
538 unittest.expect(o.localTime, unittest.equals('foo')); | |
539 checkNetworkEvent(o.networkEvent); | |
540 } | |
541 buildCounterTimeEvent--; | |
542 } | |
543 | |
544 core.int buildCounterTrace = 0; | |
545 buildTrace() { | |
546 var o = new api.Trace(); | |
547 buildCounterTrace++; | |
548 if (buildCounterTrace < 3) { | |
549 o.name = "foo"; | |
550 } | |
551 buildCounterTrace--; | |
552 return o; | |
553 } | |
554 | |
555 checkTrace(api.Trace o) { | |
556 buildCounterTrace++; | |
557 if (buildCounterTrace < 3) { | |
558 unittest.expect(o.name, unittest.equals('foo')); | |
559 } | |
560 buildCounterTrace--; | |
561 } | |
562 | |
563 | |
564 main() { | |
565 unittest.group("obj-schema-Annotation", () { | |
566 unittest.test("to-json--from-json", () { | |
567 var o = buildAnnotation(); | |
568 var od = new api.Annotation.fromJson(o.toJson()); | |
569 checkAnnotation(od); | |
570 }); | |
571 }); | |
572 | |
573 | |
574 unittest.group("obj-schema-AttributeValue", () { | |
575 unittest.test("to-json--from-json", () { | |
576 var o = buildAttributeValue(); | |
577 var od = new api.AttributeValue.fromJson(o.toJson()); | |
578 checkAttributeValue(od); | |
579 }); | |
580 }); | |
581 | |
582 | |
583 unittest.group("obj-schema-BatchUpdateSpansRequest", () { | |
584 unittest.test("to-json--from-json", () { | |
585 var o = buildBatchUpdateSpansRequest(); | |
586 var od = new api.BatchUpdateSpansRequest.fromJson(o.toJson()); | |
587 checkBatchUpdateSpansRequest(od); | |
588 }); | |
589 }); | |
590 | |
591 | |
592 unittest.group("obj-schema-Empty", () { | |
593 unittest.test("to-json--from-json", () { | |
594 var o = buildEmpty(); | |
595 var od = new api.Empty.fromJson(o.toJson()); | |
596 checkEmpty(od); | |
597 }); | |
598 }); | |
599 | |
600 | |
601 unittest.group("obj-schema-Link", () { | |
602 unittest.test("to-json--from-json", () { | |
603 var o = buildLink(); | |
604 var od = new api.Link.fromJson(o.toJson()); | |
605 checkLink(od); | |
606 }); | |
607 }); | |
608 | |
609 | |
610 unittest.group("obj-schema-ListSpansResponse", () { | |
611 unittest.test("to-json--from-json", () { | |
612 var o = buildListSpansResponse(); | |
613 var od = new api.ListSpansResponse.fromJson(o.toJson()); | |
614 checkListSpansResponse(od); | |
615 }); | |
616 }); | |
617 | |
618 | |
619 unittest.group("obj-schema-ListTracesResponse", () { | |
620 unittest.test("to-json--from-json", () { | |
621 var o = buildListTracesResponse(); | |
622 var od = new api.ListTracesResponse.fromJson(o.toJson()); | |
623 checkListTracesResponse(od); | |
624 }); | |
625 }); | |
626 | |
627 | |
628 unittest.group("obj-schema-Module", () { | |
629 unittest.test("to-json--from-json", () { | |
630 var o = buildModule(); | |
631 var od = new api.Module.fromJson(o.toJson()); | |
632 checkModule(od); | |
633 }); | |
634 }); | |
635 | |
636 | |
637 unittest.group("obj-schema-NetworkEvent", () { | |
638 unittest.test("to-json--from-json", () { | |
639 var o = buildNetworkEvent(); | |
640 var od = new api.NetworkEvent.fromJson(o.toJson()); | |
641 checkNetworkEvent(od); | |
642 }); | |
643 }); | |
644 | |
645 | |
646 unittest.group("obj-schema-Span", () { | |
647 unittest.test("to-json--from-json", () { | |
648 var o = buildSpan(); | |
649 var od = new api.Span.fromJson(o.toJson()); | |
650 checkSpan(od); | |
651 }); | |
652 }); | |
653 | |
654 | |
655 unittest.group("obj-schema-SpanUpdates", () { | |
656 unittest.test("to-json--from-json", () { | |
657 var o = buildSpanUpdates(); | |
658 var od = new api.SpanUpdates.fromJson(o.toJson()); | |
659 checkSpanUpdates(od); | |
660 }); | |
661 }); | |
662 | |
663 | |
664 unittest.group("obj-schema-StackFrame", () { | |
665 unittest.test("to-json--from-json", () { | |
666 var o = buildStackFrame(); | |
667 var od = new api.StackFrame.fromJson(o.toJson()); | |
668 checkStackFrame(od); | |
669 }); | |
670 }); | |
671 | |
672 | |
673 unittest.group("obj-schema-StackTrace", () { | |
674 unittest.test("to-json--from-json", () { | |
675 var o = buildStackTrace(); | |
676 var od = new api.StackTrace.fromJson(o.toJson()); | |
677 checkStackTrace(od); | |
678 }); | |
679 }); | |
680 | |
681 | |
682 unittest.group("obj-schema-Status", () { | |
683 unittest.test("to-json--from-json", () { | |
684 var o = buildStatus(); | |
685 var od = new api.Status.fromJson(o.toJson()); | |
686 checkStatus(od); | |
687 }); | |
688 }); | |
689 | |
690 | |
691 unittest.group("obj-schema-TimeEvent", () { | |
692 unittest.test("to-json--from-json", () { | |
693 var o = buildTimeEvent(); | |
694 var od = new api.TimeEvent.fromJson(o.toJson()); | |
695 checkTimeEvent(od); | |
696 }); | |
697 }); | |
698 | |
699 | |
700 unittest.group("obj-schema-Trace", () { | |
701 unittest.test("to-json--from-json", () { | |
702 var o = buildTrace(); | |
703 var od = new api.Trace.fromJson(o.toJson()); | |
704 checkTrace(od); | |
705 }); | |
706 }); | |
707 | |
708 | |
709 unittest.group("resource-ProjectsTracesResourceApi", () { | |
710 unittest.test("method--batchUpdate", () { | |
711 | |
712 var mock = new HttpServerMock(); | |
713 api.ProjectsTracesResourceApi res = new api.TracingApi(mock).projects.trac
es; | |
714 var arg_request = buildBatchUpdateSpansRequest(); | |
715 var arg_parent = "foo"; | |
716 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
717 var obj = new api.BatchUpdateSpansRequest.fromJson(json); | |
718 checkBatchUpdateSpansRequest(obj); | |
719 | |
720 var path = (req.url).path; | |
721 var pathOffset = 0; | |
722 var index; | |
723 var subPart; | |
724 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | |
725 pathOffset += 1; | |
726 unittest.expect(path.substring(pathOffset, pathOffset + 3), unittest.equ
als("v1/")); | |
727 pathOffset += 3; | |
728 // NOTE: We cannot test reserved expansions due to the inability to reve
rse the operation; | |
729 | |
730 var query = (req.url).query; | |
731 var queryOffset = 0; | |
732 var queryMap = {}; | |
733 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
734 parseBool(n) { | |
735 if (n == "true") return true; | |
736 if (n == "false") return false; | |
737 if (n == null) return null; | |
738 throw new core.ArgumentError("Invalid boolean: $n"); | |
739 } | |
740 if (query.length > 0) { | |
741 for (var part in query.split("&")) { | |
742 var keyvalue = part.split("="); | |
743 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
744 } | |
745 } | |
746 | |
747 | |
748 var h = { | |
749 "content-type" : "application/json; charset=utf-8", | |
750 }; | |
751 var resp = convert.JSON.encode(buildEmpty()); | |
752 return new async.Future.value(stringResponse(200, h, resp)); | |
753 }), true); | |
754 res.batchUpdate(arg_request, arg_parent).then(unittest.expectAsync(((api.E
mpty response) { | |
755 checkEmpty(response); | |
756 }))); | |
757 }); | |
758 | |
759 unittest.test("method--get", () { | |
760 | |
761 var mock = new HttpServerMock(); | |
762 api.ProjectsTracesResourceApi res = new api.TracingApi(mock).projects.trac
es; | |
763 var arg_name = "foo"; | |
764 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
765 var path = (req.url).path; | |
766 var pathOffset = 0; | |
767 var index; | |
768 var subPart; | |
769 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | |
770 pathOffset += 1; | |
771 unittest.expect(path.substring(pathOffset, pathOffset + 3), unittest.equ
als("v1/")); | |
772 pathOffset += 3; | |
773 // NOTE: We cannot test reserved expansions due to the inability to reve
rse the operation; | |
774 | |
775 var query = (req.url).query; | |
776 var queryOffset = 0; | |
777 var queryMap = {}; | |
778 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
779 parseBool(n) { | |
780 if (n == "true") return true; | |
781 if (n == "false") return false; | |
782 if (n == null) return null; | |
783 throw new core.ArgumentError("Invalid boolean: $n"); | |
784 } | |
785 if (query.length > 0) { | |
786 for (var part in query.split("&")) { | |
787 var keyvalue = part.split("="); | |
788 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
789 } | |
790 } | |
791 | |
792 | |
793 var h = { | |
794 "content-type" : "application/json; charset=utf-8", | |
795 }; | |
796 var resp = convert.JSON.encode(buildTrace()); | |
797 return new async.Future.value(stringResponse(200, h, resp)); | |
798 }), true); | |
799 res.get(arg_name).then(unittest.expectAsync(((api.Trace response) { | |
800 checkTrace(response); | |
801 }))); | |
802 }); | |
803 | |
804 unittest.test("method--list", () { | |
805 | |
806 var mock = new HttpServerMock(); | |
807 api.ProjectsTracesResourceApi res = new api.TracingApi(mock).projects.trac
es; | |
808 var arg_parent = "foo"; | |
809 var arg_filter = "foo"; | |
810 var arg_endTime = "foo"; | |
811 var arg_startTime = "foo"; | |
812 var arg_pageToken = "foo"; | |
813 var arg_pageSize = 42; | |
814 var arg_orderBy = "foo"; | |
815 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
816 var path = (req.url).path; | |
817 var pathOffset = 0; | |
818 var index; | |
819 var subPart; | |
820 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | |
821 pathOffset += 1; | |
822 unittest.expect(path.substring(pathOffset, pathOffset + 3), unittest.equ
als("v1/")); | |
823 pathOffset += 3; | |
824 // NOTE: We cannot test reserved expansions due to the inability to reve
rse the operation; | |
825 | |
826 var query = (req.url).query; | |
827 var queryOffset = 0; | |
828 var queryMap = {}; | |
829 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
830 parseBool(n) { | |
831 if (n == "true") return true; | |
832 if (n == "false") return false; | |
833 if (n == null) return null; | |
834 throw new core.ArgumentError("Invalid boolean: $n"); | |
835 } | |
836 if (query.length > 0) { | |
837 for (var part in query.split("&")) { | |
838 var keyvalue = part.split("="); | |
839 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
840 } | |
841 } | |
842 unittest.expect(queryMap["filter"].first, unittest.equals(arg_filter)); | |
843 unittest.expect(queryMap["endTime"].first, unittest.equals(arg_endTime))
; | |
844 unittest.expect(queryMap["startTime"].first, unittest.equals(arg_startTi
me)); | |
845 unittest.expect(queryMap["pageToken"].first, unittest.equals(arg_pageTok
en)); | |
846 unittest.expect(core.int.parse(queryMap["pageSize"].first), unittest.equ
als(arg_pageSize)); | |
847 unittest.expect(queryMap["orderBy"].first, unittest.equals(arg_orderBy))
; | |
848 | |
849 | |
850 var h = { | |
851 "content-type" : "application/json; charset=utf-8", | |
852 }; | |
853 var resp = convert.JSON.encode(buildListTracesResponse()); | |
854 return new async.Future.value(stringResponse(200, h, resp)); | |
855 }), true); | |
856 res.list(arg_parent, filter: arg_filter, endTime: arg_endTime, startTime:
arg_startTime, pageToken: arg_pageToken, pageSize: arg_pageSize, orderBy: arg_or
derBy).then(unittest.expectAsync(((api.ListTracesResponse response) { | |
857 checkListTracesResponse(response); | |
858 }))); | |
859 }); | |
860 | |
861 unittest.test("method--listSpans", () { | |
862 | |
863 var mock = new HttpServerMock(); | |
864 api.ProjectsTracesResourceApi res = new api.TracingApi(mock).projects.trac
es; | |
865 var arg_name = "foo"; | |
866 var arg_pageToken = "foo"; | |
867 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
868 var path = (req.url).path; | |
869 var pathOffset = 0; | |
870 var index; | |
871 var subPart; | |
872 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | |
873 pathOffset += 1; | |
874 unittest.expect(path.substring(pathOffset, pathOffset + 3), unittest.equ
als("v1/")); | |
875 pathOffset += 3; | |
876 // NOTE: We cannot test reserved expansions due to the inability to reve
rse the operation; | |
877 | |
878 var query = (req.url).query; | |
879 var queryOffset = 0; | |
880 var queryMap = {}; | |
881 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
882 parseBool(n) { | |
883 if (n == "true") return true; | |
884 if (n == "false") return false; | |
885 if (n == null) return null; | |
886 throw new core.ArgumentError("Invalid boolean: $n"); | |
887 } | |
888 if (query.length > 0) { | |
889 for (var part in query.split("&")) { | |
890 var keyvalue = part.split("="); | |
891 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
892 } | |
893 } | |
894 unittest.expect(queryMap["pageToken"].first, unittest.equals(arg_pageTok
en)); | |
895 | |
896 | |
897 var h = { | |
898 "content-type" : "application/json; charset=utf-8", | |
899 }; | |
900 var resp = convert.JSON.encode(buildListSpansResponse()); | |
901 return new async.Future.value(stringResponse(200, h, resp)); | |
902 }), true); | |
903 res.listSpans(arg_name, pageToken: arg_pageToken).then(unittest.expectAsyn
c(((api.ListSpansResponse response) { | |
904 checkListSpansResponse(response); | |
905 }))); | |
906 }); | |
907 | |
908 }); | |
909 | |
910 | |
911 } | |
912 | |
OLD | NEW |