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