Config: Make configFile field private and add getter

This commit is contained in:
Alva Swanson 2023-12-20 15:45:42 +01:00
parent 38515ce7ae
commit bf98531c46
No known key found for this signature in database
GPG Key ID: 004760E77F753090
4 changed files with 14 additions and 11 deletions

View File

@ -28,6 +28,8 @@ import java.util.Optional;
import ch.qos.logback.classic.Level;
import lombok.Getter;
import static com.google.common.base.Preconditions.checkNotNull;
import static java.lang.String.format;
import static java.util.stream.Collectors.toList;
@ -157,7 +159,8 @@ public class Config {
// Options supported only at the command-line interface (cli)
public final boolean helpRequested;
public final File configFile;
@Getter
private final File configFile;
// Options supported on cmd line and in the config file
public final String appName;

View File

@ -53,7 +53,7 @@ public class ConfigTests {
assertThat(config.appName, equalTo(config.defaultAppName));
assertThat(config.userDataDir, equalTo(config.defaultUserDataDir));
assertThat(config.appDataDir, equalTo(config.defaultAppDataDir));
assertThat(config.configFile, equalTo(config.defaultConfigFile));
assertThat(config.getConfigFile(), equalTo(config.defaultConfigFile));
}
@Test
@ -62,7 +62,7 @@ public class ConfigTests {
assertThat(config.appName, equalTo("My-Bisq"));
assertThat(config.userDataDir, equalTo(config.defaultUserDataDir));
assertThat(config.appDataDir, equalTo(new File(config.userDataDir, "My-Bisq")));
assertThat(config.configFile, equalTo(new File(config.appDataDir, DEFAULT_CONFIG_FILE_NAME)));
assertThat(config.getConfigFile(), equalTo(new File(config.appDataDir, DEFAULT_CONFIG_FILE_NAME)));
}
@Test
@ -72,7 +72,7 @@ public class ConfigTests {
assertThat(config.appName, equalTo(config.defaultAppName));
assertThat(config.userDataDir, equalTo(config.defaultUserDataDir));
assertThat(config.appDataDir, equalTo(appDataDir));
assertThat(config.configFile, equalTo(new File(config.appDataDir, DEFAULT_CONFIG_FILE_NAME)));
assertThat(config.getConfigFile(), equalTo(new File(config.appDataDir, DEFAULT_CONFIG_FILE_NAME)));
}
@Test
@ -82,7 +82,7 @@ public class ConfigTests {
assertThat(config.appName, equalTo(config.defaultAppName));
assertThat(config.userDataDir, equalTo(userDataDir));
assertThat(config.appDataDir, equalTo(new File(userDataDir, config.defaultAppName)));
assertThat(config.configFile, equalTo(new File(config.appDataDir, DEFAULT_CONFIG_FILE_NAME)));
assertThat(config.getConfigFile(), equalTo(new File(config.appDataDir, DEFAULT_CONFIG_FILE_NAME)));
}
@Test
@ -92,7 +92,7 @@ public class ConfigTests {
assertThat(config.appName, equalTo("My-Bisq"));
assertThat(config.userDataDir, equalTo(config.defaultUserDataDir));
assertThat(config.appDataDir, equalTo(appDataDir));
assertThat(config.configFile, equalTo(new File(config.appDataDir, DEFAULT_CONFIG_FILE_NAME)));
assertThat(config.getConfigFile(), equalTo(new File(config.appDataDir, DEFAULT_CONFIG_FILE_NAME)));
}
@Test
@ -166,7 +166,7 @@ public class ConfigTests {
public void whenConfigFileOptionIsSetToExistingFile_thenConfigFilePropertyReflectsItsValue() throws IOException {
File configFile = File.createTempFile("bisq", "properties");
Config config = configWithOpts(opt(CONFIG_FILE, configFile.getAbsolutePath()));
assertThat(config.configFile, equalTo(configFile));
assertThat(config.getConfigFile(), equalTo(configFile));
}
@Test
@ -175,7 +175,7 @@ public class ConfigTests {
File appDataDir = configFile.getParentFile();
String relativeConfigFilePath = configFile.getName();
Config config = configWithOpts(opt(APP_DATA_DIR, appDataDir), opt(CONFIG_FILE, relativeConfigFilePath));
assertThat(config.configFile, equalTo(configFile));
assertThat(config.getConfigFile(), equalTo(configFile));
}
@Test
@ -188,7 +188,7 @@ public class ConfigTests {
assertThat(config.appName, equalTo("My-Bisq"));
assertThat(config.userDataDir, equalTo(config.defaultUserDataDir));
assertThat(config.appDataDir, equalTo(new File(config.userDataDir, config.appName)));
assertThat(config.configFile, equalTo(configFile));
assertThat(config.getConfigFile(), equalTo(configFile));
}
@Test

View File

@ -128,7 +128,7 @@ public class FilterManager {
this.keyRing = keyRing;
this.user = user;
this.preferences = preferences;
this.configFileEditor = new ConfigFileEditor(config.configFile);
this.configFileEditor = new ConfigFileEditor(config.getConfigFile());
this.providersRepository = providersRepository;
this.ignoreDevMsg = ignoreDevMsg;

View File

@ -158,7 +158,7 @@ public class NetworkSettingsView extends ActivatableView<GridPane, Void> {
this.localBitcoinNode = localBitcoinNode;
this.torNetworkSettingsWindow = torNetworkSettingsWindow;
this.clockWatcher = clockWatcher;
this.configFileEditor = new ConfigFileEditor(config.configFile);
this.configFileEditor = new ConfigFileEditor(config.getConfigFile());
}
public void initialize() {