Bug 584: MethodParameterImpl test coverage increase 81/11881/2
authorMartin Ciglan <mciglan@cisco.com>
Fri, 10 Oct 2014 12:29:34 +0000 (14:29 +0200)
committerMartin Ciglan <mciglan@cisco.com>
Fri, 10 Oct 2014 12:39:19 +0000 (12:39 +0000)
Change-Id: I63ecbdb35266f4549ebc51c49d9a8009f8b57dcb
Signed-off-by: Martin Ciglan <mciglan@cisco.com>
code-generator/binding-generator-util/src/test/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/MethodParameterImplTest.java [new file with mode: 0644]

diff --git a/code-generator/binding-generator-util/src/test/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/MethodParameterImplTest.java b/code-generator/binding-generator-util/src/test/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/MethodParameterImplTest.java
new file mode 100644 (file)
index 0000000..ca7b455
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.binding.generator.util.generated.type.builder;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.yangtools.binding.generator.util.Types;
+import org.opendaylight.yangtools.sal.binding.model.api.Type;
+
+public class MethodParameterImplTest {
+
+    MethodParameterImpl parameter1, parameter2, parameter3, parameter4;
+    int hash1, hash2, hash3, hash4;
+
+    @Before
+    public void Setup() {
+        String name = "customParameter";
+        Type type = Types.STRING;
+        parameter1 = new MethodParameterImpl(name, type);
+        parameter2 = new MethodParameterImpl(name, type);
+        parameter3 = new MethodParameterImpl(name, null);
+        parameter4 = new MethodParameterImpl(null, type);
+
+        hash1 = parameter1.hashCode();
+        hash2 = parameter2.hashCode();
+        hash3 = parameter3.hashCode();
+        hash4 = parameter4.hashCode();
+    }
+
+    @Test
+    public void testToString() {
+        String toString = parameter1.toString();
+        assertTrue(toString.contains("MethodParameter"));
+    }
+
+    @Test
+    public void testEquals() {
+        assertTrue(parameter1.equals(parameter1));
+        assertTrue(parameter1.equals(parameter2));
+        assertFalse(parameter1.equals("string"));
+        assertFalse(parameter1.equals(null));
+        assertFalse(parameter1.equals(parameter3));
+        assertFalse(parameter2.equals(parameter4));
+        assertFalse(parameter4.equals(parameter2));
+        assertFalse(parameter3.equals(parameter2));
+    }
+
+    @Test
+    public void testHashCode() {
+        assertEquals(hash1,hash2);
+        assertTrue(!(hash1 == hash3));
+        assertTrue(!(hash1 == hash4));
+    }
+
+}