OperationSequence { public OperationSequence abortOnFirstFailure() { this.abortOnFirstFailure = true; return this; } private  OperationSequence(OperationJoin join); static OperationSequence create(OperationJoin... joins); static OperationSequence create(Operation... ops); OperationSequence next(OperationJoin... joins); OperationSequence next(Operation... ops); OperationSequence setCompletion(JoinedCompletionHandler joinedCompletion); OperationSequence setCompletion(boolean cumulative, JoinedCompletionHandler joinedCompletion); OperationSequence abortOnFirstFailure(); void sendWith(ServiceRequestSender sender);  }
@Test public void testAbortOnFirstFailure() throws Throwable { Operation op1 = createServiceOperation(this.services.get(0)); Operation op2 = createServiceOperation(this.services.get(1)); Operation op3 = createServiceOperation(this.services.get(1)); boolean[] called = new boolean[3]; op1.setCompletion((o, e) -> { called[0] = true; }); op2.setUri(UriUtils.buildUri(op1.getUri(), "/not-exist")); op2.setCompletion((o, e) -> { called[1] = true; assertNotNull("op2 should fail with error", e); host.completeIteration(); }); op3.setCompletion((o, e) -> { called[2] = true; fail("op3 completionHandler should not be called"); }); host.testStart(1); OperationSequence .create(op1) .next(op2) .next(op3) .setCompletion((ops, exc) -> { fail("Joined completion handler should not be called"); }) .abortOnFirstFailure() .sendWith(host); host.testWait(); assertTrue("op1 should be called", called[0]); assertTrue("op2 should be called", called[1]); assertFalse("op3 should not be called", called[2]); }