Fix checkstyle in mdsal-binding-generator-util
[mdsal.git] / binding / mdsal-binding-generator-util / src / test / java / org / opendaylight / mdsal / binding / model / util / generated / type / builder / MethodParameterImplTest.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.assertTrue;
13
14 import org.junit.Before;
15 import org.junit.Test;
16 import org.opendaylight.mdsal.binding.model.api.Type;
17 import org.opendaylight.mdsal.binding.model.util.Types;
18
19 public class MethodParameterImplTest {
20
21     private MethodParameterImpl parameter1;
22     private MethodParameterImpl parameter2;
23     private MethodParameterImpl parameter3;
24     private MethodParameterImpl parameter4;
25     private int hash1;
26     private int hash2;
27     private int hash3;
28     private int hash4;
29
30     @Before
31     public void before() {
32         String name = "customParameter";
33         Type type = Types.STRING;
34         parameter1 = new MethodParameterImpl(name, type);
35         parameter2 = new MethodParameterImpl(name, type);
36         parameter3 = new MethodParameterImpl(name, null);
37         parameter4 = new MethodParameterImpl(null, type);
38
39         hash1 = parameter1.hashCode();
40         hash2 = parameter2.hashCode();
41         hash3 = parameter3.hashCode();
42         hash4 = parameter4.hashCode();
43     }
44
45     @Test
46     public void testToString() {
47         String toString = parameter1.toString();
48         assertTrue(toString.contains("MethodParameter"));
49     }
50
51     @Test
52     public void testEquals() {
53         assertTrue(parameter1.equals(parameter1));
54         assertTrue(parameter1.equals(parameter2));
55         assertFalse(parameter1.equals("string"));
56         assertFalse(parameter1.equals(null));
57         assertFalse(parameter1.equals(parameter3));
58         assertFalse(parameter2.equals(parameter4));
59         assertFalse(parameter4.equals(parameter2));
60         assertFalse(parameter3.equals(parameter2));
61     }
62
63     @Test
64     public void testHashCode() {
65         assertEquals(hash1,hash2);
66         assertTrue(!(hash1 == hash3));
67         assertTrue(!(hash1 == hash4));
68     }
69 }
70