From: David ‘Bombe’ Roden Date: Tue, 14 Jul 2015 20:07:35 +0000 (+0200) Subject: Add method to include expert flag in the config data X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=8d70659996b99bd55b677e7235005bc0fcb05e1b;p=jFCPlib.git Add method to include expert flag in the config data --- diff --git a/src/main/java/net/pterodactylus/fcp/quelaton/GetConfigCommand.java b/src/main/java/net/pterodactylus/fcp/quelaton/GetConfigCommand.java index 2650b51..6fc9572 100644 --- a/src/main/java/net/pterodactylus/fcp/quelaton/GetConfigCommand.java +++ b/src/main/java/net/pterodactylus/fcp/quelaton/GetConfigCommand.java @@ -12,5 +12,6 @@ public interface GetConfigCommand extends Executable { GetConfigCommand withCurrent(); GetConfigCommand withDefaults(); GetConfigCommand withSortOrder(); + GetConfigCommand withExpertFlag(); } diff --git a/src/main/java/net/pterodactylus/fcp/quelaton/GetConfigCommandImpl.java b/src/main/java/net/pterodactylus/fcp/quelaton/GetConfigCommandImpl.java index 4c78c68..2d03b2a 100644 --- a/src/main/java/net/pterodactylus/fcp/quelaton/GetConfigCommandImpl.java +++ b/src/main/java/net/pterodactylus/fcp/quelaton/GetConfigCommandImpl.java @@ -25,6 +25,7 @@ public class GetConfigCommandImpl implements GetConfigCommand { private final AtomicBoolean withCurrent = new AtomicBoolean(); private final AtomicBoolean withDefaults = new AtomicBoolean(); private final AtomicBoolean withSortOrder = new AtomicBoolean(); + private final AtomicBoolean withExpertFlag = new AtomicBoolean(); public GetConfigCommandImpl(ExecutorService threadPool, ConnectionSupplier connectionSupplier) { this.threadPool = MoreExecutors.listeningDecorator(threadPool); @@ -50,6 +51,12 @@ public class GetConfigCommandImpl implements GetConfigCommand { } @Override + public GetConfigCommand withExpertFlag() { + withExpertFlag.set(true); + return this; + } + + @Override public ListenableFuture execute() { return threadPool.submit(this::executeDialog); } @@ -59,6 +66,7 @@ public class GetConfigCommandImpl implements GetConfigCommand { getConfig.setWithCurrent(withCurrent.get()); getConfig.setWithDefaults(withDefaults.get()); getConfig.setWithSortOrder(withSortOrder.get()); + getConfig.setWithExpertFlag(withExpertFlag.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 b8481bf..d210acc 100644 --- a/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java +++ b/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java @@ -1854,4 +1854,26 @@ public class DefaultFcpClientTest { assertThat(configData.get().getSortOrder("foo"), is(17)); } + @Test + public void defaultFcpClientCanGetConfigWithExpertFlag() + throws InterruptedException, ExecutionException, IOException { + Future configData = fcpClient.getConfig().withExpertFlag().execute(); + connectNode(); + List lines = fcpServer.collectUntil(is("EndMessage")); + String identifier = extractIdentifier(lines); + assertThat(lines, matchesFcpMessage( + "GetConfig", + "Identifier=" + identifier, + "WithExpertFlag=true", + "EndMessage" + )); + fcpServer.writeLine( + "ConfigData", + "Identifier=" + identifier, + "expertFlag.foo=true", + "EndMessage" + ); + assertThat(configData.get().getExpertFlag("foo"), is(true)); + } + }