X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-clustering-commons%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fnode%2Futils%2FPathUtilsTest.java;h=d1b89b2de048f8ec98f18545facb291932c34fba;hb=4e696d9795fe7eef40369c05c340d137394126f3;hp=b7a3c5e94903ffd1f992833d2597a79ca7226586;hpb=701434f9470989a532b735a361ecbe8e4a5e1b36;p=controller.git 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 b7a3c5e949..d1b89b2de0 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 @@ -8,59 +8,71 @@ package org.opendaylight.controller.cluster.datastore.node.utils; +import static junit.framework.TestCase.assertEquals; + import com.google.common.collect.ImmutableSet; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; 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 java.util.HashMap; -import java.util.Map; -import java.util.Set; -import static junit.framework.TestCase.assertEquals; +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; public class PathUtilsTest { @Test - public void toStringNodeIdentifier(){ - YangInstanceIdentifier.PathArgument pathArgument = nodeIdentifier(); + public void toStringNodeIdentifier() { + PathArgument pathArgument = nodeIdentifier(); - String expected = "(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test"; + String expected = + "(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test"; assertEquals(expected , PathUtils.toString(pathArgument)); } @Test - public void toStringAugmentationIdentifier(){ - String expected = "AugmentationIdentifier{childNames=[(urn:opendaylight:flow:table:statistics?revision=2013-12-15)flow-table-statistics]}"; + 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)); } @Test - public void toStringNodeWithValue(){ + 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]"; + String expected = + "(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test[100]"; assertEquals(expected, PathUtils.toString(pathArgument)); } @Test - public void toStringNodeIdentifierWithPredicates(){ + 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}]"; + 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}]"; assertEquals(expected, PathUtils.toString(pathArgument)); } @Test - public void toStringYangInstanceIdentifier(){ + public void toStringYangInstanceIdentifier() { YangInstanceIdentifier path = YangInstanceIdentifier.create(nodeIdentifier()) @@ -68,21 +80,27 @@ public class PathUtilsTest { .node(augmentationIdentifier()).node(nodeWithValue()); - 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)test[{(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)id=100}]/" + - "AugmentationIdentifier{childNames=[(urn:opendaylight:flow:table:statistics?revision=2013-12-15)flow-table-statistics]}/" + - "(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test[100]"; + 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)test[" + + "{(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)id=100}]/" + + "AugmentationIdentifier{childNames=[(urn:opendaylight:flow:table:statistics?revision=2013-12-15)" + + "flow-table-statistics]}/" + + "(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test[100]"; assertEquals(expected, PathUtils.toString(path)); } @Test - public void toYangInstanceIdentifier(){ - 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)test[{(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)id=100}]/" + - "AugmentationIdentifier{childNames=[(urn:opendaylight:flow:table:statistics?revision=2013-12-15)flow-table-statistics]}/" + - "(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test[100]"; + public void toYangInstanceIdentifier() { + 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)test[" + + "{(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)id=100}]/" + + "AugmentationIdentifier{childNames=[(urn:opendaylight:flow:table:statistics?revision=2013-12-15)" + + "flow-table-statistics]}/" + + "(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test[100]"; YangInstanceIdentifier yangInstanceIdentifier = PathUtils.toYangInstanceIdentifier(expected); @@ -93,25 +111,26 @@ 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 = ImmutableSet.of(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); } }