Skip to content

Instantly share code, notes, and snippets.

@seratch
Created December 7, 2011 03:00
Show Gist options
  • Save seratch/1441243 to your computer and use it in GitHub Desktop.
Save seratch/1441243 to your computer and use it in GitHub Desktop.
Fixing the conflict of org.hamcrest.Matchers and org.mockito.Mathers
package tools;
import static org.mockito.Matchers.*;
/**
* Problem: cannot compile the following code
*
* <pre>
* import static org.hamcrest.Matchers.*;
* import static org.mockito.Matchers.*;
* when(myService.getSomething(any(HttpSession.class)).thenReturn("something");
* </pre>
*/
public class MockitoMatchers {
@SuppressWarnings("unchecked")
public static <T> T mockitoAny(Class<T> clazz) {
return (T) anyObject();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment