Fix lead transaction cancellation
[mdsal.git] / dom / mdsal-dom-spi / src / test / java / org / opendaylight / mdsal / dom / spi / RegistrationTreeSnapshotTest.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.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12 import static org.mockito.Mockito.doNothing;
13 import static org.mockito.Mockito.mock;
14 import static org.mockito.Mockito.verify;
15
16 import java.util.concurrent.locks.Lock;
17 import org.junit.Test;
18 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
19
20 public class RegistrationTreeSnapshotTest {
21
22     @Test
23     public void basicTest() throws Exception {
24         final Lock lock = mock(Lock.class);
25         final PathArgument pathArgument = mock(PathArgument.class);
26         final RegistrationTreeNode<?> registrationTreeNode = new RegistrationTreeNode<>(null, pathArgument);
27         final RegistrationTreeSnapshot<?> registrationTreeSnapshot =
28                 new RegistrationTreeSnapshot<>(lock, registrationTreeNode);
29
30         assertNotNull(registrationTreeSnapshot.getRootNode());
31         assertEquals(registrationTreeNode, registrationTreeSnapshot.getRootNode());
32
33         doNothing().when(lock).unlock();
34         registrationTreeSnapshot.close();
35         verify(lock).unlock();
36     }
37 }