#937 Add option for AuthMe to run in sync
- Create BukkitService#runTaskOptionallyAsync and BukkitService#scheduleSyncTaskFromOptionallyAsyncTask whose behavior depends on a new setting - Use the new methods where applicable - Declare events async or sync depending on the new setting
This commit is contained in:
@@ -87,6 +87,20 @@ public final class TestHelper {
|
||||
runnable.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a {@link Runnable} passed to a mock's {@link BukkitService#runTaskOptionallyAsync} 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 runOptionallyAsyncTask(BukkitService service) {
|
||||
ArgumentCaptor<Runnable> captor = ArgumentCaptor.forClass(Runnable.class);
|
||||
verify(service).runTaskOptionallyAsync(captor.capture());
|
||||
Runnable runnable = captor.getValue();
|
||||
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
|
||||
@@ -115,6 +129,20 @@ public final class TestHelper {
|
||||
runnable.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a {@link Runnable} passed to a mock's {@link BukkitService#scheduleSyncTaskFromOptionallyAsyncTask}
|
||||
* 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 runSyncTaskFromOptionallyAsyncTask(BukkitService service) {
|
||||
ArgumentCaptor<Runnable> captor = ArgumentCaptor.forClass(Runnable.class);
|
||||
verify(service).scheduleSyncTaskFromOptionallyAsyncTask(captor.capture());
|
||||
Runnable runnable = captor.getValue();
|
||||
runnable.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign the necessary fields on ConsoleLogger with mocks.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user