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.junit.Assert.assertNotNull;
11 import static org.junit.Assert.fail;
12 import static org.mockito.Mockito.doReturn;
13 import static org.mockito.Mockito.mock;
15 import java.lang.reflect.Constructor;
16 import org.junit.Test;
17 import org.opendaylight.mdsal.dom.spi.store.SnapshotBackedWriteTransaction.TransactionReadyPrototype;
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 SnapshotBackedTransactionsTest {
24 public void basicTest() throws Exception {
25 final DataTreeSnapshot dataTreeSnapshot = mock(DataTreeSnapshot.class);
26 final DataTreeModification dataTreeModification = mock(DataTreeModification.class);
27 final TransactionReadyPrototype<Object> transactionReadyPrototype = mock(TransactionReadyPrototype.class);
28 doReturn(dataTreeModification).when(dataTreeSnapshot).newModification();
30 assertNotNull(SnapshotBackedTransactions.newReadTransaction(new Object(), false, dataTreeSnapshot));
31 assertNotNull(SnapshotBackedTransactions.newWriteTransaction(
32 new Object(), false, dataTreeSnapshot, transactionReadyPrototype));
33 assertNotNull(SnapshotBackedTransactions.newReadWriteTransaction(
34 new Object(), false, dataTreeSnapshot, transactionReadyPrototype));
37 @SuppressWarnings({"checkstyle:IllegalThrows", "checkstyle:IllegalCatch", "checkstyle:avoidHidingCauseException" })
38 @Test(expected = UnsupportedOperationException.class)
39 public void constructorTest() throws Throwable {
40 Constructor<SnapshotBackedTransactions> constructor = SnapshotBackedTransactions.class.getDeclaredConstructor();
41 constructor.setAccessible(true);
43 constructor.newInstance();
44 fail("Expected UnsupportedOperationException");
45 } catch (Exception e) {