How to mock a final class with mockito

To mock a final class with Mockito, you can use the PowerMockito library. Here's an example of how to mock a final class with PowerMockito:

import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;

public class TestClass {
  public void testMethod() {
    FinalClass mock = PowerMockito.mock(FinalClass.class);
    // Set up mock behavior, etc.

Note that you will need to include the PowerMockito library in your project dependencies in order to use this approach.