From 0981ff31f342a3013b03ad73e6778c7d5bf8d23c Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 2 Nov 2019 01:01:28 +0100 Subject: [PATCH] =?utf8?q?=F0=9F=94=A5=20Remove=20identifier=20from=20plug?= =?utf8?q?in=20connector=20interface?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../net/pterodactylus/sone/freenet/plugin/FredPluginConnector.kt | 2 +- .../kotlin/net/pterodactylus/sone/freenet/plugin/PluginConnector.kt | 2 +- .../net/pterodactylus/sone/freenet/wot/PluginWebOfTrustConnector.kt | 2 +- .../net/pterodactylus/sone/freenet/plugin/FredPluginConnectorTest.kt | 4 ++-- .../pterodactylus/sone/freenet/wot/PluginWebOfTrustConnectorTest.kt | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/net/pterodactylus/sone/freenet/plugin/FredPluginConnector.kt b/src/main/kotlin/net/pterodactylus/sone/freenet/plugin/FredPluginConnector.kt index 4dd8604..9852e61 100644 --- a/src/main/kotlin/net/pterodactylus/sone/freenet/plugin/FredPluginConnector.kt +++ b/src/main/kotlin/net/pterodactylus/sone/freenet/plugin/FredPluginConnector.kt @@ -16,7 +16,7 @@ import javax.inject.* */ class FredPluginConnector @Inject constructor(private val pluginRespiratorFacade: PluginRespiratorFacade) : PluginConnector { - override fun sendRequest(pluginName: String, identifier: String, fields: SimpleFieldSet, data: Bucket?): PluginReply { + override fun sendRequest(pluginName: String, fields: SimpleFieldSet, data: Bucket?): PluginReply { val receivedReply = Channel() val responseReceiver = FredPluginTalker { _, _, responseFields, responseData -> GlobalScope.launch { diff --git a/src/main/kotlin/net/pterodactylus/sone/freenet/plugin/PluginConnector.kt b/src/main/kotlin/net/pterodactylus/sone/freenet/plugin/PluginConnector.kt index db48dc3..86b0378 100644 --- a/src/main/kotlin/net/pterodactylus/sone/freenet/plugin/PluginConnector.kt +++ b/src/main/kotlin/net/pterodactylus/sone/freenet/plugin/PluginConnector.kt @@ -36,7 +36,7 @@ interface PluginConnector { * @throws PluginException if the plugin identified by [pluginName] does not exist */ @Throws(PluginException::class) - fun sendRequest(pluginName: String, identifier: String, fields: SimpleFieldSet, data: Bucket? = null): PluginReply + fun sendRequest(pluginName: String, fields: SimpleFieldSet, data: Bucket? = null): PluginReply } diff --git a/src/main/kotlin/net/pterodactylus/sone/freenet/wot/PluginWebOfTrustConnector.kt b/src/main/kotlin/net/pterodactylus/sone/freenet/wot/PluginWebOfTrustConnector.kt index e30cbb3..4557074 100644 --- a/src/main/kotlin/net/pterodactylus/sone/freenet/wot/PluginWebOfTrustConnector.kt +++ b/src/main/kotlin/net/pterodactylus/sone/freenet/wot/PluginWebOfTrustConnector.kt @@ -82,7 +82,7 @@ class PluginWebOfTrustConnector @Inject constructor(private val pluginConnector: private fun performRequest(fields: SimpleFieldSet): PluginReply { logger.log(Level.FINE, format("Sending FCP Request: %s", fields.get("Message"))) - return pluginConnector.sendRequest(WOT_PLUGIN_NAME, "", fields).also { + return pluginConnector.sendRequest(WOT_PLUGIN_NAME, fields).also { logger.log(Level.FINEST, format("Received FCP Response for %s: %s", fields.get("Message"), it.fields.get("Message"))) if ("Error" == it.fields.get("Message")) { throw PluginException("Could not perform request for " + fields.get("Message")) diff --git a/src/test/kotlin/net/pterodactylus/sone/freenet/plugin/FredPluginConnectorTest.kt b/src/test/kotlin/net/pterodactylus/sone/freenet/plugin/FredPluginConnectorTest.kt index 959f680..1eaa91a 100644 --- a/src/test/kotlin/net/pterodactylus/sone/freenet/plugin/FredPluginConnectorTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/freenet/plugin/FredPluginConnectorTest.kt @@ -42,14 +42,14 @@ class FredPluginConnectorTest { fun `connector throws exception if plugin can not be found`() = runBlocking { val pluginConnector = FredPluginConnector(pluginRespiratorFacade) expectedException.expect(PluginException::class.java) - pluginConnector.sendRequest("wrong.plugin", "", requestFields, requestData) + pluginConnector.sendRequest("wrong.plugin", requestFields, requestData) Unit } @Test fun `connector returns correct fields and data`() = runBlocking { val pluginConnector = FredPluginConnector(pluginRespiratorFacade) - val reply = pluginConnector.sendRequest("test.plugin", "", requestFields, requestData) + val reply = pluginConnector.sendRequest("test.plugin", requestFields, requestData) assertThat(reply.fields, equalTo(responseFields)) assertThat(reply.data, equalTo(responseData)) } diff --git a/src/test/kotlin/net/pterodactylus/sone/freenet/wot/PluginWebOfTrustConnectorTest.kt b/src/test/kotlin/net/pterodactylus/sone/freenet/wot/PluginWebOfTrustConnectorTest.kt index 79587ee..5db7fe3 100644 --- a/src/test/kotlin/net/pterodactylus/sone/freenet/wot/PluginWebOfTrustConnectorTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/freenet/wot/PluginWebOfTrustConnectorTest.kt @@ -305,7 +305,7 @@ private fun PluginConnector.connect(block: PluginWebOfTrustConnector.() -> R fun createPluginConnector(message: String, fieldsMatcher: Matcher = IsAnything(), build: SimpleFieldSetBuilder.() -> Unit = {}) = object : PluginConnector { - override fun sendRequest(pluginName: String, identifier: String, fields: SimpleFieldSet, data: Bucket?) = + override fun sendRequest(pluginName: String, fields: SimpleFieldSet, data: Bucket?) = if ((pluginName != wotPluginName) || (fields.get("Message") != message)) { throw PluginException() } else { -- 2.7.4