|
10 | 10 | public class ObtrudeTest {
|
11 | 11 | @Test
|
12 | 12 | public void testObtrudeAfterCallback() {
|
13 |
| - CompletableFuture<String> future = CompletableFuture.completedFuture("first"); |
14 |
| - CompletableFuture<String> future2 = future.thenApply(v -> v + " second"); |
| 13 | + CompletableFuture<String> parent = CompletableFuture.completedFuture("first"); |
| 14 | + CompletableFuture<String> child = parent.thenApply(v -> v + " second"); |
15 | 15 |
|
16 |
| - assertEquals("first", CompletableFutures.getCompleted(future)); |
17 |
| - assertEquals("first second", CompletableFutures.getCompleted(future2)); |
| 16 | + assertEquals("first", CompletableFutures.getCompleted(parent)); |
| 17 | + assertEquals("first second", CompletableFutures.getCompleted(child)); |
18 | 18 |
|
19 |
| - future.obtrudeValue("not-first"); |
20 |
| - assertEquals("not-first", CompletableFutures.getCompleted(future)); |
21 |
| - assertEquals("first second", CompletableFutures.getCompleted(future2)); |
| 19 | + parent.obtrudeValue("not-first"); |
| 20 | + assertEquals("not-first", CompletableFutures.getCompleted(parent)); |
| 21 | + assertEquals("first second", CompletableFutures.getCompleted(child)); |
22 | 22 | }
|
23 | 23 |
|
24 | 24 | @Test
|
25 | 25 | public void testObtrudeBeforeCallback() {
|
26 |
| - CompletableFuture<String> future = new CompletableFuture<>(); |
27 |
| - CompletableFuture<String> future2 = future.thenApply(v -> v + " second"); |
| 26 | + CompletableFuture<String> parent = new CompletableFuture<>(); |
| 27 | + CompletableFuture<String> child = parent.thenApply(v -> v + " second"); |
28 | 28 |
|
29 |
| - future.obtrudeValue("first"); |
30 |
| - assertEquals("first", CompletableFutures.getCompleted(future)); |
31 |
| - assertEquals("first second", CompletableFutures.getCompleted(future2)); |
| 29 | + parent.obtrudeValue("first"); |
| 30 | + assertEquals("first", CompletableFutures.getCompleted(parent)); |
| 31 | + assertEquals("first second", CompletableFutures.getCompleted(child)); |
32 | 32 |
|
33 |
| - future.obtrudeValue("not-first"); |
34 |
| - CompletableFuture<String> future3 = future.thenApply(v -> v + " second"); |
| 33 | + parent.obtrudeValue("not-first"); |
| 34 | + CompletableFuture<String> future3 = parent.thenApply(v -> v + " second"); |
35 | 35 |
|
36 | 36 | assertEquals("not-first second", CompletableFutures.getCompleted(future3));
|
37 | 37 | }
|
|
0 commit comments