2 * Copyright (c) 2013 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
8 package org.opendaylight.yangtools.yang.model.util;
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;
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;
21 public class BooleanTypeTest {
24 public void canCreateBooleanType() {
25 final BooleanTypeDefinition boolType = booleanType();
26 final String stringBoolType = boolType.toString();
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());
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.EMPTY_LIST, boolType.getUnknownSchemaNodes());