Skip to content
This repository was archived by the owner on Oct 16, 2022. It is now read-only.

Commit 3062f1f

Browse files
Avoid having to disable warnings by instead using nice @mock annotation
1 parent 7c1ff79 commit 3062f1f

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

tiny-async-core/src/test/java/eu/toolchain/async/RecursionSafeAsyncCallerTest.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
import org.junit.Before;
44
import org.junit.Test;
5+
import org.junit.runner.RunWith;
6+
import org.mockito.Mock;
57
import org.mockito.invocation.InvocationOnMock;
8+
import org.mockito.runners.MockitoJUnitRunner;
69
import org.mockito.stubbing.Answer;
710

811
import java.util.concurrent.ExecutorService;
@@ -13,29 +16,35 @@
1316
import static org.mockito.Mockito.mock;
1417
import static org.mockito.Mockito.verify;
1518

19+
@RunWith(MockitoJUnitRunner.class)
1620
public class RecursionSafeAsyncCallerTest {
1721
private final Object result = new Object();
1822
private final Throwable cause = new Exception();
1923

20-
private ExecutorService executor;
2124
private AsyncCaller caller;
2225

2326
private RecursionSafeAsyncCaller underTest;
2427

28+
@Mock
2529
private FutureDone<Object> done;
30+
@Mock
2631
private FutureCancelled cancelled;
32+
@Mock
2733
private FutureFinished finished;
34+
@Mock
2835
private FutureResolved<Object> resolved;
36+
@Mock
2937
private FutureFailed failed;
3038

39+
@Mock
3140
private StreamCollector<Object, Object> streamCollector;
3241

3342
private StackTraceElement[] stack = new StackTraceElement[0];
3443

35-
@SuppressWarnings("unchecked")
44+
3645
@Before
3746
public void setup() {
38-
executor = mock(ExecutorService.class);
47+
ExecutorService executor = mock(ExecutorService.class);
3948

4049
doAnswer(new Answer<Void>() {
4150
@Override
@@ -48,14 +57,6 @@ public Void answer(InvocationOnMock invocation) throws Throwable {
4857

4958
caller = mock(AsyncCaller.class);
5059
underTest = new RecursionSafeAsyncCaller(executor, caller);
51-
52-
done = mock(FutureDone.class);
53-
cancelled = mock(FutureCancelled.class);
54-
finished = mock(FutureFinished.class);
55-
resolved = mock(FutureResolved.class);
56-
failed = mock(FutureFailed.class);
57-
58-
streamCollector = mock(StreamCollector.class);
5960
}
6061

6162
@Test

0 commit comments

Comments
 (0)