X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-clustering-commons%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fnode%2Futils%2FPathUtilsTest.java;h=a12f15010c359c791d54f0a86c8140419248f441;hp=ffa8a1059eb49d77195f29954c9ead671abd2d68;hb=38fa2a64bd6e206b2d8a6b153154104347854408;hpb=7f6d29dd5b34750ca1ec172500782e69a69398c0 diff --git a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/PathUtilsTest.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/PathUtilsTest.java index ffa8a1059e..a12f15010c 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/PathUtilsTest.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/PathUtilsTest.java @@ -1,31 +1,33 @@ +/* + * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + package org.opendaylight.controller.cluster.datastore.node.utils; +import com.google.common.collect.ImmutableSet; import org.junit.Test; import org.opendaylight.controller.cluster.datastore.util.TestModel; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; - +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; import java.util.HashMap; -import java.util.HashSet; import java.util.Map; import java.util.Set; - import static junit.framework.TestCase.assertEquals; public class PathUtilsTest { - @Test - public void getParentPath(){ - assertEquals("", PathUtils.getParentPath("foobar")); - assertEquals("", PathUtils.getParentPath("/a")); - assertEquals("/a", PathUtils.getParentPath("/a/b")); - assertEquals("/a/b", PathUtils.getParentPath("/a/b/c")); - assertEquals("/a/b", PathUtils.getParentPath("a/b/c")); - } - @Test public void toStringNodeIdentifier(){ - YangInstanceIdentifier.PathArgument pathArgument = nodeIdentifier(); + PathArgument pathArgument = nodeIdentifier(); String expected = "(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test"; @@ -36,7 +38,7 @@ public class PathUtilsTest { public void toStringAugmentationIdentifier(){ String expected = "AugmentationIdentifier{childNames=[(urn:opendaylight:flow:table:statistics?revision=2013-12-15)flow-table-statistics]}"; - YangInstanceIdentifier.PathArgument pathArgument = augmentationIdentifier(); + PathArgument pathArgument = augmentationIdentifier(); assertEquals(expected, PathUtils.toString(pathArgument)); } @@ -44,7 +46,7 @@ public class PathUtilsTest { @Test public void toStringNodeWithValue(){ - YangInstanceIdentifier.PathArgument pathArgument = nodeWithValue(); + PathArgument pathArgument = nodeWithValue(); String expected = "(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test[100]"; @@ -55,7 +57,7 @@ public class PathUtilsTest { @Test public void toStringNodeIdentifierWithPredicates(){ - YangInstanceIdentifier.PathArgument pathArgument = nodeIdentifierWithPredicates(); + PathArgument pathArgument = nodeIdentifierWithPredicates(); String expected = "(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test[{(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)id=100}]"; @@ -96,26 +98,25 @@ public class PathUtilsTest { } - private YangInstanceIdentifier.NodeIdentifier nodeIdentifier(){ - return new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME); + private static NodeIdentifier nodeIdentifier(){ + return new NodeIdentifier(TestModel.TEST_QNAME); } - private YangInstanceIdentifier.AugmentationIdentifier augmentationIdentifier(){ - Set childNames = new HashSet(); - childNames.add(QNameFactory.create("(urn:opendaylight:flow:table:statistics?revision=2013-12-15)flow-table-statistics")); + private static AugmentationIdentifier augmentationIdentifier(){ + Set childNames = ImmutableSet.of(QNameFactory.create("(urn:opendaylight:flow:table:statistics?revision=2013-12-15)flow-table-statistics")); - return new YangInstanceIdentifier.AugmentationIdentifier(childNames); + return new AugmentationIdentifier(childNames); } - private YangInstanceIdentifier.NodeWithValue nodeWithValue(){ - return new YangInstanceIdentifier.NodeWithValue(TestModel.TEST_QNAME, Integer.valueOf(100)); + private static NodeWithValue nodeWithValue(){ + return new NodeWithValue<>(TestModel.TEST_QNAME, Integer.valueOf(100)); } - private YangInstanceIdentifier.NodeIdentifierWithPredicates nodeIdentifierWithPredicates(){ + private static NodeIdentifierWithPredicates nodeIdentifierWithPredicates(){ Map keys = new HashMap<>(); keys.put(TestModel.ID_QNAME, Integer.valueOf(100)); - return new YangInstanceIdentifier.NodeIdentifierWithPredicates(TestModel.TEST_QNAME, keys); + return new NodeIdentifierWithPredicates(TestModel.TEST_QNAME, keys); } }