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.util.generated.type.builder;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertFalse;
12 import static org.junit.Assert.assertTrue;
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;
19 public class MethodParameterImplTest {
21 private MethodParameterImpl parameter1;
22 private MethodParameterImpl parameter2;
23 private MethodParameterImpl parameter3;
24 private MethodParameterImpl parameter4;
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);
39 hash1 = parameter1.hashCode();
40 hash2 = parameter2.hashCode();
41 hash3 = parameter3.hashCode();
42 hash4 = parameter4.hashCode();
46 public void testToString() {
47 String toString = parameter1.toString();
48 assertTrue(toString.contains("MethodParameter"));
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));
64 public void testHashCode() {
65 assertEquals(hash1,hash2);
66 assertTrue(!(hash1 == hash3));
67 assertTrue(!(hash1 == hash4));