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.dom.api;
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;
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.common.XMLNamespace;
18 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
20 class DOMRpcIdentifierTest {
21 private static final QNameModule TEST_MODULE = QNameModule.create(XMLNamespace.of(
22 "urn:opendaylight:params:xml:ns:yang:controller:md:sal:test:store"));
23 private static final QName LOCAL_QNAME = QName.create(TEST_MODULE, "local");
24 private static final DOMRpcIdentifier GLOBAL = DOMRpcIdentifier.create(LOCAL_QNAME, null);
25 private static final DOMRpcIdentifier LOCAL = DOMRpcIdentifier.create(LOCAL_QNAME,
26 YangInstanceIdentifier.of(LOCAL_QNAME));
30 assertInstanceOf(DOMRpcIdentifier.Global.class, GLOBAL);
31 assertInstanceOf(DOMRpcIdentifier.Local.class, LOCAL);
36 assertEquals(GLOBAL.hashCode(), DOMRpcIdentifier.create(LOCAL_QNAME).hashCode());
37 assertNotEquals(GLOBAL.hashCode(), LOCAL.hashCode());
42 assertEquals(GLOBAL, DOMRpcIdentifier.create(LOCAL_QNAME));
43 assertEquals(GLOBAL, GLOBAL);
44 assertNotEquals(GLOBAL, new Object());
45 assertNotEquals(GLOBAL, LOCAL);
50 assertEquals("Global{type=(urn:opendaylight:params:xml:ns:yang:controller:md:sal:test:store)local, "
51 + "contextReference=/}", GLOBAL.toString());
52 assertEquals("Local{type=(urn:opendaylight:params:xml:ns:yang:controller:md:sal:test:store)local, "
53 + "contextReference=/(urn:opendaylight:params:xml:ns:yang:controller:md:sal:test:store)local}",