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.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.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
private static final String REV = "2016-07-28";
private static final QName ROOT = QName.create(NS, REV, "root");
private static final QName MY_LIST = QName.create(NS, REV, "my-list");
private static final QName LIST_ID = QName.create(NS, REV, "list-id");
private static final QName MANDATORY_LEAF = QName.create(NS, REV, "mandatory-leaf");
private static final QName COMMON_LEAF = QName.create(NS, REV, "common-leaf");
private static final String REV = "2016-07-28";
private static final QName ROOT = QName.create(NS, REV, "root");
private static final QName MY_LIST = QName.create(NS, REV, "my-list");
private static final QName LIST_ID = QName.create(NS, REV, "list-id");
private static final QName MANDATORY_LEAF = QName.create(NS, REV, "mandatory-leaf");
private static final QName COMMON_LEAF = QName.create(NS, REV, "common-leaf");
throws DataValidationFailedException {
final DataTree inMemoryDataTree = new InMemoryDataTreeFactory().create(
DataTreeConfiguration.DEFAULT_CONFIGURATION, schemaContext);
throws DataValidationFailedException {
final DataTree inMemoryDataTree = new InMemoryDataTreeFactory().create(
DataTreeConfiguration.DEFAULT_CONFIGURATION, schemaContext);
.withNodeIdentifier(new NodeIdentifier(ROOT));
final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
modificationTree.merge(
.withNodeIdentifier(new NodeIdentifier(ROOT));
final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
modificationTree.merge(
throws DataValidationFailedException {
return new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_CONFIGURATION, schemaContext);
}
throws DataValidationFailedException {
return new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_CONFIGURATION, schemaContext);
}
final DataTree inMemoryDataTree = emptyDataTree(SCHEMA_CONTEXT);
final MapNode myList = createMap(true);
final DataTree inMemoryDataTree = emptyDataTree(SCHEMA_CONTEXT);
final MapNode myList = createMap(true);
.withNodeIdentifier(new NodeIdentifier(ROOT)).withChild(myList);
final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
.withNodeIdentifier(new NodeIdentifier(ROOT)).withChild(myList);
final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
inMemoryDataTree.commit(prepare);
fail("Should fail due to missing mandatory leaf.");
} catch (final IllegalArgumentException e) {
inMemoryDataTree.commit(prepare);
fail("Should fail due to missing mandatory leaf.");
} catch (final IllegalArgumentException e) {
- assertEquals(
- "Node (foo?revision=2016-07-28)my-list[{(foo?revision=2016-07-28)list-id=1}] is missing mandatory "
- + "descendant /(foo?revision=2016-07-28)mandatory-leaf", e.getMessage());
+ assertEquals("Node (bug5968?revision=2016-07-28)my-list[{(bug5968?revision=2016-07-28)list-id=1}] is "
+ + "missing mandatory descendant /(bug5968?revision=2016-07-28)mandatory-leaf", e.getMessage());
inMemoryDataTree.commit(prepare);
fail("Should fail due to missing mandatory leaf.");
} catch (final IllegalArgumentException e) {
inMemoryDataTree.commit(prepare);
fail("Should fail due to missing mandatory leaf.");
} catch (final IllegalArgumentException e) {
- assertEquals(
- "Node (foo?revision=2016-07-28)my-list[{(foo?revision=2016-07-28)list-id=1}] is missing mandatory "
- + "descendant /(foo?revision=2016-07-28)mandatory-leaf", e.getMessage());
+ assertEquals("Node (bug5968?revision=2016-07-28)my-list[{(bug5968?revision=2016-07-28)list-id=1}] is "
+ + "missing mandatory descendant /(bug5968?revision=2016-07-28)mandatory-leaf", e.getMessage());
inMemoryDataTree.commit(prepare);
fail("Should fail due to missing mandatory leaf.");
} catch (final IllegalArgumentException e) {
inMemoryDataTree.commit(prepare);
fail("Should fail due to missing mandatory leaf.");
} catch (final IllegalArgumentException e) {
- assertEquals(
- "Node (foo?revision=2016-07-28)my-list[{(foo?revision=2016-07-28)list-id=1}] is missing mandatory "
- + "descendant /(foo?revision=2016-07-28)mandatory-leaf", e.getMessage());
+ assertEquals("Node (bug5968?revision=2016-07-28)my-list[{(bug5968?revision=2016-07-28)list-id=1}] is "
+ + "missing mandatory descendant /(bug5968?revision=2016-07-28)mandatory-leaf", e.getMessage());
- .node(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, listIdValue))),
+ .node(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, listIdValue))),
taskEntryNode);
}
private static MapEntryNode createMapEntry(final Object listIdValue, final Object mandatoryLeafValue,
final Object commonLeafValue) throws DataValidationFailedException {
return Builders.mapEntryBuilder()
taskEntryNode);
}
private static MapEntryNode createMapEntry(final Object listIdValue, final Object mandatoryLeafValue,
final Object commonLeafValue) throws DataValidationFailedException {
return Builders.mapEntryBuilder()
- .withNodeIdentifier(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, listIdValue)))
+ .withNodeIdentifier(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, listIdValue)))
.withChild(ImmutableNodes.leafNode(LIST_ID, listIdValue))
.withChild(ImmutableNodes.leafNode(MANDATORY_LEAF, mandatoryLeafValue))
.withChild(ImmutableNodes.leafNode(COMMON_LEAF, commonLeafValue)).build();
.withChild(ImmutableNodes.leafNode(LIST_ID, listIdValue))
.withChild(ImmutableNodes.leafNode(MANDATORY_LEAF, mandatoryLeafValue))
.withChild(ImmutableNodes.leafNode(COMMON_LEAF, commonLeafValue)).build();
private static MapEntryNode createMapEntry(final Object listIdValue, final Object commonLeafValue)
throws DataValidationFailedException {
return Builders.mapEntryBuilder()
private static MapEntryNode createMapEntry(final Object listIdValue, final Object commonLeafValue)
throws DataValidationFailedException {
return Builders.mapEntryBuilder()
- .withNodeIdentifier(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, listIdValue)))
+ .withNodeIdentifier(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, listIdValue)))
.withChild(ImmutableNodes.leafNode(LIST_ID, listIdValue))
.withChild(ImmutableNodes.leafNode(COMMON_LEAF, commonLeafValue)).build();
}
.withChild(ImmutableNodes.leafNode(LIST_ID, listIdValue))
.withChild(ImmutableNodes.leafNode(COMMON_LEAF, commonLeafValue)).build();
}
private static MapEntryNode createMapEntryM(final Object listIdValue, final Object mandatoryLeafValue)
throws DataValidationFailedException {
return Builders.mapEntryBuilder()
private static MapEntryNode createMapEntryM(final Object listIdValue, final Object mandatoryLeafValue)
throws DataValidationFailedException {
return Builders.mapEntryBuilder()
- .withNodeIdentifier(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, listIdValue)))
+ .withNodeIdentifier(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, listIdValue)))
.withChild(ImmutableNodes.leafNode(LIST_ID, listIdValue))
.withChild(ImmutableNodes.leafNode(MANDATORY_LEAF, mandatoryLeafValue)).build();
}
.withChild(ImmutableNodes.leafNode(LIST_ID, listIdValue))
.withChild(ImmutableNodes.leafNode(MANDATORY_LEAF, mandatoryLeafValue)).build();
}
final DataTree inMemoryDataTree = emptyDataTree(SCHEMA_CONTEXT);
final MapNode myList = createMap(false);
final DataTree inMemoryDataTree = emptyDataTree(SCHEMA_CONTEXT);
final MapNode myList = createMap(false);
.withNodeIdentifier(new NodeIdentifier(ROOT)).withChild(myList);
final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
.withNodeIdentifier(new NodeIdentifier(ROOT)).withChild(myList);
final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
modificationTree.merge(YangInstanceIdentifier.of(ROOT).node(MY_LIST), createMapBuilder().build());
modificationTree.merge(
YangInstanceIdentifier.of(ROOT).node(MY_LIST)
modificationTree.merge(YangInstanceIdentifier.of(ROOT).node(MY_LIST), createMapBuilder().build());
modificationTree.merge(
YangInstanceIdentifier.of(ROOT).node(MY_LIST)
- .node(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
+ .node(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
- .node(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
+ .node(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
createMapEntry("1", "mandatory-value", "common-value"));
modificationTree.ready();
createMapEntry("1", "mandatory-value", "common-value"));
modificationTree.ready();
modificationTree.merge(YangInstanceIdentifier.of(ROOT).node(MY_LIST), createMapBuilder().build());
modificationTree.merge(
YangInstanceIdentifier.of(ROOT).node(MY_LIST)
modificationTree.merge(YangInstanceIdentifier.of(ROOT).node(MY_LIST), createMapBuilder().build());
modificationTree.merge(
YangInstanceIdentifier.of(ROOT).node(MY_LIST)
- .node(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
+ .node(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
- .node(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
+ .node(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
inMemoryDataTree.commit(prepare);
fail("Should fail due to missing mandatory leaf.");
} catch (final IllegalArgumentException e) {
inMemoryDataTree.commit(prepare);
fail("Should fail due to missing mandatory leaf.");
} catch (final IllegalArgumentException e) {
- assertEquals(
- "Node (foo?revision=2016-07-28)my-list[{(foo?revision=2016-07-28)list-id=1}] is missing mandatory "
- + "descendant /(foo?revision=2016-07-28)mandatory-leaf", e.getMessage());
+ assertEquals("Node (bug5968?revision=2016-07-28)my-list[{(bug5968?revision=2016-07-28)list-id=1}] is "
+ + "missing mandatory descendant /(bug5968?revision=2016-07-28)mandatory-leaf", e.getMessage());
- .withNodeIdentifier(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, listIdValue)))
+ .withNodeIdentifier(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, listIdValue)))
modificationTree.merge(YangInstanceIdentifier.of(ROOT).node(MY_LIST), createMapBuilder().build());
modificationTree.merge(
YangInstanceIdentifier.of(ROOT).node(MY_LIST)
modificationTree.merge(YangInstanceIdentifier.of(ROOT).node(MY_LIST), createMapBuilder().build());
modificationTree.merge(
YangInstanceIdentifier.of(ROOT).node(MY_LIST)
- .node(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
+ .node(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
- .node(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
+ .node(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
createMapEntry("1", "mandatory-value", "common-value"));
modificationTree.ready();
createMapEntry("1", "mandatory-value", "common-value"));
modificationTree.ready();
modificationTree.merge(YangInstanceIdentifier.of(ROOT).node(MY_LIST), createMapBuilder().build());
modificationTree.merge(
YangInstanceIdentifier.of(ROOT).node(MY_LIST)
modificationTree.merge(YangInstanceIdentifier.of(ROOT).node(MY_LIST), createMapBuilder().build());
modificationTree.merge(
YangInstanceIdentifier.of(ROOT).node(MY_LIST)
- .node(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
+ .node(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
- .node(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
+ .node(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
inMemoryDataTree.commit(prepare);
fail("Should fail due to missing mandatory leaf.");
} catch (final IllegalArgumentException e) {
inMemoryDataTree.commit(prepare);
fail("Should fail due to missing mandatory leaf.");
} catch (final IllegalArgumentException e) {
- assertEquals(
- "Node (foo?revision=2016-07-28)my-list[{(foo?revision=2016-07-28)list-id=1}] is missing mandatory "
- + "descendant /(foo?revision=2016-07-28)mandatory-leaf", e.getMessage());
+ assertEquals("Node (bug5968?revision=2016-07-28)my-list[{(bug5968?revision=2016-07-28)list-id=1}] is "
+ + "missing mandatory descendant /(bug5968?revision=2016-07-28)mandatory-leaf", e.getMessage());
modificationTree.merge(YangInstanceIdentifier.of(ROOT).node(MY_LIST), createMapBuilder().build());
modificationTree.merge(
YangInstanceIdentifier.of(ROOT).node(MY_LIST)
modificationTree.merge(YangInstanceIdentifier.of(ROOT).node(MY_LIST), createMapBuilder().build());
modificationTree.merge(
YangInstanceIdentifier.of(ROOT).node(MY_LIST)
- .node(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
+ .node(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
- .node(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
+ .node(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
createMapEntryM("1", "mandatory-value"));
modificationTree.ready();
createMapEntryM("1", "mandatory-value"));
modificationTree.ready();
final DataTreeModification modificationTree2 = inMemoryDataTree.takeSnapshot().newModification();
modificationTree2.merge(
YangInstanceIdentifier.of(ROOT).node(MY_LIST)
final DataTreeModification modificationTree2 = inMemoryDataTree.takeSnapshot().newModification();
modificationTree2.merge(
YangInstanceIdentifier.of(ROOT).node(MY_LIST)
- .node(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
+ .node(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
createMapEntry("1", "common-value"));
modificationTree2.ready();
inMemoryDataTree.validate(modificationTree2);
createMapEntry("1", "common-value"));
modificationTree2.ready();
inMemoryDataTree.validate(modificationTree2);
modificationTree.merge(YangInstanceIdentifier.of(ROOT).node(MY_LIST), createMapBuilder().build());
modificationTree.merge(
YangInstanceIdentifier.of(ROOT).node(MY_LIST)
modificationTree.merge(YangInstanceIdentifier.of(ROOT).node(MY_LIST), createMapBuilder().build());
modificationTree.merge(
YangInstanceIdentifier.of(ROOT).node(MY_LIST)
- .node(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
+ .node(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
- .node(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
+ .node(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
createMapEntryM("1", "mandatory-value"));
modificationTree.ready();
createMapEntryM("1", "mandatory-value"));
modificationTree.ready();
final DataTreeModification modificationTree2 = inMemoryDataTree.takeSnapshot().newModification();
modificationTree2.write(
YangInstanceIdentifier.of(ROOT).node(MY_LIST)
final DataTreeModification modificationTree2 = inMemoryDataTree.takeSnapshot().newModification();
modificationTree2.write(
YangInstanceIdentifier.of(ROOT).node(MY_LIST)
- .node(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
+ .node(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
createMapEntry("1", "common-value"));
modificationTree2.merge(
YangInstanceIdentifier.of(ROOT).node(MY_LIST)
createMapEntry("1", "common-value"));
modificationTree2.merge(
YangInstanceIdentifier.of(ROOT).node(MY_LIST)
- .node(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
+ .node(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
createMapEntryM("1", "mandatory-value"));
modificationTree2.merge(
YangInstanceIdentifier.of(ROOT).node(MY_LIST)
createMapEntryM("1", "mandatory-value"));
modificationTree2.merge(
YangInstanceIdentifier.of(ROOT).node(MY_LIST)
- .node(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, "2"))),
+ .node(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, "2"))),
createMapEntry("2", "common-value"));
try {
modificationTree2.ready();
createMapEntry("2", "common-value"));
try {
modificationTree2.ready();
inMemoryDataTree.commit(prepare2);
fail("Should fail due to missing mandatory leaf.");
} catch (final IllegalArgumentException e) {
inMemoryDataTree.commit(prepare2);
fail("Should fail due to missing mandatory leaf.");
} catch (final IllegalArgumentException e) {
- assertEquals(
- "Node (foo?revision=2016-07-28)my-list[{(foo?revision=2016-07-28)list-id=2}] is missing mandatory "
- + "descendant /(foo?revision=2016-07-28)mandatory-leaf", e.getMessage());
+ assertEquals("Node (bug5968?revision=2016-07-28)my-list[{(bug5968?revision=2016-07-28)list-id=2}] is "
+ + "missing mandatory descendant /(bug5968?revision=2016-07-28)mandatory-leaf", e.getMessage());
modificationTree.merge(YangInstanceIdentifier.of(ROOT).node(MY_LIST), createMapBuilder().build());
modificationTree.merge(
YangInstanceIdentifier.of(ROOT).node(MY_LIST)
modificationTree.merge(YangInstanceIdentifier.of(ROOT).node(MY_LIST), createMapBuilder().build());
modificationTree.merge(
YangInstanceIdentifier.of(ROOT).node(MY_LIST)
- .node(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
+ .node(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
- .node(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
+ .node(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
createMapEntryM("1", "mandatory-value"));
modificationTree.ready();
createMapEntryM("1", "mandatory-value"));
modificationTree.ready();
- .node(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
+ .node(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
createMapEntry("1", "common-value"));
modificationTree2.ready();
inMemoryDataTree.validate(modificationTree2);
createMapEntry("1", "common-value"));
modificationTree2.ready();
inMemoryDataTree.validate(modificationTree2);