- @Test
- public void defaultFcpClientCanGetConfigWithoutDetails()
- throws InterruptedException, ExecutionException, IOException {
- Future<ConfigData> configData = fcpClient.getConfig().execute();
- connectNode();
- List<String> lines = fcpServer.collectUntil(is("EndMessage"));
- String identifier = extractIdentifier(lines);
- assertThat(lines, matchesFcpMessage(
- "GetConfig",
- "Identifier=" + identifier
- ));
- fcpServer.writeLine(
- "ConfigData",
- "Identifier=" + identifier,
- "EndMessage"
- );
- assertThat(configData.get(), notNullValue());
- }
-
- @Test
- public void defaultFcpClientCanGetConfigWithCurrent()
- throws InterruptedException, ExecutionException, IOException {
- Future<ConfigData> configData = fcpClient.getConfig().withCurrent().execute();
- connectNode();
- List<String> lines = fcpServer.collectUntil(is("EndMessage"));
- String identifier = extractIdentifier(lines);
- assertThat(lines, matchesFcpMessage(
- "GetConfig",
- "Identifier=" + identifier,
- "WithCurrent=true"
- ));
- fcpServer.writeLine(
- "ConfigData",
- "Identifier=" + identifier,
- "current.foo=bar",
- "EndMessage"
- );
- assertThat(configData.get().getCurrent("foo"), is("bar"));
- }
-
- @Test
- public void defaultFcpClientCanGetConfigWithDefaults()
- throws InterruptedException, ExecutionException, IOException {
- Future<ConfigData> configData = fcpClient.getConfig().withDefaults().execute();
- connectNode();
- List<String> lines = fcpServer.collectUntil(is("EndMessage"));
- String identifier = extractIdentifier(lines);
- assertThat(lines, matchesFcpMessage(
- "GetConfig",
- "Identifier=" + identifier,
- "WithDefaults=true"
- ));
- fcpServer.writeLine(
- "ConfigData",
- "Identifier=" + identifier,
- "default.foo=bar",
- "EndMessage"
- );
- assertThat(configData.get().getDefault("foo"), is("bar"));
- }
-
- @Test
- public void defaultFcpClientCanGetConfigWithSortOrder()
- throws InterruptedException, ExecutionException, IOException {
- Future<ConfigData> configData = fcpClient.getConfig().withSortOrder().execute();
- connectNode();
- List<String> lines = fcpServer.collectUntil(is("EndMessage"));
- String identifier = extractIdentifier(lines);
- assertThat(lines, matchesFcpMessage(
- "GetConfig",
- "Identifier=" + identifier,
- "WithSortOrder=true"
- ));
- fcpServer.writeLine(
- "ConfigData",
- "Identifier=" + identifier,
- "sortOrder.foo=17",
- "EndMessage"
- );
- assertThat(configData.get().getSortOrder("foo"), is(17));
- }
-
- @Test
- public void defaultFcpClientCanGetConfigWithExpertFlag()
- throws InterruptedException, ExecutionException, IOException {
- Future<ConfigData> configData = fcpClient.getConfig().withExpertFlag().execute();
- connectNode();
- List<String> lines = fcpServer.collectUntil(is("EndMessage"));
- String identifier = extractIdentifier(lines);
- assertThat(lines, matchesFcpMessage(
- "GetConfig",
- "Identifier=" + identifier,
- "WithExpertFlag=true"
- ));
- fcpServer.writeLine(
- "ConfigData",
- "Identifier=" + identifier,
- "expertFlag.foo=true",
- "EndMessage"
- );
- assertThat(configData.get().getExpertFlag("foo"), is(true));
- }
-
- @Test
- public void defaultFcpClientCanGetConfigWithForceWriteFlag()
- throws InterruptedException, ExecutionException, IOException {
- Future<ConfigData> configData = fcpClient.getConfig().withForceWriteFlag().execute();
- connectNode();
- List<String> lines = fcpServer.collectUntil(is("EndMessage"));
- String identifier = extractIdentifier(lines);
- assertThat(lines, matchesFcpMessage(
- "GetConfig",
- "Identifier=" + identifier,
- "WithForceWriteFlag=true"
- ));
- fcpServer.writeLine(
- "ConfigData",
- "Identifier=" + identifier,
- "forceWriteFlag.foo=true",
- "EndMessage"
- );
- assertThat(configData.get().getForceWriteFlag("foo"), is(true));
- }
-
- @Test
- public void defaultFcpClientCanGetConfigWithShortDescription()
- throws InterruptedException, ExecutionException, IOException {
- Future<ConfigData> configData = fcpClient.getConfig().withShortDescription().execute();
- connectNode();
- List<String> lines = fcpServer.collectUntil(is("EndMessage"));
- String identifier = extractIdentifier(lines);
- assertThat(lines, matchesFcpMessage(
- "GetConfig",
- "Identifier=" + identifier,
- "WithShortDescription=true"
- ));
- fcpServer.writeLine(
- "ConfigData",
- "Identifier=" + identifier,
- "shortDescription.foo=bar",
- "EndMessage"
- );
- 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"
- ));
- fcpServer.writeLine(
- "ConfigData",
- "Identifier=" + identifier,
- "longDescription.foo=bar",
- "EndMessage"
- );
- assertThat(configData.get().getLongDescription("foo"), is("bar"));
- }
-
- @Test
- public void defaultFcpClientCanGetConfigWithDataTypes()
- throws InterruptedException, ExecutionException, IOException {
- Future<ConfigData> configData = fcpClient.getConfig().withDataTypes().execute();
- connectNode();
- List<String> lines = fcpServer.collectUntil(is("EndMessage"));
- String identifier = extractIdentifier(lines);
- assertThat(lines, matchesFcpMessage(
- "GetConfig",
- "Identifier=" + identifier,
- "WithDataTypes=true"
- ));
- fcpServer.writeLine(
- "ConfigData",
- "Identifier=" + identifier,
- "dataType.foo=number",
- "EndMessage"
- );
- assertThat(configData.get().getDataType("foo"), is("number"));
- }
-
- @Test
- public void defaultFcpClientCanModifyConfigData() throws InterruptedException, ExecutionException, IOException {
- Future<ConfigData> newConfigData = fcpClient.modifyConfig().set("foo.bar").to("baz").execute();
- connectNode();
- List<String> lines = fcpServer.collectUntil(is("EndMessage"));
- String identifier = extractIdentifier(lines);
- assertThat(lines, matchesFcpMessage(
- "ModifyConfig",
- "Identifier=" + identifier,
- "foo.bar=baz"
- ));
- fcpServer.writeLine(
- "ConfigData",
- "Identifier=" + identifier,
- "current.foo.bar=baz",
- "EndMessage"
- );
- assertThat(newConfigData.get().getCurrent("foo.bar"), is("baz"));
- }
-