From: David ‘Bombe’ Roden Date: Sat, 2 Nov 2019 00:01:28 +0000 (+0100) Subject: 🔥 Remove identifier from plugin connector interface X-Git-Tag: v81^2~68 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=0981ff31f342a3013b03ad73e6778c7d5bf8d23c;p=Sone.git 🔥 Remove identifier from plugin connector interface --- 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 {