X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Ffreenet%2Fwot%2FWebOfTrustConnectorTest.kt;h=340d9ca5147f24644b765b0a7ce7b6cf0a814593;hb=c3e470d2626bcbd932d4b01ce3f6c6b17ce184fd;hp=afde66bbde98ba1db4922c9852beda496e7a94cd;hpb=ed0b70c34c926fbb44ec61c8be9b9b9af26b1770;p=Sone.git diff --git a/src/test/kotlin/net/pterodactylus/sone/freenet/wot/WebOfTrustConnectorTest.kt b/src/test/kotlin/net/pterodactylus/sone/freenet/wot/WebOfTrustConnectorTest.kt index afde66b..340d9ca 100644 --- a/src/test/kotlin/net/pterodactylus/sone/freenet/wot/WebOfTrustConnectorTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/freenet/wot/WebOfTrustConnectorTest.kt @@ -17,6 +17,7 @@ import kotlin.test.* class WebOfTrustConnectorTest { private val ownIdentity = DefaultOwnIdentity("id", "nickname", "requestUri", "insertUri") + private val identity = DefaultIdentity("id-a", "alpha", "url://alpha") @Test fun `wot plugin can be pinged`() { @@ -197,6 +198,70 @@ class WebOfTrustConnectorTest { .connect { setProperty(ownIdentity, "TestProperty", "TestValue") } } + @Test + fun `removing a property sends the correct identity id`() { + createPluginConnector("RemoveProperty", hasField("Identity", equalTo(ownIdentity.id))) + .connect { removeProperty(ownIdentity, "TestProperty") } + } + + @Test + fun `removing a property sends the correct property name`() { + createPluginConnector("RemoveProperty", hasField("Property", equalTo("TestProperty"))) + .connect { removeProperty(ownIdentity, "TestProperty") } + } + + @Test + fun `getting trust sends correct own identity id`() { + createPluginConnector("GetIdentity", hasField("Truster", equalTo(ownIdentity.id))) + .connect { getTrust(ownIdentity, identity) } + } + + @Test + fun `getting trust sends correct identity id`() { + createPluginConnector("GetIdentity", hasField("Identity", equalTo(identity.id))) + .connect { getTrust(ownIdentity, identity) } + } + + @Test + fun `getting trust returns correct trust values`() { + val trust = createPluginConnector("GetIdentity", hasField("Identity", equalTo(identity.id))) { + put("Trust", "12") + put("Score", "34") + put("Rank", "56") + }.connect { getTrust(ownIdentity, identity) } + assertThat(trust, isTrust(12, 34, 56)) + } + + @Test + fun `getting trust reads incorrect numbers for trust as null`() { + val trust = createPluginConnector("GetIdentity", hasField("Identity", equalTo(identity.id))) { + put("Trust", "incorrect") + put("Score", "34") + put("Rank", "56") + }.connect { getTrust(ownIdentity, identity) } + assertThat(trust, isTrust(null, 34, 56)) + } + + @Test + fun `getting trust reads incorrect numbers for score as null`() { + val trust = createPluginConnector("GetIdentity", hasField("Identity", equalTo(identity.id))) { + put("Trust", "12") + put("Score", "incorrect") + put("Rank", "56") + }.connect { getTrust(ownIdentity, identity) } + assertThat(trust, isTrust(12, null, 56)) + } + + @Test + fun `getting trust reads incorrect numbers for rank as null`() { + val trust = createPluginConnector("GetIdentity", hasField("Identity", equalTo(identity.id))) { + put("Trust", "12") + put("Score", "34") + put("Rank", "incorrect") + }.connect { getTrust(ownIdentity, identity) } + assertThat(trust, isTrust(12, 34, null)) + } + } private fun PluginConnector.connect(block: WebOfTrustConnector.() -> R) =