SimpleShardDataTreeCohort extends ShardDataTreeCohort { @Override public void abort(final FutureCallback<Void> abortCallback) { if (!dataTree.startAbort(this)) { abortCallback.onSuccess(null); return; } candidate = null; state = State.ABORTED; final Optional<CompletionStage<?>> maybeAborts = userCohorts.abort(); if (!maybeAborts.isPresent()) { abortCallback.onSuccess(null); return; } maybeAborts.get().whenComplete((noop, failure) -> { if (failure != null) { abortCallback.onFailure(failure); } else { abortCallback.onSuccess(null); } }); } SimpleShardDataTreeCohort(final ShardDataTree dataTree, final DataTreeModification transaction,
            final TransactionIdentifier transactionId, final CompositeDataTreeCohort userCohorts,
            final Optional<SortedSet<String>> participatingShardNames);   SimpleShardDataTreeCohort(final ShardDataTree dataTree, final DataTreeModification transaction,
        final TransactionIdentifier transactionId, final Exception nextFailure); @Override TransactionIdentifier getIdentifier(); @Override void canCommit(final FutureCallback<Void> newCallback); @Override void preCommit(final FutureCallback<DataTreeCandidate> newCallback); @Override void abort(final FutureCallback<Void> abortCallback); @Override void commit(final FutureCallback<UnsignedLong> newCallback); @Override State getState(); @Override boolean isFailed();  }
@Test public void testAbort() throws Exception { doReturn(Boolean.TRUE).when(mockShardDataTree).startAbort(cohort); abort(cohort).get(); verify(mockShardDataTree).startAbort(cohort); }
@Test public void testAbortWithCohorts() throws Exception { doReturn(true).when(mockShardDataTree).startAbort(cohort); doReturn(Optional.of(CompletableFuture.completedFuture(null))).when(mockUserCohorts).abort(); final Future<?> abortFuture = abort(cohort); abortFuture.get(); verify(mockShardDataTree).startAbort(cohort); }