*/
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<PluginReply>()
val responseReceiver = FredPluginTalker { _, _, responseFields, responseData ->
GlobalScope.launch {
* @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
}
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"))
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))
}
fun createPluginConnector(message: String, fieldsMatcher: Matcher<SimpleFieldSet> = IsAnything<SimpleFieldSet>(), 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 {