This is how I am mocking object of class Client
present in another project:
@Mock
private Client client;
//Mocking method of class client -
@Test
public void test()
{
Mockito.when(client.getPassportDetail(Matchers.eq(bytes),Matchers.eq(properties)))
.thenReturn(hash);
}
Structure of class Client:
class Client
{
public static boolean loadLibraries(Properties properties) {
}
public HashMap<String, String> getPassportDetail(byte[] b, Properties properties) throws Exception{
if (!loadLibraries(properties))
{
throw new UnsatisfiedLinkError();
}
}
So, when I mock getPassportDetail
method, it gets called, not mocked.