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
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();
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()
// 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);
}
}
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);
}
}