Migrate users of deprecated yang.common methods
[mdsal.git] / dom / mdsal-dom-api / src / test / java / org / opendaylight / mdsal / dom / api / DOMRpcIdentifierTest.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.dom.api;
9
10 import static org.junit.jupiter.api.Assertions.assertEquals;
11 import static org.junit.jupiter.api.Assertions.assertInstanceOf;
12 import static org.junit.jupiter.api.Assertions.assertNotEquals;
13
14 import org.junit.jupiter.api.Test;
15 import org.opendaylight.yangtools.yang.common.QName;
16 import org.opendaylight.yangtools.yang.common.QNameModule;
17 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
18
19 class DOMRpcIdentifierTest {
20     private static final QNameModule TEST_MODULE =
21         QNameModule.of("urn:opendaylight:params:xml:ns:yang:controller:md:sal:test:store");
22     private static final QName LOCAL_QNAME = QName.create(TEST_MODULE, "local");
23     private static final DOMRpcIdentifier GLOBAL = DOMRpcIdentifier.create(LOCAL_QNAME, null);
24     private static final DOMRpcIdentifier LOCAL = DOMRpcIdentifier.create(LOCAL_QNAME,
25         YangInstanceIdentifier.of(LOCAL_QNAME));
26
27     @Test
28     void createTest() {
29         assertInstanceOf(DOMRpcIdentifier.Global.class, GLOBAL);
30         assertInstanceOf(DOMRpcIdentifier.Local.class, LOCAL);
31     }
32
33     @Test
34     void hashCodeTest() {
35         assertEquals(GLOBAL.hashCode(), DOMRpcIdentifier.create(LOCAL_QNAME).hashCode());
36         assertNotEquals(GLOBAL.hashCode(), LOCAL.hashCode());
37     }
38
39     @Test
40     void equalsTest() {
41         assertEquals(GLOBAL, DOMRpcIdentifier.create(LOCAL_QNAME));
42         assertEquals(GLOBAL, GLOBAL);
43         assertNotEquals(GLOBAL, new Object());
44         assertNotEquals(GLOBAL, LOCAL);
45     }
46
47     @Test
48     void toStringTest() {
49         assertEquals("Global{type=(urn:opendaylight:params:xml:ns:yang:controller:md:sal:test:store)local, "
50             + "contextReference=/}", GLOBAL.toString());
51         assertEquals("Local{type=(urn:opendaylight:params:xml:ns:yang:controller:md:sal:test:store)local, "
52             + "contextReference=/(urn:opendaylight:params:xml:ns:yang:controller:md:sal:test:store)local}",
53             LOCAL.toString());
54     }
55 }