From 4ec09048a1e0dfbd8c8f8aeed550adb80cd6d7c6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 30 Oct 2013 20:46:15 +0100 Subject: [PATCH] Mock posts with a recipient, too. --- src/test/java/net/pterodactylus/sone/data/Mocks.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/test/java/net/pterodactylus/sone/data/Mocks.java b/src/test/java/net/pterodactylus/sone/data/Mocks.java index 0aa6035..51a24fd 100644 --- a/src/test/java/net/pterodactylus/sone/data/Mocks.java +++ b/src/test/java/net/pterodactylus/sone/data/Mocks.java @@ -55,6 +55,7 @@ public class Mocks { private final Multimap sonePosts = create(); private final Collection sones = newHashSet(); private final Multimap postReplies = create(); + private final Multimap 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>() { + @Override + public Collection 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()); -- 2.7.4