6
6
package io .opentelemetry .instrumentation .api .incubator .semconv .messaging ;
7
7
8
8
import static org .junit .jupiter .api .Assertions .assertEquals ;
9
- import static org .mockito .Mockito .lenient ;
10
9
import static org .mockito .Mockito .when ;
11
10
12
11
import io .opentelemetry .instrumentation .api .instrumenter .SpanNameExtractor ;
23
22
@ ExtendWith (MockitoExtension .class )
24
23
class MessagingSpanNameExtractorTest {
25
24
26
- @ Mock MessagingAttributesGetter <Message , Void > getter ;
27
- @ Mock ServerAttributesGetter <Message > serverAttributesGetter ;
25
+ // This test is executed in 2 modes with old and new semantic conventions
26
+ // Due to that some methods are not invoked that ofter
27
+ // Mockito can complain about that in strict mode, Lenient mode helps to run both modes
28
+ @ Mock (strictness = Mock .Strictness .LENIENT )
29
+ MessagingAttributesGetter <Message , Void > getter ;
30
+
31
+ @ Mock (strictness = Mock .Strictness .LENIENT )
32
+ ServerAttributesGetter <Message > serverAttributesGetter ;
28
33
29
34
@ ParameterizedTest
30
35
@ MethodSource ("spanNameParams" )
@@ -40,18 +45,18 @@ void shouldExtractSpanName(
40
45
41
46
when (getter .getDestinationTemplate (message )).thenReturn (destinationTemplate );
42
47
if (isAnonymous ) {
43
- lenient (). when (getter .isAnonymousDestination (message )).thenReturn (true );
48
+ when (getter .isAnonymousDestination (message )).thenReturn (true );
44
49
}
45
50
46
51
if (isTemporaryQueue ) {
47
- lenient (). when (getter .isTemporaryDestination (message )).thenReturn (true );
52
+ when (getter .isTemporaryDestination (message )).thenReturn (true );
48
53
} else {
49
- lenient (). when (getter .getDestination (message )).thenReturn (destinationName );
54
+ when (getter .getDestination (message )).thenReturn (destinationName );
50
55
}
51
56
when (getter .getOperationName (message , operation )).thenReturn (operation .operationType ());
52
57
53
- lenient (). when (serverAttributesGetter .getServerPort (message )).thenReturn (1234 );
54
- lenient (). when (serverAttributesGetter .getServerAddress (message )).thenReturn ("127.0.0.1" );
58
+ when (serverAttributesGetter .getServerPort (message )).thenReturn (1234 );
59
+ when (serverAttributesGetter .getServerAddress (message )).thenReturn ("127.0.0.1" );
55
60
56
61
SpanNameExtractor <Message > underTest =
57
62
MessagingSpanNameExtractor .create (getter , operation , serverAttributesGetter );
0 commit comments