From 54b77863a4a3d63a0298157a87afb09007b03fc4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Mon, 13 Jul 2015 19:37:44 +0200 Subject: [PATCH] Add method to modify peer by node identity --- .../fcp/quelaton/ModifyPeerCommand.java | 1 + .../fcp/quelaton/ModifyPeerCommandImpl.java | 6 ++++++ .../fcp/quelaton/DefaultFcpClientTest.java | 23 ++++++++++++++++++++++ 3 files changed, 30 insertions(+) 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")); + } + } -- 2.7.4