Remove parent type references
[mdsal.git] / binding / mdsal-binding-generator-util / src / test / java / org / opendaylight / mdsal / binding / model / util / generated / type / builder / ConstantImplTest.java
1 /*
2  * Copyright (c) 2014 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.mdsal.binding.model.util.generated.type.builder;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertFalse;
12 import static org.junit.Assert.assertNotNull;
13 import static org.junit.Assert.assertTrue;
14
15 import org.junit.Test;
16 import org.opendaylight.mdsal.binding.model.api.JavaTypeName;
17
18 public class ConstantImplTest {
19     @Test
20     public void testMethodsOfConstantImpl() {
21         final CodegenGeneratedTypeBuilder type = new CodegenGeneratedTypeBuilder(
22             JavaTypeName.create("org.opendaylight.yangtools.test.v1", "BaseType"));
23         final ConstantImpl constImpl = new ConstantImpl(type, "IpAddress", "127.0.0.1");
24         final ConstantImpl constImpl2 = new ConstantImpl(type, "IpAddress", "127.0.0.1");
25         final ConstantImpl constImpl3 = new ConstantImpl(type, "IpAddress", "127.0.0.0");
26         final ConstantImpl constImpl4 = constImpl;
27         final ConstantImpl constImpl5 = new ConstantImpl(type, null, "127.0.0.0");
28         final ConstantImpl constImpl6 = new ConstantImpl(type, "IpAddress", null);
29
30         assertEquals("BaseType", constImpl.getType().getName());
31         assertEquals("IpAddress", constImpl.getName());
32         assertEquals("127.0.0.1", constImpl.getValue());
33         assertTrue(constImpl.toFormattedString().contains("GeneratedTransferObject"));
34         assertTrue(constImpl.toString().contains("GeneratedTransferObject"));
35         assertEquals(constImpl.hashCode(), constImpl2.hashCode());
36         assertNotNull(constImpl.getType());
37         assertNotNull(constImpl.getName());
38         assertNotNull(constImpl.getValue());
39         assertNotNull(constImpl.toFormattedString());
40         assertNotNull(constImpl.toString());
41         assertNotNull(constImpl.hashCode());
42         assertFalse(constImpl.equals(null));
43         assertFalse(constImpl.equals("test"));
44
45         assertTrue(constImpl.equals(constImpl2));
46         assertFalse(constImpl.equals(constImpl3));
47         assertTrue(constImpl.equals(constImpl4));
48         assertFalse(constImpl5.equals(constImpl));
49         assertFalse(constImpl6.equals(constImpl));
50     }
51 }