From 722c2e534b560da777f87e025d320667ef8ae1d9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Mon, 13 Jul 2015 21:02:10 +0200 Subject: [PATCH] Add method to remove peer by identity --- .../fcp/quelaton/RemovePeerCommand.java | 1 + .../fcp/quelaton/RemovePeerCommandImpl.java | 6 ++++++ .../fcp/quelaton/DefaultFcpClientTest.java | 21 +++++++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/src/main/java/net/pterodactylus/fcp/quelaton/RemovePeerCommand.java b/src/main/java/net/pterodactylus/fcp/quelaton/RemovePeerCommand.java index 02b0d44..cd43adb 100644 --- a/src/main/java/net/pterodactylus/fcp/quelaton/RemovePeerCommand.java +++ b/src/main/java/net/pterodactylus/fcp/quelaton/RemovePeerCommand.java @@ -8,5 +8,6 @@ package net.pterodactylus.fcp.quelaton; public interface RemovePeerCommand { Executable byName(String name); + Executable byIdentity(String nodeIdentity); } diff --git a/src/main/java/net/pterodactylus/fcp/quelaton/RemovePeerCommandImpl.java b/src/main/java/net/pterodactylus/fcp/quelaton/RemovePeerCommandImpl.java index 9578477..6b791e8 100644 --- a/src/main/java/net/pterodactylus/fcp/quelaton/RemovePeerCommandImpl.java +++ b/src/main/java/net/pterodactylus/fcp/quelaton/RemovePeerCommandImpl.java @@ -36,6 +36,12 @@ public class RemovePeerCommandImpl implements RemovePeerCommand { return this::execute; } + @Override + public Executable byIdentity(String nodeIdentity) { + nodeIdentifier.set(nodeIdentity); + return this::execute; + } + private ListenableFuture execute() { return threadPool.submit(this::executeDialog); } diff --git a/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java b/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java index c1d09ea..eb0e193 100644 --- a/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java +++ b/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java @@ -1593,4 +1593,25 @@ public class DefaultFcpClientTest { assertThat(peer.get(), is(true)); } + @Test + public void defaultFcpClientCanRemovePeerByIdentity() throws InterruptedException, ExecutionException, IOException { + Future peer = fcpClient.removePeer().byIdentity("id1").execute(); + connectNode(); + List lines = fcpServer.collectUntil(is("EndMessage")); + String identifier = extractIdentifier(lines); + assertThat(lines, matchesFcpMessage( + "RemovePeer", + "Identifier=" + identifier, + "NodeIdentifier=id1", + "EndMessage" + )); + fcpServer.writeLine( + "PeerRemoved", + "Identifier=" + identifier, + "NodeIdentifier=Friend1", + "EndMessage" + ); + assertThat(peer.get(), is(true)); + } + } -- 2.7.4