Create tests for admin commands
This commit is contained in:
@@ -1,10 +1,15 @@
|
||||
package fr.xephi.authme;
|
||||
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* AuthMe test utilities.
|
||||
*/
|
||||
@@ -47,4 +52,18 @@ public final class TestHelper {
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a {@link Runnable} passed to a mock's {@link CommandService#runTaskAsynchronously} 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 runInnerRunnable(CommandService service) {
|
||||
ArgumentCaptor<Runnable> captor = ArgumentCaptor.forClass(Runnable.class);
|
||||
verify(service).runTaskAsynchronously(captor.capture());
|
||||
Runnable runnable = captor.getValue();
|
||||
runnable.run();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user