import net.pterodactylus.util.service.AbstractService;
import net.pterodactylus.util.thread.NamedThreadFactory;
+import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Optional;
import com.google.common.base.Predicates;
import com.google.common.collect.FluentIterable;
eventBus.post(new NewPostFoundEvent(post));
sone.addPost(post);
touchConfiguration();
- localElementTicker.schedule(new Runnable() {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void run() {
- markPostKnown(post);
- }
- }, 10, TimeUnit.SECONDS);
+ localElementTicker.schedule(new MarkPostKnown(post), 10, TimeUnit.SECONDS);
return post;
}
touchConfiguration();
}
+ @VisibleForTesting
+ class MarkPostKnown implements Runnable {
+
+ private final Post post;
+
+ public MarkPostKnown(Post post) {
+ this.post = post;
+ }
+
+ @Override
+ public void run() {
+ markPostKnown(post);
+ }
+
+ }
+
}
--- /dev/null
+package net.pterodactylus.sone.core;
+
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+import net.pterodactylus.sone.core.Core.MarkPostKnown;
+import net.pterodactylus.sone.data.Post;
+
+import org.junit.Test;
+
+/**
+ * Unit test for {@link Core} and its subclasses.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class CoreTest {
+
+ @Test
+ public void markPostKnownMarksPostAsKnown() {
+ Core core = mock(Core.class);
+ Post post = mock(Post.class);
+ MarkPostKnown markPostKnown = core.new MarkPostKnown(post);
+ markPostKnown.run();
+ verify(core).markPostKnown(eq(post));
+ }
+
+}