🎨 Reduce dependency on Node’s fields
[Sone.git] / src / test / kotlin / net / pterodactylus / sone / main / SonePluginTest.kt
index e658fe2..3983aa2 100644 (file)
@@ -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<ClientContext>())
        }
 
        @Test
@@ -108,7 +111,7 @@ class SonePluginTest {
 
        private class FirstStartListener(private val firstStartReceived: AtomicBoolean) {
                @Subscribe
-               fun firstStart(firstStart: FirstStart) {
+               fun firstStart(@Suppress("UNUSED_PARAMETER") firstStart: FirstStart) {
                        firstStartReceived.set(true)
                }
        }
@@ -139,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()
@@ -158,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 {
@@ -169,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()
@@ -183,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()
                }
        }
@@ -200,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()
                }
        }