From: David ‘Bombe’ Roden Date: Tue, 14 Jul 2015 20:10:16 +0000 (+0200) Subject: Add method to include force-write flag in config data X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=bfc572d27b7fa9b55ca082981666d83bdde1065f;p=jFCPlib.git Add method to include force-write flag in 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 6fc9572..89afb67 100644 --- a/src/main/java/net/pterodactylus/fcp/quelaton/GetConfigCommand.java +++ b/src/main/java/net/pterodactylus/fcp/quelaton/GetConfigCommand.java @@ -13,5 +13,6 @@ public interface GetConfigCommand extends Executable { GetConfigCommand withDefaults(); GetConfigCommand withSortOrder(); GetConfigCommand withExpertFlag(); + GetConfigCommand withForceWriteFlag(); } diff --git a/src/main/java/net/pterodactylus/fcp/quelaton/GetConfigCommandImpl.java b/src/main/java/net/pterodactylus/fcp/quelaton/GetConfigCommandImpl.java index 2d03b2a..e35fdec 100644 --- a/src/main/java/net/pterodactylus/fcp/quelaton/GetConfigCommandImpl.java +++ b/src/main/java/net/pterodactylus/fcp/quelaton/GetConfigCommandImpl.java @@ -26,6 +26,7 @@ public class GetConfigCommandImpl implements GetConfigCommand { private final AtomicBoolean withDefaults = new AtomicBoolean(); private final AtomicBoolean withSortOrder = new AtomicBoolean(); private final AtomicBoolean withExpertFlag = new AtomicBoolean(); + private final AtomicBoolean withForceWriteFlag = new AtomicBoolean(); public GetConfigCommandImpl(ExecutorService threadPool, ConnectionSupplier connectionSupplier) { this.threadPool = MoreExecutors.listeningDecorator(threadPool); @@ -57,6 +58,12 @@ public class GetConfigCommandImpl implements GetConfigCommand { } @Override + public GetConfigCommand withForceWriteFlag() { + withForceWriteFlag.set(true); + return this; + } + + @Override public ListenableFuture execute() { return threadPool.submit(this::executeDialog); } @@ -67,6 +74,7 @@ public class GetConfigCommandImpl implements GetConfigCommand { getConfig.setWithDefaults(withDefaults.get()); getConfig.setWithSortOrder(withSortOrder.get()); getConfig.setWithExpertFlag(withExpertFlag.get()); + getConfig.setWithForceWriteFlag(withForceWriteFlag.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 d210acc..6604bb1 100644 --- a/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java +++ b/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java @@ -1876,4 +1876,26 @@ public class DefaultFcpClientTest { assertThat(configData.get().getExpertFlag("foo"), is(true)); } + @Test + public void defaultFcpClientCanGetConfigWithForceWriteFlag() + throws InterruptedException, ExecutionException, IOException { + Future configData = fcpClient.getConfig().withForceWriteFlag().execute(); + connectNode(); + List lines = fcpServer.collectUntil(is("EndMessage")); + String identifier = extractIdentifier(lines); + assertThat(lines, matchesFcpMessage( + "GetConfig", + "Identifier=" + identifier, + "WithForceWriteFlag=true", + "EndMessage" + )); + fcpServer.writeLine( + "ConfigData", + "Identifier=" + identifier, + "forceWriteFlag.foo=true", + "EndMessage" + ); + assertThat(configData.get().getForceWriteFlag("foo"), is(true)); + } + }