🎨 Add helper for simulating first start
[Sone.git] / src / test / kotlin / net / pterodactylus / sone / web / notification / NotificationHandlerModuleTest.kt
index ca52c1f..7d96208 100644 (file)
@@ -29,6 +29,7 @@ import net.pterodactylus.sone.freenet.wot.*
 import net.pterodactylus.sone.main.*
 import net.pterodactylus.sone.notify.*
 import net.pterodactylus.sone.test.*
+import net.pterodactylus.sone.text.*
 import net.pterodactylus.sone.utils.*
 import net.pterodactylus.util.notify.*
 import org.hamcrest.MatcherAssert.*
@@ -36,7 +37,6 @@ import org.hamcrest.Matchers
 import org.hamcrest.Matchers.*
 import org.mockito.*
 import org.mockito.Mockito.*
-import java.io.*
 import java.util.concurrent.*
 import java.util.concurrent.TimeUnit.*
 import java.util.function.*
@@ -58,6 +58,7 @@ class NotificationHandlerModuleTest {
                        Loaders::class.isProvidedBy(loaders),
                        WebOfTrustConnector::class.isProvidedBy(webOfTrustConnector),
                        ScheduledExecutorService::class.withNameIsProvidedBy(ticker, "notification"),
+                       SoneTextParser::class.isProvidedByMock(),
                        NotificationHandlerModule()
        )
 
@@ -73,9 +74,7 @@ class NotificationHandlerModuleTest {
 
        @Test
        fun `mark-post-known-during-first-start handler is created with correct action`() {
-               notificationManager.addNotification(object : AbstractNotification("first-start-notification") {
-                       override fun render(writer: Writer?) = Unit
-               })
+               notificationManager.firstStart()
                val handler = injector.getInstance<MarkPostKnownDuringFirstStartHandler>()
                val post = mock<Post>()
                handler.newPostFound(NewPostFoundEvent(post))
@@ -457,4 +456,9 @@ class NotificationHandlerModuleTest {
                verify(ticker).schedule(ArgumentMatchers.eq(webOfTrustPinger), ArgumentMatchers.eq(15L), ArgumentMatchers.eq(SECONDS))
        }
 
+       @Test
+       fun `sone mention detector is created as singleton`() {
+               assertThat(injector.getInstance<SoneMentionDetector>(), notNullValue())
+       }
+
 }