🚧 Start notification handler on plugin start
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 29 Nov 2019 16:40:36 +0000 (17:40 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 29 Nov 2019 17:27:16 +0000 (18:27 +0100)
src/main/java/net/pterodactylus/sone/main/SonePlugin.java
src/test/kotlin/net/pterodactylus/sone/main/SonePluginTest.kt

index 7723db1..212897a 100644 (file)
@@ -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
index 9388cb0..eef312f 100644 (file)
@@ -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<WebOfTrustConnector>(), notNullValue())
        }
 
+       @Test
+       fun `notification handler can be created`() {
+               val injector: Injector = runSonePluginWithRealInjector()
+               assertThat(injector.getInstance<NotificationHandler>(), 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<NotificationHandler>()
+               verify(notificationHandler).start()
+       }
+
 }
 
 private fun mockInjector() = mock<Injector>().apply {