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