Reduce use of getChildByName()
[yangtools.git] / yang / yang-data-impl / src / test / java / org / opendaylight / yangtools / yang / data / impl / leafref / context / DataTreeCandidateValidatorTest.java
index b558bb964bbbc0b32ffe66a5d47cddb8b1a7fad0..624e8f343fdd4f126a252f882c8411e9d09d32f3 100644 (file)
@@ -152,8 +152,8 @@ public class DataTreeCandidateValidatorTest {
         final DataTreeModification initialDataTreeModification = inMemoryDataTree
                 .takeSnapshot().newModification();
 
-        final ContainerSchemaNode odlProjContSchemaNode = (ContainerSchemaNode) valModule
-                .getDataChildByName(odl);
+        final ContainerSchemaNode odlProjContSchemaNode = (ContainerSchemaNode) valModule.findDataChildByName(odl)
+                .get();
 
         final ContainerNode odlProjectContainer = createOdlContainer(odlProjContSchemaNode);
 
@@ -192,7 +192,7 @@ public class DataTreeCandidateValidatorTest {
     private static void writeContributors() {
 
         final ContainerSchemaNode contributorContSchemaNode = (ContainerSchemaNode) valModule
-                .getDataChildByName(odlContributor);
+                .findDataChildByName(odlContributor).get();
 
         final ContainerNode contributorContainer = createBasicContributorContainer(contributorContSchemaNode);
 
@@ -289,10 +289,10 @@ public class DataTreeCandidateValidatorTest {
         final YangInstanceIdentifier newOdlProjectMapEntryPath = YangInstanceIdentifier
                 .of(odl).node(project).node(mapEntryPath);
 
-        final ContainerSchemaNode odlProjContSchemaNode = (ContainerSchemaNode) valModule
-                .getDataChildByName(odl);
-        final ListSchemaNode projListSchemaNode = (ListSchemaNode) odlProjContSchemaNode
-                .getDataChildByName(project);
+        final ContainerSchemaNode odlProjContSchemaNode = (ContainerSchemaNode) valModule.findDataChildByName(odl)
+                .get();
+        final ListSchemaNode projListSchemaNode = (ListSchemaNode) odlProjContSchemaNode.findDataChildByName(project)
+                .get();
         final MapEntryNode newProjectMapEntry = createProjectListEntry(
                 "New Project", "New Project description ...",
                 "Leader of New Project", "Owner of New Project",
@@ -335,7 +335,7 @@ public class DataTreeCandidateValidatorTest {
     private static void write() {
 
         final ContainerSchemaNode contributorContSchemaNode = (ContainerSchemaNode) valModule
-                .getDataChildByName(odlContributor);
+                .findDataChildByName(odlContributor).get();
 
         final ContainerNode contributorContainer = createContributorContainer(contributorContSchemaNode);
 
@@ -382,10 +382,8 @@ public class DataTreeCandidateValidatorTest {
 
     private static void write2() {
 
-        final ContainerSchemaNode odlCon = (ContainerSchemaNode) valModule
-                .getDataChildByName(odl);
-        final ContainerSchemaNode con1Con = (ContainerSchemaNode) odlCon
-                .getDataChildByName(con1);
+        final ContainerSchemaNode odlCon = (ContainerSchemaNode) valModule.findDataChildByName(odl).get();
+        final ContainerSchemaNode con1Con = (ContainerSchemaNode) odlCon.findDataChildByName(con1).get();
         final LeafNode<String> l1Leaf = ImmutableNodes.leafNode(l1, "l1 value");
         final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> containerBuilder = Builders
                 .containerBuilder(con1Con);
@@ -600,7 +598,7 @@ public class DataTreeCandidateValidatorTest {
             final ContainerSchemaNode contributorContSchemaNode) {
 
         final ListSchemaNode contributorListSchemaNode = (ListSchemaNode) contributorContSchemaNode
-                .getDataChildByName(contributor);
+                .findDataChildByName(contributor).get();
 
         final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> contributorContainerBldr = Builders
                 .containerBuilder(contributorContSchemaNode);
@@ -671,14 +669,10 @@ public class DataTreeCandidateValidatorTest {
             final String odlProjectNameVal, final String odlProjectDescVal,
             final ListSchemaNode contributorListSchemaNode) {
 
-        final LeafNode<String> loginLeaf = ImmutableNodes.leafNode(login,
-                loginVal);
-        final LeafNode<String> contributorNameLeaf = ImmutableNodes.leafNode(
-                contributorName, contributorNameVal);
-        final LeafNode<String> odlProjectNameLeafRef = ImmutableNodes.leafNode(
-                odlProjectName, odlProjectNameVal);
-        final LeafNode<String> odlProjectDescLeafRef = ImmutableNodes.leafNode(
-                odlProjectDesc, odlProjectDescVal);
+        final LeafNode<String> loginLeaf = ImmutableNodes.leafNode(login, loginVal);
+        final LeafNode<String> contributorNameLeaf = ImmutableNodes.leafNode(contributorName, contributorNameVal);
+        final LeafNode<String> odlProjectNameLeafRef = ImmutableNodes.leafNode(odlProjectName, odlProjectNameVal);
+        final LeafNode<String> odlProjectDescLeafRef = ImmutableNodes.leafNode(odlProjectDesc, odlProjectDescVal);
 
         return Builders.mapEntryBuilder(contributorListSchemaNode)
                 .addChild(loginLeaf)
@@ -691,8 +685,7 @@ public class DataTreeCandidateValidatorTest {
     private static ContainerNode createOdlContainer(
             final ContainerSchemaNode container) {
 
-        final ListSchemaNode projListSchemaNode = (ListSchemaNode) container
-                .getDataChildByName(project);
+        final ListSchemaNode projListSchemaNode = (ListSchemaNode) container.findDataChildByName(project).get();
 
         final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> odlProjectContainerBldr = Builders
                 .containerBuilder(container);
@@ -760,7 +753,7 @@ public class DataTreeCandidateValidatorTest {
             final ContainerSchemaNode contributorContSchemaNode) {
 
         final ListSchemaNode contributorListSchemaNode = (ListSchemaNode) contributorContSchemaNode
-                .getDataChildByName(contributor);
+                .findDataChildByName(contributor).get();
 
         final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> contributorContainerBldr = Builders
                 .containerBuilder(contributorContSchemaNode);