Split Sone mocking back into two separate methods again.
[Sone.git] / src / test / java / net / pterodactylus / sone / data / Mocks.java
index 0315365..5181f04 100644 (file)
@@ -65,8 +65,10 @@ public class Mocks {
        }
 
        public static Sone mockLocalSone(Core core, final String id) {
-               Sone sone = mockRemoteSone(core, id);
+               final Sone sone = mock(Sone.class);
+               when(sone.getId()).thenReturn(id);
                when(sone.isLocal()).thenReturn(true);
+               when(sone.getProfile()).thenReturn(new Profile(sone));
                final Database database = core.getDatabase();
                when(sone.newPostBuilder()).thenReturn(new DefaultPostBuilder(database, id));
                when(sone.newPostReplyBuilder(anyString())).then(new Answer<PostReplyBuilder>() {
@@ -75,6 +77,14 @@ public class Mocks {
                                return new DefaultPostReplyBuilder(database, id, (String) invocation.getArguments()[0]);
                        }
                });
+               when(core.getSone(eq(id))).thenReturn(of(sone));
+               when(database.getSone(eq(id))).thenReturn(of(sone));
+               when(sone.getPosts()).then(new Answer<List<Post>>() {
+                       @Override
+                       public List<Post> answer(InvocationOnMock invocationOnMock) throws Throwable {
+                               return from(TIME_COMPARATOR).sortedCopy(sonePosts.get(sone));
+                       }
+               });
                return sone;
        }