From 4b07fb935a4f0e756a379d96c90824df093ac988 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 30 Jul 2014 14:20:18 +0200 Subject: [PATCH] Add class that marks a reply as known. --- .../java/net/pterodactylus/sone/core/Core.java | 27 ++++++++++++++-------- .../java/net/pterodactylus/sone/core/CoreTest.java | 11 +++++++++ 2 files changed, 28 insertions(+), 10 deletions(-) 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)); + } + } -- 2.7.4