From 9d47a44c367c5e84ce47ef72c6c3e1ca0697027d 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:40:36 +0100 Subject: [PATCH] =?utf8?q?=F0=9F=9A=A7=20Start=20notification=20handler=20?= =?utf8?q?on=20plugin=20start?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/main/java/net/pterodactylus/sone/main/SonePlugin.java | 3 +++ .../kotlin/net/pterodactylus/sone/main/SonePluginTest.kt | 14 ++++++++++++++ 2 files changed, 17 insertions(+) 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 { -- 2.7.4