Merge branch 'master' of ../controller
[yangtools.git] / yang / yang-model-util / src / test / java / org / opendaylight / yangtools / yang / model / util / BooleanTypeTest.java
1 /*
2  * Copyright (c) 2013 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.model.util;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertFalse;
12 import static org.junit.Assert.assertTrue;
13 import static org.opendaylight.yangtools.yang.model.util.type.BaseTypes.booleanType;
14
15 import java.util.Collections;
16 import java.util.Optional;
17 import org.junit.Test;
18 import org.opendaylight.yangtools.yang.model.api.Status;
19 import org.opendaylight.yangtools.yang.model.api.type.BooleanTypeDefinition;
20
21 public class BooleanTypeTest {
22
23     @Test
24     public void canCreateBooleanType() {
25         final BooleanTypeDefinition boolType = booleanType();
26         final String stringBoolType = boolType.toString();
27
28         assertEquals("getPath gives List of BOOLEAN_QNAME",
29                 Collections.singletonList(BaseTypes.BOOLEAN_QNAME), boolType.getPath().getPathFromRoot());
30         assertEquals("getQName gives BOOLEAN_QNAME", BaseTypes.BOOLEAN_QNAME, boolType.getQName());
31         assertFalse(boolType.getDescription().isPresent());
32
33         final String strPath = boolType.getPath().toString();
34         assertTrue("Should contain string of getPath", stringBoolType.contains(strPath));
35         assertEquals(Optional.empty(), boolType.getUnits());
36         assertEquals("Base type is null", null, boolType.getBaseType());
37         assertEquals(Optional.empty(), boolType.getDefaultValue());
38         assertEquals("Status CURRENT", Status.CURRENT, boolType.getStatus());
39         assertEquals("Should contain empty list", Collections.emptyList(), boolType.getUnknownSchemaNodes());
40     }
41 }