2 * Copyright (c) 2014 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 org.junit.Test;
11 import org.mockito.Mock;
12 import org.mockito.MockitoAnnotations;
13 import org.opendaylight.yangtools.yang.common.QName;
14 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
15 import org.opendaylight.yangtools.yang.model.api.Status;
16 import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition;
19 import java.util.Collections;
20 import java.util.List;
22 import static org.junit.Assert.assertEquals;
23 import static org.junit.Assert.assertNotEquals;
25 public class BitsTypeTest {
28 private BitsTypeDefinition.Bit bit;
31 public void canCreateBitsType(){
32 MockitoAnnotations.initMocks(this);
34 QName qName = QName.create("TestQName");
35 SchemaPath schemaPath = SchemaPath.create(Collections.singletonList(qName), true);
36 List<BitsTypeDefinition.Bit> listBit = Collections.singletonList(bit);
37 BitsType bitsType = BitsType.create(schemaPath, listBit);
39 assertNotEquals("Description is not null", null, bitsType.getDescription());
40 assertEquals("QName", BaseTypes.BITS_QNAME, bitsType.getQName());
41 assertEquals("Should be empty string", "", bitsType.getUnits());
42 assertNotEquals("Description should not be null", null, bitsType.toString());
43 assertNotEquals("Reference is not null", null, bitsType.getReference());
44 assertEquals("BaseType should be null", null, bitsType.getBaseType());
45 assertEquals("Default value should be list of bit", listBit, bitsType.getDefaultValue());
46 assertEquals("getPath should equal schemaPath", schemaPath, bitsType.getPath());
47 assertEquals("Status should be CURRENT", Status.CURRENT, bitsType.getStatus());
48 assertEquals("Should be empty list", Collections.EMPTY_LIST, bitsType.getUnknownSchemaNodes());
49 assertEquals("Values should be [enumPair]", listBit, bitsType.getBits());
51 assertEquals("Hash code of bitsType should be equal",
52 bitsType.hashCode(), bitsType.hashCode());
53 assertNotEquals("bitsType shouldn't equal to null", null, bitsType);
54 assertEquals("bitsType should equals to itself", bitsType, bitsType);
55 assertNotEquals("bitsType shouldn't equal to object of other type", "str", bitsType);