Generate @param for RPC invocation methods
[mdsal.git] / binding / mdsal-binding-generator-util / src / test / java / org / opendaylight / mdsal / binding / model / util / generated / type / builder / MethodSignatureImplTest.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.assertNotEquals;
13 import static org.junit.Assert.assertTrue;
14
15 import java.util.ArrayList;
16 import java.util.List;
17 import org.junit.Before;
18 import org.junit.Test;
19 import org.opendaylight.mdsal.binding.model.api.AccessModifier;
20 import org.opendaylight.mdsal.binding.model.api.AnnotationType;
21 import org.opendaylight.mdsal.binding.model.api.MethodSignature.Parameter;
22 import org.opendaylight.mdsal.binding.model.api.Type;
23 import org.opendaylight.mdsal.binding.model.api.TypeMemberComment;
24 import org.opendaylight.mdsal.binding.model.util.Types;
25
26 public class MethodSignatureImplTest {
27
28     private MethodSignatureImpl signature1;
29     private MethodSignatureImpl signature2;
30     private MethodSignatureImpl signature3;
31     private MethodSignatureImpl signature4;
32     private int hash1;
33     private int hash4;
34
35     @Before
36     public void setup() {
37         Type type = Types.STRING;
38         String name = "customMethod";
39         List<AnnotationType> annotations = new ArrayList<>();
40         TypeMemberComment comment = TypeMemberComment.contractOf("This is just a comment");
41         AccessModifier accessModifier = AccessModifier.PUBLIC;
42         Type returnType = Types.STRING;
43         List<Parameter> params = new ArrayList<>();
44         boolean isFinal = false;
45         boolean isAbstract = false;
46         boolean isStatic = false;
47
48         signature1 = new MethodSignatureImpl(type, name, annotations, comment,
49                 accessModifier, returnType, params, isFinal, isAbstract,
50                 isStatic);
51         signature2 = new MethodSignatureImpl(type, name, annotations, comment,
52                 accessModifier, returnType, params, isFinal, isAbstract,
53                 isStatic);
54         returnType = null;
55         signature3 = new MethodSignatureImpl(type, name, annotations, comment,
56                 accessModifier, returnType, params, isFinal, isAbstract,
57                 isStatic);
58         name = null;
59         signature4 = new MethodSignatureImpl(type, name, annotations, comment,
60                 accessModifier, returnType, params, isFinal, isAbstract,
61                 isStatic);
62
63         hash1 = signature1.hashCode();
64         hash4 = signature4.hashCode();
65     }
66
67     @Test
68     public void testToString() {
69         String toString = signature1.toString();
70         assertTrue(toString.contains("MethodSignatureImpl"));
71     }
72
73     @Test
74     public void testHashCode() {
75         assertEquals(hash1, hash1);
76         assertNotEquals(hash1, hash4);
77     }
78
79     @Test
80     public void testEquals() {
81         assertTrue(signature1.equals(signature1));
82         assertTrue(signature1.equals(signature2));
83         assertFalse(signature1.equals(signature3));
84         assertFalse(signature3.equals(signature1));
85         assertFalse(signature1.equals(null));
86         assertFalse(signature1.equals(signature4));
87         assertFalse(signature4.equals(signature1));
88         assertFalse(signature1.equals(Types.STRING));
89     }
90
91 }