Split out yang-data-tree-{api,spi}
[yangtools.git] / data / yang-data-tree-spi / src / test / java / org / opendaylight / yangtools / yang / data / tree / spi / DataTreeConfigurationTest.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.yangtools.yang.data.tree.spi;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertFalse;
12 import static org.junit.Assert.assertTrue;
13
14 import org.junit.Test;
15 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration;
16 import org.opendaylight.yangtools.yang.data.tree.api.TreeType;
17
18 public class DataTreeConfigurationTest {
19     @Test
20     public void testDataTreeConfiguration() {
21         DataTreeConfiguration.Builder builder = new DataTreeConfiguration.Builder(TreeType.CONFIGURATION);
22         builder.setUniqueIndexes(true);
23         builder.setMandatoryNodesValidation(true);
24
25         DataTreeConfiguration dataTreeConfiguration = builder.build();
26         assertEquals(TreeType.CONFIGURATION, dataTreeConfiguration.getTreeType());
27         assertTrue(dataTreeConfiguration.isUniqueIndexEnabled());
28         assertTrue(dataTreeConfiguration.isMandatoryNodesValidationEnabled());
29
30         builder = new DataTreeConfiguration.Builder(TreeType.OPERATIONAL);
31         builder.setUniqueIndexes(false);
32         builder.setMandatoryNodesValidation(false);
33
34         dataTreeConfiguration = builder.build();
35         assertEquals(TreeType.OPERATIONAL, dataTreeConfiguration.getTreeType());
36         assertFalse(dataTreeConfiguration.isUniqueIndexEnabled());
37         assertFalse(dataTreeConfiguration.isMandatoryNodesValidationEnabled());
38
39         dataTreeConfiguration = DataTreeConfiguration.getDefault(TreeType.CONFIGURATION);
40         assertEquals(TreeType.CONFIGURATION, dataTreeConfiguration.getTreeType());
41         assertFalse(dataTreeConfiguration.isUniqueIndexEnabled());
42         assertTrue(dataTreeConfiguration.isMandatoryNodesValidationEnabled());
43
44         dataTreeConfiguration = DataTreeConfiguration.getDefault(TreeType.OPERATIONAL);
45         assertEquals(TreeType.OPERATIONAL, dataTreeConfiguration.getTreeType());
46         assertFalse(dataTreeConfiguration.isUniqueIndexEnabled());
47         assertTrue(dataTreeConfiguration.isMandatoryNodesValidationEnabled());
48     }
49 }