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 java.util.ArrayList;
15 import java.util.List;
16 import org.junit.Before;
17 import org.junit.Test;
18 import org.opendaylight.yangtools.binding.generator.util.Types;
19 import org.opendaylight.yangtools.sal.binding.model.api.AccessModifier;
20 import org.opendaylight.yangtools.sal.binding.model.api.AnnotationType;
21 import org.opendaylight.yangtools.sal.binding.model.api.MethodSignature.Parameter;
22 import org.opendaylight.yangtools.sal.binding.model.api.Type;
24 public class MethodSignatureImplTest {
26 MethodSignatureImpl signature1, signature2, signature3, signature4;
31 Type type = Types.STRING;
32 String name = "customMethod";
33 List<AnnotationType> annotations = new ArrayList<>();
34 String comment = "This is just a comment";
35 AccessModifier accessModifier = AccessModifier.PUBLIC;
36 Type returnType = Types.STRING;
37 List<Parameter> params = new ArrayList<>();
38 boolean isFinal = false;
39 boolean isAbstract = false;
40 boolean isStatic = false;
42 signature1 = new MethodSignatureImpl(type, name, annotations, comment,
43 accessModifier, returnType, params, isFinal, isAbstract,
45 signature2 = new MethodSignatureImpl(type, name, annotations, comment,
46 accessModifier, returnType, params, isFinal, isAbstract,
49 signature3 = new MethodSignatureImpl(type, name, annotations, comment,
50 accessModifier, returnType, params, isFinal, isAbstract,
53 signature4 = new MethodSignatureImpl(type, name, annotations, comment,
54 accessModifier, returnType, params, isFinal, isAbstract,
57 hash1 = signature1.hashCode();
58 hash4 = signature4.hashCode();
62 public void testToString() {
63 String toString = signature1.toString();
64 assertTrue(toString.contains("MethodSignatureImpl"));
68 public void testHashCode() {
69 assertEquals(hash1, hash1);
70 assertTrue(!(hash1 == hash4));
74 public void testEquals() {
75 assertTrue(signature1.equals(signature1));
76 assertTrue(signature1.equals(signature2));
77 assertFalse(signature1.equals(signature3));
78 assertFalse(signature3.equals(signature1));
79 assertFalse(signature1.equals(null));
80 assertFalse(signature1.equals(signature4));
81 assertFalse(signature4.equals(signature1));
82 assertFalse(signature1.equals(Types.STRING));