dac72548e61ccce838f7565938dbb304700ec0aa
[yangtools.git] / data / yang-data-tree-ri / src / test / java / org / opendaylight / yangtools / yang / data / tree / impl / DataTreeTransactionTest.java
1 /*
2  * Copyright (c) 2015 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.yangtools.yang.data.tree.impl;
9
10 import org.junit.Before;
11 import org.junit.Test;
12 import org.opendaylight.yangtools.yang.data.tree.api.DataTree;
13 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration;
14 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification;
15 import org.opendaylight.yangtools.yang.data.tree.api.DataValidationFailedException;
16 import org.opendaylight.yangtools.yang.data.tree.impl.di.InMemoryDataTreeFactory;
17
18 public class DataTreeTransactionTest extends AbstractTestModelTest {
19     private DataTree tree;
20
21     @Before
22     public void setUp() {
23         tree = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_OPERATIONAL, SCHEMA_CONTEXT);
24     }
25
26     @Test
27     public void testSealedValidate() throws DataValidationFailedException {
28         final DataTreeModification mod = tree.takeSnapshot().newModification();
29         mod.ready();
30         tree.validate(mod);
31     }
32
33     @Test
34     public void testSealedPrepare() throws DataValidationFailedException {
35         final DataTreeModification mod = tree.takeSnapshot().newModification();
36         mod.ready();
37         tree.prepare(mod);
38     }
39
40     @Test(expected = IllegalArgumentException.class)
41     public void testUnsealedValidate() throws DataValidationFailedException {
42         final DataTreeModification mod = tree.takeSnapshot().newModification();
43         tree.validate(mod);
44     }
45
46     @Test(expected = IllegalArgumentException.class)
47     public void testUnsealedPrepare() throws DataValidationFailedException {
48         final DataTreeModification mod = tree.takeSnapshot().newModification();
49         tree.prepare(mod);
50     }
51 }