I am writing unit tests for a JestClient wrapper. I'm trying to use Mockito to mock the JestClient, but I'm getting the following error:
Mockito cannot mock this class: interface io.searchbox.client.JestClient
Mockito can only mock visible & non-final classes.
If you're not sure why you're getting this error, please report to the mailing list.
Here is how I am defining the mock:
@Bean(name = Identifiers.JEST_CLIENT)
@Profile(Identifiers.PROFILE_UNIT_TEST)
public JestClient getJestClient() {
JestClient client = Mockito.mock(JestClient.class);
return client;
}
I'm not sure why I'm getting the error, since JestClient is just an interface. I am using:
Jest: 0.1.6
Mockito: 2.0.36-beta
Spring: 4.2.4
EDIT: I think the issue is the Elasticsearch library. I was using Elasticsearch 1.5.2; when I switched to 2.2.0, the problem went away. Unfortunately, this doesn't help me, since the cluster I'm talking to runs on 1.5.2.