From 4834440b333d34a5cb4b365955489456cd0e5a0c Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 30 Oct 2013 07:20:06 +0100 Subject: [PATCH] Return mocked replies to a post. --- src/test/java/net/pterodactylus/sone/data/Mocks.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/test/java/net/pterodactylus/sone/data/Mocks.java b/src/test/java/net/pterodactylus/sone/data/Mocks.java index 07ca567..21e5925 100644 --- a/src/test/java/net/pterodactylus/sone/data/Mocks.java +++ b/src/test/java/net/pterodactylus/sone/data/Mocks.java @@ -38,6 +38,7 @@ import net.pterodactylus.sone.database.PostReplyBuilder; import com.google.common.base.Optional; import com.google.common.collect.FluentIterable; import com.google.common.collect.Multimap; +import com.google.common.collect.Ordering; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; @@ -50,6 +51,7 @@ public class Mocks { private final Multimap sonePosts = create(); private final Collection sones = newHashSet(); + private final Multimap postReplies = create(); public final Database database; public final Core core; @@ -158,6 +160,12 @@ public class Mocks { when(post.getSone()).thenReturn(sone); when(database.getPost(eq(id))).thenReturn(of(post)); sonePosts.put(sone, post); + when(post.getReplies()).then(new Answer>() { + @Override + public List answer(InvocationOnMock invocation) throws Throwable { + return Ordering.from(Reply.TIME_COMPARATOR).sortedCopy(postReplies.get(post)); + } + }); return post; } -- 2.7.4