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.yangtools.binding.generator.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.yangtools.binding.generator.util.Types;
17 import org.opendaylight.yangtools.sal.binding.model.api.Type;
19 public class MethodParameterImplTest {
21 MethodParameterImpl parameter1, parameter2, parameter3, parameter4;
22 int hash1, hash2, hash3, hash4;
26 String name = "customParameter";
27 Type type = Types.STRING;
28 parameter1 = new MethodParameterImpl(name, type);
29 parameter2 = new MethodParameterImpl(name, type);
30 parameter3 = new MethodParameterImpl(name, null);
31 parameter4 = new MethodParameterImpl(null, type);
33 hash1 = parameter1.hashCode();
34 hash2 = parameter2.hashCode();
35 hash3 = parameter3.hashCode();
36 hash4 = parameter4.hashCode();
40 public void testToString() {
41 String toString = parameter1.toString();
42 assertTrue(toString.contains("MethodParameter"));
46 public void testEquals() {
47 assertTrue(parameter1.equals(parameter1));
48 assertTrue(parameter1.equals(parameter2));
49 assertFalse(parameter1.equals("string"));
50 assertFalse(parameter1.equals(null));
51 assertFalse(parameter1.equals(parameter3));
52 assertFalse(parameter2.equals(parameter4));
53 assertFalse(parameter4.equals(parameter2));
54 assertFalse(parameter3.equals(parameter2));
58 public void testHashCode() {
59 assertEquals(hash1,hash2);
60 assertTrue(!(hash1 == hash3));
61 assertTrue(!(hash1 == hash4));