package org.opendaylight.yangtools.yang.data.impl.leafref.context;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.net.URISyntaxException;
-import java.util.Arrays;
-import java.util.Set;
-import org.apache.log4j.BasicConfigurator;
+import static org.junit.Assert.assertThrows;
+
+import java.util.Map;
+import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
-import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
+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.TipProducingDataTree;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
-import org.opendaylight.yangtools.yang.data.impl.TestUtils;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
import org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefContext;
import org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefDataValidationFailedException;
-import org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefValidatation;
+import org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefValidation;
import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFactory;
-import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class DataTreeCandidateValidatorTest3 {
- private static SchemaContext context;
+ private static EffectiveModelContext context;
private static Module mainModule;
private static QNameModule rootModuleQname;
private static LeafRefContext rootLeafRefContext;
- public static TipProducingDataTree inMemoryDataTree;
+ public static DataTree inMemoryDataTree;
private static QName chips;
private static QName chip;
private static final Logger LOG = LoggerFactory.getLogger(DataTreeCandidateValidatorTest3.class);
private static final String NEW_LINE = System.getProperty("line.separator");
- static {
- BasicConfigurator.configure();
- }
-
@BeforeClass
- public static void init() throws FileNotFoundException, ReactorException, URISyntaxException {
-
- initSchemaContext();
- initLeafRefContext();
- initQnames();
- initDataTree();
- }
-
- @Test
- public void dataTreeCanditateValidationTest2() {
-
- writeDevices();
-
- mergeDevices();
- }
-
- private static void writeDevices() {
-
- final ContainerSchemaNode devicesContSchemaNode = (ContainerSchemaNode) mainModule.getDataChildByName(devices);
-
- final ContainerNode devicesContainer = createDevicesContainer(devicesContSchemaNode);
-
- final YangInstanceIdentifier devicesPath = YangInstanceIdentifier.of(devices);
- final DataTreeModification writeModification = inMemoryDataTree.takeSnapshot().newModification();
- writeModification.write(devicesPath, devicesContainer);
-
- writeModification.ready();
- final DataTreeCandidate writeDevicesCandidate = inMemoryDataTree.prepare(writeModification);
-
- LOG.debug("*************************");
- LOG.debug("Before writeDevices: ");
- LOG.debug("*************************");
- LOG.debug(inMemoryDataTree.toString());
-
- boolean exception = false;
- try {
- LeafRefValidatation.validate(writeDevicesCandidate, rootLeafRefContext);
- } catch (final LeafRefDataValidationFailedException e) {
- LOG.debug("All validation errors:" + NEW_LINE + e.getMessage());
- assertEquals(6, e.getValidationsErrorsCount());
- exception = true;
- }
-
- assertTrue(exception);
-
- inMemoryDataTree.commit(writeDevicesCandidate);
-
- LOG.debug("*************************");
- LOG.debug("After writeDevices: ");
- LOG.debug("*************************");
- LOG.debug(inMemoryDataTree.toString());
- }
-
- private static void mergeDevices() {
+ public static void init() throws DataValidationFailedException {
+ context = YangParserTestUtils.parseYangResourceDirectory("/leafref-validation");
- final ContainerSchemaNode devicesContSchemaNode = (ContainerSchemaNode) mainModule.getDataChildByName(devices);
-
- final ContainerNode devicesContainer = createDevices2Container(devicesContSchemaNode);
-
- final YangInstanceIdentifier devicesPath = YangInstanceIdentifier.of(devices);
- final DataTreeModification mergeModification = inMemoryDataTree.takeSnapshot().newModification();
- mergeModification.write(devicesPath, devicesContainer);
- mergeModification.merge(devicesPath, devicesContainer);
-
- mergeModification.ready();
- final DataTreeCandidate mergeDevicesCandidate = inMemoryDataTree.prepare(mergeModification);
-
- LOG.debug("*************************");
- LOG.debug("Before mergeDevices: ");
- LOG.debug("*************************");
- LOG.debug(inMemoryDataTree.toString());
-
- boolean exception = false;
- try {
- LeafRefValidatation.validate(mergeDevicesCandidate, rootLeafRefContext);
- } catch (final LeafRefDataValidationFailedException e) {
- LOG.debug("All validation errors:" + NEW_LINE + e.getMessage());
- // :TODO verify errors count gz
- assertEquals(6, e.getValidationsErrorsCount());
- exception = true;
+ for (final Module module : context.getModules()) {
+ if (module.getName().equals("leafref-validation3")) {
+ mainModule = module;
+ }
}
- inMemoryDataTree.commit(mergeDevicesCandidate);
-
- LOG.debug("*************************");
- LOG.debug("After mergeDevices: ");
- LOG.debug("*************************");
- LOG.debug(inMemoryDataTree.toString());
-
- assertTrue(exception);
- }
+ rootModuleQname = mainModule.getQNameModule();
+ rootLeafRefContext = LeafRefContext.create(context);
- private static void initQnames() {
chips = QName.create(rootModuleQname, "chips");
chip = QName.create(rootModuleQname, "chip");
type2 = QName.create(rootModuleQname, "type2");
type3 = QName.create(rootModuleQname, "type3");
desc = QName.create(rootModuleQname, "desc");
- }
-
- private static void initSchemaContext() throws URISyntaxException, FileNotFoundException, ReactorException {
-
- final File resourceFile = new File(DataTreeCandidateValidatorTest.class.getResource(
- "/leafref-validation/leafref-validation3.yang").toURI());
- final File resourceDir = resourceFile.getParentFile();
-
- context = TestUtils.parseYangSources(Arrays.asList(resourceDir.listFiles()));
-
- final Set<Module> modules = context.getModules();
- for (final Module module : modules) {
- if (module.getName().equals("leafref-validation3")) {
- mainModule = module;
- }
- }
- rootModuleQname = mainModule.getQNameModule();
- }
-
- private static void initDataTree() {
-
- inMemoryDataTree = InMemoryDataTreeFactory.getInstance().create(TreeType.OPERATIONAL);
- inMemoryDataTree.setSchemaContext(context);
+ inMemoryDataTree = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_OPERATIONAL, context);
final DataTreeModification initialDataTreeModification = inMemoryDataTree.takeSnapshot().newModification();
- final ContainerSchemaNode chipsListContSchemaNode = (ContainerSchemaNode) mainModule.getDataChildByName(chips);
- final ContainerNode chipsContainer = createChipsContainer(chipsListContSchemaNode);
- final YangInstanceIdentifier path1 = YangInstanceIdentifier.of(chips);
- initialDataTreeModification.write(path1, chipsContainer);
-
- final ContainerSchemaNode devTypesListContSchemaNode = (ContainerSchemaNode) mainModule
- .getDataChildByName(deviceTypeStr);
- final ContainerNode deviceTypesContainer = createDevTypeStrContainer(devTypesListContSchemaNode);
- final YangInstanceIdentifier path2 = YangInstanceIdentifier.of(deviceTypeStr);
- initialDataTreeModification.write(path2, deviceTypesContainer);
+ 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);
- System.out.println(inMemoryDataTree.toString());
- }
-
- private static void initLeafRefContext() {
- rootLeafRefContext = LeafRefContext.create(context);
- }
-
- private static ContainerNode createDevTypeStrContainer(final ContainerSchemaNode container) {
-
- final ListSchemaNode devTypeListSchemaNode = (ListSchemaNode) container.getDataChildByName(deviceType);
-
- final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> devTypeContainerBldr = Builders
- .containerBuilder(container);
-
- final MapNode devTypeMap = createDevTypeList(devTypeListSchemaNode);
- devTypeContainerBldr.addChild(devTypeMap);
-
- return devTypeContainerBldr.build();
+ LOG.debug("{}", inMemoryDataTree);
}
- private static MapNode createDevTypeList(final ListSchemaNode devTypeListSchemaNode) {
-
- final CollectionNodeBuilder<MapEntryNode, MapNode> devTypeMapBldr = Builders.mapBuilder(devTypeListSchemaNode);
-
- devTypeMapBldr.addChild(createDevTypeListEntry("dev_type1_1", "dev_type2_1", "dev_type3_1", "typedesc1",
- devTypeListSchemaNode));
- devTypeMapBldr.addChild(createDevTypeListEntry("dev_type1_2", "dev_type2_2", "dev_type3_2", "typedesc2",
- devTypeListSchemaNode));
- devTypeMapBldr.addChild(createDevTypeListEntry("dev_type1_3", "dev_type2_3", "dev_type3_3", "typedesc3",
- devTypeListSchemaNode));
-
- return devTypeMapBldr.build();
+ @AfterClass
+ public static void cleanup() {
+ inMemoryDataTree = null;
+ rootLeafRefContext = null;
+ mainModule = null;
+ context = null;
}
- private static MapEntryNode createDevTypeListEntry(final String type1Val, final String type2Val,
- final String type3Val, final String descVal, final ListSchemaNode devTypeListSchemaNode) {
-
- final LeafNode<String> type1Leaf = ImmutableNodes.leafNode(type1, type1Val);
- final LeafNode<String> type2Leaf = ImmutableNodes.leafNode(type2, type2Val);
- final LeafNode<String> type3Leaf = ImmutableNodes.leafNode(type3, type3Val);
- final LeafNode<String> descLeaf = ImmutableNodes.leafNode(desc, descVal);
-
- final DataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> devTypeMapEntryBldr = Builders
- .mapEntryBuilder(devTypeListSchemaNode);
-
- devTypeMapEntryBldr.addChild(type1Leaf);
- devTypeMapEntryBldr.addChild(type2Leaf);
- devTypeMapEntryBldr.addChild(type3Leaf);
- devTypeMapEntryBldr.addChild(descLeaf);
-
- return devTypeMapEntryBldr.build();
- }
-
- private static ContainerNode createChipsContainer(final ContainerSchemaNode container) {
-
- final ListSchemaNode chipsListSchemaNode = (ListSchemaNode) container.getDataChildByName(chip);
-
- final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> chipsContainerBldr = Builders
- .containerBuilder(container);
-
- final MapNode chipsMap = createChipsList(chipsListSchemaNode);
- chipsContainerBldr.addChild(chipsMap);
-
- return chipsContainerBldr.build();
+ @Test
+ public void dataTreeCanditateValidationTest2() throws DataValidationFailedException {
+ writeDevices();
+ mergeDevices();
}
- private static MapNode createChipsList(final ListSchemaNode chipsListSchemaNode) {
-
- final CollectionNodeBuilder<MapEntryNode, MapNode> chipsMapBldr = Builders.mapBuilder(chipsListSchemaNode);
-
- chipsMapBldr.addChild(createChipsListEntry("dev_type_1", "desc1", chipsListSchemaNode));
- chipsMapBldr.addChild(createChipsListEntry("dev_type_2", "desc2", chipsListSchemaNode));
-
- return chipsMapBldr.build();
- }
+ private static void writeDevices() throws DataValidationFailedException {
+ final DataTreeModification writeModification = inMemoryDataTree.takeSnapshot().newModification();
+ writeModification.write(YangInstanceIdentifier.of(devices), Builders.containerBuilder()
+ .withNodeIdentifier(new NodeIdentifier(devices))
+ .addChild(Builders.mapBuilder()
+ .withNodeIdentifier(new NodeIdentifier(device))
+ .addChild(createDeviceListEntry("dev_type1_1", "dev_type2_1", "dev_type3_1", "typedesc1", 123456,
+ "192.168.0.1"))
+ .addChild(createDeviceListEntry("dev_type1_2", "dev_type2_2", "dev_type3_2", "typedesc1", 123457,
+ "192.168.0.1"))
+ .addChild(createDeviceListEntry("dev_type1_1", "dev_type2_2", "dev_type3_3", "typedesc2", 123458,
+ "192.168.0.1"))
+ .addChild(createDeviceListEntry("unk11", "unk22", "unk33", "unk_desc2", 123457, "192.168.0.1"))
+ .build())
+ .build());
- private static MapEntryNode createChipsListEntry(final String devTypeVal, final String chipDescVal,
- final ListSchemaNode chipsListSchemaNode) {
+ writeModification.ready();
+ final DataTreeCandidate writeDevicesCandidate = inMemoryDataTree.prepare(writeModification);
- final LeafNode<String> devTypeLeaf = ImmutableNodes.leafNode(devType, devTypeVal);
- final LeafNode<String> chipDescLeaf = ImmutableNodes.leafNode(chipDesc, chipDescVal);
+ LOG.debug("*************************");
+ LOG.debug("Before writeDevices: ");
+ LOG.debug("*************************");
+ LOG.debug("{}", inMemoryDataTree);
- final DataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> chipsMapEntryBldr = Builders
- .mapEntryBuilder(chipsListSchemaNode);
+ final LeafRefDataValidationFailedException ex = assertThrows(LeafRefDataValidationFailedException.class,
+ () -> LeafRefValidation.validate(writeDevicesCandidate, rootLeafRefContext));
+ assertEquals(6, ex.getValidationsErrorsCount());
- chipsMapEntryBldr.addChild(devTypeLeaf);
- chipsMapEntryBldr.addChild(chipDescLeaf);
+ inMemoryDataTree.commit(writeDevicesCandidate);
- return chipsMapEntryBldr.build();
+ LOG.debug("*************************");
+ LOG.debug("After writeDevices: ");
+ LOG.debug("*************************");
+ LOG.debug("{}", inMemoryDataTree);
}
- private static ContainerNode createDevicesContainer(final ContainerSchemaNode container) {
-
- final ListSchemaNode devicesListSchemaNode = (ListSchemaNode) container.getDataChildByName(device);
+ private static void mergeDevices() throws DataValidationFailedException {
+ final ContainerNode devicesContainer = Builders.containerBuilder()
+ .withNodeIdentifier(new NodeIdentifier(devices))
+ .addChild(Builders.mapBuilder()
+ .withNodeIdentifier(new NodeIdentifier(device))
+ .addChild(createDeviceListEntry("dev_type1_3", "dev_type2_3", "dev_type3_3", "typedesc3", 123459,
+ "192.168.0.1"))
+ .addChild(createDeviceListEntry("dev_type1_3", "dev_type2_3", "dev_type3_3", "typedesc2", 123460,
+ "192.168.0.1"))
+ .addChild(createDeviceListEntry("dev_type1_3", "dev_type2_2", "dev_type3_1", "typedesc1", 123461,
+ "192.168.0.1"))
+ .addChild(createDeviceListEntry("unk1", "unk2", "unk3", "unk_desc", 123462, "192.168.0.1"))
+ .build())
+ .build();
- final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> devicesContainerBldr = Builders
- .containerBuilder(container);
-
- final MapNode devicesMap = createDeviceList(devicesListSchemaNode);
- devicesContainerBldr.addChild(devicesMap);
+ final YangInstanceIdentifier devicesPath = YangInstanceIdentifier.of(devices);
+ final DataTreeModification mergeModification = inMemoryDataTree.takeSnapshot().newModification();
+ mergeModification.write(devicesPath, devicesContainer);
+ mergeModification.merge(devicesPath, devicesContainer);
- return devicesContainerBldr.build();
- }
+ mergeModification.ready();
+ final DataTreeCandidate mergeDevicesCandidate = inMemoryDataTree.prepare(mergeModification);
- private static MapNode createDeviceList(final ListSchemaNode deviceListSchemaNode) {
+ LOG.debug("*************************");
+ LOG.debug("Before mergeDevices: ");
+ LOG.debug("*************************");
+ LOG.debug("{}", inMemoryDataTree);
- final CollectionNodeBuilder<MapEntryNode, MapNode> devicesMapBldr = Builders.mapBuilder(deviceListSchemaNode);
+ final LeafRefDataValidationFailedException ex = assertThrows(LeafRefDataValidationFailedException.class,
+ () -> LeafRefValidation.validate(mergeDevicesCandidate, rootLeafRefContext));
+ // :TODO verify errors count gz
+ assertEquals(6, ex.getValidationsErrorsCount());
- devicesMapBldr.addChild(createDeviceListEntry("dev_type1_1", "dev_type2_1", "dev_type3_1", "typedesc1", 123456,
- "192.168.0.1", deviceListSchemaNode));
- devicesMapBldr.addChild(createDeviceListEntry("dev_type1_2", "dev_type2_2", "dev_type3_2", "typedesc1", 123457,
- "192.168.0.1", deviceListSchemaNode));
- devicesMapBldr.addChild(createDeviceListEntry("dev_type1_1", "dev_type2_2", "dev_type3_3", "typedesc2", 123458,
- "192.168.0.1", deviceListSchemaNode));
- devicesMapBldr.addChild(createDeviceListEntry("unk11", "unk22", "unk33", "unk_desc2", 123457, "192.168.0.1",
- deviceListSchemaNode));
+ inMemoryDataTree.commit(mergeDevicesCandidate);
- return devicesMapBldr.build();
+ LOG.debug("*************************");
+ LOG.debug("After mergeDevices: ");
+ LOG.debug("*************************");
+ LOG.debug("{}", inMemoryDataTree);
}
- private static ContainerNode createDevices2Container(final ContainerSchemaNode container) {
-
- final ListSchemaNode devicesListSchemaNode = (ListSchemaNode) container.getDataChildByName(device);
-
- final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> devicesContainerBldr = Builders
- .containerBuilder(container);
-
- final MapNode devicesMap = createDevice2List(devicesListSchemaNode);
- devicesContainerBldr.addChild(devicesMap);
-
- return devicesContainerBldr.build();
+ private static MapEntryNode createDevTypeListEntry(final String type1Val, final String type2Val,
+ final String type3Val, final String descVal) {
+ return Builders.mapEntryBuilder()
+ .withNodeIdentifier(NodeIdentifierWithPredicates.of(deviceType,
+ Map.of(type1, type1Val, type2, type2Val, type3, type3Val)))
+ .addChild(ImmutableNodes.leafNode(type1, type1Val))
+ .addChild(ImmutableNodes.leafNode(type2, type2Val))
+ .addChild(ImmutableNodes.leafNode(type3, type3Val))
+ .addChild(ImmutableNodes.leafNode(desc, descVal))
+ .build();
}
- private static MapNode createDevice2List(final ListSchemaNode deviceListSchemaNode) {
-
- final CollectionNodeBuilder<MapEntryNode, MapNode> devicesMapBldr = Builders.mapBuilder(deviceListSchemaNode);
-
- devicesMapBldr.addChild(createDeviceListEntry("dev_type1_3", "dev_type2_3", "dev_type3_3", "typedesc3", 123459,
- "192.168.0.1", deviceListSchemaNode));
- devicesMapBldr.addChild(createDeviceListEntry("dev_type1_3", "dev_type2_3", "dev_type3_3", "typedesc2", 123460,
- "192.168.0.1", deviceListSchemaNode));
- devicesMapBldr.addChild(createDeviceListEntry("dev_type1_3", "dev_type2_2", "dev_type3_1", "typedesc1", 123461,
- "192.168.0.1", deviceListSchemaNode));
- devicesMapBldr.addChild(createDeviceListEntry("unk1", "unk2", "unk3", "unk_desc", 123462, "192.168.0.1",
- deviceListSchemaNode));
-
- return devicesMapBldr.build();
+ private static MapEntryNode createChipsListEntry(final String devTypeVal, final String chipDescVal) {
+ return Builders.mapEntryBuilder()
+ .withNodeIdentifier(NodeIdentifierWithPredicates.of(chip, devType, devTypeVal))
+ .addChild(ImmutableNodes.leafNode(devType, devTypeVal))
+ .addChild(ImmutableNodes.leafNode(chipDesc, chipDescVal))
+ .build();
}
private static MapEntryNode createDeviceListEntry(final String type1TextVal, final String type2TextVal,
- final String type3TextVal, final String descVal, final int snVal, final String defaultIpVal,
- final ListSchemaNode devicesListSchemaNode) {
-
- final LeafNode<String> typeText1Leaf = ImmutableNodes.leafNode(typeText1, type1TextVal);
- final LeafNode<String> typeText2Leaf = ImmutableNodes.leafNode(typeText2, type2TextVal);
- final LeafNode<String> typeText3Leaf = ImmutableNodes.leafNode(typeText3, type3TextVal);
- final LeafNode<String> descLeaf = ImmutableNodes.leafNode(devDesc, descVal);
- final LeafNode<Integer> snValLeaf = ImmutableNodes.leafNode(sn, snVal);
- final LeafNode<String> defaultIpLeaf = ImmutableNodes.leafNode(defaultIp, defaultIpVal);
-
- final DataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> devicesMapEntryBldr = Builders
- .mapEntryBuilder(devicesListSchemaNode);
-
- devicesMapEntryBldr.addChild(typeText1Leaf);
- devicesMapEntryBldr.addChild(typeText2Leaf);
- devicesMapEntryBldr.addChild(typeText3Leaf);
- devicesMapEntryBldr.addChild(descLeaf);
- devicesMapEntryBldr.addChild(snValLeaf);
- devicesMapEntryBldr.addChild(defaultIpLeaf);
-
- return devicesMapEntryBldr.build();
+ final String type3TextVal, final String descVal, final int snVal, final String defaultIpVal) {
+ return Builders.mapEntryBuilder()
+ .withNodeIdentifier(NodeIdentifierWithPredicates.of(device, Map.of(typeText1, type1TextVal, sn, snVal)))
+ .addChild(ImmutableNodes.leafNode(typeText1, type1TextVal))
+ .addChild(ImmutableNodes.leafNode(typeText2, type2TextVal))
+ .addChild(ImmutableNodes.leafNode(typeText3, type3TextVal))
+ .addChild(ImmutableNodes.leafNode(devDesc, descVal))
+ .addChild(ImmutableNodes.leafNode(sn, snVal))
+ .addChild(ImmutableNodes.leafNode(defaultIp, defaultIpVal))
+ .build();
}
-}
\ No newline at end of file
+}