Adjust to yangtools-2.0.0 changes
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / AbstractShardTest.java
1 /*
2  * Copyright (c) 2015 Brocade Communications Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.controller.cluster.datastore;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertTrue;
13 import static org.junit.Assert.fail;
14 import static org.mockito.Matchers.any;
15 import static org.mockito.Mockito.doAnswer;
16 import static org.mockito.Mockito.doReturn;
17 import static org.mockito.Mockito.mock;
18 import static org.opendaylight.controller.cluster.datastore.DataStoreVersions.CURRENT_VERSION;
19 import static org.opendaylight.controller.cluster.datastore.ShardDataTreeMocking.successfulCanCommit;
20 import static org.opendaylight.controller.cluster.datastore.ShardDataTreeMocking.successfulCommit;
21 import static org.opendaylight.controller.cluster.datastore.ShardDataTreeMocking.successfulPreCommit;
22
23 import akka.actor.ActorRef;
24 import akka.actor.PoisonPill;
25 import akka.actor.Props;
26 import akka.dispatch.Dispatchers;
27 import akka.japi.Creator;
28 import akka.pattern.Patterns;
29 import akka.testkit.TestActorRef;
30 import akka.util.Timeout;
31 import com.google.common.primitives.UnsignedLong;
32 import com.google.common.util.concurrent.FutureCallback;
33 import com.google.common.util.concurrent.Uninterruptibles;
34 import java.io.IOException;
35 import java.util.Collections;
36 import java.util.HashMap;
37 import java.util.Map;
38 import java.util.Optional;
39 import java.util.Set;
40 import java.util.concurrent.CountDownLatch;
41 import java.util.concurrent.ExecutionException;
42 import java.util.concurrent.TimeUnit;
43 import java.util.concurrent.TimeoutException;
44 import java.util.concurrent.atomic.AtomicInteger;
45 import org.junit.After;
46 import org.junit.Assert;
47 import org.junit.Before;
48 import org.opendaylight.controller.cluster.access.concepts.MemberName;
49 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
50 import org.opendaylight.controller.cluster.datastore.DatastoreContext.Builder;
51 import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier;
52 import org.opendaylight.controller.cluster.datastore.messages.BatchedModifications;
53 import org.opendaylight.controller.cluster.datastore.messages.ForwardedReadyTransaction;
54 import org.opendaylight.controller.cluster.datastore.modification.MergeModification;
55 import org.opendaylight.controller.cluster.datastore.modification.MutableCompositeModification;
56 import org.opendaylight.controller.cluster.datastore.modification.WriteModification;
57 import org.opendaylight.controller.cluster.datastore.persisted.CommitTransactionPayload;
58 import org.opendaylight.controller.cluster.datastore.persisted.MetadataShardDataTreeSnapshot;
59 import org.opendaylight.controller.cluster.datastore.persisted.ShardSnapshotState;
60 import org.opendaylight.controller.cluster.raft.ReplicatedLogEntry;
61 import org.opendaylight.controller.cluster.raft.TestActorFactory;
62 import org.opendaylight.controller.cluster.raft.persisted.Snapshot;
63 import org.opendaylight.controller.cluster.raft.utils.InMemoryJournal;
64 import org.opendaylight.controller.cluster.raft.utils.InMemorySnapshotStore;
65 import org.opendaylight.controller.md.cluster.datastore.model.CarsModel;
66 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
67 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
68 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
69 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
70 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
71 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
72 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
73 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
74 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
75 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateTip;
76 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
77 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
78 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
79 import org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType;
80 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
81 import org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFactory;
82 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
83 import scala.concurrent.Await;
84 import scala.concurrent.Future;
85 import scala.concurrent.duration.Duration;
86
87 /**
88  * Abstract base for shard unit tests.
89  *
90  * @author Thomas Pantelis
91  */
92 public abstract class AbstractShardTest extends AbstractActorTest {
93     protected static final SchemaContext SCHEMA_CONTEXT = TestModel.createTestContext();
94
95     private static final AtomicInteger NEXT_SHARD_NUM = new AtomicInteger();
96
97     protected static final int HEARTBEAT_MILLIS = 100;
98
99     protected final ShardIdentifier shardID = ShardIdentifier.create("inventory", MemberName.forName("member-1"),
100         "config" + NEXT_SHARD_NUM.getAndIncrement());
101
102     protected final Builder dataStoreContextBuilder = DatastoreContext.newBuilder()
103             .shardJournalRecoveryLogBatchSize(3).shardSnapshotBatchCount(5000)
104             .shardHeartbeatIntervalInMillis(HEARTBEAT_MILLIS);
105
106     protected final TestActorFactory actorFactory = new TestActorFactory(getSystem());
107
108     @Before
109     public void setUp() {
110         InMemorySnapshotStore.clear();
111         InMemoryJournal.clear();
112     }
113
114     @After
115     public void tearDown() {
116         InMemorySnapshotStore.clear();
117         InMemoryJournal.clear();
118         actorFactory.close();
119     }
120
121     protected DatastoreContext newDatastoreContext() {
122         return dataStoreContextBuilder.build();
123     }
124
125     protected Props newShardProps() {
126         return newShardBuilder().props();
127     }
128
129     protected Shard.Builder newShardBuilder() {
130         return Shard.builder().id(shardID).datastoreContext(newDatastoreContext())
131             .schemaContextProvider(() -> SCHEMA_CONTEXT);
132     }
133
134     protected void testRecovery(final Set<Integer> listEntryKeys) throws Exception {
135         // Create the actor and wait for recovery complete.
136
137         final int nListEntries = listEntryKeys.size();
138
139         final CountDownLatch recoveryComplete = new CountDownLatch(1);
140
141         final Creator<Shard> creator = () -> new Shard(newShardBuilder()) {
142             @Override
143             protected void onRecoveryComplete() {
144                 try {
145                     super.onRecoveryComplete();
146                 } finally {
147                     recoveryComplete.countDown();
148                 }
149             }
150         };
151
152         final TestActorRef<Shard> shard = TestActorRef.create(getSystem(),
153                 Props.create(new DelegatingShardCreator(creator)).withDispatcher(Dispatchers.DefaultDispatcherId()),
154                 "testRecovery");
155
156         assertEquals("Recovery complete", true, recoveryComplete.await(5, TimeUnit.SECONDS));
157
158         // Verify data in the data store.
159
160         final NormalizedNode<?, ?> outerList = readStore(shard, TestModel.OUTER_LIST_PATH);
161         assertNotNull(TestModel.OUTER_LIST_QNAME.getLocalName() + " not found", outerList);
162         assertTrue(TestModel.OUTER_LIST_QNAME.getLocalName() + " value is not Iterable",
163                 outerList.getValue() instanceof Iterable);
164         for (final Object entry: (Iterable<?>) outerList.getValue()) {
165             assertTrue(TestModel.OUTER_LIST_QNAME.getLocalName() + " entry is not MapEntryNode",
166                     entry instanceof MapEntryNode);
167             final MapEntryNode mapEntry = (MapEntryNode)entry;
168             final Optional<DataContainerChild<? extends PathArgument, ?>> idLeaf =
169                     mapEntry.getChild(new YangInstanceIdentifier.NodeIdentifier(TestModel.ID_QNAME));
170             assertTrue("Missing leaf " + TestModel.ID_QNAME.getLocalName(), idLeaf.isPresent());
171             final Object value = idLeaf.get().getValue();
172             assertTrue("Unexpected value for leaf " + TestModel.ID_QNAME.getLocalName() + ": " + value,
173                     listEntryKeys.remove(value));
174         }
175
176         if (!listEntryKeys.isEmpty()) {
177             fail("Missing " + TestModel.OUTER_LIST_QNAME.getLocalName() + " entries with keys: " + listEntryKeys);
178         }
179
180         assertEquals("Last log index", nListEntries,
181                 shard.underlyingActor().getShardMBean().getLastLogIndex());
182         assertEquals("Commit index", nListEntries,
183                 shard.underlyingActor().getShardMBean().getCommitIndex());
184         assertEquals("Last applied", nListEntries,
185                 shard.underlyingActor().getShardMBean().getLastApplied());
186
187         shard.tell(PoisonPill.getInstance(), ActorRef.noSender());
188     }
189
190     protected void verifyLastApplied(final TestActorRef<Shard> shard, final long expectedValue) {
191         long lastApplied = -1;
192         for (int i = 0; i < 20 * 5; i++) {
193             lastApplied = shard.underlyingActor().getShardMBean().getLastApplied();
194             if (lastApplied == expectedValue) {
195                 return;
196             }
197             Uninterruptibles.sleepUninterruptibly(50, TimeUnit.MILLISECONDS);
198         }
199
200         Assert.fail(String.format("Expected last applied: %d, Actual: %d", expectedValue, lastApplied));
201     }
202
203     protected DataTree createDelegatingMockDataTree() throws Exception {
204         final DataTree actual = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_CONFIGURATION);
205         final DataTree mock = mock(DataTree.class);
206
207         doAnswer(invocation -> {
208             actual.validate(invocation.getArgumentAt(0, DataTreeModification.class));
209             return null;
210         }).when(mock).validate(any(DataTreeModification.class));
211
212         doAnswer(invocation -> actual.prepare(invocation.getArgumentAt(0, DataTreeModification.class))).when(
213                 mock).prepare(any(DataTreeModification.class));
214
215         doAnswer(invocation -> {
216             actual.commit(invocation.getArgumentAt(0, DataTreeCandidate.class));
217             return null;
218         }).when(mock).commit(any(DataTreeCandidate.class));
219
220         doAnswer(invocation -> {
221             actual.setSchemaContext(invocation.getArgumentAt(0, SchemaContext.class));
222             return null;
223         }).when(mock).setSchemaContext(any(SchemaContext.class));
224
225         doAnswer(invocation -> actual.takeSnapshot()).when(mock).takeSnapshot();
226
227         doAnswer(invocation -> actual.getRootPath()).when(mock).getRootPath();
228
229         return mock;
230     }
231
232     protected ShardDataTreeCohort mockShardDataTreeCohort() {
233         ShardDataTreeCohort cohort = mock(ShardDataTreeCohort.class);
234         DataTreeCandidate candidate = mockCandidate("candidate");
235         successfulCanCommit(cohort);
236         successfulPreCommit(cohort, candidate);
237         successfulCommit(cohort);
238         doReturn(candidate).when(cohort).getCandidate();
239         return cohort;
240     }
241
242     protected Map<TransactionIdentifier, CapturingShardDataTreeCohort> setupCohortDecorator(final Shard shard,
243             final TransactionIdentifier... transactionIDs) {
244         final Map<TransactionIdentifier, CapturingShardDataTreeCohort> cohortMap = new HashMap<>();
245         for (TransactionIdentifier id: transactionIDs) {
246             cohortMap.put(id, new CapturingShardDataTreeCohort());
247         }
248
249         shard.getCommitCoordinator().setCohortDecorator((transactionID, actual) -> {
250             CapturingShardDataTreeCohort cohort = cohortMap.get(transactionID);
251             cohort.setDelegate(actual);
252             return cohort;
253         });
254
255         return cohortMap;
256     }
257
258     protected BatchedModifications prepareBatchedModifications(final TransactionIdentifier transactionID,
259                                                                final MutableCompositeModification modification) {
260         return prepareBatchedModifications(transactionID, modification, false);
261     }
262
263     protected static BatchedModifications prepareBatchedModifications(final TransactionIdentifier transactionID,
264                                                              final MutableCompositeModification modification,
265                                                              final boolean doCommitOnReady) {
266         final BatchedModifications batchedModifications = new BatchedModifications(transactionID, CURRENT_VERSION);
267         batchedModifications.addModification(modification);
268         batchedModifications.setReady(true);
269         batchedModifications.setDoCommitOnReady(doCommitOnReady);
270         batchedModifications.setTotalMessagesSent(1);
271         return batchedModifications;
272     }
273
274     protected static BatchedModifications prepareBatchedModifications(final TransactionIdentifier transactionID,
275             final YangInstanceIdentifier path, final NormalizedNode<?, ?> data, final boolean doCommitOnReady) {
276         final MutableCompositeModification modification = new MutableCompositeModification();
277         modification.addModification(new WriteModification(path, data));
278         return prepareBatchedModifications(transactionID, modification, doCommitOnReady);
279     }
280
281     protected static ForwardedReadyTransaction prepareForwardedReadyTransaction(final TestActorRef<Shard> shard,
282             final TransactionIdentifier transactionID, final YangInstanceIdentifier path,
283             final NormalizedNode<?, ?> data, final boolean doCommitOnReady) {
284         ReadWriteShardDataTreeTransaction rwTx = shard.underlyingActor().getDataStore()
285                 .newReadWriteTransaction(transactionID);
286         rwTx.getSnapshot().write(path, data);
287         return new ForwardedReadyTransaction(transactionID, CURRENT_VERSION, rwTx, doCommitOnReady);
288     }
289
290     public static NormalizedNode<?,?> readStore(final TestActorRef<? extends Shard> shard,
291             final YangInstanceIdentifier id) throws ExecutionException, InterruptedException {
292         return shard.underlyingActor().getDataStore().readNode(id).orNull();
293     }
294
295     public static NormalizedNode<?,?> readStore(final DataTree store, final YangInstanceIdentifier id) {
296         return store.takeSnapshot().readNode(id).orElse(null);
297     }
298
299     public void writeToStore(final TestActorRef<Shard> shard, final YangInstanceIdentifier id,
300             final NormalizedNode<?,?> node) throws InterruptedException, ExecutionException {
301         Future<Object> future = Patterns.ask(shard, newBatchedModifications(nextTransactionId(),
302                 id, node, true, true, 1), new Timeout(5, TimeUnit.SECONDS));
303         try {
304             Await.ready(future, Duration.create(5, TimeUnit.SECONDS));
305         } catch (TimeoutException e) {
306             throw new ExecutionException(e);
307         }
308     }
309
310     public static void writeToStore(final ShardDataTree store, final YangInstanceIdentifier id,
311             final NormalizedNode<?,?> node) throws DataValidationFailedException {
312         BatchedModifications batched = newBatchedModifications(nextTransactionId(), id, node, true, true, 1);
313         DataTreeModification modification = store.getDataTree().takeSnapshot().newModification();
314         batched.apply(modification);
315         store.notifyListeners(commitTransaction(store.getDataTree(), modification));
316     }
317
318     public static void writeToStore(final DataTree store, final YangInstanceIdentifier id,
319             final NormalizedNode<?,?> node) throws DataValidationFailedException {
320         final DataTreeModification transaction = store.takeSnapshot().newModification();
321
322         transaction.write(id, node);
323         transaction.ready();
324         store.validate(transaction);
325         final DataTreeCandidate candidate = store.prepare(transaction);
326         store.commit(candidate);
327     }
328
329     public void mergeToStore(final ShardDataTree store, final YangInstanceIdentifier id,
330             final NormalizedNode<?,?> node) throws DataValidationFailedException {
331         final BatchedModifications batched = new BatchedModifications(nextTransactionId(), CURRENT_VERSION);
332         batched.addModification(new MergeModification(id, node));
333         batched.setReady(true);
334         batched.setDoCommitOnReady(true);
335         batched.setTotalMessagesSent(1);
336
337         DataTreeModification modification = store.getDataTree().takeSnapshot().newModification();
338         batched.apply(modification);
339         store.notifyListeners(commitTransaction(store.getDataTree(), modification));
340     }
341
342     DataTree setupInMemorySnapshotStore() throws DataValidationFailedException {
343         final DataTree testStore = new InMemoryDataTreeFactory().create(
344             DataTreeConfiguration.DEFAULT_OPERATIONAL, SCHEMA_CONTEXT);
345
346         writeToStore(testStore, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
347
348         final NormalizedNode<?, ?> root = readStore(testStore, YangInstanceIdentifier.EMPTY);
349
350         InMemorySnapshotStore.addSnapshot(shardID.toString(), Snapshot.create(
351                 new ShardSnapshotState(new MetadataShardDataTreeSnapshot(root)),
352                 Collections.<ReplicatedLogEntry>emptyList(), 0, 1, -1, -1, 1, null, null));
353         return testStore;
354     }
355
356     static CommitTransactionPayload payloadForModification(final DataTree source, final DataTreeModification mod,
357             final TransactionIdentifier transactionId) throws DataValidationFailedException, IOException {
358         source.validate(mod);
359         final DataTreeCandidate candidate = source.prepare(mod);
360         source.commit(candidate);
361         return CommitTransactionPayload.create(transactionId, candidate);
362     }
363
364     static BatchedModifications newBatchedModifications(final TransactionIdentifier transactionID,
365             final YangInstanceIdentifier path, final NormalizedNode<?, ?> data, final boolean ready,
366             final boolean doCommitOnReady, final int messagesSent) {
367         final BatchedModifications batched = new BatchedModifications(transactionID, CURRENT_VERSION);
368         batched.addModification(new WriteModification(path, data));
369         batched.setReady(ready);
370         batched.setDoCommitOnReady(doCommitOnReady);
371         batched.setTotalMessagesSent(messagesSent);
372         return batched;
373     }
374
375     @SuppressWarnings("unchecked")
376     static void verifyOuterListEntry(final TestActorRef<Shard> shard, final Object expIDValue) throws Exception {
377         final NormalizedNode<?, ?> outerList = readStore(shard, TestModel.OUTER_LIST_PATH);
378         assertNotNull(TestModel.OUTER_LIST_QNAME.getLocalName() + " not found", outerList);
379         assertTrue(TestModel.OUTER_LIST_QNAME.getLocalName() + " value is not Iterable",
380                 outerList.getValue() instanceof Iterable);
381         final Object entry = ((Iterable<Object>)outerList.getValue()).iterator().next();
382         assertTrue(TestModel.OUTER_LIST_QNAME.getLocalName() + " entry is not MapEntryNode",
383                 entry instanceof MapEntryNode);
384         final MapEntryNode mapEntry = (MapEntryNode)entry;
385         final Optional<DataContainerChild<? extends PathArgument, ?>> idLeaf =
386                 mapEntry.getChild(new YangInstanceIdentifier.NodeIdentifier(TestModel.ID_QNAME));
387         assertTrue("Missing leaf " + TestModel.ID_QNAME.getLocalName(), idLeaf.isPresent());
388         assertEquals(TestModel.ID_QNAME.getLocalName() + " value", expIDValue, idLeaf.get().getValue());
389     }
390
391     public static DataTreeCandidateTip mockCandidate(final String name) {
392         final DataTreeCandidateTip mockCandidate = mock(DataTreeCandidateTip.class, name);
393         final DataTreeCandidateNode mockCandidateNode = mock(DataTreeCandidateNode.class, name + "-node");
394         doReturn(ModificationType.WRITE).when(mockCandidateNode).getModificationType();
395         doReturn(Optional.of(ImmutableNodes.containerNode(CarsModel.CARS_QNAME)))
396                 .when(mockCandidateNode).getDataAfter();
397         doReturn(CarsModel.BASE_PATH).when(mockCandidate).getRootPath();
398         doReturn(mockCandidateNode).when(mockCandidate).getRootNode();
399         return mockCandidate;
400     }
401
402     static DataTreeCandidateTip mockUnmodifiedCandidate(final String name) {
403         final DataTreeCandidateTip mockCandidate = mock(DataTreeCandidateTip.class, name);
404         final DataTreeCandidateNode mockCandidateNode = mock(DataTreeCandidateNode.class, name + "-node");
405         doReturn(ModificationType.UNMODIFIED).when(mockCandidateNode).getModificationType();
406         doReturn(YangInstanceIdentifier.EMPTY).when(mockCandidate).getRootPath();
407         doReturn(mockCandidateNode).when(mockCandidate).getRootNode();
408         return mockCandidate;
409     }
410
411     static DataTreeCandidate commitTransaction(final DataTree store, final DataTreeModification modification)
412             throws DataValidationFailedException {
413         modification.ready();
414         store.validate(modification);
415         final DataTreeCandidate candidate = store.prepare(modification);
416         store.commit(candidate);
417         return candidate;
418     }
419
420     @SuppressWarnings("serial")
421     public static final class DelegatingShardCreator implements Creator<Shard> {
422         private final Creator<Shard> delegate;
423
424         DelegatingShardCreator(final Creator<Shard> delegate) {
425             this.delegate = delegate;
426         }
427
428         @Override
429         public Shard create() throws Exception {
430             return delegate.create();
431         }
432     }
433
434     public static class CapturingShardDataTreeCohort extends ShardDataTreeCohort {
435         private volatile ShardDataTreeCohort delegate;
436         private FutureCallback<Void> canCommit;
437         private FutureCallback<DataTreeCandidate> preCommit;
438         private FutureCallback<UnsignedLong> commit;
439
440         public void setDelegate(final ShardDataTreeCohort delegate) {
441             this.delegate = delegate;
442         }
443
444         public FutureCallback<Void> getCanCommit() {
445             assertNotNull("canCommit was not invoked", canCommit);
446             return canCommit;
447         }
448
449         public FutureCallback<DataTreeCandidate> getPreCommit() {
450             assertNotNull("preCommit was not invoked", preCommit);
451             return preCommit;
452         }
453
454         public FutureCallback<UnsignedLong> getCommit() {
455             assertNotNull("commit was not invoked", commit);
456             return commit;
457         }
458
459         @Override
460         public TransactionIdentifier getIdentifier() {
461             return delegate.getIdentifier();
462         }
463
464         @Override
465         DataTreeCandidateTip getCandidate() {
466             return delegate.getCandidate();
467         }
468
469         @Override
470         DataTreeModification getDataTreeModification() {
471             return delegate.getDataTreeModification();
472         }
473
474         @Override
475         public void canCommit(final FutureCallback<Void> callback) {
476             canCommit = mockFutureCallback(callback);
477             delegate.canCommit(canCommit);
478         }
479
480         @Override
481         public void preCommit(final FutureCallback<DataTreeCandidate> callback) {
482             preCommit = mockFutureCallback(callback);
483             delegate.preCommit(preCommit);
484         }
485
486         @Override
487         public void commit(final FutureCallback<UnsignedLong> callback) {
488             commit = mockFutureCallback(callback);
489             delegate.commit(commit);
490         }
491
492         @SuppressWarnings("unchecked")
493         private static <T> FutureCallback<T> mockFutureCallback(final FutureCallback<T> actual) {
494             FutureCallback<T> mock = mock(FutureCallback.class);
495             doAnswer(invocation -> {
496                 actual.onFailure(invocation.getArgumentAt(0, Throwable.class));
497                 return null;
498             }).when(mock).onFailure(any(Throwable.class));
499
500             doAnswer(invocation -> {
501                 actual.onSuccess((T) invocation.getArgumentAt(0, Throwable.class));
502                 return null;
503             }).when(mock).onSuccess((T) any(Object.class));
504
505             return mock;
506         }
507
508         @Override
509         public void abort(final FutureCallback<Void> callback) {
510             delegate.abort(callback);
511         }
512
513         @Override
514         public boolean isFailed() {
515             return delegate.isFailed();
516         }
517
518         @Override
519         public State getState() {
520             return delegate.getState();
521         }
522     }
523 }