mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-30 14:13:35 +01:00
Move new configuration packages and add test for PropertyMap
This commit is contained in:
parent
cb07b3df3d
commit
204a564a9a
@ -1,12 +1,12 @@
|
||||
package fr.xephi.authme.settings.custom;
|
||||
|
||||
import fr.xephi.authme.settings.custom.domain.Comment;
|
||||
import fr.xephi.authme.settings.custom.domain.Property;
|
||||
import fr.xephi.authme.settings.custom.domain.SettingsClass;
|
||||
import fr.xephi.authme.settings.domain.Comment;
|
||||
import fr.xephi.authme.settings.domain.Property;
|
||||
import fr.xephi.authme.settings.domain.SettingsClass;
|
||||
|
||||
import static fr.xephi.authme.settings.custom.domain.Property.newProperty;
|
||||
import static fr.xephi.authme.settings.custom.domain.PropertyType.BOOLEAN;
|
||||
import static fr.xephi.authme.settings.custom.domain.PropertyType.STRING;
|
||||
import static fr.xephi.authme.settings.domain.Property.newProperty;
|
||||
import static fr.xephi.authme.settings.domain.PropertyType.BOOLEAN;
|
||||
import static fr.xephi.authme.settings.domain.PropertyType.STRING;
|
||||
|
||||
public class ConverterSettings implements SettingsClass {
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
package fr.xephi.authme.settings.custom;
|
||||
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.settings.custom.domain.Comment;
|
||||
import fr.xephi.authme.settings.custom.domain.Property;
|
||||
import fr.xephi.authme.settings.custom.domain.SettingsClass;
|
||||
import fr.xephi.authme.settings.domain.Comment;
|
||||
import fr.xephi.authme.settings.domain.Property;
|
||||
import fr.xephi.authme.settings.domain.SettingsClass;
|
||||
|
||||
import static fr.xephi.authme.settings.custom.domain.Property.newProperty;
|
||||
import static fr.xephi.authme.settings.custom.domain.PropertyType.BOOLEAN;
|
||||
import static fr.xephi.authme.settings.custom.domain.PropertyType.STRING;
|
||||
import static fr.xephi.authme.settings.domain.Property.newProperty;
|
||||
import static fr.xephi.authme.settings.domain.PropertyType.BOOLEAN;
|
||||
import static fr.xephi.authme.settings.domain.PropertyType.STRING;
|
||||
|
||||
public class DatabaseSettings implements SettingsClass {
|
||||
|
||||
|
@ -1,16 +1,16 @@
|
||||
package fr.xephi.authme.settings.custom;
|
||||
|
||||
import fr.xephi.authme.settings.custom.domain.Comment;
|
||||
import fr.xephi.authme.settings.custom.domain.Property;
|
||||
import fr.xephi.authme.settings.custom.domain.SettingsClass;
|
||||
import fr.xephi.authme.settings.domain.Comment;
|
||||
import fr.xephi.authme.settings.domain.Property;
|
||||
import fr.xephi.authme.settings.domain.SettingsClass;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static fr.xephi.authme.settings.custom.domain.Property.newProperty;
|
||||
import static fr.xephi.authme.settings.custom.domain.PropertyType.BOOLEAN;
|
||||
import static fr.xephi.authme.settings.custom.domain.PropertyType.INTEGER;
|
||||
import static fr.xephi.authme.settings.custom.domain.PropertyType.STRING;
|
||||
import static fr.xephi.authme.settings.custom.domain.PropertyType.STRING_LIST;
|
||||
import static fr.xephi.authme.settings.domain.Property.newProperty;
|
||||
import static fr.xephi.authme.settings.domain.PropertyType.BOOLEAN;
|
||||
import static fr.xephi.authme.settings.domain.PropertyType.INTEGER;
|
||||
import static fr.xephi.authme.settings.domain.PropertyType.STRING;
|
||||
import static fr.xephi.authme.settings.domain.PropertyType.STRING_LIST;
|
||||
|
||||
public class EmailSettings implements SettingsClass {
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
package fr.xephi.authme.settings.custom;
|
||||
|
||||
import fr.xephi.authme.settings.custom.domain.Comment;
|
||||
import fr.xephi.authme.settings.custom.domain.Property;
|
||||
import fr.xephi.authme.settings.custom.domain.PropertyType;
|
||||
import fr.xephi.authme.settings.custom.domain.SettingsClass;
|
||||
import fr.xephi.authme.settings.domain.Comment;
|
||||
import fr.xephi.authme.settings.domain.Property;
|
||||
import fr.xephi.authme.settings.domain.PropertyType;
|
||||
import fr.xephi.authme.settings.domain.SettingsClass;
|
||||
|
||||
import static fr.xephi.authme.settings.custom.domain.Property.newProperty;
|
||||
import static fr.xephi.authme.settings.domain.Property.newProperty;
|
||||
|
||||
public class HooksSettings implements SettingsClass {
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
package fr.xephi.authme.settings.custom;
|
||||
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.settings.custom.domain.Comment;
|
||||
import fr.xephi.authme.settings.custom.domain.Property;
|
||||
import fr.xephi.authme.settings.custom.domain.SettingsClass;
|
||||
import fr.xephi.authme.settings.custom.propertymap.PropertyMap;
|
||||
import fr.xephi.authme.settings.domain.Comment;
|
||||
import fr.xephi.authme.settings.domain.Property;
|
||||
import fr.xephi.authme.settings.domain.SettingsClass;
|
||||
import fr.xephi.authme.settings.propertymap.PropertyMap;
|
||||
import fr.xephi.authme.util.CollectionUtils;
|
||||
import fr.xephi.authme.util.StringUtils;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
@ -1,15 +1,15 @@
|
||||
package fr.xephi.authme.settings.custom;
|
||||
|
||||
import fr.xephi.authme.settings.custom.domain.Comment;
|
||||
import fr.xephi.authme.settings.custom.domain.Property;
|
||||
import fr.xephi.authme.settings.custom.domain.SettingsClass;
|
||||
import fr.xephi.authme.settings.domain.Comment;
|
||||
import fr.xephi.authme.settings.domain.Property;
|
||||
import fr.xephi.authme.settings.domain.SettingsClass;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static fr.xephi.authme.settings.custom.domain.Property.newProperty;
|
||||
import static fr.xephi.authme.settings.custom.domain.PropertyType.BOOLEAN;
|
||||
import static fr.xephi.authme.settings.custom.domain.PropertyType.INTEGER;
|
||||
import static fr.xephi.authme.settings.custom.domain.PropertyType.STRING_LIST;
|
||||
import static fr.xephi.authme.settings.domain.Property.newProperty;
|
||||
import static fr.xephi.authme.settings.domain.PropertyType.BOOLEAN;
|
||||
import static fr.xephi.authme.settings.domain.PropertyType.INTEGER;
|
||||
import static fr.xephi.authme.settings.domain.PropertyType.STRING_LIST;
|
||||
|
||||
|
||||
public class ProtectionSettings implements SettingsClass {
|
||||
|
@ -1,13 +1,13 @@
|
||||
package fr.xephi.authme.settings.custom;
|
||||
|
||||
import fr.xephi.authme.settings.custom.domain.Comment;
|
||||
import fr.xephi.authme.settings.custom.domain.Property;
|
||||
import fr.xephi.authme.settings.custom.domain.SettingsClass;
|
||||
import fr.xephi.authme.settings.domain.Comment;
|
||||
import fr.xephi.authme.settings.domain.Property;
|
||||
import fr.xephi.authme.settings.domain.SettingsClass;
|
||||
|
||||
import static fr.xephi.authme.settings.custom.domain.Property.newProperty;
|
||||
import static fr.xephi.authme.settings.custom.domain.PropertyType.BOOLEAN;
|
||||
import static fr.xephi.authme.settings.custom.domain.PropertyType.INTEGER;
|
||||
import static fr.xephi.authme.settings.custom.domain.PropertyType.STRING;
|
||||
import static fr.xephi.authme.settings.domain.Property.newProperty;
|
||||
import static fr.xephi.authme.settings.domain.PropertyType.BOOLEAN;
|
||||
import static fr.xephi.authme.settings.domain.PropertyType.INTEGER;
|
||||
import static fr.xephi.authme.settings.domain.PropertyType.STRING;
|
||||
|
||||
public class PurgeSettings implements SettingsClass {
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
package fr.xephi.authme.settings.custom;
|
||||
|
||||
import fr.xephi.authme.settings.custom.domain.Comment;
|
||||
import fr.xephi.authme.settings.custom.domain.Property;
|
||||
import fr.xephi.authme.settings.custom.domain.SettingsClass;
|
||||
import fr.xephi.authme.settings.domain.Comment;
|
||||
import fr.xephi.authme.settings.domain.Property;
|
||||
import fr.xephi.authme.settings.domain.SettingsClass;
|
||||
|
||||
import static fr.xephi.authme.settings.custom.domain.Property.newProperty;
|
||||
import static fr.xephi.authme.settings.custom.domain.PropertyType.BOOLEAN;
|
||||
import static fr.xephi.authme.settings.custom.domain.PropertyType.INTEGER;
|
||||
import static fr.xephi.authme.settings.domain.Property.newProperty;
|
||||
import static fr.xephi.authme.settings.domain.PropertyType.BOOLEAN;
|
||||
import static fr.xephi.authme.settings.domain.PropertyType.INTEGER;
|
||||
|
||||
public class SecuritySettings implements SettingsClass {
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
package fr.xephi.authme.settings.custom.domain;
|
||||
package fr.xephi.authme.settings.domain;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
@ -1,4 +1,4 @@
|
||||
package fr.xephi.authme.settings.custom.domain;
|
||||
package fr.xephi.authme.settings.domain;
|
||||
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package fr.xephi.authme.settings.custom.domain;
|
||||
package fr.xephi.authme.settings.domain;
|
||||
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package fr.xephi.authme.settings.custom.domain;
|
||||
package fr.xephi.authme.settings.domain;
|
||||
|
||||
/**
|
||||
* Marker for classes that define {@link Property} fields.
|
@ -1,4 +1,4 @@
|
||||
package fr.xephi.authme.settings.custom.propertymap;
|
||||
package fr.xephi.authme.settings.propertymap;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
@ -1,6 +1,6 @@
|
||||
package fr.xephi.authme.settings.custom.propertymap;
|
||||
package fr.xephi.authme.settings.propertymap;
|
||||
|
||||
import fr.xephi.authme.settings.custom.domain.Property;
|
||||
import fr.xephi.authme.settings.domain.Property;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
@ -1,6 +1,6 @@
|
||||
package fr.xephi.authme.settings.custom.propertymap;
|
||||
package fr.xephi.authme.settings.propertymap;
|
||||
|
||||
import fr.xephi.authme.settings.custom.domain.Property;
|
||||
import fr.xephi.authme.settings.domain.Property;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
@ -1,8 +1,8 @@
|
||||
package fr.xephi.authme.settings.custom;
|
||||
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.settings.custom.domain.Property;
|
||||
import fr.xephi.authme.settings.custom.domain.PropertyType;
|
||||
import fr.xephi.authme.settings.domain.Property;
|
||||
import fr.xephi.authme.settings.domain.PropertyType;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.junit.Test;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
@ -12,7 +12,7 @@ import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
|
||||
import static fr.xephi.authme.settings.custom.domain.Property.newProperty;
|
||||
import static fr.xephi.authme.settings.domain.Property.newProperty;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
@ -0,0 +1,53 @@
|
||||
package fr.xephi.authme.settings.propertymap;
|
||||
|
||||
import fr.xephi.authme.settings.domain.Property;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* Test for {@link PropertyMap}.
|
||||
*/
|
||||
public class PropertyMapTest {
|
||||
|
||||
@Test
|
||||
public void shouldKeepEntriesByInsertionAndGroup() {
|
||||
// given
|
||||
List<String> paths = Arrays.asList("japan", "indonesia.jakarta", "japan.tokyo", "china.shanghai", "egypt.cairo",
|
||||
"china.shenzhen", "china", "indonesia.jakarta.tugu", "egypt", "japan.nagoya", "japan.tokyo.taito");
|
||||
PropertyMap map = new PropertyMap();
|
||||
|
||||
// when
|
||||
for (String path : paths) {
|
||||
Property<?> property = createPropertyWithPath(path);
|
||||
map.put(property, new String[0]);
|
||||
}
|
||||
|
||||
// then
|
||||
Set<Map.Entry<Property, String[]>> entrySet = map.entrySet();
|
||||
List<String> resultPaths = new ArrayList<>(entrySet.size());
|
||||
for (Map.Entry<Property, String[]> entry : entrySet) {
|
||||
resultPaths.add(entry.getKey().getPath());
|
||||
}
|
||||
|
||||
Assert.assertThat(resultPaths, contains("japan", "japan.tokyo", "japan.tokyo.taito", "japan.nagoya",
|
||||
"indonesia.jakarta", "indonesia.jakarta.tugu", "china", "china.shanghai", "china.shenzhen",
|
||||
"egypt", "egypt.cairo"));
|
||||
}
|
||||
|
||||
private static Property<?> createPropertyWithPath(String path) {
|
||||
Property<?> property = mock(Property.class);
|
||||
when(property.getPath()).thenReturn(path);
|
||||
return property;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user