Move reply like functionality from Sone to Reply.
[Sone.git] / src / test / java / net / pterodactylus / sone / data / Mocks.java
index 0e8a731..f1b0a09 100644 (file)
@@ -64,6 +64,7 @@ public class Mocks {
        private final Multimap<Post, PostReply> postReplies = create();
        private final Multimap<String, Post> directedPosts = create();
        private final SetMultimap<Post, Sone> postLikingSones = HashMultimap.create();
+       private final SetMultimap<PostReply, Sone> 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<Void>() {
                                @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.<Sone>any());
-                       doAnswer(new Answer() {
+                       doAnswer(new Answer<Void>() {
                                @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<Void>() {
+                               @Override
+                               public Void answer(InvocationOnMock invocation) throws Throwable {
+                                       postReplyLikingSones.put(postReply, (Sone) invocation.getArguments()[0]);
+                                       return null;
+                               }
+                       }).when(postReply).like(Matchers.<Sone>any());
+                       doAnswer(new Answer<Void>() {
+                               @Override
+                               public Void answer(InvocationOnMock invocation) throws Throwable {
+                                       postReplyLikingSones.remove(postReply, invocation.getArguments()[0]);
+                                       return null;
+                               }
+                       }).when(postReply).unlike(Matchers.<Sone>any());
+                       when(postReply.getLikes()).thenAnswer(new Answer<Set<Sone>>() {
+                               @Override
+                               public Set<Sone> answer(InvocationOnMock invocation) throws Throwable {
+                                       return postReplyLikingSones.get(postReply);
+                               }
+                       });
                        return postReply;
                }
        }