Add read-write transaction to the AsyncDataBroker APIs
[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 javax.annotation.Nonnull;
16 import org.junit.Test;
17 import org.mockito.Mock;
18 import org.opendaylight.mdsal.dom.api.DOMTransactionChain;
19
20 public class ForwardingDOMTransactionChainTest extends ForwardingDOMTransactionChain {
21
22     @Mock(name = "domTransactionChain")
23     private DOMTransactionChain domTransactionChain;
24
25     @Test
26     public void basicTest() throws Exception {
27         initMocks(this);
28
29         doReturn(null).when(domTransactionChain).newWriteOnlyTransaction();
30         this.newWriteOnlyTransaction();
31         verify(domTransactionChain).newWriteOnlyTransaction();
32
33         doReturn(null).when(domTransactionChain).newReadOnlyTransaction();
34         this.newReadOnlyTransaction();
35         verify(domTransactionChain).newReadOnlyTransaction();
36
37         doNothing().when(domTransactionChain).close();
38         this.close();
39         verify(domTransactionChain).close();
40     }
41
42     @Nonnull
43     @Override
44     protected DOMTransactionChain delegate() {
45         return domTransactionChain;
46     }
47 }