✏️ Fix name of getOwnIdentities() method
authorDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Wed, 8 Jan 2025 07:38:36 +0000 (08:38 +0100)
committerDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Wed, 8 Jan 2025 08:12:40 +0000 (09:12 +0100)
src/main/java/net/pterodactylus/fcp/plugin/WebOfTrustPlugin.java
src/test/java/net/pterodactylus/fcp/plugin/WebOfTrustPluginTest.java

index cc47ccd..7ec12a3 100644 (file)
@@ -121,8 +121,24 @@ public class WebOfTrustPlugin {
         *             if an I/O error occurs
         * @throws FcpException
         *             if an FCP error occurs
+        * @deprecated Use {@link #getOwnIdentities()} instead
         */
+       @Deprecated
        public Set<OwnIdentity> getOwnIdentites() throws IOException, FcpException {
+               return getOwnIdentities();
+       }
+
+       /**
+        * Returns all own identities of the web-of-trust plugins. Almost all other
+        * commands require an {@link OwnIdentity} to return meaningful values.
+        *
+        * @return All own identities of the web-of-trust plugin
+        * @throws IOException
+        *             if an I/O error occurs
+        * @throws FcpException
+        *             if an FCP error occurs
+        */
+       public Set<OwnIdentity> getOwnIdentities() throws IOException, FcpException {
                Map<String, String> replies = fcpClient.sendPluginMessage(webOfTrustPluginName, createParameters("Message", "GetOwnIdentities"));
                if (!replies.get("Message").equals("OwnIdentities")) {
                        throw new FcpException("WebOfTrust Plugin did not reply with “OwnIdentities” message!");
index dab71e0..e8d5f35 100644 (file)
@@ -134,7 +134,7 @@ public class WebOfTrustPluginTest {
        public void gettingOwnIdentitiesSendsCorrectMessage() throws Exception {
                TestFcpConnection fcpConnection = createConnectionThatDeliversOwnIdentities();
                WebOfTrustPlugin webOfTrustPlugin = createWebOfTrustPlugin(fcpConnection);
-               webOfTrustPlugin.getOwnIdentites();
+               webOfTrustPlugin.getOwnIdentities();
                assertThat(fcpConnection.sentMessages.get(0), allOf(
                                isNamed(equalTo("FCPPluginMessage")),
                                hasField("Identifier", not(nullValue())),
@@ -147,6 +147,34 @@ public class WebOfTrustPluginTest {
        public void gettingOwnIdentitiesParsesOwnIdentitiesCorrectly() throws Exception {
                TestFcpConnection fcpConnection = createConnectionThatDeliversOwnIdentities();
                WebOfTrustPlugin webOfTrustPlugin = createWebOfTrustPlugin(fcpConnection);
+               Set<OwnIdentity> ownIdentities = webOfTrustPlugin.getOwnIdentities();
+               assertThat(ownIdentities, containsInAnyOrder(
+                               allOf(isOwnIdentity(equalTo("identity-0"), equalTo("Nick 0"), equalTo("request-uri-0"), equalTo("insert-uri-0")),
+                                               hasContexts(containsInAnyOrder("test-context-1", "test-context-2")),
+                                               hasProperties(allOf(aMapWithSize(2), hasEntry("prop1", "value1"), hasEntry("prop2", "value2")))),
+                               allOf(isOwnIdentity(equalTo("identity-1"), equalTo("Nick 1"), equalTo("request-uri-1"), equalTo("insert-uri-1")),
+                                               hasContexts(containsInAnyOrder("test-context-2", "test-context-3")),
+                                               hasProperties(allOf(aMapWithSize(2), hasEntry("prop3", "value3"), hasEntry("prop4", "value4"))))
+               ));
+       }
+
+       @Test
+       public void gettingOwnIdentitiesUsingDeprecatedMethodSendsCorrectMessage() throws Exception {
+               TestFcpConnection fcpConnection = createConnectionThatDeliversOwnIdentities();
+               WebOfTrustPlugin webOfTrustPlugin = createWebOfTrustPlugin(fcpConnection);
+               webOfTrustPlugin.getOwnIdentites();
+               assertThat(fcpConnection.sentMessages.get(0), allOf(
+                               isNamed(equalTo("FCPPluginMessage")),
+                               hasField("Identifier", not(nullValue())),
+                               hasField("PluginName", equalTo("plugins.WebOfTrust.WebOfTrust")),
+                               hasField("Param.Message", equalTo("GetOwnIdentities"))
+               ));
+       }
+
+       @Test
+       public void gettingOwnIdentitiesUsingDeprecatedMethodParsesOwnIdentitiesCorrectly() throws Exception {
+               TestFcpConnection fcpConnection = createConnectionThatDeliversOwnIdentities();
+               WebOfTrustPlugin webOfTrustPlugin = createWebOfTrustPlugin(fcpConnection);
                Set<OwnIdentity> ownIdentities = webOfTrustPlugin.getOwnIdentites();
                assertThat(ownIdentities, containsInAnyOrder(
                                allOf(isOwnIdentity(equalTo("identity-0"), equalTo("Nick 0"), equalTo("request-uri-0"), equalTo("insert-uri-0")),