Minor - fix checkTestMocks task and rename PlayerDataTaskManager

- Fix tool task to scan test folder
- Rename PlayerDataTaskManager to LimboPlayerTaskManager to match its test class
This commit is contained in:
ljacqu 2016-10-06 20:29:50 +02:00
parent 4b2ad51354
commit 71f3b86383
11 changed files with 42 additions and 42 deletions

View File

@ -19,7 +19,7 @@ import fr.xephi.authme.settings.properties.HooksSettings;
import fr.xephi.authme.settings.properties.PluginSettings;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.settings.properties.RestrictionSettings;
import fr.xephi.authme.task.PlayerDataTaskManager;
import fr.xephi.authme.task.LimboPlayerTaskManager;
import fr.xephi.authme.service.BukkitService;
import fr.xephi.authme.util.PlayerUtils;
import org.apache.commons.lang.reflect.MethodUtils;
@ -67,7 +67,7 @@ public class AsynchronousJoin implements AsynchronousProcess {
private BukkitService bukkitService;
@Inject
private PlayerDataTaskManager playerDataTaskManager;
private LimboPlayerTaskManager limboPlayerTaskManager;
@Inject
private AsynchronousLogin asynchronousLogin;
@ -185,8 +185,8 @@ public class AsynchronousJoin implements AsynchronousProcess {
});
// Timeout and message task
playerDataTaskManager.registerTimeoutTask(player);
playerDataTaskManager.registerMessageTask(name, isAuthAvailable);
limboPlayerTaskManager.registerTimeoutTask(player);
limboPlayerTaskManager.registerMessageTask(name, isAuthAvailable);
}
private boolean isPlayerUnrestricted(String name) {

View File

@ -24,7 +24,7 @@ import fr.xephi.authme.settings.properties.EmailSettings;
import fr.xephi.authme.settings.properties.HooksSettings;
import fr.xephi.authme.settings.properties.PluginSettings;
import fr.xephi.authme.settings.properties.RestrictionSettings;
import fr.xephi.authme.task.PlayerDataTaskManager;
import fr.xephi.authme.task.LimboPlayerTaskManager;
import fr.xephi.authme.service.BukkitService;
import fr.xephi.authme.util.PlayerUtils;
import fr.xephi.authme.util.StringUtils;
@ -71,7 +71,7 @@ public class AsynchronousLogin implements AsynchronousProcess {
private TempbanManager tempbanManager;
@Inject
private PlayerDataTaskManager playerDataTaskManager;
private LimboPlayerTaskManager limboPlayerTaskManager;
AsynchronousLogin() {
}
@ -120,7 +120,7 @@ public class AsynchronousLogin implements AsynchronousProcess {
service.send(player, MessageKey.USER_NOT_REGISTERED);
// Recreate the message task to immediately send the message again as response
// and to make sure we send the right register message (password vs. email registration)
playerDataTaskManager.registerMessageTask(name, false);
limboPlayerTaskManager.registerMessageTask(name, false);
return null;
}

View File

@ -10,7 +10,7 @@ import fr.xephi.authme.process.ProcessService;
import fr.xephi.authme.process.SynchronousProcess;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.settings.properties.RestrictionSettings;
import fr.xephi.authme.task.PlayerDataTaskManager;
import fr.xephi.authme.task.LimboPlayerTaskManager;
import fr.xephi.authme.service.BukkitService;
import fr.xephi.authme.service.TeleportationService;
import org.bukkit.entity.Player;
@ -34,7 +34,7 @@ public class ProcessSynchronousPlayerLogout implements SynchronousProcess {
private ProtocolLibService protocolLibService;
@Inject
private PlayerDataTaskManager playerDataTaskManager;
private LimboPlayerTaskManager limboPlayerTaskManager;
@Inject
private SessionManager sessionManager;
@ -53,8 +53,8 @@ public class ProcessSynchronousPlayerLogout implements SynchronousProcess {
protocolLibService.sendBlankInventoryPacket(player);
}
playerDataTaskManager.registerTimeoutTask(player);
playerDataTaskManager.registerMessageTask(name, true);
limboPlayerTaskManager.registerTimeoutTask(player);
limboPlayerTaskManager.registerMessageTask(name, true);
applyLogoutEffect(player);

View File

@ -6,7 +6,7 @@ import fr.xephi.authme.permission.AuthGroupType;
import fr.xephi.authme.process.ProcessService;
import fr.xephi.authme.process.SynchronousProcess;
import fr.xephi.authme.settings.properties.HooksSettings;
import fr.xephi.authme.task.PlayerDataTaskManager;
import fr.xephi.authme.task.LimboPlayerTaskManager;
import fr.xephi.authme.util.PlayerUtils;
import org.bukkit.entity.Player;
@ -19,7 +19,7 @@ public class ProcessSyncEmailRegister implements SynchronousProcess {
private ProcessService service;
@Inject
private PlayerDataTaskManager playerDataTaskManager;
private LimboPlayerTaskManager limboPlayerTaskManager;
ProcessSyncEmailRegister() { }
@ -31,8 +31,8 @@ public class ProcessSyncEmailRegister implements SynchronousProcess {
}
service.send(player, MessageKey.ACCOUNT_NOT_ACTIVATED);
playerDataTaskManager.registerTimeoutTask(player);
playerDataTaskManager.registerMessageTask(name, true);
limboPlayerTaskManager.registerTimeoutTask(player);
limboPlayerTaskManager.registerMessageTask(name, true);
player.saveData();
ConsoleLogger.fine(player.getName() + " registered " + PlayerUtils.getPlayerIp(player));

View File

@ -10,7 +10,7 @@ import fr.xephi.authme.service.BungeeService;
import fr.xephi.authme.settings.properties.EmailSettings;
import fr.xephi.authme.settings.properties.HooksSettings;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.task.PlayerDataTaskManager;
import fr.xephi.authme.task.LimboPlayerTaskManager;
import fr.xephi.authme.util.PlayerUtils;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@ -31,7 +31,7 @@ public class ProcessSyncPasswordRegister implements SynchronousProcess {
private LimboCache limboCache;
@Inject
private PlayerDataTaskManager playerDataTaskManager;
private LimboPlayerTaskManager limboPlayerTaskManager;
ProcessSyncPasswordRegister() {
}
@ -54,8 +54,8 @@ public class ProcessSyncPasswordRegister implements SynchronousProcess {
private void requestLogin(Player player) {
final String name = player.getName().toLowerCase();
limboCache.updatePlayerData(player);
playerDataTaskManager.registerTimeoutTask(player);
playerDataTaskManager.registerMessageTask(name, true);
limboPlayerTaskManager.registerTimeoutTask(player);
limboPlayerTaskManager.registerMessageTask(name, true);
if (player.isInsideVehicle() && player.getVehicle() != null) {
player.getVehicle().eject();

View File

@ -13,7 +13,7 @@ import fr.xephi.authme.process.ProcessService;
import fr.xephi.authme.security.PasswordSecurity;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.settings.properties.RestrictionSettings;
import fr.xephi.authme.task.PlayerDataTaskManager;
import fr.xephi.authme.task.LimboPlayerTaskManager;
import fr.xephi.authme.service.BukkitService;
import fr.xephi.authme.service.TeleportationService;
import org.bukkit.command.CommandSender;
@ -46,7 +46,7 @@ public class AsynchronousUnregister implements AsynchronousProcess {
private LimboCache limboCache;
@Inject
private PlayerDataTaskManager playerDataTaskManager;
private LimboPlayerTaskManager limboPlayerTaskManager;
@Inject
private TeleportationService teleportationService;
@ -114,8 +114,8 @@ public class AsynchronousUnregister implements AsynchronousProcess {
limboCache.deletePlayerData(player);
limboCache.addPlayerData(player);
playerDataTaskManager.registerTimeoutTask(player);
playerDataTaskManager.registerMessageTask(name, false);
limboPlayerTaskManager.registerTimeoutTask(player);
limboPlayerTaskManager.registerMessageTask(name, false);
applyBlindEffect(player);
}
authGroupHandler.setGroup(player, AuthGroupType.UNREGISTERED);

View File

@ -20,7 +20,7 @@ import static fr.xephi.authme.service.BukkitService.TICKS_PER_SECOND;
/**
* Registers tasks associated with a PlayerData.
*/
public class PlayerDataTaskManager {
public class LimboPlayerTaskManager {
@Inject
private Messages messages;
@ -37,7 +37,7 @@ public class PlayerDataTaskManager {
@Inject
private PlayerCache playerCache;
PlayerDataTaskManager() {
LimboPlayerTaskManager() {
}

View File

@ -13,7 +13,7 @@ import fr.xephi.authme.settings.properties.DatabaseSettings;
import fr.xephi.authme.settings.properties.HooksSettings;
import fr.xephi.authme.settings.properties.PluginSettings;
import fr.xephi.authme.settings.properties.RestrictionSettings;
import fr.xephi.authme.task.PlayerDataTaskManager;
import fr.xephi.authme.task.LimboPlayerTaskManager;
import fr.xephi.authme.service.BukkitService;
import org.bukkit.entity.Player;
import org.junit.BeforeClass;
@ -58,7 +58,7 @@ public class AsynchronousLoginTest {
@Mock
private ProcessService processService;
@Mock
private PlayerDataTaskManager playerDataTaskManager;
private LimboPlayerTaskManager limboPlayerTaskManager;
@Mock
private BukkitService bukkitService;
@Mock

View File

@ -13,7 +13,7 @@ import fr.xephi.authme.security.PasswordSecurity;
import fr.xephi.authme.security.crypts.HashedPassword;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.settings.properties.RestrictionSettings;
import fr.xephi.authme.task.PlayerDataTaskManager;
import fr.xephi.authme.task.LimboPlayerTaskManager;
import fr.xephi.authme.service.BukkitService;
import fr.xephi.authme.service.TeleportationService;
import org.bukkit.command.CommandSender;
@ -55,7 +55,7 @@ public class AsynchronousUnregisterTest {
@Mock
private LimboCache limboCache;
@Mock
private PlayerDataTaskManager playerDataTaskManager;
private LimboPlayerTaskManager limboPlayerTaskManager;
@Mock
private TeleportationService teleportationService;
@Mock
@ -85,7 +85,7 @@ public class AsynchronousUnregisterTest {
// then
verify(service).send(player, MessageKey.WRONG_PASSWORD);
verify(passwordSecurity).comparePassword(userPassword, password, name);
verifyZeroInteractions(dataSource, playerDataTaskManager, limboCache, authGroupHandler, teleportationService);
verifyZeroInteractions(dataSource, limboPlayerTaskManager, limboCache, authGroupHandler, teleportationService);
verify(player, only()).getName();
}
@ -175,7 +175,7 @@ public class AsynchronousUnregisterTest {
verify(dataSource).removeAuth(name);
verify(playerCache).removePlayer(name);
verify(authGroupHandler).setGroup(player, AuthGroupType.UNREGISTERED);
verifyZeroInteractions(teleportationService, playerDataTaskManager);
verifyZeroInteractions(teleportationService, limboPlayerTaskManager);
verify(bukkitService, never()).runTask(any(Runnable.class));
}

View File

@ -28,13 +28,13 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
/**
* Test for {@link PlayerDataTaskManager}.
* Test for {@link LimboPlayerTaskManager}.
*/
@RunWith(MockitoJUnitRunner.class)
public class LimboPlayerTaskManagerTest {
@InjectMocks
private PlayerDataTaskManager playerDataTaskManager;
private LimboPlayerTaskManager limboPlayerTaskManager;
@Mock
private Messages messages;
@ -70,7 +70,7 @@ public class LimboPlayerTaskManagerTest {
given(settings.getProperty(RegistrationSettings.USE_EMAIL_REGISTRATION)).willReturn(true);
// when
playerDataTaskManager.registerMessageTask(name, false);
limboPlayerTaskManager.registerMessageTask(name, false);
// then
verify(limboPlayer).setMessageTask(bukkiTask);
@ -85,7 +85,7 @@ public class LimboPlayerTaskManagerTest {
given(settings.getProperty(RegistrationSettings.MESSAGE_INTERVAL)).willReturn(5);
// when
playerDataTaskManager.registerMessageTask(name, true);
limboPlayerTaskManager.registerMessageTask(name, true);
// then
verify(limboCache).getPlayerData(name);
@ -104,7 +104,7 @@ public class LimboPlayerTaskManagerTest {
given(settings.getProperty(RegistrationSettings.MESSAGE_INTERVAL)).willReturn(0);
// when
playerDataTaskManager.registerMessageTask(name, true);
limboPlayerTaskManager.registerMessageTask(name, true);
// then
verifyZeroInteractions(limboPlayer, bukkitService);
@ -128,7 +128,7 @@ public class LimboPlayerTaskManagerTest {
given(settings.getProperty(RegistrationSettings.USE_EMAIL_REGISTRATION)).willReturn(true);
// when
playerDataTaskManager.registerMessageTask(name, false);
limboPlayerTaskManager.registerMessageTask(name, false);
// then
verify(limboPlayer).setMessageTask(bukkiTask);
@ -149,7 +149,7 @@ public class LimboPlayerTaskManagerTest {
given(bukkitService.runTaskLater(any(TimeoutTask.class), anyLong())).willReturn(bukkitTask);
// when
playerDataTaskManager.registerTimeoutTask(player);
limboPlayerTaskManager.registerTimeoutTask(player);
// then
verify(limboPlayer).setTimeoutTask(bukkitTask);
@ -167,7 +167,7 @@ public class LimboPlayerTaskManagerTest {
given(settings.getProperty(RestrictionSettings.TIMEOUT)).willReturn(27);
// when
playerDataTaskManager.registerTimeoutTask(player);
limboPlayerTaskManager.registerTimeoutTask(player);
// then
verifyZeroInteractions(bukkitService, messages);
@ -184,7 +184,7 @@ public class LimboPlayerTaskManagerTest {
given(settings.getProperty(RestrictionSettings.TIMEOUT)).willReturn(0);
// when
playerDataTaskManager.registerTimeoutTask(player);
limboPlayerTaskManager.registerTimeoutTask(player);
// then
verifyZeroInteractions(limboPlayer, bukkitService);
@ -205,7 +205,7 @@ public class LimboPlayerTaskManagerTest {
given(bukkitService.runTaskLater(any(TimeoutTask.class), anyLong())).willReturn(bukkitTask);
// when
playerDataTaskManager.registerTimeoutTask(player);
limboPlayerTaskManager.registerTimeoutTask(player);
// then
verify(existingTask).cancel();

View File

@ -36,7 +36,7 @@ public class CheckTestMocks implements AutoToolTask {
@Override
public void executeDefault() {
ClassCollector collector = new ClassCollector(TestHelper.SOURCES_FOLDER, TestHelper.PROJECT_ROOT);
ClassCollector collector = new ClassCollector(TestHelper.TEST_SOURCES_FOLDER, TestHelper.PROJECT_ROOT);
for (Class<?> clazz : collector.collectClasses(c -> isTestClassWithMocks(c))) {
checkClass(clazz);
}