2 * Copyright (c) 2016 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.dom.codec.impl;
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.lang.reflect.Method;
16 import org.junit.Before;
17 import org.junit.Test;
19 public class UnionValueOptionContextTest {
20 private static UnionValueOptionContext TEST_UVOC_1;
21 private static UnionValueOptionContext TEST_UVOC_2;
24 public void setUp() throws Exception {
25 final Method methodFoo1 = TestDataObject1.class.getMethod("foo");
26 final Method methodFoo2 = TestDataObject2.class.getMethod("foo");
27 TEST_UVOC_1 = new UnionValueOptionContext(TestUnion.class, TestDataObject1.class, methodFoo1,
28 ValueTypeCodec.EMPTY_CODEC);
29 TEST_UVOC_2 = new UnionValueOptionContext(TestUnion.class, TestDataObject2.class, methodFoo2,
30 ValueTypeCodec.EMPTY_CODEC);
34 public void hashCodeTest() throws Exception {
35 final Method methodFoo1 = TestDataObject1.class.getMethod("foo");
36 final UnionValueOptionContext test_uvoc = new UnionValueOptionContext(TestUnion.class, TestDataObject1.class,
37 methodFoo1, ValueTypeCodec.EMPTY_CODEC);
39 assertEquals("HashCode", test_uvoc.hashCode(), TEST_UVOC_1.hashCode());
40 assertNotEquals("HashCode", TEST_UVOC_1.hashCode(), TEST_UVOC_2.hashCode());
44 public void equalsTest() throws Exception {
45 final Method methodFoo1 = TestDataObject1.class.getMethod("foo");
46 final UnionValueOptionContext test_uvoc = new UnionValueOptionContext(TestUnion.class, TestDataObject1.class,
47 methodFoo1, ValueTypeCodec.EMPTY_CODEC);
49 assertTrue("Equals", TEST_UVOC_1.equals(test_uvoc));
50 assertFalse("Not equals", TEST_UVOC_1.equals(TEST_UVOC_2));
53 protected static final class TestDataObject1 {
59 protected static final class TestDataObject2 {
65 public static final class TestUnion {
66 public TestUnion(final TestDataObject1 arg) {
70 public TestUnion(final TestDataObject2 arg) {