Migrate yang-data-tree-ri to JUnit5
[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 static org.junit.jupiter.api.Assertions.assertThrows;
11
12 import org.junit.jupiter.api.BeforeEach;
13 import org.junit.jupiter.api.Test;
14 import org.opendaylight.yangtools.yang.data.tree.api.DataTree;
15 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration;
16 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification;
17 import org.opendaylight.yangtools.yang.data.tree.api.DataValidationFailedException;
18 import org.opendaylight.yangtools.yang.data.tree.impl.di.InMemoryDataTreeFactory;
19
20 class DataTreeTransactionTest extends AbstractTestModelTest {
21     private DataTree tree;
22
23     @BeforeEach
24     void setUp() {
25         tree = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_OPERATIONAL, SCHEMA_CONTEXT);
26     }
27
28     @Test
29     void testSealedValidate() throws DataValidationFailedException {
30         final var mod = tree.takeSnapshot().newModification();
31         mod.ready();
32         tree.validate(mod);
33     }
34
35     @Test
36     void testSealedPrepare() throws DataValidationFailedException {
37         final var mod = tree.takeSnapshot().newModification();
38         mod.ready();
39         tree.prepare(mod);
40     }
41
42     @Test
43     void testUnsealedValidate() throws DataValidationFailedException {
44         assertThrows(IllegalArgumentException.class, () -> {
45             final DataTreeModification mod = tree.takeSnapshot().newModification();
46             tree.validate(mod);
47         });
48     }
49
50     @Test
51     void testUnsealedPrepare() throws DataValidationFailedException {
52         assertThrows(IllegalArgumentException.class, () -> {
53             final DataTreeModification mod = tree.takeSnapshot().newModification();
54             tree.prepare(mod);
55         });
56     }
57 }