From: David ‘Bombe’ Roden Date: Tue, 14 Jul 2015 19:19:02 +0000 (+0200) Subject: Add method to modify peer note by node identifier X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=74a13907af14380c5a02c3b44eb517174d134beb;p=jFCPlib.git Add method to modify peer note by node identifier --- 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)); + } + }