Introduce top-level pom file.
[mdsal.git] / code-generator / binding-generator-util / src / test / java / org / opendaylight / yangtools / binding / generator / util / generated / type / builder / MethodSignatureBuilderTest.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.yangtools.binding.generator.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.Before;
16 import org.junit.Test;
17 import org.opendaylight.yangtools.binding.generator.util.Types;
18 import org.opendaylight.yangtools.sal.binding.model.api.MethodSignature;
19 import org.opendaylight.yangtools.sal.binding.model.api.Type;
20 import org.opendaylight.yangtools.sal.binding.model.api.type.builder.MethodSignatureBuilder;
21
22 public class MethodSignatureBuilderTest {
23
24     MethodSignatureBuilder builder1, builder2, builder3, builder4;
25     int hash1, hash2, hash3;
26
27     @Before
28     public void setup() {
29         builder1 = new MethodSignatureBuilderImpl("methodSignature");
30         builder2 = new MethodSignatureBuilderImpl("otherMethodSignature");
31         builder2.setReturnType(Types.STRING);
32         builder3 = new MethodSignatureBuilderImpl(null);
33         builder3.setAbstract(false);
34         builder4 = new MethodSignatureBuilderImpl("otherMethodSignature");
35         builder4.setReturnType(Types.BOOLEAN);
36
37         hash1 = builder1.hashCode();
38         hash2 = builder2.hashCode();
39         hash3 = builder3.hashCode();
40     }
41
42     @Test
43     public void testAddParameter() {
44         Type type = Types.STRING;
45         String name = "customParam";
46         builder1.addParameter(type, name);
47         Type methodType = Types.voidType();
48         MethodSignature signature = builder1.toInstance(methodType);
49         assertNotNull(signature);
50     }
51
52     @Test
53     public void testToString() {
54         String toString = builder1.toString();
55         assertTrue(toString.contains("MethodSignatureBuilderImpl"));
56     }
57
58     @Test
59     public void testHashCode() {
60         assertEquals(hash1, hash1);
61     }
62
63     @Test
64     public void testEquals() {
65         assertTrue(builder1.equals(builder1));
66         assertFalse(builder1.equals(builder2));
67         assertFalse(builder1.equals(null));
68         assertFalse(builder1.equals("string"));
69         assertFalse(builder3.equals(builder2));
70         assertFalse(builder4.equals(builder2));
71     }
72 }