From 38a682c6c826befa8b291175c1801d02a8c22c62 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 14 Jul 2015 22:12:13 +0200 Subject: [PATCH] Add method to include short description in config data --- .../fcp/quelaton/GetConfigCommand.java | 1 + .../fcp/quelaton/GetConfigCommandImpl.java | 8 ++++++++ .../fcp/quelaton/DefaultFcpClientTest.java | 22 ++++++++++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/src/main/java/net/pterodactylus/fcp/quelaton/GetConfigCommand.java b/src/main/java/net/pterodactylus/fcp/quelaton/GetConfigCommand.java index 89afb67..a886cdc 100644 --- a/src/main/java/net/pterodactylus/fcp/quelaton/GetConfigCommand.java +++ b/src/main/java/net/pterodactylus/fcp/quelaton/GetConfigCommand.java @@ -14,5 +14,6 @@ public interface GetConfigCommand extends Executable { GetConfigCommand withSortOrder(); GetConfigCommand withExpertFlag(); GetConfigCommand withForceWriteFlag(); + GetConfigCommand withShortDescription(); } diff --git a/src/main/java/net/pterodactylus/fcp/quelaton/GetConfigCommandImpl.java b/src/main/java/net/pterodactylus/fcp/quelaton/GetConfigCommandImpl.java index e35fdec..1a8ffd8 100644 --- a/src/main/java/net/pterodactylus/fcp/quelaton/GetConfigCommandImpl.java +++ b/src/main/java/net/pterodactylus/fcp/quelaton/GetConfigCommandImpl.java @@ -27,6 +27,7 @@ public class GetConfigCommandImpl implements GetConfigCommand { private final AtomicBoolean withSortOrder = new AtomicBoolean(); private final AtomicBoolean withExpertFlag = new AtomicBoolean(); private final AtomicBoolean withForceWriteFlag = new AtomicBoolean(); + private final AtomicBoolean withShortDescription = new AtomicBoolean(); public GetConfigCommandImpl(ExecutorService threadPool, ConnectionSupplier connectionSupplier) { this.threadPool = MoreExecutors.listeningDecorator(threadPool); @@ -64,6 +65,12 @@ public class GetConfigCommandImpl implements GetConfigCommand { } @Override + public GetConfigCommand withShortDescription() { + withShortDescription.set(true); + return this; + } + + @Override public ListenableFuture execute() { return threadPool.submit(this::executeDialog); } @@ -75,6 +82,7 @@ public class GetConfigCommandImpl implements GetConfigCommand { getConfig.setWithSortOrder(withSortOrder.get()); getConfig.setWithExpertFlag(withExpertFlag.get()); getConfig.setWithForceWriteFlag(withForceWriteFlag.get()); + getConfig.setWithShortDescription(withShortDescription.get()); try (GetConfigDialog getConfigDialog = new GetConfigDialog()) { return getConfigDialog.send(getConfig).get(); } diff --git a/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java b/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java index 6604bb1..e181fca 100644 --- a/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java +++ b/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java @@ -1898,4 +1898,26 @@ public class DefaultFcpClientTest { assertThat(configData.get().getForceWriteFlag("foo"), is(true)); } + @Test + public void defaultFcpClientCanGetConfigWithShortDescription() + throws InterruptedException, ExecutionException, IOException { + Future configData = fcpClient.getConfig().withShortDescription().execute(); + connectNode(); + List lines = fcpServer.collectUntil(is("EndMessage")); + String identifier = extractIdentifier(lines); + assertThat(lines, matchesFcpMessage( + "GetConfig", + "Identifier=" + identifier, + "WithShortDescription=true", + "EndMessage" + )); + fcpServer.writeLine( + "ConfigData", + "Identifier=" + identifier, + "shortDescription.foo=bar", + "EndMessage" + ); + assertThat(configData.get().getShortDescription("foo"), is("bar")); + } + } -- 2.7.4