mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 00:45:44 +01:00
Fix test helper
This commit is contained in:
@@ -4,7 +4,9 @@ import java.util.function.Consumer;
|
|||||||
|
|
||||||
public interface SyncAsyncExecutor {
|
public interface SyncAsyncExecutor {
|
||||||
|
|
||||||
ExecutionType execute(Runnable runnable);
|
default ExecutionType execute(Runnable runnable) {
|
||||||
|
return execute(ignored -> runnable.run());
|
||||||
|
}
|
||||||
|
|
||||||
ExecutionType execute(Consumer<ExecutionType> runnable);
|
ExecutionType execute(Consumer<ExecutionType> runnable);
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,23 @@
|
|||||||
package sonia.scm.repository.spi;
|
package sonia.scm.repository.spi;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
import static sonia.scm.repository.spi.SyncAsyncExecutor.ExecutionType.SYNCHRONOUS;
|
||||||
|
|
||||||
public final class SyncAsyncExecutors {
|
public final class SyncAsyncExecutors {
|
||||||
|
|
||||||
public static SyncAsyncExecutor synchronousExecutor() {
|
public static SyncAsyncExecutor synchronousExecutor() {
|
||||||
return new SyncAsyncExecutor(Runnable::run, Instant.MAX);
|
return new SyncAsyncExecutor() {
|
||||||
|
@Override
|
||||||
|
public ExecutionType execute(Consumer<ExecutionType> runnable) {
|
||||||
|
runnable.accept(SYNCHRONOUS);
|
||||||
|
return SYNCHRONOUS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasExecutedAllSynchronously() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,10 +20,6 @@ public class DefaultSyncAsyncExecutor implements SyncAsyncExecutor {
|
|||||||
this.switchToAsyncTime = switchToAsyncTime;
|
this.switchToAsyncTime = switchToAsyncTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExecutionType execute(Runnable runnable) {
|
|
||||||
return execute(ignored -> runnable.run());
|
|
||||||
}
|
|
||||||
|
|
||||||
public ExecutionType execute(Consumer<ExecutionType> runnable) {
|
public ExecutionType execute(Consumer<ExecutionType> runnable) {
|
||||||
if (Instant.now().isAfter(switchToAsyncTime)) {
|
if (Instant.now().isAfter(switchToAsyncTime)) {
|
||||||
executor.execute(() -> runnable.accept(ASYNCHRONOUS));
|
executor.execute(() -> runnable.accept(ASYNCHRONOUS));
|
||||||
|
|||||||
Reference in New Issue
Block a user