mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-04 23:48:42 +01:00
Fixed test compile errors
This commit is contained in:
parent
8dcfd3ad9a
commit
4776305b78
@ -25,6 +25,7 @@ import com.djrapitops.plugin.utilities.Verify;
|
|||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
import java.io.File;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
@ -60,6 +61,21 @@ public class PlanConfig extends Config {
|
|||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For testing
|
||||||
|
public PlanConfig(
|
||||||
|
File configFile,
|
||||||
|
PlanFiles files,
|
||||||
|
WorldAliasSettings worldAliasSettings,
|
||||||
|
PluginLogger logger
|
||||||
|
) {
|
||||||
|
super(configFile);
|
||||||
|
|
||||||
|
this.files = files;
|
||||||
|
this.extensionSettings = new ExtensionSettings(this);
|
||||||
|
this.worldAliasSettings = worldAliasSettings;
|
||||||
|
this.logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
public <T> T get(Setting<T> setting) {
|
public <T> T get(Setting<T> setting) {
|
||||||
T value = setting.getValueFrom(this);
|
T value = setting.getValueFrom(this);
|
||||||
Verify.isTrue(setting.isValid(value), () -> new IllegalStateException(
|
Verify.isTrue(setting.isValid(value), () -> new IllegalStateException(
|
||||||
|
@ -57,13 +57,13 @@ public class ConfigSettingKeyTest {
|
|||||||
|
|
||||||
public static void assertValidDefaultValuesForAllSettings(PlanConfig config, Iterable<Setting> settings) {
|
public static void assertValidDefaultValuesForAllSettings(PlanConfig config, Iterable<Setting> settings) {
|
||||||
List<String> fails = new ArrayList<>();
|
List<String> fails = new ArrayList<>();
|
||||||
for (Setting setting : settings) {
|
for (Setting<?> setting : settings) {
|
||||||
checkSettingForFailures(config, setting).ifPresent(fails::add);
|
checkSettingForFailures(config, setting).ifPresent(fails::add);
|
||||||
}
|
}
|
||||||
assertTrue(fails.isEmpty(), fails::toString);
|
assertTrue(fails.isEmpty(), fails::toString);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Optional<String> checkSettingForFailures(PlanConfig config, Setting setting) {
|
private static Optional<String> checkSettingForFailures(PlanConfig config, Setting<?> setting) {
|
||||||
try {
|
try {
|
||||||
if (!config.contains(setting.getPath())) {
|
if (!config.contains(setting.getPath())) {
|
||||||
return Optional.of("Did not contain " + setting.getPath());
|
return Optional.of("Did not contain " + setting.getPath());
|
||||||
@ -138,7 +138,7 @@ public class ConfigSettingKeyTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private PlanConfig createConfig(File configFile) throws IOException {
|
private PlanConfig createConfig(File configFile) throws IOException {
|
||||||
PlanConfig config = new PlanConfig(configFile, null, new TestPluginLogger());
|
PlanConfig config = new PlanConfig(configFile, null, null, new TestPluginLogger());
|
||||||
config.save();
|
config.save();
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ class ConfigUpdaterTest {
|
|||||||
Path config = tempDir.resolve("oldconfig.yml");
|
Path config = tempDir.resolve("oldconfig.yml");
|
||||||
Files.copy(oldConfig.toPath(), config, StandardCopyOption.REPLACE_EXISTING);
|
Files.copy(oldConfig.toPath(), config, StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
|
||||||
PlanConfig planConfig = new PlanConfig(config.toFile(), null, new TestPluginLogger());
|
PlanConfig planConfig = new PlanConfig(config.toFile(), null, null, new TestPluginLogger());
|
||||||
|
|
||||||
UNDER_TEST.applyConfigUpdate(planConfig);
|
UNDER_TEST.applyConfigUpdate(planConfig);
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ class ConfigUpdaterTest {
|
|||||||
Path config = tempDir.resolve("oldconfig.yml");
|
Path config = tempDir.resolve("oldconfig.yml");
|
||||||
Files.copy(oldBungeeConfig.toPath(), config, StandardCopyOption.REPLACE_EXISTING);
|
Files.copy(oldBungeeConfig.toPath(), config, StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
|
||||||
PlanConfig planConfig = new PlanConfig(config.toFile(), null, new TestPluginLogger());
|
PlanConfig planConfig = new PlanConfig(config.toFile(), null, null, new TestPluginLogger());
|
||||||
|
|
||||||
UNDER_TEST.applyConfigUpdate(planConfig);
|
UNDER_TEST.applyConfigUpdate(planConfig);
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ class ConfigUpdaterTest {
|
|||||||
Path config = tempDir.resolve("oldconfig.yml");
|
Path config = tempDir.resolve("oldconfig.yml");
|
||||||
Files.copy(oldConfig.toPath(), config, StandardCopyOption.REPLACE_EXISTING);
|
Files.copy(oldConfig.toPath(), config, StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
|
||||||
PlanConfig planConfig = new PlanConfig(config.toFile(), null, new TestPluginLogger());
|
PlanConfig planConfig = new PlanConfig(config.toFile(), null, null, new TestPluginLogger());
|
||||||
|
|
||||||
ConfigChange[] changes = UNDER_TEST.configEnhancementPatch();
|
ConfigChange[] changes = UNDER_TEST.configEnhancementPatch();
|
||||||
assertMoveChangesAreAppliedProperly(planConfig, changes);
|
assertMoveChangesAreAppliedProperly(planConfig, changes);
|
||||||
@ -133,7 +133,7 @@ class ConfigUpdaterTest {
|
|||||||
Path config = tempDir.resolve("oldconfig.yml");
|
Path config = tempDir.resolve("oldconfig.yml");
|
||||||
Files.copy(oldBungeeConfig.toPath(), config, StandardCopyOption.REPLACE_EXISTING);
|
Files.copy(oldBungeeConfig.toPath(), config, StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
|
||||||
PlanConfig planConfig = new PlanConfig(config.toFile(), null, new TestPluginLogger());
|
PlanConfig planConfig = new PlanConfig(config.toFile(), null, null, new TestPluginLogger());
|
||||||
|
|
||||||
ConfigChange[] changes = UNDER_TEST.configEnhancementPatch();
|
ConfigChange[] changes = UNDER_TEST.configEnhancementPatch();
|
||||||
assertMoveChangesAreAppliedProperly(planConfig, changes);
|
assertMoveChangesAreAppliedProperly(planConfig, changes);
|
||||||
|
@ -27,7 +27,7 @@ public class FieldFetcher {
|
|||||||
/* static method class*/
|
/* static method class*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> List<T> getPublicStaticFields(Class fromClass, Class<T> ofType) throws IllegalAccessException {
|
public static <T> List<T> getPublicStaticFields(Class<?> fromClass, Class<T> ofType) throws IllegalAccessException {
|
||||||
List<T> list = new ArrayList<>();
|
List<T> list = new ArrayList<>();
|
||||||
for (Field field : fromClass.getDeclaredFields()) {
|
for (Field field : fromClass.getDeclaredFields()) {
|
||||||
if (!Modifier.isPublic(field.getModifiers())) {
|
if (!Modifier.isPublic(field.getModifiers())) {
|
||||||
|
Loading…
Reference in New Issue
Block a user