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.assertNotEquals;
13 import org.junit.BeforeClass;
14 import org.junit.Test;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.union.rev150121.LowestLevel1;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.union.rev150121.LowestLevel2;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.union.rev150121.UnionTestType;
19 public class UnionValueOptionContextTest {
20 private static UnionValueOptionContext TEST_UVOC_1;
21 private static UnionValueOptionContext TEST_UVOC_2;
24 public static void beforeClass() throws Exception {
25 TEST_UVOC_1 = new UnionValueOptionContext(UnionTestType.class, LowestLevel1.class,
26 UnionTestType.class.getMethod("getLowestLevel1"), SchemaUnawareCodec.NOOP_CODEC);
27 TEST_UVOC_2 = new UnionValueOptionContext(UnionTestType.class, LowestLevel2.class,
28 UnionTestType.class.getMethod("getLowestLevel2"), SchemaUnawareCodec.NOOP_CODEC);
32 public void hashCodeTest() throws Exception {
33 final UnionValueOptionContext test_uvoc = new UnionValueOptionContext(UnionTestType.class, LowestLevel1.class,
34 UnionTestType.class.getMethod("getLowestLevel1"), SchemaUnawareCodec.NOOP_CODEC);
36 assertEquals("HashCode", test_uvoc.hashCode(), TEST_UVOC_1.hashCode());
37 assertNotEquals("HashCode", TEST_UVOC_1.hashCode(), TEST_UVOC_2.hashCode());
41 public void equalsTest() throws Exception {
42 final UnionValueOptionContext test_uvoc = new UnionValueOptionContext(UnionTestType.class, LowestLevel1.class,
43 UnionTestType.class.getMethod("getLowestLevel1"), SchemaUnawareCodec.NOOP_CODEC);
45 assertEquals(TEST_UVOC_1, test_uvoc);
46 assertNotEquals(TEST_UVOC_1, TEST_UVOC_2);