cfa21127bb327447c4dcb4734373b3ab8e892a15
[mdsal.git] / dom / mdsal-dom-spi / src / test / java / org / opendaylight / mdsal / dom / spi / ForwardingDOMTransactionChainTest.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;
9
10 import static org.mockito.Mockito.doNothing;
11 import static org.mockito.Mockito.doReturn;
12 import static org.mockito.Mockito.verify;
13 import static org.mockito.MockitoAnnotations.initMocks;
14
15 import org.junit.Test;
16 import org.mockito.Mock;
17 import org.opendaylight.mdsal.dom.api.DOMTransactionChain;
18
19 public class ForwardingDOMTransactionChainTest extends ForwardingDOMTransactionChain {
20
21     @Mock(name = "domTransactionChain")
22     private DOMTransactionChain domTransactionChain;
23
24     @Test
25     public void basicTest() throws Exception {
26         initMocks(this);
27
28         doReturn(null).when(domTransactionChain).newWriteOnlyTransaction();
29         this.newWriteOnlyTransaction();
30         verify(domTransactionChain).newWriteOnlyTransaction();
31
32         doReturn(null).when(domTransactionChain).newReadOnlyTransaction();
33         this.newReadOnlyTransaction();
34         verify(domTransactionChain).newReadOnlyTransaction();
35
36         doNothing().when(domTransactionChain).close();
37         this.close();
38         verify(domTransactionChain).close();
39     }
40
41     @Override
42     protected DOMTransactionChain delegate() {
43         return domTransactionChain;
44     }
45 }