Test AntiBot + SwitchAntiBotCommand

This commit is contained in:
ljacqu
2016-03-24 22:11:40 +01:00
parent 351b24fd14
commit 55c24b8e64
8 changed files with 372 additions and 25 deletions
@@ -1,6 +1,7 @@
package fr.xephi.authme;
import fr.xephi.authme.command.CommandService;
import fr.xephi.authme.util.BukkitService;
import org.mockito.ArgumentCaptor;
import java.io.File;
@@ -8,6 +9,7 @@ import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;
import static org.mockito.Matchers.anyLong;
import static org.mockito.Mockito.verify;
/**
@@ -66,4 +68,32 @@ public final class TestHelper {
runnable.run();
}
/**
* Execute a {@link Runnable} passed to a mock's {@link BukkitService#scheduleSyncDelayedTask(Runnable)} method.
* Note that calling this method expects that there be a runnable sent to the method and will fail
* otherwise.
*
* @param service The mock service
*/
public static void runSyncDelayedTask(BukkitService service) {
ArgumentCaptor<Runnable> captor = ArgumentCaptor.forClass(Runnable.class);
verify(service).scheduleSyncDelayedTask(captor.capture());
Runnable runnable = captor.getValue();
runnable.run();
}
/**
* Execute a {@link Runnable} passed to a mock's {@link BukkitService#scheduleSyncDelayedTask(Runnable, long)}
* method. Note that calling this method expects that there be a runnable sent to the method and will fail
* otherwise.
*
* @param service The mock service
*/
public static void runSyncDelayedTaskWithDelay(BukkitService service) {
ArgumentCaptor<Runnable> captor = ArgumentCaptor.forClass(Runnable.class);
verify(service).scheduleSyncDelayedTask(captor.capture(), anyLong());
Runnable runnable = captor.getValue();
runnable.run();
}
}