Package cleanup

- authme.cache to authme.data
- Rename PlayerData to LimboPlayer to match with LimboCache
- Move authme.converter to authme.datasource.converter
- Split output package into output and message
This commit is contained in:
Gabriele C
2016-10-04 21:49:14 +02:00
committed by ljacqu
parent 7e2912cc60
commit 58c42cf300
149 changed files with 491 additions and 475 deletions
@@ -4,8 +4,8 @@ import ch.jalu.injector.testing.BeforeInjecting;
import ch.jalu.injector.testing.DelayedInjectionRunner;
import ch.jalu.injector.testing.InjectDelayed;
import fr.xephi.authme.ReflectionTestUtils;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.output.Messages;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.message.Messages;
import fr.xephi.authme.permission.AdminPermission;
import fr.xephi.authme.permission.PermissionsManager;
import fr.xephi.authme.settings.Settings;
@@ -1,12 +1,11 @@
package fr.xephi.authme.service;
import fr.xephi.authme.TestHelper;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.security.HashAlgorithm;
import fr.xephi.authme.security.crypts.HashedPassword;
import fr.xephi.authme.security.crypts.SHA256;
import fr.xephi.authme.service.MigrationService;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.SecuritySettings;
import org.junit.BeforeClass;
@@ -1,12 +1,10 @@
package fr.xephi.authme.service;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.cache.limbo.PlayerData;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.data.auth.PlayerCache;
import fr.xephi.authme.data.limbo.LimboPlayer;
import fr.xephi.authme.events.FirstSpawnTeleportEvent;
import fr.xephi.authme.events.SpawnTeleportEvent;
import fr.xephi.authme.service.BukkitService;
import fr.xephi.authme.service.TeleportationService;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.SpawnLoader;
import fr.xephi.authme.settings.properties.RestrictionSettings;
@@ -237,7 +235,7 @@ public class TeleportationServiceTest {
given(settings.getProperty(RestrictionSettings.NO_TELEPORT)).willReturn(true);
Player player = mock(Player.class);
PlayerAuth auth = mock(PlayerAuth.class);
PlayerData limbo = mock(PlayerData.class);
LimboPlayer limbo = mock(LimboPlayer.class);
// when
teleportationService.teleportOnLogin(player, auth, limbo);
@@ -255,7 +253,7 @@ public class TeleportationServiceTest {
Location spawn = mockLocation();
given(spawnLoader.getSpawnLocation(player)).willReturn(spawn);
PlayerAuth auth = mock(PlayerAuth.class);
PlayerData limbo = mock(PlayerData.class);
LimboPlayer limbo = mock(LimboPlayer.class);
Location limboLocation = mockLocation();
given(limboLocation.getWorld().getName()).willReturn("forced1");
given(limbo.getLocation()).willReturn(limboLocation);
@@ -279,7 +277,7 @@ public class TeleportationServiceTest {
Location spawn = mockLocation();
given(spawnLoader.getSpawnLocation(player)).willReturn(spawn);
PlayerAuth auth = mock(PlayerAuth.class);
PlayerData limbo = mock(PlayerData.class);
LimboPlayer limbo = mock(LimboPlayer.class);
Location limboLocation = mockLocation();
given(limboLocation.getWorld().getName()).willReturn("Forced1"); // different case
given(limbo.getLocation()).willReturn(limboLocation);
@@ -306,7 +304,7 @@ public class TeleportationServiceTest {
Player player = mock(Player.class);
given(player.isOnline()).willReturn(true);
PlayerData limbo = mock(PlayerData.class);
LimboPlayer limbo = mock(LimboPlayer.class);
Location limboLocation = mockLocation();
given(limbo.getLocation()).willReturn(limboLocation);
@@ -335,7 +333,7 @@ public class TeleportationServiceTest {
given(player.isOnline()).willReturn(true);
World world = mock(World.class);
given(player.getWorld()).willReturn(world);
PlayerData limbo = mock(PlayerData.class);
LimboPlayer limbo = mock(LimboPlayer.class);
Location limboLocation = mockLocation();
given(limbo.getLocation()).willReturn(limboLocation);
@@ -363,7 +361,7 @@ public class TeleportationServiceTest {
given(player.isOnline()).willReturn(true);
World world = mock(World.class);
given(player.getWorld()).willReturn(world);
PlayerData limbo = mock(PlayerData.class);
LimboPlayer limbo = mock(LimboPlayer.class);
Location location = mockLocation();
given(limbo.getLocation()).willReturn(location);
@@ -388,7 +386,7 @@ public class TeleportationServiceTest {
given(player.isOnline()).willReturn(true);
World world = mock(World.class);
given(player.getWorld()).willReturn(world);
PlayerData limbo = mock(PlayerData.class);
LimboPlayer limbo = mock(LimboPlayer.class);
Location location = mockLocation();
given(limbo.getLocation()).willReturn(location);
@@ -409,7 +407,7 @@ public class TeleportationServiceTest {
PlayerAuth auth = PlayerAuth.builder().name("bobby").build();
Player player = mock(Player.class);
PlayerData limbo = mock(PlayerData.class);
LimboPlayer limbo = mock(LimboPlayer.class);
// when
teleportationService.teleportOnLogin(player, auth, limbo);
@@ -5,11 +5,10 @@ import ch.jalu.injector.testing.DelayedInjectionRunner;
import ch.jalu.injector.testing.InjectDelayed;
import com.google.common.base.Strings;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.geoip.GeoLiteAPI;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.geoip.GeoIpManager;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.permission.PermissionsManager;
import fr.xephi.authme.permission.PlayerStatePermission;
import fr.xephi.authme.service.ValidationService;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.EmailSettings;
import fr.xephi.authme.settings.properties.ProtectionSettings;
@@ -46,7 +45,7 @@ public class ValidationServiceTest {
@Mock
private PermissionsManager permissionsManager;
@Mock
private GeoLiteAPI geoLiteApi;
private GeoIpManager geoIpManager;
@BeforeInjecting
public void createService() {
@@ -267,7 +266,7 @@ public class ValidationServiceTest {
// then
assertThat(result, equalTo(true));
verifyZeroInteractions(geoLiteApi);
verifyZeroInteractions(geoIpManager);
}
@Test
@@ -276,14 +275,14 @@ public class ValidationServiceTest {
given(settings.getProperty(ProtectionSettings.COUNTRIES_WHITELIST)).willReturn(asList("ch", "it"));
given(settings.getProperty(ProtectionSettings.COUNTRIES_BLACKLIST)).willReturn(Collections.<String>emptyList());
String ip = "127.0.0.1";
given(geoLiteApi.getCountryCode(ip)).willReturn("CH");
given(geoIpManager.getCountryCode(ip)).willReturn("CH");
// when
boolean result = validationService.isCountryAdmitted(ip);
// then
assertThat(result, equalTo(true));
verify(geoLiteApi).getCountryCode(ip);
verify(geoIpManager).getCountryCode(ip);
}
@Test
@@ -292,14 +291,14 @@ public class ValidationServiceTest {
given(settings.getProperty(ProtectionSettings.COUNTRIES_WHITELIST)).willReturn(asList("ch", "it"));
given(settings.getProperty(ProtectionSettings.COUNTRIES_BLACKLIST)).willReturn(Collections.<String>emptyList());
String ip = "123.45.67.89";
given(geoLiteApi.getCountryCode(ip)).willReturn("BR");
given(geoIpManager.getCountryCode(ip)).willReturn("BR");
// when
boolean result = validationService.isCountryAdmitted(ip);
// then
assertThat(result, equalTo(false));
verify(geoLiteApi).getCountryCode(ip);
verify(geoIpManager).getCountryCode(ip);
}
@Test
@@ -308,14 +307,14 @@ public class ValidationServiceTest {
given(settings.getProperty(ProtectionSettings.COUNTRIES_WHITELIST)).willReturn(Collections.<String>emptyList());
given(settings.getProperty(ProtectionSettings.COUNTRIES_BLACKLIST)).willReturn(asList("ch", "it"));
String ip = "127.0.0.1";
given(geoLiteApi.getCountryCode(ip)).willReturn("BR");
given(geoIpManager.getCountryCode(ip)).willReturn("BR");
// when
boolean result = validationService.isCountryAdmitted(ip);
// then
assertThat(result, equalTo(true));
verify(geoLiteApi).getCountryCode(ip);
verify(geoIpManager).getCountryCode(ip);
}
@Test
@@ -324,14 +323,14 @@ public class ValidationServiceTest {
given(settings.getProperty(ProtectionSettings.COUNTRIES_WHITELIST)).willReturn(Collections.<String>emptyList());
given(settings.getProperty(ProtectionSettings.COUNTRIES_BLACKLIST)).willReturn(asList("ch", "it"));
String ip = "123.45.67.89";
given(geoLiteApi.getCountryCode(ip)).willReturn("IT");
given(geoIpManager.getCountryCode(ip)).willReturn("IT");
// when
boolean result = validationService.isCountryAdmitted(ip);
// then
assertThat(result, equalTo(false));
verify(geoLiteApi).getCountryCode(ip);
verify(geoIpManager).getCountryCode(ip);
}
private static void assertErrorEquals(ValidationResult validationResult, MessageKey messageKey, String... args) {