core/src/test/java/io/machinecode/then/core/OnceDeferredTest.java
//Test OnceDeferred which should throw various CompletionException if completion is attempted twice
Test OnceDeferred which should throw various CompletionException if completion is attempted twice
Test OnceDeferred which should throw various CompletionException if completion is attempted twice
@Test
    public void deferredAlreadyResolvedTest() throws Exception {
        final Object val = new Object();
        try {
            final OnceDeferred<Object,Throwable,Void> p = new OnceDeferred<>();
            p.resolve(val);
            p.resolve(val);
            Assert.fail();
        } catch (final ResolvedException e) {
        }
        try {
            final OnceDeferred<Object,Throwable,Void> p = new OnceDeferred<>();
            p.resolve(val);
            p.reject(new Throwable());
            Assert.fail();
        } catch (final ResolvedException e) {
        }
        final OnceDeferred<Object,Throwable,Void> p = new OnceDeferred<>();
        p.resolve(val);
        p.cancel(true);
    }
@ Test public void deferredAlreadyResolvedTest ( ) throws Exception { final Object val = new Object ( ) ; try { final OnceDeferred < Object , Throwable , Void > p = new OnceDeferred < > ( ) ; p . resolve ( val ) ; p . resolve ( val ) ; Assert . fail ( ) ; } catch ( final ResolvedException e ) { } try { final OnceDeferred < Object , Throwable , Void > p = new OnceDeferred < > ( ) ; p . resolve ( val ) ; p . reject ( new Throwable ( ) ) ; Assert . fail ( ) ; } catch ( final ResolvedException e ) { } final OnceDeferred < Object , Throwable , Void > p = new OnceDeferred < > ( ) ; p . resolve ( val ) ; p . cancel ( true ) ; }
Test OnceDeferred which should throw various CompletionException if completion is attempted twice
Test OnceDeferred which should throw various CompletionException if completion is attempted twice
//Expected //Expected