X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FSimpleShardDataTreeCohortTest.java;h=5b218715737b6a34032aacc0beb01826e2da1444;hb=refs%2Fchanges%2F27%2F54327%2F9;hp=232d9aa618a0b88909d00d7788dee12df8e5a11f;hpb=5464f50be733df1bbbe31cf05665d542d3b7c5e7;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/SimpleShardDataTreeCohortTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/SimpleShardDataTreeCohortTest.java index 232d9aa618..5b21871573 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/SimpleShardDataTreeCohortTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/SimpleShardDataTreeCohortTest.java @@ -19,9 +19,10 @@ import static org.mockito.Mockito.verifyNoMoreInteractions; import com.google.common.primitives.UnsignedLong; import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.ListenableFuture; import java.util.Collections; import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Future; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; @@ -61,7 +62,7 @@ public class SimpleShardDataTreeCohortTest extends AbstractTest { doNothing().when(mockUserCohorts).commit(); doReturn(Optional.empty()).when(mockUserCohorts).abort(); - cohort = new SimpleShardDataTreeCohort(mockShardDataTree, mockModification, nextTransactionId(), + cohort = new SimpleShardDataTreeCohort.Normal(mockShardDataTree, mockModification, nextTransactionId(), mockUserCohorts); } @@ -210,23 +211,39 @@ public class SimpleShardDataTreeCohortTest extends AbstractTest { verify(mockUserCohorts).abort(); } + private static Future abort(final ShardDataTreeCohort cohort) { + final CompletableFuture f = new CompletableFuture<>(); + cohort.abort(new FutureCallback() { + @Override + public void onSuccess(final Void result) { + f.complete(null); + } + + @Override + public void onFailure(final Throwable failure) { + f.completeExceptionally(failure); + } + }); + + return f; + } + @Test public void testAbort() throws Exception { - doNothing().when(mockShardDataTree).startAbort(cohort); - - cohort.abort().get(); + doReturn(true).when(mockShardDataTree).startAbort(cohort); + abort(cohort).get(); verify(mockShardDataTree).startAbort(cohort); } @Test public void testAbortWithCohorts() throws Exception { - doNothing().when(mockShardDataTree).startAbort(cohort); + doReturn(true).when(mockShardDataTree).startAbort(cohort); final Promise> cohortFuture = akka.dispatch.Futures.promise(); doReturn(Optional.of(cohortFuture.future())).when(mockUserCohorts).abort(); - final ListenableFuture abortFuture = cohort.abort(); + final Future abortFuture = abort(cohort); cohortFuture.success(Collections.emptyList());