2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.mdsal.dom.spi.store;
10 import static org.mockito.ArgumentMatchers.any;
11 import static org.mockito.Mockito.doReturn;
12 import static org.mockito.Mockito.mock;
13 import static org.mockito.MockitoAnnotations.initMocks;
15 import com.google.common.base.MoreObjects;
16 import org.junit.Test;
17 import org.mockito.Mock;
18 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
19 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
21 public class AbstractSnapshotBackedTransactionChainTest extends AbstractSnapshotBackedTransactionChain<Object> {
24 private static DataTreeSnapshot dataTreeSnapshot;
27 private static DOMStoreThreePhaseCommitCohort domStoreThreePhaseCommitCohort;
30 public void basicTest() throws Exception {
32 SnapshotBackedWriteTransaction<Object> snapshotBackedWriteTransaction =
33 mock(SnapshotBackedWriteTransaction.class);
34 DataTreeModification dataTreeModification = mock(DataTreeModification.class);
35 doReturn(dataTreeModification).when(dataTreeSnapshot).newModification();
36 doReturn(MoreObjects.toStringHelper(this)).when(snapshotBackedWriteTransaction).addToStringAttributes(any());
38 this.newReadOnlyTransaction().close();
39 this.newWriteOnlyTransaction().close();
40 this.newReadWriteTransaction().close();
42 this.transactionReady(snapshotBackedWriteTransaction, dataTreeModification, null);
45 this.transactionAborted(snapshotBackedWriteTransaction);
48 this.onTransactionCommited(snapshotBackedWriteTransaction);
49 this.onTransactionFailed(snapshotBackedWriteTransaction, null);
54 protected Object nextTransactionIdentifier() {
59 protected boolean getDebugTransactions() {
64 protected DataTreeSnapshot takeSnapshot() {
65 return dataTreeSnapshot;
69 protected DOMStoreThreePhaseCommitCohort createCohort(final SnapshotBackedWriteTransaction<Object> transaction,
70 final DataTreeModification modification,
71 final Exception operationError) {
72 return domStoreThreePhaseCommitCohort;