2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.yangtools.yang.data.api.schema.tree;
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertFalse;
13 import static org.junit.Assert.assertTrue;
15 import org.junit.Test;
17 public class DataTreeConfigurationTest {
20 public void testDataTreeConfiguration() {
21 DataTreeConfiguration.Builder builder = new DataTreeConfiguration.Builder(TreeType.CONFIGURATION);
22 builder.setUniqueIndexes(true);
23 builder.setMandatoryNodesValidation(true);
25 DataTreeConfiguration dataTreeConfiguration = builder.build();
26 assertEquals(TreeType.CONFIGURATION, dataTreeConfiguration.getTreeType());
27 assertTrue(dataTreeConfiguration.isUniqueIndexEnabled());
28 assertTrue(dataTreeConfiguration.isMandatoryNodesValidationEnabled());
30 builder = new DataTreeConfiguration.Builder(TreeType.OPERATIONAL);
31 builder.setUniqueIndexes(false);
32 builder.setMandatoryNodesValidation(false);
34 dataTreeConfiguration = builder.build();
35 assertEquals(TreeType.OPERATIONAL, dataTreeConfiguration.getTreeType());
36 assertFalse(dataTreeConfiguration.isUniqueIndexEnabled());
37 assertFalse(dataTreeConfiguration.isMandatoryNodesValidationEnabled());
39 dataTreeConfiguration = DataTreeConfiguration.getDefault(TreeType.CONFIGURATION);
40 assertEquals(TreeType.CONFIGURATION, dataTreeConfiguration.getTreeType());
41 assertFalse(dataTreeConfiguration.isUniqueIndexEnabled());
42 assertTrue(dataTreeConfiguration.isMandatoryNodesValidationEnabled());
44 dataTreeConfiguration = DataTreeConfiguration.getDefault(TreeType.OPERATIONAL);
45 assertEquals(TreeType.OPERATIONAL, dataTreeConfiguration.getTreeType());
46 assertFalse(dataTreeConfiguration.isUniqueIndexEnabled());
47 assertTrue(dataTreeConfiguration.isMandatoryNodesValidationEnabled());