🚧 Use ticker from Sone module for notifications
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 12 Dec 2019 19:00:47 +0000 (20:00 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 12 Dec 2019 19:00:47 +0000 (20:00 +0100)
src/main/kotlin/net/pterodactylus/sone/web/notification/NotificationHandlerModule.kt
src/main/kotlin/net/pterodactylus/sone/web/notification/SoneLockedHandler.kt
src/main/kotlin/net/pterodactylus/sone/web/notification/StartupHandler.kt
src/test/kotlin/net/pterodactylus/sone/web/notification/NotificationHandlerModuleTest.kt

index 539f001..0d7bb25 100644 (file)
@@ -77,10 +77,6 @@ class NotificationHandlerModule : AbstractModule() {
                        ListNotification<Sone>("sones-locked-notification", "sones", loaders.loadTemplate("/templates/notify/lockedSonesNotification.html"), dismissable = true)
 
        @Provides
-       fun getScheduledExecutorService(): ScheduledExecutorService =
-                       newScheduledThreadPool(1)
-
-       @Provides
        @Singleton
        @Named("localPost")
        fun getLocalPostNotification(loaders: Loaders) =
index e8f2a79..2217bad 100644 (file)
@@ -33,7 +33,7 @@ import javax.inject.*
 class SoneLockedHandler @Inject constructor(
                private val notificationManager: NotificationManager,
                @Named("soneLocked") private val notification: ListNotification<Sone>,
-               private val executor: ScheduledExecutorService) {
+               @Named("notification") private val executor: ScheduledExecutorService) {
 
        private val future: AtomicReference<ScheduledFuture<*>> = AtomicReference()
 
index c3b69f0..06acf94 100644 (file)
@@ -30,7 +30,7 @@ import javax.inject.*
 class StartupHandler @Inject constructor(
                private val notificationManager: NotificationManager,
                @Named("startup") private val notification: TemplateNotification,
-               private val ticker: ScheduledExecutorService) {
+               @Named("notification") private val ticker: ScheduledExecutorService) {
 
        @Subscribe
        fun startup(startup: Startup) {
index 477e6e3..b84b3ee 100644 (file)
@@ -34,6 +34,7 @@ import org.hamcrest.MatcherAssert.*
 import org.hamcrest.Matchers.*
 import org.mockito.Mockito.*
 import java.io.*
+import java.util.concurrent.*
 import kotlin.test.*
 
 /**
@@ -42,12 +43,14 @@ import kotlin.test.*
 class NotificationHandlerModuleTest {
 
        private val core = mock<Core>()
+       private val ticker = mock<ScheduledExecutorService>()
        private val notificationManager = NotificationManager()
        private val loaders = TestLoaders()
        private val injector: Injector = createInjector(
                        Core::class.isProvidedBy(core),
                        NotificationManager::class.isProvidedBy(notificationManager),
                        Loaders::class.isProvidedBy(loaders),
+                       ScheduledExecutorService::class.withNameIsProvidedBy(ticker, "notification"),
                        NotificationHandlerModule()
        )