X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fmain%2FSonePluginTest.kt;h=3983aa24c7a23b4b836f09704cf8c0221429170a;hb=07643fdd510640d6c0b20963e4f4f36e06469fb5;hp=b846522a40102c925ef04955e6acc09b589800ae;hpb=1ce940852c7e96a83233bcb706d0f87a1c655c54;p=Sone.git diff --git a/src/test/kotlin/net/pterodactylus/sone/main/SonePluginTest.kt b/src/test/kotlin/net/pterodactylus/sone/main/SonePluginTest.kt index b846522..3983aa2 100644 --- a/src/test/kotlin/net/pterodactylus/sone/main/SonePluginTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/main/SonePluginTest.kt @@ -15,6 +15,7 @@ import net.pterodactylus.sone.web.* import net.pterodactylus.sone.web.notification.* import org.hamcrest.MatcherAssert.* import org.hamcrest.Matchers.* +import org.junit.experimental.categories.* import org.mockito.Mockito.* import java.io.* import java.util.concurrent.atomic.* @@ -24,6 +25,7 @@ import kotlin.test.* * Unit test for [SonePlugin]. */ @Dirty +@Category(NotParallel::class) class SonePluginTest { private var sonePlugin = SonePlugin { injector } @@ -36,6 +38,7 @@ class SonePluginTest { setField(node, "clientCore", clientCore) whenever(pluginRespirator.node).thenReturn(node) setField(clientCore, "uskManager", uskManager) + setField(clientCore, "clientContext", mock()) } @Test @@ -100,9 +103,15 @@ class SonePluginTest { assertThat(getInjected(NotificationHandler::class.java), notNullValue()) } + @Test + fun `ticker shutdown is being requested`() { + sonePlugin.runPlugin(pluginRespirator) + assertThat(getInjected(TickerShutdown::class.java), notNullValue()) + } + private class FirstStartListener(private val firstStartReceived: AtomicBoolean) { @Subscribe - fun firstStart(firstStart: FirstStart) { + fun firstStart(@Suppress("UNUSED_PARAMETER") firstStart: FirstStart) { firstStartReceived.set(true) } } @@ -133,13 +142,13 @@ class SonePluginTest { private class ConfigNotReadListener(private val configNotReadReceiver: AtomicBoolean) { @Subscribe - fun configNotRead(configNotRead: ConfigNotRead) { + fun configNotRead(@Suppress("UNUSED_PARAMETER") configNotRead: ConfigNotRead) { configNotReadReceiver.set(true) } } @Test - fun `config-not-read event is sent to event bus when new config is true`() { + fun `config-not-read event is sent to event bus when config file is invalid`() { File("sone.properties").deleteAfter { writeText("Invalid") val configNotReadReceived = AtomicBoolean() @@ -152,7 +161,7 @@ class SonePluginTest { } @Test - fun `config-not-read event is not sent to event bus when first start is true`() { + fun `config-not-read event is not sent to event bus when config file does not exist`() { File("sone.properties").delete() val configNotReadReceived = AtomicBoolean() runSonePluginWithRealInjector { @@ -163,7 +172,7 @@ class SonePluginTest { } @Test - fun `config-not-read event is not sent to event bus when new config is false`() { + fun `config-not-read event is not sent to event bus when config file is valid`() { File("sone.properties").deleteAfter { writeText("# comment") val configNotReadReceived = AtomicBoolean() @@ -177,7 +186,7 @@ class SonePluginTest { private class StartupListener(private val startupReceived: () -> Unit) { @Subscribe - fun startup(startup: Startup) { + fun startup(@Suppress("UNUSED_PARAMETER") startup: Startup) { startupReceived() } } @@ -194,7 +203,7 @@ class SonePluginTest { private class ShutdownListener(private val shutdownReceived: () -> Unit) { @Subscribe - fun shutdown(shutdown: Shutdown) { + fun shutdown(@Suppress("UNUSED_PARAMETER") shutdown: Shutdown) { shutdownReceived() } }