#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:
ljacqu
2016-09-18 21:58:14 +02:00
parent ff9f50f63f
commit 4eab258993
20 changed files with 169 additions and 172 deletions
@@ -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.
*