From 74a13907af14380c5a02c3b44eb517174d134beb Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 14 Jul 2015 21:19:02 +0200 Subject: [PATCH] Add method to modify peer note by node identifier --- .../fcp/quelaton/ModifyPeerNoteCommand.java | 1 + .../fcp/quelaton/ModifyPeerNoteCommandImpl.java | 6 +++++ .../fcp/quelaton/DefaultFcpClientTest.java | 26 ++++++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/src/main/java/net/pterodactylus/fcp/quelaton/ModifyPeerNoteCommand.java b/src/main/java/net/pterodactylus/fcp/quelaton/ModifyPeerNoteCommand.java index 713c8eb..690671f 100644 --- a/src/main/java/net/pterodactylus/fcp/quelaton/ModifyPeerNoteCommand.java +++ b/src/main/java/net/pterodactylus/fcp/quelaton/ModifyPeerNoteCommand.java @@ -10,5 +10,6 @@ public interface ModifyPeerNoteCommand { ModifyPeerNoteCommand darknetComment(String text); Executable byName(String name); + Executable byIdentifier(String identifier); } diff --git a/src/main/java/net/pterodactylus/fcp/quelaton/ModifyPeerNoteCommandImpl.java b/src/main/java/net/pterodactylus/fcp/quelaton/ModifyPeerNoteCommandImpl.java index 6b2ff71..ecb4ed9 100644 --- a/src/main/java/net/pterodactylus/fcp/quelaton/ModifyPeerNoteCommandImpl.java +++ b/src/main/java/net/pterodactylus/fcp/quelaton/ModifyPeerNoteCommandImpl.java @@ -49,6 +49,12 @@ public class ModifyPeerNoteCommandImpl implements ModifyPeerNoteCommand { return this::execute; } + @Override + public Executable byIdentifier(String identifier) { + nodeIdentifier.set(identifier); + return this::execute; + } + private ListenableFuture execute() { if (darknetComment.get() == null) { return Futures.immediateFuture(false); diff --git a/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java b/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java index e0b5a2e..4781101 100644 --- a/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java +++ b/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java @@ -1714,4 +1714,30 @@ public class DefaultFcpClientTest { assertThat(noteUpdated.get(), is(false)); } + @Test + public void defaultFcpClientCanModifyPeerNoteByIdentifier() + throws InterruptedException, ExecutionException, IOException { + Future noteUpdated = fcpClient.modifyPeerNote().darknetComment("foo").byIdentifier("id1").execute(); + connectNode(); + List lines = fcpServer.collectUntil(is("EndMessage")); + String identifier = extractIdentifier(lines); + assertThat(lines, matchesFcpMessage( + "ModifyPeerNote", + "Identifier=" + identifier, + "NodeIdentifier=id1", + "PeerNoteType=1", + "NoteText=Zm9v", + "EndMessage" + )); + fcpServer.writeLine( + "PeerNote", + "Identifier=" + identifier, + "NodeIdentifier=id1", + "NoteText=Zm9v", + "PeerNoteType=1", + "EndMessage" + ); + assertThat(noteUpdated.get(), is(true)); + } + } -- 2.7.4