#347 Add remaining missing properties
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
package fr.xephi.authme.settings.custom;
|
||||
|
||||
import fr.xephi.authme.ReflectionTestUtils;
|
||||
import fr.xephi.authme.settings.domain.Property;
|
||||
import fr.xephi.authme.settings.propertymap.PropertyMap;
|
||||
import fr.xephi.authme.util.StringUtils;
|
||||
import org.bukkit.configuration.MemorySection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -16,8 +18,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
@@ -40,7 +40,19 @@ public class ConfigFileConsistencyTest {
|
||||
boolean result = settings.containsAllSettings(SettingsFieldRetriever.getAllPropertyFields());
|
||||
|
||||
// then
|
||||
assertThat(result, equalTo(true));
|
||||
if (!result) {
|
||||
FileConfiguration configuration =
|
||||
(FileConfiguration) ReflectionTestUtils.getFieldValue(NewSetting.class, settings, "configuration");
|
||||
|
||||
Set<String> knownProperties = getAllKnownPropertyPaths();
|
||||
List<String> missingProperties = new ArrayList<>();
|
||||
for (String path : knownProperties) {
|
||||
if (!configuration.contains(path)) {
|
||||
missingProperties.add(path);
|
||||
}
|
||||
}
|
||||
fail("Found missing properties!\n-" + StringUtils.join("\n-", missingProperties));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
@@ -14,6 +15,7 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.hamcrest.Matchers.arrayWithSize;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.fail;
|
||||
@@ -82,6 +84,17 @@ public class SettingsClassConsistencyTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldHaveHiddenDefaultConstructorOnly() {
|
||||
for (Class<?> clazz : classes) {
|
||||
Constructor<?>[] constructors = clazz.getDeclaredConstructors();
|
||||
assertThat(clazz + " should only have one constructor",
|
||||
constructors, arrayWithSize(1));
|
||||
assertThat("Constructor of " + clazz + " is private",
|
||||
Modifier.isPrivate(constructors[0].getModifiers()), equalTo(true));
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isValidConstantField(Field field) {
|
||||
int modifiers = field.getModifiers();
|
||||
return Modifier.isPublic(modifiers) && Modifier.isStatic(modifiers) && Modifier.isFinal(modifiers);
|
||||
|
||||
Reference in New Issue
Block a user