From 0194e21f0855ffc97f4f43e28dac4ba732e12c5a 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:05:21 +0200 Subject: [PATCH] Add method to include sort order in the 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 7ae47b5..2650b51 100644 --- a/src/main/java/net/pterodactylus/fcp/quelaton/GetConfigCommand.java +++ b/src/main/java/net/pterodactylus/fcp/quelaton/GetConfigCommand.java @@ -11,5 +11,6 @@ public interface GetConfigCommand extends Executable { GetConfigCommand withCurrent(); GetConfigCommand withDefaults(); + GetConfigCommand withSortOrder(); } diff --git a/src/main/java/net/pterodactylus/fcp/quelaton/GetConfigCommandImpl.java b/src/main/java/net/pterodactylus/fcp/quelaton/GetConfigCommandImpl.java index 6e91c00..4c78c68 100644 --- a/src/main/java/net/pterodactylus/fcp/quelaton/GetConfigCommandImpl.java +++ b/src/main/java/net/pterodactylus/fcp/quelaton/GetConfigCommandImpl.java @@ -24,6 +24,7 @@ public class GetConfigCommandImpl implements GetConfigCommand { private final ConnectionSupplier connectionSupplier; private final AtomicBoolean withCurrent = new AtomicBoolean(); private final AtomicBoolean withDefaults = new AtomicBoolean(); + private final AtomicBoolean withSortOrder = new AtomicBoolean(); public GetConfigCommandImpl(ExecutorService threadPool, ConnectionSupplier connectionSupplier) { this.threadPool = MoreExecutors.listeningDecorator(threadPool); @@ -43,6 +44,12 @@ public class GetConfigCommandImpl implements GetConfigCommand { } @Override + public GetConfigCommand withSortOrder() { + withSortOrder.set(true); + return this; + } + + @Override public ListenableFuture execute() { return threadPool.submit(this::executeDialog); } @@ -51,6 +58,7 @@ public class GetConfigCommandImpl implements GetConfigCommand { GetConfig getConfig = new GetConfig(new RandomIdentifierGenerator().generate()); getConfig.setWithCurrent(withCurrent.get()); getConfig.setWithDefaults(withDefaults.get()); + getConfig.setWithSortOrder(withSortOrder.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 8fe4774..b8481bf 100644 --- a/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java +++ b/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java @@ -1832,4 +1832,26 @@ public class DefaultFcpClientTest { assertThat(configData.get().getDefault("foo"), is("bar")); } + @Test + public void defaultFcpClientCanGetConfigWithSortOrder() + throws InterruptedException, ExecutionException, IOException { + Future configData = fcpClient.getConfig().withSortOrder().execute(); + connectNode(); + List lines = fcpServer.collectUntil(is("EndMessage")); + String identifier = extractIdentifier(lines); + assertThat(lines, matchesFcpMessage( + "GetConfig", + "Identifier=" + identifier, + "WithSortOrder=true", + "EndMessage" + )); + fcpServer.writeLine( + "ConfigData", + "Identifier=" + identifier, + "sortOrder.foo=17", + "EndMessage" + ); + assertThat(configData.get().getSortOrder("foo"), is(17)); + } + } -- 2.7.4