I have tried to sort this out for a week, but no luck at all. The issue is with the unit tests.
This is the class that I am trying to test:
import brave.Span;
import brave.Tracer;
@Service
public class InternetBackEndRestClient {
@Autowired
private Tracer tracer;
public PasswordJwtResponse generatePassworJwt(PasswordJwtRequest passwordJwtRequest, String traceId) throws LogonProxyException {
log.info("{\"Starting method\": \"generatePassworJwt\", \"input\": {} }", passwordJwtRequest);
Span newSpan = tracer.nextSpan().name("spanPasswordJwtResponse");
...
}
}
How can I do the unit test? Brave.Tracer is a final class so that I cannot mock it. Is there anyway to set up a context? or mock Tracer?
@RunWith(MockitoJUnitRunner.class)
public class InternetBackEndRestClientTest {
@InjectMocks
private InternetBackEndRestClient internetBackEndRestClient;
@Mock
private Tracer tracer;
@Test
public void generatePassworJwt_test() {
internetBackEndRestClient.generatePassworJwt(...);
....
}
}
Could anyone help me please?