X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FAbstractShardTest.java;h=7fe5e87860078452619f6aa4ffed27600030268d;hp=6f07390ba207afe5aad2b5b5c50aad8883123d57;hb=ccca30bbb1545643c427fc59c23329c5d49f8d4b;hpb=bfb38b42aa055a2478a5972f15ca4246dee796e9 diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractShardTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractShardTest.java index 6f07390ba2..7fe5e87860 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractShardTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractShardTest.java @@ -11,7 +11,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.nullable; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; @@ -19,6 +20,7 @@ import static org.opendaylight.controller.cluster.datastore.DataStoreVersions.CU import static org.opendaylight.controller.cluster.datastore.ShardDataTreeMocking.successfulCanCommit; import static org.opendaylight.controller.cluster.datastore.ShardDataTreeMocking.successfulCommit; import static org.opendaylight.controller.cluster.datastore.ShardDataTreeMocking.successfulPreCommit; + import akka.actor.ActorRef; import akka.actor.PoisonPill; import akka.actor.Props; @@ -27,16 +29,16 @@ import akka.japi.Creator; import akka.pattern.Patterns; import akka.testkit.TestActorRef; import akka.util.Timeout; -import com.google.common.base.Optional; import com.google.common.primitives.UnsignedLong; import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.Uninterruptibles; import java.io.IOException; import java.util.Collections; import java.util.HashMap; import java.util.Map; +import java.util.Optional; import java.util.Set; +import java.util.SortedSet; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; @@ -55,15 +57,15 @@ import org.opendaylight.controller.cluster.datastore.modification.MergeModificat import org.opendaylight.controller.cluster.datastore.modification.MutableCompositeModification; import org.opendaylight.controller.cluster.datastore.modification.WriteModification; import org.opendaylight.controller.cluster.datastore.persisted.CommitTransactionPayload; -import org.opendaylight.controller.cluster.datastore.persisted.PreBoronShardDataTreeSnapshot; +import org.opendaylight.controller.cluster.datastore.persisted.MetadataShardDataTreeSnapshot; +import org.opendaylight.controller.cluster.datastore.persisted.ShardSnapshotState; import org.opendaylight.controller.cluster.raft.ReplicatedLogEntry; -import org.opendaylight.controller.cluster.raft.Snapshot; import org.opendaylight.controller.cluster.raft.TestActorFactory; +import org.opendaylight.controller.cluster.raft.persisted.Snapshot; import org.opendaylight.controller.cluster.raft.utils.InMemoryJournal; import org.opendaylight.controller.cluster.raft.utils.InMemorySnapshotStore; import org.opendaylight.controller.md.cluster.datastore.model.CarsModel; import org.opendaylight.controller.md.cluster.datastore.model.TestModel; -import org.opendaylight.yangtools.concepts.Identifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild; @@ -73,34 +75,35 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateTip; +import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException; import org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType; -import org.opendaylight.yangtools.yang.data.api.schema.tree.TipProducingDataTree; -import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType; import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; import org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFactory; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import scala.concurrent.Await; import scala.concurrent.Future; -import scala.concurrent.duration.Duration; +import scala.concurrent.duration.FiniteDuration; /** * Abstract base for shard unit tests. * * @author Thomas Pantelis */ -public abstract class AbstractShardTest extends AbstractActorTest{ - protected static final SchemaContext SCHEMA_CONTEXT = TestModel.createTestContext(); +public abstract class AbstractShardTest extends AbstractActorTest { + protected static final EffectiveModelContext SCHEMA_CONTEXT = TestModel.createTestContext(); private static final AtomicInteger NEXT_SHARD_NUM = new AtomicInteger(); + protected static final int HEARTBEAT_MILLIS = 100; + protected final ShardIdentifier shardID = ShardIdentifier.create("inventory", MemberName.forName("member-1"), "config" + NEXT_SHARD_NUM.getAndIncrement()); - protected final Builder dataStoreContextBuilder = DatastoreContext.newBuilder(). - shardJournalRecoveryLogBatchSize(3).shardSnapshotBatchCount(5000). - shardHeartbeatIntervalInMillis(100); + protected final Builder dataStoreContextBuilder = DatastoreContext.newBuilder() + .shardJournalRecoveryLogBatchSize(3).shardSnapshotBatchCount(5000) + .shardHeartbeatIntervalInMillis(HEARTBEAT_MILLIS); protected final TestActorFactory actorFactory = new TestActorFactory(getSystem()); @@ -126,7 +129,8 @@ public abstract class AbstractShardTest extends AbstractActorTest{ } protected Shard.Builder newShardBuilder() { - return Shard.builder().id(shardID).datastoreContext(newDatastoreContext()).schemaContext(SCHEMA_CONTEXT); + return Shard.builder().id(shardID).datastoreContext(newDatastoreContext()) + .schemaContextProvider(() -> SCHEMA_CONTEXT); } protected void testRecovery(final Set listEntryKeys) throws Exception { @@ -136,27 +140,21 @@ public abstract class AbstractShardTest extends AbstractActorTest{ final CountDownLatch recoveryComplete = new CountDownLatch(1); - @SuppressWarnings("serial") - final Creator creator = new Creator() { + final Creator creator = () -> new Shard(newShardBuilder()) { @Override - public Shard create() throws Exception { - return new Shard(newShardBuilder()) { - @Override - protected void onRecoveryComplete() { - try { - super.onRecoveryComplete(); - } finally { - recoveryComplete.countDown(); - } - } - }; + protected void onRecoveryComplete() { + try { + super.onRecoveryComplete(); + } finally { + recoveryComplete.countDown(); + } } }; - final TestActorRef shard = TestActorRef.create(getSystem(), - Props.create(new DelegatingShardCreator(creator)).withDispatcher(Dispatchers.DefaultDispatcherId()), "testRecovery"); + final TestActorRef shard = TestActorRef.create(getSystem(), Props.create(Shard.class, + new DelegatingShardCreator(creator)).withDispatcher(Dispatchers.DefaultDispatcherId()), "testRecovery"); - assertEquals("Recovery complete", true, recoveryComplete.await(5, TimeUnit.SECONDS)); + assertTrue("Recovery complete", recoveryComplete.await(5, TimeUnit.SECONDS)); // Verify data in the data store. @@ -164,7 +162,7 @@ public abstract class AbstractShardTest extends AbstractActorTest{ assertNotNull(TestModel.OUTER_LIST_QNAME.getLocalName() + " not found", outerList); assertTrue(TestModel.OUTER_LIST_QNAME.getLocalName() + " value is not Iterable", outerList.getValue() instanceof Iterable); - for(final Object entry: (Iterable) outerList.getValue()) { + for (final Object entry: (Iterable) outerList.getValue()) { assertTrue(TestModel.OUTER_LIST_QNAME.getLocalName() + " entry is not MapEntryNode", entry instanceof MapEntryNode); final MapEntryNode mapEntry = (MapEntryNode)entry; @@ -172,13 +170,12 @@ public abstract class AbstractShardTest extends AbstractActorTest{ mapEntry.getChild(new YangInstanceIdentifier.NodeIdentifier(TestModel.ID_QNAME)); assertTrue("Missing leaf " + TestModel.ID_QNAME.getLocalName(), idLeaf.isPresent()); final Object value = idLeaf.get().getValue(); - assertTrue("Unexpected value for leaf "+ TestModel.ID_QNAME.getLocalName() + ": " + value, + assertTrue("Unexpected value for leaf " + TestModel.ID_QNAME.getLocalName() + ": " + value, listEntryKeys.remove(value)); } - if(!listEntryKeys.isEmpty()) { - fail("Missing " + TestModel.OUTER_LIST_QNAME.getLocalName() + " entries with keys: " + - listEntryKeys); + if (!listEntryKeys.isEmpty()) { + fail("Missing " + TestModel.OUTER_LIST_QNAME.getLocalName() + " entries with keys: " + listEntryKeys); } assertEquals("Last log index", nListEntries, @@ -193,9 +190,9 @@ public abstract class AbstractShardTest extends AbstractActorTest{ protected void verifyLastApplied(final TestActorRef shard, final long expectedValue) { long lastApplied = -1; - for(int i = 0; i < 20 * 5; i++) { + for (int i = 0; i < 20 * 5; i++) { lastApplied = shard.underlyingActor().getShardMBean().getLastApplied(); - if(lastApplied == expectedValue) { + if (lastApplied == expectedValue) { return; } Uninterruptibles.sleepUninterruptibly(50, TimeUnit.MILLISECONDS); @@ -204,36 +201,31 @@ public abstract class AbstractShardTest extends AbstractActorTest{ Assert.fail(String.format("Expected last applied: %d, Actual: %d", expectedValue, lastApplied)); } - protected TipProducingDataTree createDelegatingMockDataTree() throws Exception { - TipProducingDataTree actual = InMemoryDataTreeFactory.getInstance().create(TreeType.CONFIGURATION); - final TipProducingDataTree mock = mock(TipProducingDataTree.class); + protected DataTree createDelegatingMockDataTree() throws Exception { + final DataTree actual = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_CONFIGURATION); + final DataTree mock = mock(DataTree.class); doAnswer(invocation -> { - actual.validate(invocation.getArgumentAt(0, DataTreeModification.class)); + actual.validate(invocation.getArgument(0)); return null; }).when(mock).validate(any(DataTreeModification.class)); - doAnswer(invocation -> { - return actual.prepare(invocation.getArgumentAt(0, DataTreeModification.class)); - }).when(mock).prepare(any(DataTreeModification.class)); + doAnswer(invocation -> actual.prepare(invocation.getArgument(0))).when( + mock).prepare(any(DataTreeModification.class)); doAnswer(invocation -> { - actual.commit(invocation.getArgumentAt(0, DataTreeCandidate.class)); + actual.commit(invocation.getArgument(0)); return null; }).when(mock).commit(any(DataTreeCandidate.class)); doAnswer(invocation -> { - actual.setSchemaContext(invocation.getArgumentAt(0, SchemaContext.class)); + actual.setEffectiveModelContext(invocation.getArgument(0)); return null; - }).when(mock).setSchemaContext(any(SchemaContext.class)); + }).when(mock).setEffectiveModelContext(any(EffectiveModelContext.class)); - doAnswer(invocation -> { - return actual.takeSnapshot(); - }).when(mock).takeSnapshot(); + doAnswer(invocation -> actual.takeSnapshot()).when(mock).takeSnapshot(); - doAnswer(invocation -> { - return actual.getRootPath(); - }).when(mock).getRootPath(); + doAnswer(invocation -> actual.getRootPath()).when(mock).getRootPath(); return mock; } @@ -251,17 +243,14 @@ public abstract class AbstractShardTest extends AbstractActorTest{ protected Map setupCohortDecorator(final Shard shard, final TransactionIdentifier... transactionIDs) { final Map cohortMap = new HashMap<>(); - for(TransactionIdentifier id: transactionIDs) { + for (TransactionIdentifier id: transactionIDs) { cohortMap.put(id, new CapturingShardDataTreeCohort()); } - shard.getCommitCoordinator().setCohortDecorator(new ShardCommitCoordinator.CohortDecorator() { - @Override - public ShardDataTreeCohort decorate(final Identifier transactionID, final ShardDataTreeCohort actual) { - CapturingShardDataTreeCohort cohort = cohortMap.get(transactionID); - cohort.setDelegate(actual); - return cohort; - } + shard.getCommitCoordinator().setCohortDecorator((transactionID, actual) -> { + CapturingShardDataTreeCohort cohort = cohortMap.get(transactionID); + cohort.setDelegate(actual); + return cohort; }); return cohortMap; @@ -277,7 +266,7 @@ public abstract class AbstractShardTest extends AbstractActorTest{ final boolean doCommitOnReady) { final BatchedModifications batchedModifications = new BatchedModifications(transactionID, CURRENT_VERSION); batchedModifications.addModification(modification); - batchedModifications.setReady(true); + batchedModifications.setReady(); batchedModifications.setDoCommitOnReady(doCommitOnReady); batchedModifications.setTotalMessagesSent(1); return batchedModifications; @@ -293,51 +282,38 @@ public abstract class AbstractShardTest extends AbstractActorTest{ protected static ForwardedReadyTransaction prepareForwardedReadyTransaction(final TestActorRef shard, final TransactionIdentifier transactionID, final YangInstanceIdentifier path, final NormalizedNode data, final boolean doCommitOnReady) { - ReadWriteShardDataTreeTransaction rwTx = shard.underlyingActor().getDataStore(). - newReadWriteTransaction(transactionID); + ReadWriteShardDataTreeTransaction rwTx = shard.underlyingActor().getDataStore() + .newReadWriteTransaction(transactionID); rwTx.getSnapshot().write(path, data); - return new ForwardedReadyTransaction(transactionID, CURRENT_VERSION, rwTx, doCommitOnReady); + return new ForwardedReadyTransaction(transactionID, CURRENT_VERSION, rwTx, doCommitOnReady, Optional.empty()); } - public static NormalizedNode readStore(final TestActorRef shard, final YangInstanceIdentifier id) - throws ExecutionException, InterruptedException { - return shard.underlyingActor().getDataStore().readNode(id).orNull(); + public static NormalizedNode readStore(final TestActorRef shard, + final YangInstanceIdentifier id) { + return shard.underlyingActor().getDataStore().readNode(id).orElse(null); } public static NormalizedNode readStore(final DataTree store, final YangInstanceIdentifier id) { - return store.takeSnapshot().readNode(id).orNull(); + return store.takeSnapshot().readNode(id).orElse(null); } public void writeToStore(final TestActorRef shard, final YangInstanceIdentifier id, final NormalizedNode node) throws InterruptedException, ExecutionException { - Future future = Patterns.ask(shard, newBatchedModifications(nextTransactionId(), id, node, true, true, 1), - new Timeout(5, TimeUnit.SECONDS)); + Future future = Patterns.ask(shard, newBatchedModifications(nextTransactionId(), + id, node, true, true, 1), new Timeout(5, TimeUnit.SECONDS)); try { - Await.ready(future, Duration.create(5, TimeUnit.SECONDS)); - } catch(TimeoutException e) { + Await.ready(future, FiniteDuration.create(5, TimeUnit.SECONDS)); + } catch (TimeoutException e) { throw new ExecutionException(e); } } public static void writeToStore(final ShardDataTree store, final YangInstanceIdentifier id, - final NormalizedNode node) throws Exception { + final NormalizedNode node) throws DataValidationFailedException { BatchedModifications batched = newBatchedModifications(nextTransactionId(), id, node, true, true, 1); DataTreeModification modification = store.getDataTree().takeSnapshot().newModification(); batched.apply(modification); - store.commit(modification); - } - - public void mergeToStore(final ShardDataTree store, final YangInstanceIdentifier id, - final NormalizedNode node) throws Exception { - final BatchedModifications batched = new BatchedModifications(nextTransactionId(), CURRENT_VERSION); - batched.addModification(new MergeModification(id, node)); - batched.setReady(true); - batched.setDoCommitOnReady(true); - batched.setTotalMessagesSent(1); - - DataTreeModification modification = store.getDataTree().takeSnapshot().newModification(); - batched.apply(modification); - store.commit(modification); + store.notifyListeners(commitTransaction(store.getDataTree(), modification)); } public static void writeToStore(final DataTree store, final YangInstanceIdentifier id, @@ -351,17 +327,30 @@ public abstract class AbstractShardTest extends AbstractActorTest{ store.commit(candidate); } + public void mergeToStore(final ShardDataTree store, final YangInstanceIdentifier id, + final NormalizedNode node) throws DataValidationFailedException { + final BatchedModifications batched = new BatchedModifications(nextTransactionId(), CURRENT_VERSION); + batched.addModification(new MergeModification(id, node)); + batched.setReady(); + batched.setDoCommitOnReady(true); + batched.setTotalMessagesSent(1); + + DataTreeModification modification = store.getDataTree().takeSnapshot().newModification(); + batched.apply(modification); + store.notifyListeners(commitTransaction(store.getDataTree(), modification)); + } + DataTree setupInMemorySnapshotStore() throws DataValidationFailedException { - final DataTree testStore = InMemoryDataTreeFactory.getInstance().create(TreeType.OPERATIONAL); - testStore.setSchemaContext(SCHEMA_CONTEXT); + final DataTree testStore = new InMemoryDataTreeFactory().create( + DataTreeConfiguration.DEFAULT_OPERATIONAL, SCHEMA_CONTEXT); writeToStore(testStore, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME)); - final NormalizedNode root = readStore(testStore, YangInstanceIdentifier.EMPTY); + final NormalizedNode root = readStore(testStore, YangInstanceIdentifier.empty()); InMemorySnapshotStore.addSnapshot(shardID.toString(), Snapshot.create( - new PreBoronShardDataTreeSnapshot(root).serialize(), - Collections.emptyList(), 0, 1, -1, -1)); + new ShardSnapshotState(new MetadataShardDataTreeSnapshot(root)), + Collections.emptyList(), 0, 1, -1, -1, 1, null, null)); return testStore; } @@ -374,18 +363,30 @@ public abstract class AbstractShardTest extends AbstractActorTest{ } static BatchedModifications newBatchedModifications(final TransactionIdentifier transactionID, - final YangInstanceIdentifier path, final NormalizedNode data, final boolean ready, final boolean doCommitOnReady, - final int messagesSent) { + final YangInstanceIdentifier path, final NormalizedNode data, final boolean ready, + final boolean doCommitOnReady, final int messagesSent) { final BatchedModifications batched = new BatchedModifications(transactionID, CURRENT_VERSION); batched.addModification(new WriteModification(path, data)); - batched.setReady(ready); + if (ready) { + batched.setReady(); + } batched.setDoCommitOnReady(doCommitOnReady); batched.setTotalMessagesSent(messagesSent); return batched; } + static BatchedModifications newReadyBatchedModifications(final TransactionIdentifier transactionID, + final YangInstanceIdentifier path, final NormalizedNode data, + final SortedSet participatingShardNames) { + final BatchedModifications batched = new BatchedModifications(transactionID, CURRENT_VERSION); + batched.addModification(new WriteModification(path, data)); + batched.setReady(Optional.of(participatingShardNames)); + batched.setTotalMessagesSent(1); + return batched; + } + @SuppressWarnings("unchecked") - static void verifyOuterListEntry(final TestActorRef shard, final Object expIDValue) throws Exception { + static void verifyOuterListEntry(final TestActorRef shard, final Object expIDValue) { final NormalizedNode outerList = readStore(shard, TestModel.OUTER_LIST_PATH); assertNotNull(TestModel.OUTER_LIST_QNAME.getLocalName() + " not found", outerList); assertTrue(TestModel.OUTER_LIST_QNAME.getLocalName() + " value is not Iterable", @@ -404,7 +405,8 @@ public abstract class AbstractShardTest extends AbstractActorTest{ final DataTreeCandidateTip mockCandidate = mock(DataTreeCandidateTip.class, name); final DataTreeCandidateNode mockCandidateNode = mock(DataTreeCandidateNode.class, name + "-node"); doReturn(ModificationType.WRITE).when(mockCandidateNode).getModificationType(); - doReturn(Optional.of(ImmutableNodes.containerNode(CarsModel.CARS_QNAME))).when(mockCandidateNode).getDataAfter(); + doReturn(Optional.of(ImmutableNodes.containerNode(CarsModel.CARS_QNAME))) + .when(mockCandidateNode).getDataAfter(); doReturn(CarsModel.BASE_PATH).when(mockCandidate).getRootPath(); doReturn(mockCandidateNode).when(mockCandidate).getRootNode(); return mockCandidate; @@ -414,15 +416,18 @@ public abstract class AbstractShardTest extends AbstractActorTest{ final DataTreeCandidateTip mockCandidate = mock(DataTreeCandidateTip.class, name); final DataTreeCandidateNode mockCandidateNode = mock(DataTreeCandidateNode.class, name + "-node"); doReturn(ModificationType.UNMODIFIED).when(mockCandidateNode).getModificationType(); - doReturn(YangInstanceIdentifier.EMPTY).when(mockCandidate).getRootPath(); + doReturn(YangInstanceIdentifier.empty()).when(mockCandidate).getRootPath(); doReturn(mockCandidateNode).when(mockCandidate).getRootNode(); return mockCandidate; } - static void commitTransaction(final DataTree store, final DataTreeModification modification) throws DataValidationFailedException { + static DataTreeCandidate commitTransaction(final DataTree store, final DataTreeModification modification) + throws DataValidationFailedException { modification.ready(); store.validate(modification); - store.commit(store.prepare(modification)); + final DataTreeCandidate candidate = store.prepare(modification); + store.commit(candidate); + return candidate; } @SuppressWarnings("serial") @@ -445,7 +450,7 @@ public abstract class AbstractShardTest extends AbstractActorTest{ private FutureCallback preCommit; private FutureCallback commit; - public void setDelegate(ShardDataTreeCohort delegate) { + public void setDelegate(final ShardDataTreeCohort delegate) { this.delegate = delegate; } @@ -480,42 +485,42 @@ public abstract class AbstractShardTest extends AbstractActorTest{ } @Override - public void canCommit(FutureCallback callback) { + public void canCommit(final FutureCallback callback) { canCommit = mockFutureCallback(callback); delegate.canCommit(canCommit); } @Override - public void preCommit(FutureCallback callback) { + public void preCommit(final FutureCallback callback) { preCommit = mockFutureCallback(callback); delegate.preCommit(preCommit); } @Override - public void commit(FutureCallback callback) { + public void commit(final FutureCallback callback) { commit = mockFutureCallback(callback); delegate.commit(commit); } @SuppressWarnings("unchecked") - private FutureCallback mockFutureCallback(final FutureCallback actual ) { + private static FutureCallback mockFutureCallback(final FutureCallback actual) { FutureCallback mock = mock(FutureCallback.class); doAnswer(invocation -> { - actual.onFailure(invocation.getArgumentAt(0, Throwable.class)); + actual.onFailure(invocation.getArgument(0)); return null; }).when(mock).onFailure(any(Throwable.class)); doAnswer(invocation -> { - actual.onSuccess((T) invocation.getArgumentAt(0, Throwable.class)); + actual.onSuccess(invocation.getArgument(0)); return null; - }).when(mock).onSuccess((T) any(Object.class)); + }).when(mock).onSuccess((T) nullable(Object.class)); return mock; } @Override - public ListenableFuture abort() { - return delegate.abort(); + public void abort(final FutureCallback callback) { + delegate.abort(callback); } @Override @@ -527,5 +532,10 @@ public abstract class AbstractShardTest extends AbstractActorTest{ public State getState() { return delegate.getState(); } + + @Override + Optional> getParticipatingShardNames() { + return delegate.getParticipatingShardNames(); + } } }