✅ Test for correct l10n in SoneModule
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 10 Jul 2019 19:43:19 +0000 (21:43 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 10 Jul 2019 19:43:19 +0000 (21:43 +0200)
src/main/kotlin/net/pterodactylus/sone/main/SoneModule.kt
src/test/kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt

index 6a349eb..18f4b95 100644 (file)
@@ -6,6 +6,7 @@ import com.google.inject.*
 import com.google.inject.matcher.*
 import com.google.inject.name.Names.*
 import com.google.inject.spi.*
+import freenet.l10n.*
 import net.pterodactylus.sone.database.*
 import net.pterodactylus.sone.database.memory.*
 import net.pterodactylus.sone.freenet.wot.*
@@ -49,6 +50,7 @@ class SoneModule(private val sonePlugin: SonePlugin) : AbstractModule() {
                bind(PluginYear::class.java).toInstance(PluginYear(sonePlugin.year))
                bind(PluginHomepage::class.java).toInstance(PluginHomepage(sonePlugin.homepage))
                bind(Database::class.java).to(MemoryDatabase::class.java).`in`(Singleton::class.java)
+               bind(BaseL10n::class.java).toInstance(sonePlugin.l10n().base)
                loaders?.let { bind(Loaders::class.java).toInstance(it) }
 
                bindListener(Matchers.any(), object : TypeListener {
index 62f947c..0b8ef04 100644 (file)
@@ -4,6 +4,7 @@ import com.google.common.base.*
 import com.google.common.eventbus.*
 import com.google.inject.Guice.*
 import com.google.inject.name.Names.*
+import freenet.l10n.*
 import net.pterodactylus.sone.database.*
 import net.pterodactylus.sone.database.memory.*
 import net.pterodactylus.sone.freenet.wot.*
@@ -12,9 +13,9 @@ import net.pterodactylus.util.config.*
 import net.pterodactylus.util.version.Version
 import org.hamcrest.MatcherAssert.*
 import org.hamcrest.Matchers.*
-import org.junit.*
 import java.io.*
 import java.util.concurrent.atomic.*
+import kotlin.test.*
 
 const val versionString = "v80"
 
@@ -24,15 +25,17 @@ class SoneModuleTest {
        private val pluginVersion = Version("", 80)
        private val pluginYear = 2019
        private val pluginHomepage = "home://page"
+       private val l10n = deepMock<PluginL10n>()
        private val sonePlugin = mock<SonePlugin>().apply {
                whenever(version).thenReturn(versionString)
                whenever(year).thenReturn(pluginYear)
                whenever(homepage).thenReturn(pluginHomepage)
+               whenever(l10n()).thenReturn(l10n)
        }
 
        private val injector by lazy { createInjector(SoneModule(sonePlugin)) }
 
-       @After
+       @AfterTest
        fun removePropertiesFromCurrentDirectory() {
                File(currentDir, "sone.properties").delete()
        }
@@ -134,6 +137,11 @@ class SoneModuleTest {
        }
 
        @Test
+       fun `base l10n is bound correctly`() {
+               assertThat(injector.getInstance(), sameInstance(l10n.base))
+       }
+
+       @Test
        fun `default loader is used without dev options`() {
                assertThat(injector.getInstance<Loaders>(), instanceOf(DefaultLoaders::class.java))
        }