{"action":"created","issue":{"url":"https://api.github.com/repos/hamcrest/JavaHamcrest/issues/111","repository_url":"https://api.github.com/repos/hamcrest/JavaHamcrest","labels_url":"https://api.github.com/repos/hamcrest/JavaHamcrest/issues/111/labels{/name}","comments_url":"https://api.github.com/repos/hamcrest/JavaHamcrest/issues/111/comments","events_url":"https://api.github.com/repos/hamcrest/JavaHamcrest/issues/111/events","html_url":"https://github.com/hamcrest/JavaHamcrest/issues/111","id":94583615,"number":111,"title":"Implement equals in Matchers","user":{"login":"alechenninger","id":3496559,"avatar_url":"https://avatars.githubusercontent.com/u/3496559?v=3","gravatar_id":"","url":"https://api.github.com/users/alechenninger","html_url":"https://github.com/alechenninger","followers_url":"https://api.github.com/users/alechenninger/followers","following_url":"https://api.github.com/users/alechenninger/following{/other_user}","gists_url":"https://api.github.com/users/alechenninger/gists{/gist_id}","starred_url":"https://api.github.com/users/alechenninger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alechenninger/subscriptions","organizations_url":"https://api.github.com/users/alechenninger/orgs","repos_url":"https://api.github.com/users/alechenninger/repos","events_url":"https://api.github.com/users/alechenninger/events{/privacy}","received_events_url":"https://api.github.com/users/alechenninger/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-07-12T17:23:04Z","updated_at":"2016-04-08T15:21:00Z","closed_at":null,"body":"If you have an API which uses Matcher, it is difficult to mock methods because matchers are only equal by JVM identity.\r\n\r\nie instead of...\r\n```java\r\n        when(context.findAllByUrl(Browser.class, equalTo(\"foo\"))).thenReturn(found);\r\n        assertSame(found, By.url(\"foo\").findAll(Browser.class, context));\r\n```\r\n\r\nI have to do...\r\n```java\r\n        Matcher equalToFoo = equalTo(\"foo\");\r\n        when(context.findAllByUrl(Browser.class, equalToFoo)).thenReturn(found);\r\n        assertSame(found, By.url(equalToFoo).findAll(Browser.class, context));\r\n```\r\n\r\nWith mockito this can be mitigated with using `refEq()` in the `when` stubbing, but IMHO it's easy enough for IDE's to generate good equals methods that it's not unreasonable to expect them to be implemented.\r\n\r\nCheers"},"comment":{"url":"https://api.github.com/repos/hamcrest/JavaHamcrest/issues/comments/207475992","html_url":"https://github.com/hamcrest/JavaHamcrest/issues/111#issuecomment-207475992","issue_url":"https://api.github.com/repos/hamcrest/JavaHamcrest/issues/111","id":207475992,"user":{"login":"sf105","id":141017,"avatar_url":"https://avatars.githubusercontent.com/u/141017?v=3","gravatar_id":"","url":"https://api.github.com/users/sf105","html_url":"https://github.com/sf105","followers_url":"https://api.github.com/users/sf105/followers","following_url":"https://api.github.com/users/sf105/following{/other_user}","gists_url":"https://api.github.com/users/sf105/gists{/gist_id}","starred_url":"https://api.github.com/users/sf105/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sf105/subscriptions","organizations_url":"https://api.github.com/users/sf105/orgs","repos_url":"https://api.github.com/users/sf105/repos","events_url":"https://api.github.com/users/sf105/events{/privacy}","received_events_url":"https://api.github.com/users/sf105/received_events","type":"User","site_admin":false},"created_at":"2016-04-08T15:21:00Z","updated_at":"2016-04-08T15:21:00Z","body":"Sorry, but I think this case is too obscure, plus it raises the bar for people implementing their own matchers--don't forget it needs `hashCode()` too. "}}