Add method to include long description in config data
authorDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Tue, 14 Jul 2015 20:14:04 +0000 (22:14 +0200)
committerDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Tue, 14 Jul 2015 20:14:04 +0000 (22:14 +0200)
src/main/java/net/pterodactylus/fcp/quelaton/GetConfigCommand.java
src/main/java/net/pterodactylus/fcp/quelaton/GetConfigCommandImpl.java
src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java

index a886cdc..c937f2b 100644 (file)
@@ -15,5 +15,6 @@ public interface GetConfigCommand extends Executable<ConfigData> {
        GetConfigCommand withExpertFlag();
        GetConfigCommand withForceWriteFlag();
        GetConfigCommand withShortDescription();
+       GetConfigCommand withLongDescription();
 
 }
index 1a8ffd8..cc78f96 100644 (file)
@@ -28,6 +28,7 @@ public class GetConfigCommandImpl implements GetConfigCommand {
        private final AtomicBoolean withExpertFlag = new AtomicBoolean();
        private final AtomicBoolean withForceWriteFlag = new AtomicBoolean();
        private final AtomicBoolean withShortDescription = new AtomicBoolean();
+       private final AtomicBoolean withLongDescription = new AtomicBoolean();
 
        public GetConfigCommandImpl(ExecutorService threadPool, ConnectionSupplier connectionSupplier) {
                this.threadPool = MoreExecutors.listeningDecorator(threadPool);
@@ -71,6 +72,12 @@ public class GetConfigCommandImpl implements GetConfigCommand {
        }
 
        @Override
+       public GetConfigCommand withLongDescription() {
+               withLongDescription.set(true);
+               return this;
+       }
+
+       @Override
        public ListenableFuture<ConfigData> execute() {
                return threadPool.submit(this::executeDialog);
        }
@@ -83,6 +90,7 @@ public class GetConfigCommandImpl implements GetConfigCommand {
                getConfig.setWithExpertFlag(withExpertFlag.get());
                getConfig.setWithForceWriteFlag(withForceWriteFlag.get());
                getConfig.setWithShortDescription(withShortDescription.get());
+               getConfig.setWithLongDescription(withLongDescription.get());
                try (GetConfigDialog getConfigDialog = new GetConfigDialog()) {
                        return getConfigDialog.send(getConfig).get();
                }
index e181fca..01c7175 100644 (file)
@@ -1920,4 +1920,26 @@ public class DefaultFcpClientTest {
                assertThat(configData.get().getShortDescription("foo"), is("bar"));
        }
 
+       @Test
+       public void defaultFcpClientCanGetConfigWithLongDescription()
+       throws InterruptedException, ExecutionException, IOException {
+               Future<ConfigData> configData = fcpClient.getConfig().withLongDescription().execute();
+               connectNode();
+               List<String> lines = fcpServer.collectUntil(is("EndMessage"));
+               String identifier = extractIdentifier(lines);
+               assertThat(lines, matchesFcpMessage(
+                       "GetConfig",
+                       "Identifier=" + identifier,
+                       "WithLongDescription=true",
+                       "EndMessage"
+               ));
+               fcpServer.writeLine(
+                       "ConfigData",
+                       "Identifier=" + identifier,
+                       "longDescription.foo=bar",
+                       "EndMessage"
+               );
+               assertThat(configData.get().getLongDescription("foo"), is("bar"));
+       }
+
 }