+ final ArgumentCaptor<String> postIdCaptor = forClass(String.class);
+ when(sone.newPostReplyBuilder(postIdCaptor.capture())).then(new Answer<PostReplyBuilder>() {
+ @Override
+ public PostReplyBuilder answer(InvocationOnMock invocationOnMock) throws Throwable {
+ return new DefaultPostReplyBuilder(database, id, postIdCaptor.getValue());
+ }
+ });
+ return sone;
+ }
+
+ public static Sone mockRemoteSone(Core core, final String id) {
+ Sone sone = mock(Sone.class);
+ when(sone.getId()).thenReturn(id);
+ when(sone.isLocal()).thenReturn(false);
+ when(sone.getProfile()).thenReturn(new Profile(sone));
+ final Database database = core.getDatabase();
+ when(sone.newPostBuilder()).thenThrow(IllegalStateException.class);
+ when(sone.newPostReplyBuilder(Matchers.<String>anyObject())).thenThrow(IllegalStateException.class);