From 6ac356bc119250192e68934894bf9f5eedc4989c Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 11 Jul 2019 16:06:29 +0200 Subject: [PATCH] =?utf8?q?=E2=9C=A8=20Add=20debug=20flags=20to=20Core?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/net/pterodactylus/sone/main/SoneModule.kt | 7 +++++++ .../kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt | 15 ++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/net/pterodactylus/sone/main/SoneModule.kt b/src/main/kotlin/net/pterodactylus/sone/main/SoneModule.kt index 18f4b95..07ec56e 100644 --- a/src/main/kotlin/net/pterodactylus/sone/main/SoneModule.kt +++ b/src/main/kotlin/net/pterodactylus/sone/main/SoneModule.kt @@ -7,6 +7,7 @@ import com.google.inject.matcher.* import com.google.inject.name.Names.* import com.google.inject.spi.* import freenet.l10n.* +import net.pterodactylus.sone.core.* import net.pterodactylus.sone.database.* import net.pterodactylus.sone.database.memory.* import net.pterodactylus.sone.freenet.wot.* @@ -60,6 +61,12 @@ class SoneModule(private val sonePlugin: SonePlugin) : AbstractModule() { }) } + @Provides + fun getCore(configuration: Configuration, freenetInterface: FreenetInterface, identityManager: IdentityManager, soneDownloader: SoneDownloader, imageInserter: ImageInserter, updateChecker: UpdateChecker, webOfTrustUpdater: WebOfTrustUpdater, eventBus: EventBus, database: Database) = + Core(configuration, freenetInterface, identityManager, soneDownloader, imageInserter, updateChecker, webOfTrustUpdater, eventBus, database).apply { + debugInformation.showVersionInformation = configuration.getBooleanValue("Debug/ShowVersionInformation").getValue(false) + } + } private fun String.parseVersion(): Version = Version.parse(this) diff --git a/src/test/kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt b/src/test/kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt index 0b8ef04..dd7923d 100644 --- a/src/test/kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt @@ -5,6 +5,9 @@ import com.google.common.eventbus.* import com.google.inject.Guice.* import com.google.inject.name.Names.* import freenet.l10n.* +import freenet.node.* +import freenet.pluginmanager.* +import net.pterodactylus.sone.core.* import net.pterodactylus.sone.database.* import net.pterodactylus.sone.database.memory.* import net.pterodactylus.sone.freenet.wot.* @@ -33,7 +36,11 @@ class SoneModuleTest { whenever(l10n()).thenReturn(l10n) } - private val injector by lazy { createInjector(SoneModule(sonePlugin)) } + private val injector by lazy { createInjector( + SoneModule(sonePlugin), + FreenetInterface::class.isProvidedByDeepMock(), + PluginRespirator::class.isProvidedByDeepMock() + ) } @AfterTest fun removePropertiesFromCurrentDirectory() { @@ -92,6 +99,12 @@ class SoneModuleTest { } @Test + fun `debug information flag is read from config`() { + File(currentDir, "sone.properties").writeText("Debug/ShowVersionInformation=true") + assertThat(injector.getInstance().debugInformation.showVersionInformation, equalTo(true)) + } + + @Test fun `event bus is bound`() { assertThat(injector.getInstance(), notNullValue()) } -- 2.7.4