Do not format QNames to string on input
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / test / java / org / opendaylight / controller / cluster / datastore / node / utils / QNameFactoryTest.java
1 /*
2  * Copyright (c) 2014, 2015 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.controller.cluster.datastore.node.utils;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotSame;
12 import static org.junit.Assert.assertSame;
13
14 import org.junit.Test;
15 import org.opendaylight.controller.cluster.datastore.node.utils.QNameFactory.Key;
16 import org.opendaylight.controller.cluster.datastore.util.TestModel;
17 import org.opendaylight.yangtools.yang.common.QName;
18 import org.opendaylight.yangtools.yang.common.Revision;
19
20 public class QNameFactoryTest {
21
22     @Test
23     @Deprecated
24     public void testBasicString() {
25         QName expected = TestModel.AUG_NAME_QNAME;
26         QName created = QNameFactory.create(expected.toString());
27         assertNotSame(expected, created);
28         assertEquals(expected, created);
29
30         QName cached = QNameFactory.create(expected.toString());
31         assertSame(created, cached);
32     }
33
34     @Test
35     public void testBasic() {
36         QName expected = TestModel.AUG_NAME_QNAME;
37         QName created = QNameFactory.create(createKey(expected));
38         assertNotSame(expected, created);
39         assertEquals(expected, created);
40
41         QName cached = QNameFactory.create(createKey(expected));
42         assertSame(created, cached);
43     }
44
45     private static Key createKey(final QName qname) {
46         return new Key(qname.getLocalName(), qname.getNamespace().toString(),
47             qname.getRevision().map(Revision::toString).orElse(null));
48     }
49 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.