use of org.opendaylight.yangtools.yang.data.tree.impl.di.InMemoryDataTreeFactory in project yangtools by opendaylight.
the class DataTreeCandidateValidatorTest3 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-validation3")) {
mainModule = module;
}
}
rootModuleQname = mainModule.getQNameModule();
rootLeafRefContext = LeafRefContext.create(context);
chips = QName.create(rootModuleQname, "chips");
chip = QName.create(rootModuleQname, "chip");
devType = QName.create(rootModuleQname, "dev_type");
chipDesc = QName.create(rootModuleQname, "chip_desc");
devices = QName.create(rootModuleQname, "devices");
device = QName.create(rootModuleQname, "device");
typeText1 = QName.create(rootModuleQname, "type_text1");
typeText2 = QName.create(rootModuleQname, "type_text2");
typeText3 = QName.create(rootModuleQname, "type_text3");
devDesc = QName.create(rootModuleQname, "dev_desc");
sn = QName.create(rootModuleQname, "sn");
defaultIp = QName.create(rootModuleQname, "default_ip");
deviceTypeStr = QName.create(rootModuleQname, "device_types");
deviceType = QName.create(rootModuleQname, "device_type");
type1 = QName.create(rootModuleQname, "type1");
type2 = QName.create(rootModuleQname, "type2");
type3 = QName.create(rootModuleQname, "type3");
desc = QName.create(rootModuleQname, "desc");
inMemoryDataTree = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_OPERATIONAL, context);
final DataTreeModification initialDataTreeModification = inMemoryDataTree.takeSnapshot().newModification();
initialDataTreeModification.write(YangInstanceIdentifier.of(chips), Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(chips)).addChild(Builders.mapBuilder().withNodeIdentifier(new NodeIdentifier(chip)).addChild(createChipsListEntry("dev_type_1", "desc1")).addChild(createChipsListEntry("dev_type_2", "desc2")).build()).build());
initialDataTreeModification.write(YangInstanceIdentifier.of(deviceTypeStr), Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(deviceTypeStr)).addChild(Builders.mapBuilder().withNodeIdentifier(new NodeIdentifier(deviceType)).addChild(createDevTypeListEntry("dev_type1_1", "dev_type2_1", "dev_type3_1", "typedesc1")).addChild(createDevTypeListEntry("dev_type1_2", "dev_type2_2", "dev_type3_2", "typedesc2")).addChild(createDevTypeListEntry("dev_type1_3", "dev_type2_3", "dev_type3_3", "typedesc3")).build()).build());
initialDataTreeModification.ready();
final DataTreeCandidate writeChipsCandidate = inMemoryDataTree.prepare(initialDataTreeModification);
inMemoryDataTree.commit(writeChipsCandidate);
LOG.debug("{}", inMemoryDataTree);
}
Aggregations