From: David ‘Bombe’ Roden Date: Fri, 29 Nov 2019 16:34:35 +0000 (+0100) Subject: 🚧 Add notification handler to web interface module X-Git-Tag: v81^2~15^2~2 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=3b10e05d2dbe5588cd81732499ff6576b122795e;p=Sone.git 🚧 Add notification handler to web interface module --- diff --git a/src/main/kotlin/net/pterodactylus/sone/web/WebInterfaceModule.kt b/src/main/kotlin/net/pterodactylus/sone/web/WebInterfaceModule.kt index 3d87aa7..63f3fc6 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/WebInterfaceModule.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/WebInterfaceModule.kt @@ -1,5 +1,6 @@ package net.pterodactylus.sone.web +import com.google.common.eventbus.* import com.google.inject.* import freenet.support.api.* import net.pterodactylus.sone.core.* @@ -10,6 +11,7 @@ import net.pterodactylus.sone.freenet.wot.* import net.pterodactylus.sone.main.* import net.pterodactylus.sone.template.* import net.pterodactylus.sone.text.* +import net.pterodactylus.sone.web.notification.* import net.pterodactylus.util.notify.* import net.pterodactylus.util.template.* import javax.inject.* @@ -132,4 +134,9 @@ class WebInterfaceModule : AbstractModule() { fun getNotificationManager() = NotificationManager() + @Provides + @Singleton + fun getNotificationHandler(eventBus: EventBus, loaders: Loaders, notificationManager: NotificationManager) = + NotificationHandler(eventBus, loaders, notificationManager) + } diff --git a/src/test/kotlin/net/pterodactylus/sone/web/WebInterfaceModuleTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/WebInterfaceModuleTest.kt index ec45e67..2bb31c9 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/WebInterfaceModuleTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/WebInterfaceModuleTest.kt @@ -14,6 +14,7 @@ import net.pterodactylus.sone.main.* import net.pterodactylus.sone.template.* import net.pterodactylus.sone.test.* import net.pterodactylus.sone.text.* +import net.pterodactylus.sone.web.notification.* import net.pterodactylus.sone.web.page.* import net.pterodactylus.util.notify.* import net.pterodactylus.util.template.* @@ -291,4 +292,16 @@ class WebInterfaceModuleTest { assertThat(firstNotificationManager, sameInstance(secondNotificationManager)) } + @Test + fun `notification handler can be created`() { + assertThat(injector.getInstance(), notNullValue()) + } + + @Test + fun `notification handler is created as singleton`() { + val firstNotificationHandler = injector.getInstance() + val secondNotificationHandler = injector.getInstance() + assertThat(firstNotificationHandler, sameInstance(secondNotificationHandler)) + } + }