66package io .opentelemetry .instrumentation .api .incubator .semconv .messaging ;
77
88import static org .junit .jupiter .api .Assertions .assertEquals ;
9- import static org .mockito .Mockito .lenient ;
109import static org .mockito .Mockito .when ;
1110
1211import io .opentelemetry .instrumentation .api .instrumenter .SpanNameExtractor ;
2322@ ExtendWith (MockitoExtension .class )
2423class MessagingSpanNameExtractorTest {
2524
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 ;
2833
2934 @ ParameterizedTest
3035 @ MethodSource ("spanNameParams" )
@@ -40,18 +45,18 @@ void shouldExtractSpanName(
4045
4146 when (getter .getDestinationTemplate (message )).thenReturn (destinationTemplate );
4247 if (isAnonymous ) {
43- lenient (). when (getter .isAnonymousDestination (message )).thenReturn (true );
48+ when (getter .isAnonymousDestination (message )).thenReturn (true );
4449 }
4550
4651 if (isTemporaryQueue ) {
47- lenient (). when (getter .isTemporaryDestination (message )).thenReturn (true );
52+ when (getter .isTemporaryDestination (message )).thenReturn (true );
4853 } else {
49- lenient (). when (getter .getDestination (message )).thenReturn (destinationName );
54+ when (getter .getDestination (message )).thenReturn (destinationName );
5055 }
5156 when (getter .getOperationName (message , operation )).thenReturn (operation .operationType ());
5257
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" );
5560
5661 SpanNameExtractor <Message > underTest =
5762 MessagingSpanNameExtractor .create (getter , operation , serverAttributesGetter );
0 commit comments