From: David ‘Bombe’ Roden Date: Tue, 14 Jul 2015 20:16:04 +0000 (+0200) Subject: Add method to include data types in config data X-Git-Url: https://git.pterodactylus.net/?p=jFCPlib.git;a=commitdiff_plain;h=52084c776e2569d6b1fbcfe61e4923a96a38842c Add method to include data types 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 c937f2b..0df93c7 100644 --- a/src/main/java/net/pterodactylus/fcp/quelaton/GetConfigCommand.java +++ b/src/main/java/net/pterodactylus/fcp/quelaton/GetConfigCommand.java @@ -16,5 +16,6 @@ public interface GetConfigCommand extends Executable { GetConfigCommand withForceWriteFlag(); GetConfigCommand withShortDescription(); GetConfigCommand withLongDescription(); + GetConfigCommand withDataTypes(); } diff --git a/src/main/java/net/pterodactylus/fcp/quelaton/GetConfigCommandImpl.java b/src/main/java/net/pterodactylus/fcp/quelaton/GetConfigCommandImpl.java index cc78f96..c2095b3 100644 --- a/src/main/java/net/pterodactylus/fcp/quelaton/GetConfigCommandImpl.java +++ b/src/main/java/net/pterodactylus/fcp/quelaton/GetConfigCommandImpl.java @@ -29,6 +29,7 @@ public class GetConfigCommandImpl implements GetConfigCommand { private final AtomicBoolean withForceWriteFlag = new AtomicBoolean(); private final AtomicBoolean withShortDescription = new AtomicBoolean(); private final AtomicBoolean withLongDescription = new AtomicBoolean(); + private final AtomicBoolean withDataTypes = new AtomicBoolean(); public GetConfigCommandImpl(ExecutorService threadPool, ConnectionSupplier connectionSupplier) { this.threadPool = MoreExecutors.listeningDecorator(threadPool); @@ -78,6 +79,12 @@ public class GetConfigCommandImpl implements GetConfigCommand { } @Override + public GetConfigCommand withDataTypes() { + withDataTypes.set(true); + return this; + } + + @Override public ListenableFuture execute() { return threadPool.submit(this::executeDialog); } @@ -91,6 +98,7 @@ public class GetConfigCommandImpl implements GetConfigCommand { getConfig.setWithForceWriteFlag(withForceWriteFlag.get()); getConfig.setWithShortDescription(withShortDescription.get()); getConfig.setWithLongDescription(withLongDescription.get()); + getConfig.setWithDataTypes(withDataTypes.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 01c7175..88f25a8 100644 --- a/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java +++ b/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java @@ -1942,4 +1942,26 @@ public class DefaultFcpClientTest { assertThat(configData.get().getLongDescription("foo"), is("bar")); } + @Test + public void defaultFcpClientCanGetConfigWithDataTypes() + throws InterruptedException, ExecutionException, IOException { + Future configData = fcpClient.getConfig().withDataTypes().execute(); + connectNode(); + List lines = fcpServer.collectUntil(is("EndMessage")); + String identifier = extractIdentifier(lines); + assertThat(lines, matchesFcpMessage( + "GetConfig", + "Identifier=" + identifier, + "WithDataTypes=true", + "EndMessage" + )); + fcpServer.writeLine( + "ConfigData", + "Identifier=" + identifier, + "dataType.foo=number", + "EndMessage" + ); + assertThat(configData.get().getDataType("foo"), is("number")); + } + }