Populate data/ hierarchy
[yangtools.git] / model / yang-model-ri / src / test / java / org / opendaylight / yangtools / yang / model / ri / type / 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.ri.type;
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 java.util.Optional;
15 import org.junit.Test;
16 import org.opendaylight.yangtools.yang.model.api.Status;
17 import org.opendaylight.yangtools.yang.model.api.type.BinaryTypeDefinition;
18 import org.opendaylight.yangtools.yang.model.api.type.TypeDefinitions;
19
20 public class BinaryTypeTest {
21     @Test
22     public void canCreateBinaryType() {
23         final BinaryTypeDefinition binType = BaseTypes.binaryType();
24         final BinaryTypeDefinition binType1 = BaseTypes.binaryType();
25
26         assertFalse(binType.getLengthConstraint().isPresent());
27         assertEquals(Optional.empty(), binType.getDefaultValue());
28         assertEquals("CURRENT", Status.CURRENT, binType.getStatus());
29         assertEquals("Base type is null", null, binType.getBaseType());
30         assertEquals("getQName gives BINARY_QNAME", TypeDefinitions.BINARY, binType.getQName());
31         assertEquals(Optional.empty(), binType.getUnits());
32
33         assertTrue("binType1 should equal to binType", binType.equals(binType1) && binType1.equals(binType));
34         assertTrue("Hash code of binType and binType1 should be equal",
35                 binType.hashCode() == binType1.hashCode());
36         assertEquals("binType should equals to itself", binType, binType);
37         assertFalse("binType shouldn't equal to null", binType.equals(null));
38         assertFalse("binType shouldn't equal to object of other type", binType.equals("str"));
39     }
40 }