Rework NormalizedNode type hierarchy
[yangtools.git] / yang / yang-data-impl / src / test / java / org / opendaylight / yangtools / yang / data / impl / schema / tree / StructuralApplyModificationTest.java
index a2c754f8ad5706b75fa095f76fa75b5952d9bf2d..1adb18187a65a4b317ed26a79d22307364415288 100644 (file)
@@ -26,14 +26,13 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailed
 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 
-public final class StructuralApplyModificationTest {
-
+public final class StructuralApplyModificationTest extends AbstractTestModelTest {
     private DataTree inMemoryDataTree;
 
     @Before
     public void setUp() {
         inMemoryDataTree = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_CONFIGURATION);
-        inMemoryDataTree.setSchemaContext(TestModel.createTestContext());
+        inMemoryDataTree.setEffectiveModelContext(SCHEMA_CONTEXT);
     }
 
     @Test
@@ -45,8 +44,8 @@ public final class StructuralApplyModificationTest {
         addListEntryModification.write(YangInstanceIdentifier.create(rootContainerId),
             Builders.containerBuilder().withNodeIdentifier(rootContainerId).build());
 
-        final YangInstanceIdentifier.NodeIdentifierWithPredicates outerListEntryId =
-            new YangInstanceIdentifier.NodeIdentifierWithPredicates(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1);
+        final NodeIdentifierWithPredicates outerListEntryId = NodeIdentifierWithPredicates.of(
+            TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1);
 
         // Write list entry (MapEntryNode) without creating list parent (MapNode)
         final MapEntryNode outerListEntry = Builders.mapEntryBuilder().withNodeIdentifier(outerListEntryId).build();
@@ -110,12 +109,8 @@ public final class StructuralApplyModificationTest {
     public void testNestedStrucutralNodes() throws DataValidationFailedException {
         final DataTreeModification addListEntryModification = inMemoryDataTree.takeSnapshot().newModification();
 
-        final YangInstanceIdentifier path = YangInstanceIdentifier.create(
-            getNId(TestModel.NON_PRESENCE_QNAME),
-            getNId(TestModel.DEEP_CHOICE_QNAME),
-            getNId(TestModel.A_LIST_QNAME),
-            getNId(TestModel.A_LIST_QNAME, TestModel.A_NAME_QNAME, "1")
-        );
+        final YangInstanceIdentifier path = TestModel.DEEP_CHOICE_PATH.node(TestModel.A_LIST_QNAME)
+            .node(getNId(TestModel.A_LIST_QNAME, TestModel.A_NAME_QNAME, "1"));
 
         addListEntryModification.write(path,
             Builders.mapEntryBuilder()
@@ -128,14 +123,13 @@ public final class StructuralApplyModificationTest {
 
         // Check parent structure auto created
         assertNodeExistence(path, true);
-        assertNodeExistence(YangInstanceIdentifier.create(getNId(TestModel.NON_PRESENCE_QNAME)), true);
-        assertNodeExistence(YangInstanceIdentifier.create(
-            getNId(TestModel.NON_PRESENCE_QNAME), getNId(TestModel.DEEP_CHOICE_QNAME)), true);
+        assertNodeExistence(TestModel.NON_PRESENCE_PATH, true);
+        assertNodeExistence(TestModel.DEEP_CHOICE_PATH, true);
     }
 
     private void assertNodeExistence(final YangInstanceIdentifier outerListParentPath, final boolean shouldBePresent) {
         final DataTreeSnapshot snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
-        final Optional<NormalizedNode<?, ?>> readNode = snapshotAfterCommits.readNode(outerListParentPath);
+        final Optional<NormalizedNode> readNode = snapshotAfterCommits.readNode(outerListParentPath);
         assertEquals(readNode.isPresent(), shouldBePresent);
     }
 
@@ -144,6 +138,6 @@ public final class StructuralApplyModificationTest {
     }
 
     private static NodeIdentifierWithPredicates getNId(final QName qname, final QName key, final String val) {
-        return new NodeIdentifierWithPredicates(qname, key, val);
+        return NodeIdentifierWithPredicates.of(qname, key, val);
     }
 }