X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fdata%2FMocks.java;h=f1b0a09b2bf877b6306095a399d73d479b4acd7b;hb=5652f08ddbbdcc4d638c0aaa2383cadb583451c5;hp=0e8a7313de9a12dc8af394339130620790cb9456;hpb=634e4f484de3e51a55e4dae41ed8481921597733;p=Sone.git diff --git a/src/test/java/net/pterodactylus/sone/data/Mocks.java b/src/test/java/net/pterodactylus/sone/data/Mocks.java index 0e8a731..f1b0a09 100644 --- a/src/test/java/net/pterodactylus/sone/data/Mocks.java +++ b/src/test/java/net/pterodactylus/sone/data/Mocks.java @@ -64,6 +64,7 @@ public class Mocks { private final Multimap postReplies = create(); private final Multimap directedPosts = create(); private final SetMultimap postLikingSones = HashMultimap.create(); + private final SetMultimap postReplyLikingSones = HashMultimap.create(); public final Database database; public final Core core; @@ -258,16 +259,16 @@ public class Mocks { return Ordering.from(Reply.TIME_COMPARATOR).sortedCopy(postReplies.get(post)); } }); - doAnswer(new Answer() { + doAnswer(new Answer() { @Override - public Object answer(InvocationOnMock invocation) throws Throwable { + public Void answer(InvocationOnMock invocation) throws Throwable { postLikingSones.put(post, (Sone) invocation.getArguments()[0]); return null; } }).when(post).like(Matchers.any()); - doAnswer(new Answer() { + doAnswer(new Answer() { @Override - public Object answer(InvocationOnMock invocation) throws Throwable { + public Void answer(InvocationOnMock invocation) throws Throwable { postLikingSones.remove(post, (Sone) invocation.getArguments()[0]); return null; } @@ -323,6 +324,26 @@ public class Mocks { if (text.isPresent()) { when(postReply.getText()).thenReturn(text.get()); } + doAnswer(new Answer() { + @Override + public Void answer(InvocationOnMock invocation) throws Throwable { + postReplyLikingSones.put(postReply, (Sone) invocation.getArguments()[0]); + return null; + } + }).when(postReply).like(Matchers.any()); + doAnswer(new Answer() { + @Override + public Void answer(InvocationOnMock invocation) throws Throwable { + postReplyLikingSones.remove(postReply, invocation.getArguments()[0]); + return null; + } + }).when(postReply).unlike(Matchers.any()); + when(postReply.getLikes()).thenAnswer(new Answer>() { + @Override + public Set answer(InvocationOnMock invocation) throws Throwable { + return postReplyLikingSones.get(postReply); + } + }); return postReply; } }