8
8
import static org .assertj .core .api .Assertions .assertThat ;
9
9
10
10
import io .opentelemetry .api .common .Attributes ;
11
- import io .opentelemetry .sdk .common .InstrumentationScopeInfo ;
12
11
import org .junit .jupiter .api .Test ;
13
12
14
13
class ComponentRegistryTest {
@@ -22,83 +21,35 @@ class ComponentRegistryTest {
22
21
23
22
@ Test
24
23
void get_SameInstance () {
25
- assertThat (registry .get (InstrumentationScopeInfo .builder (NAME ).build ()))
26
- .isSameAs (registry .get (InstrumentationScopeInfo .builder (NAME ).build ()));
27
- assertThat (registry .get (InstrumentationScopeInfo .builder (NAME ).setVersion (VERSION ).build ()))
28
- .isSameAs (registry .get (InstrumentationScopeInfo .builder (NAME ).setVersion (VERSION ).build ()));
29
- assertThat (
30
- registry .get (InstrumentationScopeInfo .builder (NAME ).setSchemaUrl (SCHEMA_URL ).build ()))
24
+ assertThat (registry .get (NAME , null , null , Attributes .empty ()))
25
+ .isSameAs (registry .get (NAME , null , null , Attributes .empty ()))
26
+ .isSameAs (registry .get (NAME , null , null , Attributes .builder ().put ("k1" , "v2" ).build ()));
27
+
28
+ assertThat (registry .get (NAME , VERSION , null , Attributes .empty ()))
29
+ .isSameAs (registry .get (NAME , VERSION , null , Attributes .empty ()))
30
+ .isSameAs (registry .get (NAME , VERSION , null , Attributes .builder ().put ("k1" , "v2" ).build ()));
31
+ assertThat (registry .get (NAME , null , SCHEMA_URL , Attributes .empty ()))
32
+ .isSameAs (registry .get (NAME , null , SCHEMA_URL , Attributes .empty ()))
31
33
.isSameAs (
32
- registry .get (InstrumentationScopeInfo .builder (NAME ). setSchemaUrl ( SCHEMA_URL ).build ()));
33
- assertThat (
34
- registry .get (InstrumentationScopeInfo . builder ( NAME ). setAttributes ( ATTRIBUTES ). build ()))
34
+ registry .get (NAME , null , SCHEMA_URL , Attributes .builder (). put ( "k1" , "v2" ).build ()));
35
+ assertThat (registry . get ( NAME , VERSION , SCHEMA_URL , Attributes . empty ()))
36
+ . isSameAs ( registry .get (NAME , VERSION , SCHEMA_URL , Attributes . empty ()))
35
37
.isSameAs (
36
- registry .get (InstrumentationScopeInfo .builder (NAME ).setAttributes (ATTRIBUTES ).build ()));
37
- assertThat (
38
- registry .get (
39
- InstrumentationScopeInfo .builder (NAME )
40
- .setVersion (VERSION )
41
- .setSchemaUrl (SCHEMA_URL )
42
- .setAttributes (ATTRIBUTES )
43
- .build ()))
44
- .isSameAs (
45
- registry .get (
46
- InstrumentationScopeInfo .builder (NAME )
47
- .setVersion (VERSION )
48
- .setSchemaUrl (SCHEMA_URL )
49
- .setAttributes (ATTRIBUTES )
50
- .build ()));
38
+ registry .get (NAME , VERSION , SCHEMA_URL , Attributes .builder ().put ("k1" , "v2" ).build ()));
51
39
}
52
40
53
41
@ Test
54
42
void get_DifferentInstance () {
55
- InstrumentationScopeInfo allFields =
56
- InstrumentationScopeInfo .builder (NAME )
57
- .setVersion (VERSION )
58
- .setSchemaUrl (SCHEMA_URL )
59
- .setAttributes (ATTRIBUTES )
60
- .build ();
43
+ assertThat (registry .get (NAME , VERSION , SCHEMA_URL , ATTRIBUTES ))
44
+ .isNotSameAs (registry .get (NAME + "_1" , VERSION , SCHEMA_URL , ATTRIBUTES ))
45
+ .isNotSameAs (registry .get (NAME , VERSION + "_1" , SCHEMA_URL , ATTRIBUTES ))
46
+ .isNotSameAs (registry .get (NAME , VERSION , SCHEMA_URL + "_1" , ATTRIBUTES ));
47
+
48
+ assertThat (registry .get (NAME , VERSION , null , Attributes .empty ()))
49
+ .isNotSameAs (registry .get (NAME , null , null , Attributes .empty ()));
61
50
62
- assertThat (registry .get (allFields ))
63
- .isNotSameAs (
64
- registry .get (
65
- InstrumentationScopeInfo .builder (NAME + "_1" )
66
- .setVersion (VERSION )
67
- .setSchemaUrl (SCHEMA_URL )
68
- .setAttributes (ATTRIBUTES )
69
- .build ()));
70
- assertThat (registry .get (allFields ))
71
- .isNotSameAs (
72
- registry .get (
73
- InstrumentationScopeInfo .builder (NAME )
74
- .setVersion (VERSION + "_1" )
75
- .setSchemaUrl (SCHEMA_URL )
76
- .setAttributes (ATTRIBUTES )
77
- .build ()));
78
- assertThat (registry .get (allFields ))
79
- .isNotSameAs (
80
- registry .get (
81
- InstrumentationScopeInfo .builder (NAME )
82
- .setVersion (VERSION )
83
- .setSchemaUrl (SCHEMA_URL + "_1" )
84
- .setAttributes (ATTRIBUTES )
85
- .build ()));
86
- assertThat (registry .get (allFields ))
87
- .isNotSameAs (
88
- registry .get (
89
- InstrumentationScopeInfo .builder (NAME )
90
- .setVersion (VERSION )
91
- .setSchemaUrl (SCHEMA_URL )
92
- .setAttributes (Attributes .builder ().put ("k1" , "v2" ).build ())
93
- .build ()));
94
- assertThat (registry .get (InstrumentationScopeInfo .builder (NAME ).setVersion (VERSION ).build ()))
95
- .isNotSameAs (registry .get (InstrumentationScopeInfo .builder (NAME ).build ()));
96
- assertThat (
97
- registry .get (InstrumentationScopeInfo .builder (NAME ).setSchemaUrl (SCHEMA_URL ).build ()))
98
- .isNotSameAs (registry .get (InstrumentationScopeInfo .builder (NAME ).build ()));
99
- assertThat (
100
- registry .get (InstrumentationScopeInfo .builder (NAME ).setAttributes (ATTRIBUTES ).build ()))
101
- .isNotSameAs (registry .get (InstrumentationScopeInfo .builder (NAME ).build ()));
51
+ assertThat (registry .get (NAME , null , SCHEMA_URL , Attributes .empty ()))
52
+ .isNotSameAs (registry .get (NAME , null , null , Attributes .empty ()));
102
53
}
103
54
104
55
private static final class TestComponent {}
0 commit comments