From: David ‘Bombe’ Roden Date: Fri, 29 Nov 2019 16:40:36 +0000 (+0100) Subject: 🚧 Start notification handler on plugin start X-Git-Tag: v81^2~15^2~1 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=9d47a44c367c5e84ce47ef72c6c3e1ca0697027d;p=Sone.git 🚧 Start notification handler on plugin start --- diff --git a/src/main/java/net/pterodactylus/sone/main/SonePlugin.java b/src/main/java/net/pterodactylus/sone/main/SonePlugin.java index 7723db1..212897a 100644 --- a/src/main/java/net/pterodactylus/sone/main/SonePlugin.java +++ b/src/main/java/net/pterodactylus/sone/main/SonePlugin.java @@ -26,6 +26,7 @@ import net.pterodactylus.sone.core.*; import net.pterodactylus.sone.fcp.*; import net.pterodactylus.sone.freenet.wot.*; import net.pterodactylus.sone.web.*; +import net.pterodactylus.sone.web.notification.NotificationHandler; import freenet.l10n.BaseL10n.*; import freenet.l10n.*; @@ -196,12 +197,14 @@ public class SonePlugin implements FredPlugin, FredPluginFCP, FredPluginL10n, Fr /* create the web interface. */ webInterface = injector.getInstance(WebInterface.class); + NotificationHandler notificationHandler = injector.getInstance(NotificationHandler.class); /* start core! */ core.start(); webInterface.start(); webInterface.setFirstStart(injector.getInstance(Key.get(Boolean.class, Names.named("FirstStart")))); webInterface.setNewConfig(injector.getInstance(Key.get(Boolean.class, Names.named("NewConfig")))); + notificationHandler.start(); } @VisibleForTesting diff --git a/src/test/kotlin/net/pterodactylus/sone/main/SonePluginTest.kt b/src/test/kotlin/net/pterodactylus/sone/main/SonePluginTest.kt index 9388cb0..eef312f 100644 --- a/src/test/kotlin/net/pterodactylus/sone/main/SonePluginTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/main/SonePluginTest.kt @@ -10,6 +10,7 @@ import net.pterodactylus.sone.fcp.* import net.pterodactylus.sone.freenet.wot.* import net.pterodactylus.sone.test.* import net.pterodactylus.sone.web.* +import net.pterodactylus.sone.web.notification.* import org.hamcrest.MatcherAssert.* import org.hamcrest.Matchers.* import org.mockito.Mockito.* @@ -64,6 +65,12 @@ class SonePluginTest { assertThat(injector.getInstance(), notNullValue()) } + @Test + fun `notification handler can be created`() { + val injector: Injector = runSonePluginWithRealInjector() + assertThat(injector.getInstance(), notNullValue()) + } + private fun runSonePluginWithRealInjector(): Injector { lateinit var injector: Injector val sonePlugin = SonePlugin { @@ -83,6 +90,13 @@ class SonePluginTest { verify(core).start() } + @Test + fun `notification handler is being started`() { + sonePlugin.runPlugin(pluginRespirator) + val notificationHandler = injector.getInstance() + verify(notificationHandler).start() + } + } private fun mockInjector() = mock().apply {