import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
public class CaseAugmentTest {
ImmutableSet.of(C1L2_QNAME, C1L3_QNAME));
@Before
- public void prepare() throws ReactorException {
+ public void prepare() {
schemaContext = TestModel.createTestContext("/case-augment-test.yang");
assertNotNull("Schema context must not be null.", schemaContext);
}
- private InMemoryDataTree initDataTree() {
- InMemoryDataTree inMemoryDataTree = (InMemoryDataTree) InMemoryDataTreeFactory.getInstance().create(
- DataTreeConfiguration.DEFAULT_CONFIGURATION);
- inMemoryDataTree.setSchemaContext(schemaContext);
+ private DataTree initDataTree() {
+ DataTree inMemoryDataTree = new InMemoryDataTreeFactory().create(
+ DataTreeConfiguration.DEFAULT_CONFIGURATION, schemaContext);
return inMemoryDataTree;
}
@Test
public void testWriteAugment() throws DataValidationFailedException {
- final InMemoryDataTree inMemoryDataTree = initDataTree();
+ final DataTree inMemoryDataTree = initDataTree();
AugmentationNode augmentationNode = Builders.augmentationBuilder()
.withNodeIdentifier(AUGMENT_ID)
Builders.choiceBuilder().withNodeIdentifier(CHOICE_ID)
.withChild(augmentationNode)
.build()).build();
- final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+ final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
modificationTree.write(TestModel.TEST_PATH, container);
modificationTree.ready();
@Test
public void testWriteCase1All() throws DataValidationFailedException {
- final InMemoryDataTree inMemoryDataTree = initDataTree();
+ final DataTree inMemoryDataTree = initDataTree();
AugmentationNode augmentationNode = Builders.augmentationBuilder()
.withNodeIdentifier(AUGMENT_ID)
.withChild(leafNode(QName.create(TestModel.TEST_QNAME, "case1-leaf1"), "leaf-value"))
.withChild(augmentationNode)
.build()).build();
- final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+ final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
modificationTree.write(TestModel.TEST_PATH, container);
modificationTree.ready();
@Test(expected = IllegalArgumentException.class)
public void testWriteConflict() throws DataValidationFailedException {
- final InMemoryDataTree inMemoryDataTree = initDataTree();
+ final DataTree inMemoryDataTree = initDataTree();
AugmentationNode augmentationNode = Builders.augmentationBuilder()
.withNodeIdentifier(AUGMENT_ID)
.build()).build();
try {
- final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+ final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
modificationTree.write(TestModel.TEST_PATH, container);
modificationTree.ready();
throw e;
}
}
-
}