implement DEV workspace and project automation authority

This commit is contained in:
2026-09-29 07:09:37 +01:00
parent 0ddf3ef70d
commit e3c3b2cbb7
62 changed files with 2180 additions and 354 deletions
@@ -12,6 +12,39 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
final class ExecutorOperationExecutorTest {
@Test
void cancellationDoesNotPretendAnUncooperativeWorkerHasStopped() throws Exception {
final var executor = Executors.newSingleThreadExecutor();
final var started = new CountDownLatch(1);
final var finish = new CountDownLatch(1);
try {
var handle = new ExecutorOperationExecutor(executor).submit("stubborn worker", () -> {
started.countDown();
boolean done = false;
while (!done) try { finish.await(); done = true; } catch (InterruptedException ignored) { }
return 42;
});
assertTrue(started.await(2, TimeUnit.SECONDS));
handle.cancel();
assertTrue(handle.completion().toCompletableFuture().isCancelled());
org.junit.jupiter.api.Assertions.assertFalse(handle.termination().toCompletableFuture().isDone());
finish.countDown();
handle.termination().toCompletableFuture().get(2, TimeUnit.SECONDS);
} finally { finish.countDown(); executor.shutdownNow(); }
}
@Test
void cancellingQueuedWorkCompletesTerminationWithoutRunningItsBody() throws Exception {
final var executor = Executors.newSingleThreadExecutor();
final var finish = new CountDownLatch(1);
try {
executor.submit(() -> { try { finish.await(); } catch (InterruptedException ignored) { } });
var handle = new ExecutorOperationExecutor(executor).submit("queued", () -> { throw new AssertionError("must not execute"); });
handle.cancel();
handle.termination().toCompletableFuture().get(2, TimeUnit.SECONDS);
} finally { finish.countDown(); executor.shutdownNow(); }
}
@Test
void completesWithTypedResultAndTerminalSnapshot() throws Exception {
final var executor = Executors.newSingleThreadExecutor();