Don’t use an argument captor when using an answer.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Mon, 28 Oct 2013 20:50:54 +0000 (21:50 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 28 Feb 2014 21:25:48 +0000 (22:25 +0100)
src/test/java/net/pterodactylus/sone/data/Mocks.java

index e1b9102..34aff9b 100644 (file)
@@ -63,11 +63,10 @@ public class Mocks {
                when(sone.isLocal()).thenReturn(true);
                final Database database = core.getDatabase();
                when(sone.newPostBuilder()).thenReturn(new DefaultPostBuilder(database, id));
-               final ArgumentCaptor<String> postIdCaptor = forClass(String.class);
-               when(sone.newPostReplyBuilder(postIdCaptor.capture())).then(new Answer<PostReplyBuilder>() {
+               when(sone.newPostReplyBuilder(anyString())).then(new Answer<PostReplyBuilder>() {
                        @Override
-                       public PostReplyBuilder answer(InvocationOnMock invocationOnMock) throws Throwable {
-                               return new DefaultPostReplyBuilder(database, id, postIdCaptor.getValue());
+                       public PostReplyBuilder answer(InvocationOnMock invocation) throws Throwable {
+                               return new DefaultPostReplyBuilder(database, id, (String) invocation.getArguments()[0]);
                        }
                });
                return sone;