@Override
    public Configuration toConfiguration(final CommandLine commandLine) {
        final Configuration resultConfiguration = new Configuration();

        final String executorName = commandLine.getOptionValue(executorOption.getOpt());
        if (executorName != null) {
            resultConfiguration.set(DeploymentOptions.TARGET, executorName);
        }

        final String targetName = commandLine.getOptionValue(targetOption.getOpt());
        if (targetName != null) {
            resultConfiguration.set(DeploymentOptions.TARGET, targetName);
        }

        DynamicPropertiesUtil.encodeDynamicProperties(commandLine, resultConfiguration);
        resultConfiguration.set(DeploymentOptionsInternal.CONF_DIR, configurationDir);

        return resultConfiguration;
    }
@Test
    void testWithPreexistingConfigurationInConstructor() throws CliArgsException {
        final Configuration loadedConfig = new Configuration();
        loadedConfig.set(CoreOptions.DEFAULT_PARALLELISM, 2);
        loadedConfig.set(DeploymentOptions.ATTACHED, false);

        final ConfigOption<List<Integer>> listOption =
                key("test.list").intType().asList().noDefaultValue();

        final List<Integer> listValue = Arrays.asList(41, 42, 23);
        final String encodedListValue =
                listValue.stream().map(Object::toString).collect(Collectors.joining(";"));

        final String[] args = {
            "-e",
            "test-executor",
            "-D" + listOption.key() + "=" + encodedListValue,
            "-D" + CoreOptions.DEFAULT_PARALLELISM.key() + "=5"
        };

        final GenericCLI cliUnderTest =
                new GenericCLI(loadedConfig, tmp.toAbsolutePath().toString());
        final CommandLine commandLine = CliFrontendParser.parse(testOptions, args, true);

        final Configuration configuration = cliUnderTest.toConfiguration(commandLine);

        assertThat(configuration.get(DeploymentOptions.TARGET)).isEqualTo("test-executor");
        assertThat(configuration.get(CoreOptions.DEFAULT_PARALLELISM)).isEqualTo(5);
        assertThat(configuration.get(DeploymentOptions.ATTACHED)).isFalse();
        assertThat(configuration.get(listOption)).isEqualTo(listValue);
    }