Fix leafref require-instance implementation
[yangtools.git] / yang / yang-model-util / src / test / java / org / opendaylight / yangtools / yang / model / util / BinaryTypeTest.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.assertNull;
13 import static org.junit.Assert.assertTrue;
14 import static org.opendaylight.yangtools.yang.model.util.type.BaseTypes.binaryType;
15 import java.util.Collections;
16 import org.junit.Test;
17 import org.opendaylight.yangtools.yang.model.api.Status;
18 import org.opendaylight.yangtools.yang.model.api.type.BinaryTypeDefinition;
19
20 public class BinaryTypeTest {
21
22     @Test
23     public void canCreateBinaryType() {
24         BinaryTypeDefinition binType = binaryType();
25         BinaryTypeDefinition binType1 = binaryType();
26
27         assertEquals(0, binType.getLengthConstraints().size());
28         assertNull(binType.getDefaultValue());
29         assertEquals("CURRENT", Status.CURRENT, binType.getStatus());
30         assertEquals("Base type is null", null, binType.getBaseType());
31         assertEquals("getQName gives BINARY_QNAME", BaseTypes.BINARY_QNAME, binType.getQName());
32         assertNull("Units should be null", binType.getUnits());
33         assertEquals("getPath gives List of BINARY_QNAME",
34                 Collections.singletonList(BaseTypes.BINARY_QNAME), binType.getPath().getPathFromRoot());
35
36         assertTrue("binType1 should equal to binType",
37                 binType.equals(binType1) && binType1.equals(binType));
38         assertTrue("Hash code of binType and binType1 should be equal",
39                 binType.hashCode() == binType1.hashCode());
40         assertEquals("binType should equals to itself", binType, binType);
41         assertFalse("binType shouldn't equal to null", binType.equals(null));
42         assertFalse("binType shouldn't equal to object of other type", binType.equals("str"));
43     }
44
45 }