From 3b10e05d2dbe5588cd81732499ff6576b122795e Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 29 Nov 2019 17:34:35 +0100 Subject: [PATCH] =?utf8?q?=F0=9F=9A=A7=20Add=20notification=20handler=20to?= =?utf8?q?=20web=20interface=20module?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../kotlin/net/pterodactylus/sone/web/WebInterfaceModule.kt | 7 +++++++ .../net/pterodactylus/sone/web/WebInterfaceModuleTest.kt | 13 +++++++++++++ 2 files changed, 20 insertions(+) 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)) + } + } -- 2.7.4