From: David ‘Bombe’ Roden Date: Wed, 30 Jul 2014 12:20:18 +0000 (+0200) Subject: Add class that marks a reply as known. X-Git-Tag: 0.9-rc1^2~3^2~197 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=4b07fb935a4f0e756a379d96c90824df093ac988;p=Sone.git Add class that marks a reply as known. --- diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index e99c157..ffed7a9 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -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); + } + + } + } diff --git a/src/test/java/net/pterodactylus/sone/core/CoreTest.java b/src/test/java/net/pterodactylus/sone/core/CoreTest.java index 4d32298..263c2d0 100644 --- a/src/test/java/net/pterodactylus/sone/core/CoreTest.java +++ b/src/test/java/net/pterodactylus/sone/core/CoreTest.java @@ -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)); + } + }