{"action":"created","issue":{"url":"https://api.github.com/repos/mockito/mockito/issues/815","repository_url":"https://api.github.com/repos/mockito/mockito","labels_url":"https://api.github.com/repos/mockito/mockito/issues/815/labels{/name}","comments_url":"https://api.github.com/repos/mockito/mockito/issues/815/comments","events_url":"https://api.github.com/repos/mockito/mockito/issues/815/events","html_url":"https://github.com/mockito/mockito/issues/815","id":195214560,"number":815,"title":"Proposal for lambda and void friendly when+then syntax","user":{"login":"ChristianSchwarz","id":1437411,"avatar_url":"https://avatars.githubusercontent.com/u/1437411?v=3","gravatar_id":"","url":"https://api.github.com/users/ChristianSchwarz","html_url":"https://github.com/ChristianSchwarz","followers_url":"https://api.github.com/users/ChristianSchwarz/followers","following_url":"https://api.github.com/users/ChristianSchwarz/following{/other_user}","gists_url":"https://api.github.com/users/ChristianSchwarz/gists{/gist_id}","starred_url":"https://api.github.com/users/ChristianSchwarz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ChristianSchwarz/subscriptions","organizations_url":"https://api.github.com/users/ChristianSchwarz/orgs","repos_url":"https://api.github.com/users/ChristianSchwarz/repos","events_url":"https://api.github.com/users/ChristianSchwarz/events{/privacy}","received_events_url":"https://api.github.com/users/ChristianSchwarz/received_events","type":"User","site_admin":false},"labels":[{"id":493313987,"url":"https://api.github.com/repos/mockito/mockito/labels/exploring%20idea","name":"exploring idea","color":"fef2c0","default":false},{"id":195456190,"url":"https://api.github.com/repos/mockito/mockito/labels/java-8","name":"java-8","color":"AA3939","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-12-13T10:26:02Z","updated_at":"2016-12-23T00:21:17Z","closed_at":null,"body":"This is a API proposal for an \"when+then\" that can be used to stub void methods (and static calls if they will be suported in the future) with a lambda friendly \"then\" API.\r\n\r\nThis ticket relates to #643 \r\n\r\nUses case:\r\n\r\n * Stubbing using an instance method reference: `when(mock::voidMethod).then(...);`\r\n * Stubbing using an Lambda expression:` when(()-> mock.voidMethod(gt(4))).then(...);`\r\n * Possible future use case, stubbing a static method:` when(()->Util.voidMethod(4)).then(..);`\r\n * Stubbing and processing the first argument:` when(()-> mock.voidMethod(gt(4))).then(firstArg -> println(firstArg));`\r\n  * Stubbing and processing the InvocationOnMock: `when(mock::voidMethod).thenAnswer(invocation -> println(invocation.getMethod()));`\r\n\r\nThe API:\r\n```java\r\nclass Mockito{\r\n    OngoingVoidStubbing when(VoidCall call);\r\n}\r\n\r\ninterface VoidCall { \r\n    void run() throws Throwable;\r\n}\r\n\r\ninterface OngoingVoidStubbing {\r\n    OngoingVoidStubbing thenAnswer(VoidAnswer answer);\r\n    OngoingVoidStubbing then(VoidAnswer0 answer);\r\n    <A> OngoingVoidStubbing then(VoidAnswer1<A> answer);\r\n    <A,B> OngoingVoidStubbing then(VoidAnswer2<A,B> answer);\r\n    <A,B,C> OngoingVoidStubbing then(VoidAnswer3<A,B,C> answer);\r\n    OngoingVoidStubbing thenDoNothing();\r\n    //... all other thenXXX methods from OngoingStubbing except thenReturn(..)\r\n}\r\n\r\ninterface VoidAnswer{\r\n     void answer(InvocationOnMock invocation) throws Throwable;\r\n}\r\n\r\ninterface VoidAnswer0{\r\n     <A> void answer(A firstArg) throws Throwable;\r\n}\r\n```\r\n     \r\nCurrent state: I have a working prototype ([gist patch](https://gist.github.com/ChristianSchwarz/db9973bb4a7043d4db410d36b7cf87d1)), currently I can't send a PR cause I am behind a firewall."},"comment":{"url":"https://api.github.com/repos/mockito/mockito/issues/comments/268919648","html_url":"https://github.com/mockito/mockito/issues/815#issuecomment-268919648","issue_url":"https://api.github.com/repos/mockito/mockito/issues/815","id":268919648,"user":{"login":"TimvdLippe","id":5948271,"avatar_url":"https://avatars.githubusercontent.com/u/5948271?v=3","gravatar_id":"","url":"https://api.github.com/users/TimvdLippe","html_url":"https://github.com/TimvdLippe","followers_url":"https://api.github.com/users/TimvdLippe/followers","following_url":"https://api.github.com/users/TimvdLippe/following{/other_user}","gists_url":"https://api.github.com/users/TimvdLippe/gists{/gist_id}","starred_url":"https://api.github.com/users/TimvdLippe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TimvdLippe/subscriptions","organizations_url":"https://api.github.com/users/TimvdLippe/orgs","repos_url":"https://api.github.com/users/TimvdLippe/repos","events_url":"https://api.github.com/users/TimvdLippe/events{/privacy}","received_events_url":"https://api.github.com/users/TimvdLippe/received_events","type":"User","site_admin":false},"created_at":"2016-12-23T00:21:17Z","updated_at":"2016-12-23T00:21:17Z","body":"PR is at #742"}}
{"actor":{"display_login":"TimvdLippe"}}