When using verify in Mockito, all the function arguments must either be exact values or argument matchers. You cannot mix and match the two within the same verify. In other words, the following two statements are correct,
verify(mockFtpClient).rename("a.txt", "b.txt"); verify(mockFtpClient).rename(eq("a.txt"), eq("b.txt"));
But this is not
verify(mockFtpClient).rename(eq("a.txt"), "b.txt");
Today, I needed to match an anyString() and a null in the same verify statement. Mockito’s documentation didn’t have an example on how to use an argument matcher for null string. It turns out there is a hamcrest style isNull matcher in Mockito:
verify(mockFtpClient).rename(anyString(), org.mockito.Matchers.isNull(String.class));
(The above example makes no sense semantically because you’d never want to pass a null string to the FtpClient’s rename function).