package core.framework.test.async;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
 * @author neo
 */
class MockExecutorTest {
    private MockExecutor executor;

    @BeforeEach
    void createMockExecutor() {
        executor = new MockExecutor();
    }

    @Test
    void get() throws ExecutionException, InterruptedException, TimeoutException {
        Future<Integer> future = executor.submit("action", () -> 12);

        assertTrue(future.isDone());
        assertFalse(future.isCancelled());
        assertEquals(12, future.get(0, TimeUnit.MILLISECONDS).intValue());
    }
}

@@ -297,142 +297,20 @@
 org.
-junit.jupiter.api.Assertions.assertEquals;%0Aimport static org.junit.jupiter.api.Assertions.assertFalse;%0Aimport static org.junit.jupiter
+assertj.core
 .api
@@ -328,19 +328,19 @@
 .assertT
-rue
+hat
 ;%0A%0A/**%0A 
@@ -695,18 +695,19 @@
 ertT
-rue
+hat
 (future
+)
 .isD
@@ -715,40 +715,14 @@
 ne()
-);%0A        assertFalse(future
 .is
+Not
 Canc
@@ -728,17 +728,16 @@
 celled()
-)
 ;%0A      
@@ -748,19 +748,13 @@
 sert
-Equals(12, 
+That(
 futu
@@ -789,19 +789,194 @@
 NDS)
+)
 .i
-ntValue()
+sEqualTo(12);%0A    %7D%0A%0A    @Test%0A    void submitTask() %7B%0A        Future%3CVoid%3E future = executor.submit(%22action%22, () -%3E %7B%0A        %7D);%0A%0A        assertThat(future).isDone().isNotCancelled(
 );%0A 

test executor submit task