Add class that marks a reply as known.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 30 Jul 2014 12:20:18 +0000 (14:20 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 30 Jul 2014 12:20:18 +0000 (14:20 +0200)
src/main/java/net/pterodactylus/sone/core/Core.java
src/test/java/net/pterodactylus/sone/core/CoreTest.java

index e99c157..ffed7a9 100644 (file)
@@ -1503,16 +1503,7 @@ public class Core extends AbstractService implements SoneProvider, PostProvider,
                eventBus.post(new NewPostReplyFoundEvent(reply));
                sone.addReply(reply);
                touchConfiguration();
-               localElementTicker.schedule(new Runnable() {
-
-                       /**
-                        * {@inheritDoc}
-                        */
-                       @Override
-                       public void run() {
-                               markReplyKnown(reply);
-                       }
-               }, 10, TimeUnit.SECONDS);
+               localElementTicker.schedule(new MarkReplyKnown(reply), 10, TimeUnit.SECONDS);
                return reply;
        }
 
@@ -2190,4 +2181,20 @@ public class Core extends AbstractService implements SoneProvider, PostProvider,
 
        }
 
+       @VisibleForTesting
+       class MarkReplyKnown implements Runnable {
+
+               private final PostReply postReply;
+
+               public MarkReplyKnown(PostReply postReply) {
+                       this.postReply = postReply;
+               }
+
+               @Override
+               public void run() {
+                       markReplyKnown(postReply);
+               }
+
+       }
+
 }
index 4d32298..263c2d0 100644 (file)
@@ -5,7 +5,9 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 
 import net.pterodactylus.sone.core.Core.MarkPostKnown;
+import net.pterodactylus.sone.core.Core.MarkReplyKnown;
 import net.pterodactylus.sone.data.Post;
+import net.pterodactylus.sone.data.PostReply;
 
 import org.junit.Test;
 
@@ -25,4 +27,13 @@ public class CoreTest {
                verify(core).markPostKnown(eq(post));
        }
 
+       @Test
+       public void markReplyKnownMarksReplyAsKnown() {
+               Core core = mock(Core.class);
+               PostReply postReply = mock(PostReply.class);
+               MarkReplyKnown markReplyKnown = core.new MarkReplyKnown(postReply);
+               markReplyKnown.run();
+               verify(core).markReplyKnown(eq(postReply));
+       }
+
 }