2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.mdsal.binding.model.ri.generated.type.builder;
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;
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;
20 public class MethodParameterImplTest {
22 private MethodParameterImpl parameter1;
23 private MethodParameterImpl parameter2;
24 private MethodParameterImpl parameter3;
25 private MethodParameterImpl parameter4;
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);
40 hash1 = parameter1.hashCode();
41 hash2 = parameter2.hashCode();
42 hash3 = parameter3.hashCode();
43 hash4 = parameter4.hashCode();
47 public void testToString() {
48 String toString = parameter1.toString();
49 assertTrue(toString.contains("MethodParameter"));
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));
65 public void testHashCode() {
66 assertEquals(hash1, hash2);
67 assertNotEquals(hash1, hash3);
68 assertNotEquals(hash1, hash4);