title: Mockito mock a class that has irrelevant static methods
body: <p>I want to mock an object with Mockito of a class that has some irrelevant static methods.</p>
  
  <p>There are many questions here on stack overflow that explain that mocking static methods is not possible with Mockito. However, the static methods of the object that I need in my unit test are irrelevant for the test.</p>
  
  <p>More concretely, I want to write a unit test for a method that looks for documents in a cache and in case of a cache miss loads them from a Couchbase lite database. Unfortunately the com.couchbase.lite.Document class has some static methods and trying to mock them</p>
  
  <pre><code>Document mockDocument = Mockito.mock(Document.class);
  </code></pre>
  
  <p>results in a <code>java.lang.UnsatisfiedLinkError</code>.
  I intend to mock some of the non-static methods e.g.</p>
  
  <pre><code>doReturn("SomeString").when(mockDocument).getString("someKey");
  </code></pre>
  
  <p>but the static methods are never used, neither in the tested method nor in the unit test itself.
  Concerning Couchbase, I guess that the library is not particularly relevant for my question, just the fact that I want to mock an object of some library class which contains both, irrelevant static as well as relevant non-static methods.</p>
  
  <p><strong>Update:</strong>
  Here is the stack trace</p>
  
  <pre><code>java.lang.UnsatisfiedLinkError: com.couchbase.lite.internal.core.C4Log.setLevel(Ljava/lang/String;I)V
  
  at com.couchbase.lite.internal.core.C4Log.setLevel(Native Method)
  at com.couchbase.lite.FileLogger.setupDomainObjects(FileLogger.java:84)
  at com.couchbase.lite.FileLogger.&lt;init&gt;(FileLogger.java:47)
  at com.couchbase.lite.Log.&lt;init&gt;(Log.java:35)
  at com.couchbase.lite.AbstractDatabase.&lt;clinit&gt;(AbstractDatabase.java:80)
  at com.couchbase.lite.internal.support.Log.sendToLoggers(Log.java:401)
  at com.couchbase.lite.internal.support.Log.e(Log.java:247)
  at com.couchbase.lite.NativeLibraryLoader.load(NativeLibraryLoader.java:41)
  at com.couchbase.lite.Document.&lt;clinit&gt;(Document.java:42)
  at sun.reflect.GeneratedSerializationConstructorAccessor10.newInstance(Unknown Source)
  at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
  at org.objenesis.instantiator.sun.SunReflectionFactoryInstantiator.newInstance(SunReflectionFactoryInstantiator.java:48)
  at org.objenesis.ObjenesisBase.newInstance(ObjenesisBase.java:73)
  at org.mockito.internal.creation.instance.ObjenesisInstantiator.newInstance(ObjenesisInstantiator.java:19)
  at org.mockito.internal.creation.bytebuddy.SubclassByteBuddyMockMaker.createMock(SubclassByteBuddyMockMaker.java:47)
  at org.mockito.internal.creation.bytebuddy.ByteBuddyMockMaker.createMock(ByteBuddyMockMaker.java:25)
  at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:35)
  at org.mockito.internal.MockitoCore.mock(MockitoCore.java:63)
  at org.mockito.Mockito.mock(Mockito.java:1910)
  at org.mockito.Mockito.mock(Mockito.java:1819)
  at com.my.app.ClassOfTheTest.nameOfTheTest(ClassOfTheTest.java:1234)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:498)
  at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
  at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
  at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
  at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
  at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
  at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:48)
  at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:48)
  at org.junit.rules.RunRules.evaluate(RunRules.java:20)
  </code></pre>