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.binding.generator.util;
10 import static org.junit.Assert.assertFalse;
11 import static org.junit.Assert.assertNotEquals;
12 import static org.junit.Assert.assertTrue;
14 import org.junit.Rule;
15 import org.junit.Test;
16 import org.junit.rules.ExpectedException;
18 public class AbstractBaseTypeTest {
21 public ExpectedException expException = ExpectedException.none();
24 public void testgetFullyQualifiedName() {
25 AbstractBaseType baseType = new AbstractBaseType("", "");
26 assertTrue(baseType.getFullyQualifiedName().isEmpty());
30 public void testCreateAbstractBaseTypeWithNullPackagename() {
31 expException.expect(IllegalArgumentException.class);
32 expException.expectMessage("Package Name for Generated Type cannot be null!");
33 AbstractBaseType baseTypeNullpackagename = new AbstractBaseType(null, "Test");
37 public void testCreateAbstractBaseTypeWithNullTypeName() {
38 expException.expect(IllegalArgumentException.class);
39 expException.expectMessage("Name of Generated Type cannot be null!");
40 AbstractBaseType baseTypeNullTypeName = new AbstractBaseType("org.opendaylight.yangtools.test", null);
44 public void testHashCode() {
45 AbstractBaseType baseType1 = new AbstractBaseType("org.opendaylight.yangtools.test", "Test");
46 AbstractBaseType baseType2 = new AbstractBaseType("org.opendaylight.yangtools.test", "Test2");
47 assertNotEquals(baseType1.hashCode(), baseType2.hashCode());
51 public void testToString() {
52 AbstractBaseType baseType = new AbstractBaseType("org.opendaylight.yangtools.test", "Test");
53 assertTrue(baseType.toString().contains("org.opendaylight.yangtools.test.Test"));
54 baseType = new AbstractBaseType("", "Test");
55 assertTrue(baseType.toString().contains("Test"));
59 public void testEquals() {
60 AbstractBaseType baseType1 = new AbstractBaseType("org.opendaylight.yangtools.test", "Test");
61 AbstractBaseType baseType2 = new AbstractBaseType("org.opendaylight.yangtools.test", "Test2");
62 AbstractBaseType baseType3 = null;
63 AbstractBaseType baseType4 = new AbstractBaseType("org.opendaylight.yangtools.test", "Test");
64 AbstractBaseType baseType5 = new AbstractBaseType("org.opendaylight.yangtools.test1", "Test");
66 assertFalse(baseType1.equals(baseType2));
67 assertFalse(baseType1.equals(baseType3));
68 assertTrue(baseType1.equals(baseType4));
69 assertFalse(baseType1.equals(baseType5));
70 assertFalse(baseType1.equals(null));