Convert mdsal-binding-dom-codec to a JPMS module
[mdsal.git] / binding / mdsal-binding-dom-codec / src / test / java / org / opendaylight / mdsal / binding / dom / codec / impl / UnionValueOptionContextTest.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.mdsal.binding.dom.codec.impl;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotEquals;
12
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;
18
19 public class UnionValueOptionContextTest {
20     private static UnionValueOptionContext TEST_UVOC_1;
21     private static UnionValueOptionContext TEST_UVOC_2;
22
23     @BeforeClass
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);
29     }
30
31     @Test
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);
35
36         assertEquals("HashCode", test_uvoc.hashCode(), TEST_UVOC_1.hashCode());
37         assertNotEquals("HashCode", TEST_UVOC_1.hashCode(), TEST_UVOC_2.hashCode());
38     }
39
40     @Test
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);
44
45         assertEquals(TEST_UVOC_1, test_uvoc);
46         assertNotEquals(TEST_UVOC_1, TEST_UVOC_2);
47     }
48 }