From: David ‘Bombe’ Roden Date: Mon, 13 Jul 2015 17:37:44 +0000 (+0200) Subject: Add method to modify peer by node identity X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=54b77863a4a3d63a0298157a87afb09007b03fc4;p=jFCPlib.git Add method to modify peer by node identity --- diff --git a/src/main/java/net/pterodactylus/fcp/quelaton/ModifyPeerCommand.java b/src/main/java/net/pterodactylus/fcp/quelaton/ModifyPeerCommand.java index 4e83048..7037e3b 100644 --- a/src/main/java/net/pterodactylus/fcp/quelaton/ModifyPeerCommand.java +++ b/src/main/java/net/pterodactylus/fcp/quelaton/ModifyPeerCommand.java @@ -15,5 +15,6 @@ public interface ModifyPeerCommand { ModifyPeerCommand disable(); Executable> byName(String name); + Executable> byIdentity(String nodeIdentity); } diff --git a/src/main/java/net/pterodactylus/fcp/quelaton/ModifyPeerCommandImpl.java b/src/main/java/net/pterodactylus/fcp/quelaton/ModifyPeerCommandImpl.java index 4bac846..50d780f 100644 --- a/src/main/java/net/pterodactylus/fcp/quelaton/ModifyPeerCommandImpl.java +++ b/src/main/java/net/pterodactylus/fcp/quelaton/ModifyPeerCommandImpl.java @@ -50,6 +50,12 @@ public class ModifyPeerCommandImpl implements ModifyPeerCommand { return this::execute; } + @Override + public Executable> byIdentity(String nodeIdentity) { + nodeIdentifier.set(nodeIdentity); + return this::execute; + } + private ListenableFuture> execute() { return threadPool.submit(this::executeSequence); } diff --git a/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java b/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java index 2ac40bd..b0b50ae 100644 --- a/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java +++ b/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java @@ -1288,4 +1288,27 @@ public class DefaultFcpClientTest { assertThat(peer.get().get().getIdentity(), is("id1")); } + @Test + public void defaultFcpClientCanEnablePeerByIdentity() throws InterruptedException, ExecutionException, IOException { + Future> peer = fcpClient.modifyPeer().enable().byIdentity("id1").execute(); + connectNode(); + List lines = fcpServer.collectUntil(is("EndMessage")); + String identifier = extractIdentifier(lines); + assertThat(lines, matchesFcpMessage( + "ModifyPeer", + "Identifier=" + identifier, + "NodeIdentifier=id1", + "IsDisabled=false", + "EndMessage" + )); + fcpServer.writeLine( + "Peer", + "Identifier=" + identifier, + "NodeIdentifier=Friend1", + "identity=id1", + "EndMessage" + ); + assertThat(peer.get().get().getIdentity(), is("id1")); + } + }