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.assertNotEquals;
13 import static org.junit.Assert.assertTrue;
15 import java.util.ArrayList;
16 import java.util.List;
17 import org.junit.Before;
18 import org.junit.Test;
19 import org.opendaylight.mdsal.binding.model.api.AccessModifier;
20 import org.opendaylight.mdsal.binding.model.api.AnnotationType;
21 import org.opendaylight.mdsal.binding.model.api.MethodSignature.Parameter;
22 import org.opendaylight.mdsal.binding.model.api.Type;
23 import org.opendaylight.mdsal.binding.model.api.TypeMemberComment;
24 import org.opendaylight.mdsal.binding.model.util.Types;
26 public class MethodSignatureImplTest {
28 private MethodSignatureImpl signature1;
29 private MethodSignatureImpl signature2;
30 private MethodSignatureImpl signature3;
31 private MethodSignatureImpl signature4;
37 Type type = Types.STRING;
38 String name = "customMethod";
39 List<AnnotationType> annotations = new ArrayList<>();
40 TypeMemberComment comment = TypeMemberComment.contractOf("This is just a comment");
41 AccessModifier accessModifier = AccessModifier.PUBLIC;
42 Type returnType = Types.STRING;
43 List<Parameter> params = new ArrayList<>();
44 boolean isFinal = false;
45 boolean isAbstract = false;
46 boolean isStatic = false;
48 signature1 = new MethodSignatureImpl(type, name, annotations, comment,
49 accessModifier, returnType, params, isFinal, isAbstract,
51 signature2 = new MethodSignatureImpl(type, name, annotations, comment,
52 accessModifier, returnType, params, isFinal, isAbstract,
55 signature3 = new MethodSignatureImpl(type, name, annotations, comment,
56 accessModifier, returnType, params, isFinal, isAbstract,
59 signature4 = new MethodSignatureImpl(type, name, annotations, comment,
60 accessModifier, returnType, params, isFinal, isAbstract,
63 hash1 = signature1.hashCode();
64 hash4 = signature4.hashCode();
68 public void testToString() {
69 String toString = signature1.toString();
70 assertTrue(toString.contains("MethodSignatureImpl"));
74 public void testHashCode() {
75 assertEquals(hash1, hash1);
76 assertNotEquals(hash1, hash4);
80 public void testEquals() {
81 assertTrue(signature1.equals(signature1));
82 assertTrue(signature1.equals(signature2));
83 assertFalse(signature1.equals(signature3));
84 assertFalse(signature3.equals(signature1));
85 assertFalse(signature1.equals(null));
86 assertFalse(signature1.equals(signature4));
87 assertFalse(signature4.equals(signature1));
88 assertFalse(signature1.equals(Types.STRING));