2 * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.javav2.dom.codec.impl.context;
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;
18 import org.opendaylight.mdsal.binding.javav2.dom.codec.impl.value.ValueTypeCodec;
20 public class UnionValueOptionContextTest {
22 private static UnionValueOptionContext TEST_UVOC_1;
23 private static UnionValueOptionContext TEST_UVOC_2;
26 public void setUp() throws Exception {
27 final Method methodFoo1 = TestDataObject1.class.getMethod("foo");
28 final Method methodFoo2 = TestDataObject2.class.getMethod("foo");
29 TEST_UVOC_1 = new UnionValueOptionContext(TestUnion.class, TestDataObject1.class, methodFoo1,
30 ValueTypeCodec.EMPTY_CODEC);
31 TEST_UVOC_2 = new UnionValueOptionContext(TestUnion.class, TestDataObject2.class, methodFoo2,
32 ValueTypeCodec.EMPTY_CODEC);
36 public void hashCodeTest() throws Exception {
37 final Method methodFoo1 = TestDataObject1.class.getMethod("foo");
38 final UnionValueOptionContext test_uvoc = new UnionValueOptionContext(TestUnion.class, TestDataObject1.class,
39 methodFoo1, ValueTypeCodec.EMPTY_CODEC);
41 assertEquals("HashCode", test_uvoc.hashCode(), TEST_UVOC_1.hashCode());
42 assertNotEquals("HashCode", TEST_UVOC_1.hashCode(), TEST_UVOC_2.hashCode());
46 public void equalsTest() throws Exception {
47 final Method methodFoo1 = TestDataObject1.class.getMethod("foo");
48 final UnionValueOptionContext test_uvoc = new UnionValueOptionContext(TestUnion.class, TestDataObject1.class,
49 methodFoo1, ValueTypeCodec.EMPTY_CODEC);
51 assertTrue("Equals", TEST_UVOC_1.equals(test_uvoc));
52 assertFalse("Not equals", TEST_UVOC_1.equals(TEST_UVOC_2));
55 protected static final class TestDataObject1 {
60 protected static final class TestDataObject2 {
65 public static final class TestUnion {
66 public TestUnion(final TestDataObject1 arg) {
69 public TestUnion(final TestDataObject2 arg) {