use of org.opendaylight.yangtools.yang.data.tree.impl.di.InMemoryDataTreeFactory in project yangtools by opendaylight.
the class ConfigStatementValidationTest method testOnPathCaseLeafFail.
@Test(expected = SchemaValidationFailedException.class)
public void testOnPathCaseLeafFail() throws DataValidationFailedException {
final DataTree inMemoryDataTree = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_CONFIGURATION, SCHEMA_CONTEXT);
final YangInstanceIdentifier.NodeIdentifier choice1Id = new YangInstanceIdentifier.NodeIdentifier(QName.create(TestModel.TEST_QNAME, "choice1"));
final YangInstanceIdentifier.NodeIdentifier case2ContId = new YangInstanceIdentifier.NodeIdentifier(QName.create(TestModel.TEST_QNAME, "case2-cont"));
final YangInstanceIdentifier ii = TestModel.TEST_PATH.node(choice1Id).node(case2ContId);
final ContainerNode case2Cont = Builders.containerBuilder().withNodeIdentifier(case2ContId).withChild(leafNode(QName.create(TestModel.TEST_QNAME, "case2-leaf1"), "leaf-value")).build();
final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
modificationTree.write(ii, case2Cont);
modificationTree.ready();
}
use of org.opendaylight.yangtools.yang.data.tree.impl.di.InMemoryDataTreeFactory in project yangtools by opendaylight.
the class ConfigStatementValidationTest method testOnPathFail.
@Test(expected = SchemaValidationFailedException.class)
public void testOnPathFail() throws DataValidationFailedException {
final DataTree inMemoryDataTree = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_CONFIGURATION, SCHEMA_CONTEXT);
final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
final YangInstanceIdentifier ii = OUTER_LIST_1_PATH.node(new YangInstanceIdentifier.NodeIdentifier(TestModel.INNER_LIST_QNAME)).node(INNER_FOO_ENTRY_NODE.getIdentifier());
modificationTree.write(ii, INNER_FOO_ENTRY_NODE);
inMemoryDataTree.validate(modificationTree);
final DataTreeCandidate prepare = inMemoryDataTree.prepare(modificationTree);
inMemoryDataTree.commit(prepare);
}
use of org.opendaylight.yangtools.yang.data.tree.impl.di.InMemoryDataTreeFactory in project yangtools by opendaylight.
the class InMemoryDataTreeBenchmark method setup.
@Setup(Level.Trial)
public void setup() throws DataValidationFailedException {
datastore = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_CONFIGURATION, BenchmarkModel.createTestContext());
final DataTreeModification modification = begin();
modification.write(BenchmarkModel.TEST_PATH, ImmutableContainerNodeBuilder.create().withNodeIdentifier(BenchmarkModel.TEST).withChild(EMPTY_OUTER_LIST).build());
commit(modification);
}
use of org.opendaylight.yangtools.yang.data.tree.impl.di.InMemoryDataTreeFactory in project yangtools by opendaylight.
the class UniqueConstraintTest method initDataTree.
private static InMemoryDataTree initDataTree(final EffectiveModelContext schemaContext, final boolean uniqueIndex) throws DataValidationFailedException {
final InMemoryDataTree inMemoryDataTree = (InMemoryDataTree) new InMemoryDataTreeFactory().create(new DataTreeConfiguration.Builder(TreeType.CONFIGURATION).setUniqueIndexes(uniqueIndex).build());
inMemoryDataTree.setEffectiveModelContext(schemaContext);
final MapNode taskNode = Builders.mapBuilder().withNodeIdentifier(new NodeIdentifier(TASK)).build();
final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
modificationTree.write(YangInstanceIdentifier.of(TASK_CONTAINER).node(TASK), taskNode);
modificationTree.ready();
inMemoryDataTree.validate(modificationTree);
final DataTreeCandidate prepare = inMemoryDataTree.prepare(modificationTree);
inMemoryDataTree.commit(prepare);
return inMemoryDataTree;
}
use of org.opendaylight.yangtools.yang.data.tree.impl.di.InMemoryDataTreeFactory in project yangtools by opendaylight.
the class DataTreeCandidateValidatorTest method init.
@BeforeClass
public static void init() throws DataValidationFailedException {
context = YangParserTestUtils.parseYangResourceDirectory("/leafref-validation");
for (final Module module : context.getModules()) {
if (module.getName().equals("leafref-validation")) {
valModule = module;
}
}
valModuleQname = valModule.getQNameModule();
rootLeafRefContext = LeafRefContext.create(context);
odl = QName.create(valModuleQname, "odl-project");
project = QName.create(valModuleQname, "project");
name = QName.create(valModuleQname, "name");
desc = QName.create(valModuleQname, "desc");
lead = QName.create(valModuleQname, "project-lead");
owner = QName.create(valModuleQname, "project-owner");
odlContributor = QName.create(valModuleQname, "odl-contributor");
contributor = QName.create(valModuleQname, "contributor");
odlProjectName = QName.create(valModuleQname, "odl-project-name");
login = QName.create(valModuleQname, "login");
contributorName = QName.create(valModuleQname, "contributor-name");
con1 = QName.create(valModuleQname, "con1");
l1 = QName.create(valModuleQname, "l1");
l2 = QName.create(valModuleQname, "l2");
odlProjectDesc = QName.create(valModuleQname, "odl-project-desc");
ch1 = QName.create(valModuleQname, "ch1");
ch2 = QName.create(valModuleQname, "ch2");
leafrefInChoice = QName.create(valModuleQname, "leafref-in-choice");
listInChoice = QName.create(valModuleQname, "list-in-choice");
leafrefInChoiceToChoice = QName.create(valModuleQname, "leafref-in-choice-to-choice");
con3 = QName.create(valModuleQname, "con3");
list3InChoice = QName.create(valModuleQname, "list3-in-choice");
l3 = QName.create(valModuleQname, "l3");
choiceInCon3 = QName.create(valModuleQname, "choice-in-con3");
listInChoiceKey = QName.create(valModuleQname, "list-in-choice-key");
k = QName.create(valModuleQname, "k");
leafrefLeafList = QName.create(valModuleQname, "leafref-leaf-list");
inMemoryDataTree = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_OPERATIONAL, context);
final DataTreeModification initialDataTreeModification = inMemoryDataTree.takeSnapshot().newModification();
final ContainerNode odlProjectContainer = createOdlContainer();
final YangInstanceIdentifier path = YangInstanceIdentifier.of(odl);
initialDataTreeModification.write(path, odlProjectContainer);
initialDataTreeModification.ready();
final DataTreeCandidate writeContributorsCandidate = inMemoryDataTree.prepare(initialDataTreeModification);
inMemoryDataTree.commit(writeContributorsCandidate);
}
Aggregations