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 java.util.ArrayList;
15 import java.util.List;
16 import org.junit.Before;
17 import org.junit.Test;
18 import org.opendaylight.mdsal.binding.model.api.AccessModifier;
19 import org.opendaylight.mdsal.binding.model.api.AnnotationType;
20 import org.opendaylight.mdsal.binding.model.api.MethodSignature.Parameter;
21 import org.opendaylight.mdsal.binding.model.api.Type;
22 import org.opendaylight.mdsal.binding.model.util.Types;
24 public class MethodSignatureImplTest {
26 private MethodSignatureImpl signature1;
27 private MethodSignatureImpl signature2;
28 private MethodSignatureImpl signature3;
29 private MethodSignatureImpl signature4;
35 Type type = Types.STRING;
36 String name = "customMethod";
37 List<AnnotationType> annotations = new ArrayList<>();
38 String comment = "This is just a comment";
39 AccessModifier accessModifier = AccessModifier.PUBLIC;
40 Type returnType = Types.STRING;
41 List<Parameter> params = new ArrayList<>();
42 boolean isFinal = false;
43 boolean isAbstract = false;
44 boolean isStatic = false;
46 signature1 = new MethodSignatureImpl(type, name, annotations, comment,
47 accessModifier, returnType, params, isFinal, isAbstract,
49 signature2 = new MethodSignatureImpl(type, name, annotations, comment,
50 accessModifier, returnType, params, isFinal, isAbstract,
53 signature3 = new MethodSignatureImpl(type, name, annotations, comment,
54 accessModifier, returnType, params, isFinal, isAbstract,
57 signature4 = new MethodSignatureImpl(type, name, annotations, comment,
58 accessModifier, returnType, params, isFinal, isAbstract,
61 hash1 = signature1.hashCode();
62 hash4 = signature4.hashCode();
66 public void testToString() {
67 String toString = signature1.toString();
68 assertTrue(toString.contains("MethodSignatureImpl"));
72 public void testHashCode() {
73 assertEquals(hash1, hash1);
74 assertTrue(!(hash1 == hash4));
78 public void testEquals() {
79 assertTrue(signature1.equals(signature1));
80 assertTrue(signature1.equals(signature2));
81 assertFalse(signature1.equals(signature3));
82 assertFalse(signature3.equals(signature1));
83 assertFalse(signature1.equals(null));
84 assertFalse(signature1.equals(signature4));
85 assertFalse(signature4.equals(signature1));
86 assertFalse(signature1.equals(Types.STRING));