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