0

I am testing a function which would involve static method. so I am using powermock and mockito.

the original static method takes 3 arguments:

RSAHelper.RSADecrypt(AppHelper.getApplicationContext(), LibUtil.getDecryptionKeyName(), Base64.decode(encryptedData, Base64.DEFAULT));

so I am using

when(RSAHelper.RSADecrypt(any(), any(), eq(Base64.decode(GOOD_ENCRYPTION_STRING, Base64.DEFAULT)))).thenReturn(userData);

but this causes:

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: Invalid use of argument matchers! 3 matchers expected, 1 recorded:

and when I am using

when(RSAHelper.RSADecrypt(any(), any(), any())).thenReturn(userData)

and this works, but I just want to return different value based on third parameter. Since I already use matchers for all three parameters, I dont know where I was wrong is use the first way of impelemtation. need help. thanks

  • Show us your static imports. I mean "import static ..." lines - maybe your eq is imported from e.g. hamcrest and not Mockito? – Krzysztof Krasoń Mar 27 '18 at 07:30
  • import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.when; – Chen Adam Mar 27 '18 at 07:33
  • Please take a look on https://stackoverflow.com/questions/31948463/getting-invaliduseofmatchersexception-from-call-to-verify-even-though-all-argu – Volodymyr Demenkov Mar 27 '18 at 07:35

0 Answers0