Mock posts with a recipient, too.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 30 Oct 2013 19:46:15 +0000 (20:46 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 28 Feb 2014 21:25:50 +0000 (22:25 +0100)
src/test/java/net/pterodactylus/sone/data/Mocks.java

index 0aa6035..51a24fd 100644 (file)
@@ -55,6 +55,7 @@ public class Mocks {
        private final Multimap<Sone, Post> sonePosts = create();
        private final Collection<Sone> sones = newHashSet();
        private final Multimap<Post, PostReply> postReplies = create();
+       private final Multimap<String, Post> directedPosts = create();
        public final Database database;
        public final Core core;
 
@@ -67,6 +68,12 @@ public class Mocks {
                                return FluentIterable.from(sones).filter(Sone.LOCAL_SONE_FILTER).toList();
                        }
                });
+               when(database.getDirectedPosts(anyString())).then(new Answer<Collection<Post>>() {
+                       @Override
+                       public Collection<Post> answer(InvocationOnMock invocation) throws Throwable {
+                               return directedPosts.get((String) invocation.getArguments()[0]);
+                       }
+               });
        }
 
        private static Core mockCore(Database database) {
@@ -216,6 +223,9 @@ public class Mocks {
                        when(post.getId()).thenReturn(id);
                        when(post.getSone()).thenReturn(sone);
                        when(post.getRecipientId()).thenReturn(recipientId);
+                       if (recipientId.isPresent()) {
+                               directedPosts.put(recipientId.get(), post);
+                       }
                        when(post.getTime()).thenReturn(time);
                        if (text.isPresent()) {
                                when(post.getText()).thenReturn(text.get());