{"action":"opened","issue":{"url":"https://api.github.com/repos/henri-tremblay/mytest/issues/295","labels_url":"https://api.github.com/repos/henri-tremblay/mytest/issues/295/labels{/name}","comments_url":"https://api.github.com/repos/henri-tremblay/mytest/issues/295/comments","events_url":"https://api.github.com/repos/henri-tremblay/mytest/issues/295/events","html_url":"https://github.com/henri-tremblay/mytest/issues/295","id":83269085,"number":295,"title":"Have a capturingMatcher","user":{"login":"henri-tremblay","id":1216819,"avatar_url":"https://avatars.githubusercontent.com/u/1216819?v=3","gravatar_id":"","url":"https://api.github.com/users/henri-tremblay","html_url":"https://github.com/henri-tremblay","followers_url":"https://api.github.com/users/henri-tremblay/followers","following_url":"https://api.github.com/users/henri-tremblay/following{/other_user}","gists_url":"https://api.github.com/users/henri-tremblay/gists{/gist_id}","starred_url":"https://api.github.com/users/henri-tremblay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/henri-tremblay/subscriptions","organizations_url":"https://api.github.com/users/henri-tremblay/orgs","repos_url":"https://api.github.com/users/henri-tremblay/repos","events_url":"https://api.github.com/users/henri-tremblay/events{/privacy}","received_events_url":"https://api.github.com/users/henri-tremblay/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/henri-tremblay/mytest/labels/core","name":"core","color":"f7c6c7"},{"url":"https://api.github.com/repos/henri-tremblay/mytest/labels/enhancement","name":"enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/henri-tremblay/mytest/labels/fixed","name":"fixed","color":"c7def8"},{"url":"https://api.github.com/repos/henri-tremblay/mytest/labels/major","name":"major","color":"f7c6c7"}],"state":"open","locked":false,"assignee":{"login":"henri-tremblay","id":1216819,"avatar_url":"https://avatars.githubusercontent.com/u/1216819?v=3","gravatar_id":"","url":"https://api.github.com/users/henri-tremblay","html_url":"https://github.com/henri-tremblay","followers_url":"https://api.github.com/users/henri-tremblay/followers","following_url":"https://api.github.com/users/henri-tremblay/following{/other_user}","gists_url":"https://api.github.com/users/henri-tremblay/gists{/gist_id}","starred_url":"https://api.github.com/users/henri-tremblay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/henri-tremblay/subscriptions","organizations_url":"https://api.github.com/users/henri-tremblay/orgs","repos_url":"https://api.github.com/users/henri-tremblay/repos","events_url":"https://api.github.com/users/henri-tremblay/events{/privacy}","received_events_url":"https://api.github.com/users/henri-tremblay/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/henri-tremblay/mytest/milestones/1","html_url":"https://github.com/henri-tremblay/mytest/milestones/2.4","labels_url":"https://api.github.com/repos/henri-tremblay/mytest/milestones/1/labels","id":1139050,"number":1,"title":"2.4","description":"EasyMock 2.4","creator":{"login":"henri-tremblay","id":1216819,"avatar_url":"https://avatars.githubusercontent.com/u/1216819?v=3","gravatar_id":"","url":"https://api.github.com/users/henri-tremblay","html_url":"https://github.com/henri-tremblay","followers_url":"https://api.github.com/users/henri-tremblay/followers","following_url":"https://api.github.com/users/henri-tremblay/following{/other_user}","gists_url":"https://api.github.com/users/henri-tremblay/gists{/gist_id}","starred_url":"https://api.github.com/users/henri-tremblay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/henri-tremblay/subscriptions","organizations_url":"https://api.github.com/users/henri-tremblay/orgs","repos_url":"https://api.github.com/users/henri-tremblay/repos","events_url":"https://api.github.com/users/henri-tremblay/events{/privacy}","received_events_url":"https://api.github.com/users/henri-tremblay/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":57,"state":"closed","created_at":"2015-05-29T01:57:42Z","updated_at":"2015-06-01T02:16:58Z","due_on":"2008-07-02T04:00:00Z","closed_at":"2015-05-29T01:57:42Z"},"comments":0,"created_at":"2015-06-01T02:16:58Z","updated_at":"2015-06-01T02:16:58Z","closed_at":null,"body":"*Migrated from:* CodeHaus issue EASYMOCK-54\n*Original reporter:* Henri Tremblay\n\n---------------------------------------------------------\nSubmitted by Jan Van den Bergh.\n\nIn one of my projects I had the following (pseudo-)code I wanted to\nunit test:\n\nprivate T transformer;\n\npublic X someMethod(Y input) {\nX result = new X(...);\ntransformer.transform(input, result, ...);\n\nreturn result;\n}\n\nThe unit test had to be as complete as possible. It had to check that\na correctly initialized X was passed to the transformer and that the\nsame X was returned from the method.\n\nIn the end, I wrote a custom IArgumentMatcher that is able to capture\nthe object passed to it. A unit test looks like this:\n\npublic void testSomeMethod() {\nT transformer = createMock(T.class);\nservice.setTransformer(transformer);\n\nObjectCapture<X> capture = new ObjectCapture<X>(X.class);\nY input = new Y(...);\n\n// expected behaviour\ntransformer.transform(eq(Y), ObjectCapturer.capture(capture), ...);\nreplay(transformer);\n\n// do it\nX result = service.someMethod(input);\n\n// verify\nverify(transformer);\nassertSame(capture.getObject(), result);\n}\n\nCould you tell me if there is any other way to test this with Easymock\n(without changing the interface of the service or the transformer)?\n\nIf not, and if you're interested, I'd be happy to share this code with\nyou.\n\nSee blog: http://tapestryjava.blogspot.com/2006/02/capturing-parameters-in-easymock-20.html\n"}}