c334119c0c5c87ef7dc893fa0a7fcac1432c1c84
[mdsal.git] / binding / mdsal-binding-generator-util / src / test / java / org / opendaylight / mdsal / binding / model / util / generated / type / builder / AbstractTypeMemberTest.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 import org.opendaylight.mdsal.binding.model.api.MethodSignature;
18
19 public class AbstractTypeMemberTest {
20
21     @Test
22     public void testMethodsForAbstractTypeMemberBuilder() {
23         final MethodSignatureBuilderImpl methodSignatureBuilderImpl = new MethodSignatureBuilderImpl("TestProperty");
24         final CodegenGeneratedTypeBuilder typeBuilderImpl = new CodegenGeneratedTypeBuilder(
25             JavaTypeName.create("org.opendaylight.yangtools.test", "TestType"));
26         final CodegenGeneratedTypeBuilder typeBuilderImpl2 = new CodegenGeneratedTypeBuilder(
27             JavaTypeName.create("org.opendaylight.yangtools.test", "TestType2"));
28         methodSignatureBuilderImpl.setComment("test comment");
29         methodSignatureBuilderImpl.setFinal(true);
30         methodSignatureBuilderImpl.setStatic(true);
31
32         final MethodSignature genProperty = methodSignatureBuilderImpl.toInstance(typeBuilderImpl);
33         final MethodSignature genProperty2 = methodSignatureBuilderImpl.toInstance(typeBuilderImpl2);
34         assertEquals("test comment", genProperty.getComment());
35         assertTrue(genProperty.isFinal());
36         assertTrue(genProperty.isStatic());
37         assertEquals(genProperty.hashCode(), genProperty2.hashCode());
38         assertTrue(genProperty.toString().contains("org.opendaylight.yangtools.test.TestType"));
39         assertNotNull(genProperty.toString());
40         assertTrue(genProperty.equals(genProperty2));
41         assertFalse(genProperty.equals(null));
42
43     }
44 }