forked from open-telemetry/opentelemetry-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EventDataToAnnotationTest.java
49 lines (38 loc) · 1.35 KB
/
EventDataToAnnotationTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
package io.opentelemetry.exporter.zipkin;
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.sdk.trace.data.EventData;
import org.junit.jupiter.api.Test;
class EventDataToAnnotationTest {
@Test
void basicConversion() {
Attributes attrs =
Attributes.builder()
.put("v1", "v1")
.put("v2", 12L)
.put("v3", 123.45)
.put("v4", false)
.put("v5", "foo", "bar", "baz")
.put("v6", 1, 2, 3)
.put("v7", 1.23, 3.45)
.put("v8", true, false, true)
.build();
String expected =
"\"cat\":{\"v1\":\"v1\",\"v2\":12,\"v3\":123.45,\"v4\":false,\"v5\":[\"foo\",\"bar\",\"baz\"],\"v6\":[1,2,3],\"v7\":[1.23,3.45],\"v8\":[true,false,true]}";
EventData eventData = EventData.create(0, "cat", attrs);
String result = EventDataToAnnotation.apply(eventData);
assertThat(result).isEqualTo(expected);
}
@Test
void empty() {
Attributes attrs = Attributes.empty();
String expected = "\"dog\":{}";
EventData eventData = EventData.create(0, "dog", attrs);
String result = EventDataToAnnotation.apply(eventData);
assertThat(result).isEqualTo(expected);
}
}