From: David ‘Bombe’ Roden Date: Mon, 19 Jan 2026 20:52:37 +0000 (+0100) Subject: ✅ Add test for removeProperty() X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=af6b62dd279653e0380f397e3da55ae3df984f70;p=jFCPlib.git ✅ Add test for removeProperty() --- diff --git a/src/test/java/net/pterodactylus/fcp/plugin/WebOfTrustPluginTest.java b/src/test/java/net/pterodactylus/fcp/plugin/WebOfTrustPluginTest.java index 5e73b73..20932a3 100644 --- a/src/test/java/net/pterodactylus/fcp/plugin/WebOfTrustPluginTest.java +++ b/src/test/java/net/pterodactylus/fcp/plugin/WebOfTrustPluginTest.java @@ -741,6 +741,38 @@ public class WebOfTrustPluginTest { } + public static class RemovePropertyTests extends Common { + + @Test + public void removePropertySendsTheCorrectCommand() throws Exception { + TestFcpConnection fcpConnection = createConnectionThatSendsPropertyRemoved(); + WebOfTrustPlugin webOfTrustPlugin = createWebOfTrustPlugin(fcpConnection); + webOfTrustPlugin.removeProperty(ownIdentity, "SomeProperty"); + assertThat(fcpConnection.sentMessages.get(0), allOf( + isNamed(equalTo("FCPPluginMessage")), + hasField("Identifier", notNullValue()), + hasField("PluginName", equalTo("plugins.WebOfTrust.WebOfTrust")), + hasField("Param.Message", equalTo("RemoveProperty")), + hasField("Param.Identity", equalTo("own-id")), + hasField("Param.Property", equalTo("SomeProperty")) + )); + } + + @Test + public void removePropertyThrowsExceptionWhenDifferentReplyIsSentByPlugin() { + FcpConnection fcpConnection = createConnectionThatSendsOtherMessage(); + WebOfTrustPlugin webOfTrustPlugin = createWebOfTrustPlugin(fcpConnection); + assertThrows(FcpException.class, () -> webOfTrustPlugin.removeProperty(ownIdentity, "SomeProperty")); + } + + private TestFcpConnection createConnectionThatSendsPropertyRemoved() { + return createConnection("PropertyRemoved"); + } + + private final OwnIdentity ownIdentity = new OwnIdentity("own-id", "Own ID", "or", "ir", emptyList(), emptyMap()); + + } + private static class Common { @SafeVarargs