Create tests for admin commands

This commit is contained in:
ljacqu
2016-03-13 10:17:09 +01:00
parent 4d45b18759
commit 00125487f1
19 changed files with 1001 additions and 47 deletions
@@ -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();
}
}