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