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