X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fmain%2FSonePluginTest.kt;fp=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fmain%2FSonePluginTest.kt;h=9e5158bb3eb08da0bd6037b0766cd15fc2e3bfb7;hb=4e4f20c6e94411757bef48141ea08d0132cb0e09;hp=677823c6e26352f5077350f9a13f4402392d7b7f;hpb=8bd33b61d226641aad09285e97c156d4d6e25aed;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 677823c..9e5158b 100644 --- a/src/test/kotlin/net/pterodactylus/sone/main/SonePluginTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/main/SonePluginTest.kt @@ -100,18 +100,20 @@ class SonePluginTest { assertThat(getInjected(NotificationHandler::class.java), notNullValue()) } + private class FirstStartListener(private val firstStartReceived: AtomicBoolean) { + @Subscribe + fun firstStart(firstStart: FirstStart) { + firstStartReceived.set(true) + } + } + @Test fun `first-start event is sent to event bus when first start is true`() { File("sone.properties").delete() val firstStartReceived = AtomicBoolean() runSonePluginWithRealInjector { val eventBus = it.getInstance(EventBus::class.java) - eventBus.register(object : Any() { - @Subscribe - fun firstStart(firstStart: FirstStart) { - firstStartReceived.set(true) - } - }) + eventBus.register(FirstStartListener(firstStartReceived)) } sonePlugin.runPlugin(pluginRespirator) assertThat(firstStartReceived.get(), equalTo(true)) @@ -124,12 +126,7 @@ class SonePluginTest { val firstStartReceived = AtomicBoolean() runSonePluginWithRealInjector { val eventBus = it.getInstance(EventBus::class.java) - eventBus.register(object : Any() { - @Subscribe - fun firstStart(firstStart: FirstStart) { - firstStartReceived.set(true) - } - }) + eventBus.register(FirstStartListener(firstStartReceived)) } sonePlugin.runPlugin(pluginRespirator) assertThat(firstStartReceived.get(), equalTo(false))