Fix odlparent-3.0.0 checkstyle issues
[mdsal.git] / dom / mdsal-dom-spi / src / test / java / org / opendaylight / mdsal / dom / spi / store / SnapshotBackedTransactionsTest.java
1 /*
2  * Copyright (c) 2016 Cisco 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.mdsal.dom.spi.store;
9
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;
14
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;
20
21 public class SnapshotBackedTransactionsTest {
22
23     @Test
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();
29
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));
35     }
36
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);
42         try {
43             constructor.newInstance();
44             fail("Expected UnsupportedOperationException");
45         } catch (Exception e) {
46             throw e.getCause();
47         }
48     }
49 }