From: David ‘Bombe’ Roden Date: Mon, 19 Jan 2026 20:41:35 +0000 (+0100) Subject: ✅ Add test for setProperty() X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=a5e52c01ef1582f3e1a31b87886bb2c4ce028e9f;p=jFCPlib.git ✅ Add test for setProperty() --- diff --git a/src/test/java/net/pterodactylus/fcp/plugin/WebOfTrustPluginTest.java b/src/test/java/net/pterodactylus/fcp/plugin/WebOfTrustPluginTest.java index ce3525f..fe92b48 100644 --- a/src/test/java/net/pterodactylus/fcp/plugin/WebOfTrustPluginTest.java +++ b/src/test/java/net/pterodactylus/fcp/plugin/WebOfTrustPluginTest.java @@ -668,6 +668,39 @@ public class WebOfTrustPluginTest { } + public static class SetPropertyTests extends Common { + + @Test + public void setPropertySendsTheCorrectCommand() throws Exception { + TestFcpConnection fcpConnection = createConnectionThatSendsPropertyAdded(); + WebOfTrustPlugin webOfTrustPlugin = createWebOfTrustPlugin(fcpConnection); + webOfTrustPlugin.setProperty(ownIdentity, "SomeProperty", "SomeValue"); + assertThat(fcpConnection.sentMessages.get(0), allOf( + isNamed(equalTo("FCPPluginMessage")), + hasField("Identifier", notNullValue()), + hasField("PluginName", equalTo("plugins.WebOfTrust.WebOfTrust")), + hasField("Param.Message", equalTo("SetProperty")), + hasField("Param.Identity", equalTo("own-id")), + hasField("Param.Property", equalTo("SomeProperty")), + hasField("Param.Value", equalTo("SomeValue")) + )); + } + + @Test + public void setPropertyThrowsExceptionWhenDifferentReplyIsSentByPlugin() { + FcpConnection fcpConnection = createConnectionThatSendsOtherMessage(); + WebOfTrustPlugin webOfTrustPlugin = createWebOfTrustPlugin(fcpConnection); + assertThrows(FcpException.class, () -> webOfTrustPlugin.setProperty(ownIdentity, "SomeProperty", "SomeValue")); + } + + private TestFcpConnection createConnectionThatSendsPropertyAdded() { + return createConnection("PropertyAdded"); + } + + private final OwnIdentity ownIdentity = new OwnIdentity("own-id", "Own ID", "or", "ir", emptyList(), emptyMap()); + + } + private static class Common { @SafeVarargs