@Test public void ifConfigParameterIsNotSetInTomlOrCliThenDefaultIsUsed() throws Exception { Path configFile = Files.createTempFile("emptyConfig", ".txt"); Path keysFile = Files.createTempFile("key", ".tmp").toAbsolutePath(); Files.write(keysFile, Collections.singletonList("SOMEDATA")); String[] requiredParams = { "--tomlfile", configFile.toString(), "--url", "http: "--port", "9001", "--othernodes", "http: "--socket", "myipcfile.ipc", "--publickeys", keysFile.toString(), "--privatekeys", keysFile.toString() }; commandLine.execute(requiredParams); final CliResult result = commandLine.getExecutionResult(); assertThat(result).isNotNull(); assertThat(result.getConfig()).isPresent(); assertThat(result.getStatus()).isEqualTo(0); final Config config = result.getConfig().get(); final SslConfig sslConfig = config.getP2PServerConfig().getSslConfig(); assertThat(this.getUnixSocketServerAddress(config)) .isEqualTo("unix:" + Paths.get("myipcfile.ipc").toAbsolutePath()); assertThat(config.getKeys().getKeyData()).isNotNull(); assertThat(config.getAlwaysSendTo()).isEmpty(); assertThat(config.getKeys().getPasswordFile()).isNull(); assertThat(config.getJdbcConfig().getUrl()).isEqualTo("jdbc:h2:mem:tessera"); assertThat(config.isUseWhiteList()).isFalse(); assertThat(sslConfig.getTls()).isEqualByComparingTo(SslAuthenticationMode.OFF); assertThat(sslConfig.getServerTlsCertificatePath()).isNull(); assertThat(sslConfig.getServerTrustCertificates()).isEmpty(); assertThat(sslConfig.getServerTlsKeyPath()).isNull(); assertThat(sslConfig.getServerTrustMode()).isEqualByComparingTo(SslTrustMode.TOFU); assertThat(sslConfig.getKnownClientsFile()).isNull(); assertThat(sslConfig.getClientTlsCertificatePath()).isNull(); assertThat(sslConfig.getClientTrustCertificates()).isEmpty(); assertThat(sslConfig.getClientTlsKeyPath()).isNull(); assertThat(sslConfig.getClientTrustMode()).isEqualByComparingTo(SslTrustMode.TOFU); assertThat(sslConfig.getKnownServersFile()).isNull(); }
@Override public CliResult execute(String... args) throws Exception { final ConfigBuilder configBuilder = Optional.ofNullable(tomlfile) .map(fileDelegate::newInputStream) .map(stream -> this.configFactory.create(stream, null)) .orElse(ConfigBuilder.create()); final KeyDataBuilder keyDataBuilder = Optional.ofNullable(tomlfile) .map(fileDelegate::newInputStream) .map(configFactory::createKeyDataBuilder) .orElse(KeyDataBuilder.create()); ConfigBuilder adjustedConfig = applyOverrides(configBuilder, keyDataBuilder); Config config = adjustedConfig.build(); return writeToOutputFile(config, outputPath); }
LegacyCliAdapter implements CliAdapter, Callable<CliResult> { @Override public CliResult execute(String... args) throws Exception { final ConfigBuilder configBuilder = Optional.ofNullable(tomlfile) .map(fileDelegate::newInputStream) .map(stream -> this.configFactory.create(stream, null)) .orElse(ConfigBuilder.create()); final KeyDataBuilder keyDataBuilder = Optional.ofNullable(tomlfile) .map(fileDelegate::newInputStream) .map(configFactory::createKeyDataBuilder) .orElse(KeyDataBuilder.create()); ConfigBuilder adjustedConfig = applyOverrides(configBuilder, keyDataBuilder); Config config = adjustedConfig.build(); return writeToOutputFile(config, outputPath); } }
LegacyCliAdapter implements CliAdapter, Callable<CliResult> { @Override public CliResult execute(String... args) throws Exception { final ConfigBuilder configBuilder = Optional.ofNullable(tomlfile) .map(fileDelegate::newInputStream) .map(stream -> this.configFactory.create(stream, null)) .orElse(ConfigBuilder.create()); final KeyDataBuilder keyDataBuilder = Optional.ofNullable(tomlfile) .map(fileDelegate::newInputStream) .map(configFactory::createKeyDataBuilder) .orElse(KeyDataBuilder.create()); ConfigBuilder adjustedConfig = applyOverrides(configBuilder, keyDataBuilder); Config config = adjustedConfig.build(); return writeToOutputFile(config, outputPath); } LegacyCliAdapter(); }
LegacyCliAdapter implements CliAdapter, Callable<CliResult> { @Override public CliResult execute(String... args) throws Exception { final ConfigBuilder configBuilder = Optional.ofNullable(tomlfile) .map(fileDelegate::newInputStream) .map(stream -> this.configFactory.create(stream, null)) .orElse(ConfigBuilder.create()); final KeyDataBuilder keyDataBuilder = Optional.ofNullable(tomlfile) .map(fileDelegate::newInputStream) .map(configFactory::createKeyDataBuilder) .orElse(KeyDataBuilder.create()); ConfigBuilder adjustedConfig = applyOverrides(configBuilder, keyDataBuilder); Config config = adjustedConfig.build(); return writeToOutputFile(config, outputPath); } LegacyCliAdapter(); @Override CliType getType(); @Override CliResult call(); @Override CliResult execute(String... args); void setOverrides(final LegacyOverridesMixin overrides); }
LegacyCliAdapter implements CliAdapter, Callable<CliResult> { @Override public CliResult execute(String... args) throws Exception { final ConfigBuilder configBuilder = Optional.ofNullable(tomlfile) .map(fileDelegate::newInputStream) .map(stream -> this.configFactory.create(stream, null)) .orElse(ConfigBuilder.create()); final KeyDataBuilder keyDataBuilder = Optional.ofNullable(tomlfile) .map(fileDelegate::newInputStream) .map(configFactory::createKeyDataBuilder) .orElse(KeyDataBuilder.create()); ConfigBuilder adjustedConfig = applyOverrides(configBuilder, keyDataBuilder); Config config = adjustedConfig.build(); return writeToOutputFile(config, outputPath); } LegacyCliAdapter(); @Override CliType getType(); @Override CliResult call(); @Override CliResult execute(String... args); void setOverrides(final LegacyOverridesMixin overrides);  }