From: David ‘Bombe’ Roden Date: Wed, 30 Oct 2013 06:20:06 +0000 (+0100) Subject: Return mocked replies to a post. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=4834440b333d34a5cb4b365955489456cd0e5a0c;p=Sone.git Return mocked replies to a post. --- 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; }