X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FTestObjects.kt;fp=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FTestObjects.kt;h=f9025330e52f23c62ad58cd05b775045f1f4e7d1;hp=a42e5babf05f2c00b3b95e12a31d8fcac0c34ab5;hb=d5cd41949b7e62fdc40ef7390661dcda8c18a139;hpb=f46c1adf87d003ada9950708e94c9da9737e2d8d diff --git a/src/test/kotlin/net/pterodactylus/sone/web/ajax/TestObjects.kt b/src/test/kotlin/net/pterodactylus/sone/web/ajax/TestObjects.kt index a42e5ba..f902533 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/ajax/TestObjects.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/ajax/TestObjects.kt @@ -3,7 +3,6 @@ package net.pterodactylus.sone.web.ajax import com.fasterxml.jackson.databind.ObjectMapper import com.google.common.eventbus.EventBus import freenet.clients.http.ToadletContext -import freenet.l10n.BaseL10n import freenet.support.SimpleReadOnlyArrayBucket import freenet.support.api.HTTPRequest import net.pterodactylus.sone.core.Core @@ -20,6 +19,7 @@ import net.pterodactylus.sone.data.Sone import net.pterodactylus.sone.data.Sone.SoneStatus import net.pterodactylus.sone.data.Sone.SoneStatus.idle import net.pterodactylus.sone.data.SoneOptions.DefaultSoneOptions +import net.pterodactylus.sone.freenet.* import net.pterodactylus.sone.test.deepMock import net.pterodactylus.sone.test.get import net.pterodactylus.sone.test.mock @@ -32,7 +32,7 @@ import net.pterodactylus.util.template.TemplateContextFactory import net.pterodactylus.util.web.Method.GET import net.pterodactylus.util.web.Method.POST import org.mockito.ArgumentMatchers -import java.util.NoSuchElementException +import java.util.* import javax.naming.SizeLimitExceededException /** @@ -44,7 +44,6 @@ open class TestObjects { val webInterface = mock() var formPassword = "form-password" - val l10n = mock() val core = mock() val eventBus = mock() val preferences = Preferences(eventBus) @@ -74,6 +73,11 @@ open class TestObjects { val images = mutableMapOf() val translations = mutableMapOf() + private val translation = object : Translation { + override val currentLocale = Locale.ENGLISH + override fun translate(key: String) = translations[key] ?: "" + } + init { whenever(webInterface.templateContextFactory).thenReturn(TemplateContextFactory()) whenever(webInterface.getCurrentSone(ArgumentMatchers.eq(toadletContext), ArgumentMatchers.anyBoolean())).thenReturn(currentSone) @@ -85,9 +89,7 @@ open class TestObjects { whenever(webInterface.getNotification(ArgumentMatchers.anyString())).then { notifications[it[0]].asOptional() } whenever(webInterface.getNewPosts(currentSone)).thenAnswer { newPosts.values } whenever(webInterface.getNewReplies(currentSone)).thenAnswer { newReplies.values } - whenever(webInterface.l10n).thenReturn(l10n) - - whenever(l10n.getString(ArgumentMatchers.anyString())).then { translations[it[0]] } + whenever(webInterface.translation).thenReturn(translation) whenever(core.preferences).thenReturn(preferences) whenever(core.updateChecker).thenReturn(updateChecker)