From a1c8d845054f6adcc6ef98e46e7b578874cc866a Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 28 Jul 2019 13:17:02 +0200 Subject: [PATCH] =?utf8?q?=E2=9C=A8=20Add=20=E2=80=9Cshow=20metrics?= =?utf8?q?=E2=80=9D=20debug=20information=20flag?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/net/pterodactylus/sone/core/DebugInformation.kt | 3 +++ src/main/kotlin/net/pterodactylus/sone/main/SoneModule.kt | 1 + src/test/kotlin/net/pterodactylus/sone/core/DebugInformationTest.kt | 5 +++++ src/test/kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt | 6 ++++++ 4 files changed, 15 insertions(+) diff --git a/src/main/kotlin/net/pterodactylus/sone/core/DebugInformation.kt b/src/main/kotlin/net/pterodactylus/sone/core/DebugInformation.kt index acb0155..3115b87 100644 --- a/src/main/kotlin/net/pterodactylus/sone/core/DebugInformation.kt +++ b/src/main/kotlin/net/pterodactylus/sone/core/DebugInformation.kt @@ -22,4 +22,7 @@ class DebugInformation { @Volatile var showVersionInformation = false + @Volatile + var showMetrics = false + } diff --git a/src/main/kotlin/net/pterodactylus/sone/main/SoneModule.kt b/src/main/kotlin/net/pterodactylus/sone/main/SoneModule.kt index 8f018f5..6657486 100644 --- a/src/main/kotlin/net/pterodactylus/sone/main/SoneModule.kt +++ b/src/main/kotlin/net/pterodactylus/sone/main/SoneModule.kt @@ -67,6 +67,7 @@ open class SoneModule(private val sonePlugin: SonePlugin, private val eventBus: 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) + debugInformation.showMetrics = configuration.getBooleanValue("Debug/ShowMetrics").getValue(false) }.also(eventBus::register) } diff --git a/src/test/kotlin/net/pterodactylus/sone/core/DebugInformationTest.kt b/src/test/kotlin/net/pterodactylus/sone/core/DebugInformationTest.kt index 5ec1ea9..6813253 100644 --- a/src/test/kotlin/net/pterodactylus/sone/core/DebugInformationTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/core/DebugInformationTest.kt @@ -30,4 +30,9 @@ class DebugInformationTest { assertThat(debugInformation.showVersionInformation, equalTo(false)) } + @Test + fun `new debug information has show metrics set to off`() { + assertThat(debugInformation.showMetrics, equalTo(false)) + } + } diff --git a/src/test/kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt b/src/test/kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt index 526c089..d125769 100644 --- a/src/test/kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt @@ -108,6 +108,12 @@ class SoneModuleTest { } @Test + fun `show metrics debug information flag is read from config`() { + File(currentDir, "sone.properties").writeText("Debug/ShowMetrics=true") + assertThat(injector.getInstance().debugInformation.showMetrics, equalTo(true)) + } + + @Test fun `event bus is bound`() { assertThat(injector.getInstance(), notNullValue()) } -- 2.7.4