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.ri.generated.type.builder;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertFalse;
12 import static org.junit.Assert.assertNotNull;
13 import static org.junit.Assert.assertTrue;
15 import org.junit.Before;
16 import org.junit.Test;
17 import org.opendaylight.mdsal.binding.model.api.MethodSignature;
18 import org.opendaylight.mdsal.binding.model.api.Type;
19 import org.opendaylight.mdsal.binding.model.api.type.builder.MethodSignatureBuilder;
20 import org.opendaylight.mdsal.binding.model.ri.Types;
22 public class MethodSignatureBuilderTest {
24 private MethodSignatureBuilder builder1;
25 private MethodSignatureBuilder builder2;
26 private MethodSignatureBuilder builder3;
27 private MethodSignatureBuilder builder4;
34 builder1 = new MethodSignatureBuilderImpl("methodSignature");
35 builder2 = new MethodSignatureBuilderImpl("otherMethodSignature");
36 builder2.setReturnType(Types.STRING);
37 builder3 = new MethodSignatureBuilderImpl(null);
38 builder3.setAbstract(false);
39 builder4 = new MethodSignatureBuilderImpl("otherMethodSignature");
40 builder4.setReturnType(Types.BOOLEAN);
42 hash1 = builder1.hashCode();
43 hash2 = builder2.hashCode();
44 hash3 = builder3.hashCode();
48 public void testAddParameter() {
49 Type type = Types.STRING;
50 String name = "customParam";
51 builder1.addParameter(type, name);
52 Type methodType = Types.voidType();
53 MethodSignature signature = builder1.toInstance(methodType);
54 assertNotNull(signature);
58 public void testToString() {
59 String toString = builder1.toString();
60 assertTrue(toString.contains("MethodSignatureBuilderImpl"));
64 public void testHashCode() {
65 assertEquals(hash1, hash1);
69 public void testEquals() {
70 assertTrue(builder1.equals(builder1));
71 assertFalse(builder1.equals(builder2));
72 assertFalse(builder1.equals(null));
73 assertFalse(builder1.equals("string"));
74 assertFalse(builder3.equals(builder2));
75 assertFalse(builder4.equals(builder2));