✅ Add test for removeProperty()
authorDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Mon, 19 Jan 2026 20:52:37 +0000 (21:52 +0100)
committerDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Mon, 19 Jan 2026 20:53:45 +0000 (21:53 +0100)
src/test/java/net/pterodactylus/fcp/plugin/WebOfTrustPluginTest.java

index 5e73b73..20932a3 100644 (file)
@@ -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