From: David ‘Bombe’ Roden Date: Wed, 8 Jan 2025 07:38:36 +0000 (+0100) Subject: ✏️ Fix name of getOwnIdentities() method X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=e7191fd598664d9d231501ed9cafd26b1c1a3e73;p=jFCPlib.git ✏️ Fix name of getOwnIdentities() method --- diff --git a/src/main/java/net/pterodactylus/fcp/plugin/WebOfTrustPlugin.java b/src/main/java/net/pterodactylus/fcp/plugin/WebOfTrustPlugin.java index cc47ccd..7ec12a3 100644 --- a/src/main/java/net/pterodactylus/fcp/plugin/WebOfTrustPlugin.java +++ b/src/main/java/net/pterodactylus/fcp/plugin/WebOfTrustPlugin.java @@ -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 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 getOwnIdentities() throws IOException, FcpException { Map replies = fcpClient.sendPluginMessage(webOfTrustPluginName, createParameters("Message", "GetOwnIdentities")); if (!replies.get("Message").equals("OwnIdentities")) { throw new FcpException("WebOfTrust Plugin did not reply with “OwnIdentities” message!"); diff --git a/src/test/java/net/pterodactylus/fcp/plugin/WebOfTrustPluginTest.java b/src/test/java/net/pterodactylus/fcp/plugin/WebOfTrustPluginTest.java index dab71e0..e8d5f35 100644 --- a/src/test/java/net/pterodactylus/fcp/plugin/WebOfTrustPluginTest.java +++ b/src/test/java/net/pterodactylus/fcp/plugin/WebOfTrustPluginTest.java @@ -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 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 ownIdentities = webOfTrustPlugin.getOwnIdentites(); assertThat(ownIdentities, containsInAnyOrder( allOf(isOwnIdentity(equalTo("identity-0"), equalTo("Nick 0"), equalTo("request-uri-0"), equalTo("insert-uri-0")),