| 7 | import org.junit.Test; |
| 8 | |
| 9 | public class WaitQueueTest { |
| 10 | |
| 11 | private <T> T get(Future<T> future) throws CheckedFutureException { |
| 12 | return future.get(Duration.ZERO); |
| 13 | } |
| 14 | |
| 15 | private <T> Continuation<T, T> newContinuation() { |
| 16 | return new Continuation<T, T>() { |
| 17 | @Override |
| 18 | Future<T> apply(Future<T> result) { |
| 19 | return result; |
| 20 | } |
| 21 | }; |
| 22 | } |
| 23 | |
| 24 | @Test |
| 25 | public void addAndFlush1() throws CheckedFutureException { |
| 26 | Continuation<Integer, Integer> c = newContinuation(); |
| 27 | |
| 28 | c.flush(Future.value(1)); |
| 29 | |
| 30 | assertEquals(new Integer(1), get(c)); |
| 31 | } |
| 32 | |
| 33 | @Test |
| 34 | public void addAndFlush2() throws CheckedFutureException { |
| 35 | Continuation<Integer, Integer> c1 = newContinuation(); |
| 36 | Continuation<Integer, Integer> c2 = newContinuation(); |
| 37 | |
| 38 | c1.add(c2).flush(Future.value(1)); |
| 39 | |
| 40 | assertEquals(new Integer(1), get(c1)); |
| 41 | assertEquals(new Integer(1), get(c2)); |
| 42 | } |
| 43 | |
| 44 | @Test |
| 45 | public void addAndFlush3() throws CheckedFutureException { |
| 46 | Continuation<Integer, Integer> c1 = newContinuation(); |
| 47 | Continuation<Integer, Integer> c2 = newContinuation(); |
| 48 | Continuation<Integer, Integer> c3 = newContinuation(); |
| 49 | |
| 50 | c1.add(c2).add(c3).flush(Future.value(1)); |
| 51 | |
| 52 | assertEquals(new Integer(1), get(c1)); |
| 53 | assertEquals(new Integer(1), get(c2)); |
| 54 | assertEquals(new Integer(1), get(c3)); |
| 55 | } |
| 56 | |
| 57 | @Test |
| 58 | public void addAndFlush4() throws CheckedFutureException { |
| 59 | Continuation<Integer, Integer> c1 = newContinuation(); |
| 60 | Continuation<Integer, Integer> c2 = newContinuation(); |
| 61 | Continuation<Integer, Integer> c3 = newContinuation(); |
| 62 | Continuation<Integer, Integer> c4 = newContinuation(); |
| 63 | |
| 64 | c1.add(c2).add(c3).add(c4).flush(Future.value(1)); |
| 65 | |
| 66 | assertEquals(new Integer(1), get(c1)); |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…