Augment can also target a relative path from uses context, this
expands the testing model to cover that case, too.
The test case flushes out the problem of not handling
action/notification nodes when targeted in this manner, leading
to an obvious hiccup.
JIRA: MDSAL-517
Change-Id: If389440622c31f544917b04e3825fe6e08e08244
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
final UsesNode parentUsesNode) {
SchemaNode result = parentUsesNode.getSourceGrouping();
for (final QName node : targetPath.getNodeIdentifiers()) {
final UsesNode parentUsesNode) {
SchemaNode result = parentUsesNode.getSourceGrouping();
for (final QName node : targetPath.getNodeIdentifiers()) {
+ // FIXME: this dispatch is rather ugly, we probably want to refactor it a bit
if (result instanceof DataNodeContainer) {
final QName resultNode = node.bindTo(result.getQName().getModule());
if (result instanceof DataNodeContainer) {
final QName resultNode = node.bindTo(result.getQName().getModule());
- result = ((DataNodeContainer) result).getDataChildByName(resultNode);
+
+ SchemaNode found = ((DataNodeContainer) result).getDataChildByName(resultNode);
+ if (found == null) {
+ if (result instanceof ActionNodeContainer) {
+ found = ((ActionNodeContainer) result).findAction(resultNode).orElse(null);
+ }
+ if (found == null && result instanceof NotificationNodeContainer) {
+ found = ((NotificationNodeContainer) result).findNotification(resultNode).orElse(null);
+ }
+ }
+ result = found;
} else if (result instanceof ChoiceSchemaNode) {
result = findNamedCase((ChoiceSchemaNode) result, node.getLocalName());
} else if (result instanceof ChoiceSchemaNode) {
result = findNamedCase((ChoiceSchemaNode) result, node.getLocalName());
+ } else if (result instanceof ActionDefinition) {
+ final ActionDefinition action = (ActionDefinition) result;
+ final QName resultNode = node.bindTo(result.getQName().getModule());
+
+ final ContainerSchemaNode input = action.getInput();
+ final ContainerSchemaNode output = action.getOutput();
+ if (resultNode.equals(input.getQName())) {
+ result = input;
+ } else if (resultNode.equals(output.getQName())) {
+ result = output;
+ } else {
+ result = null;
+ }
+ } else if (result != null) {
+ throw new IllegalStateException("Cannot handle " + result);
}
}
if (result == null) {
}
}
if (result == null) {
final List<Type> types = DefaultBindingGenerator.generateFor(
YangParserTestUtils.parseYangResourceDirectory("/mdsal-517"));
assertNotNull(types);
final List<Type> types = DefaultBindingGenerator.generateFor(
YangParserTestUtils.parseYangResourceDirectory("/mdsal-517"));
assertNotNull(types);
- assertEquals(7, types.size());
+ assertEquals(11, types.size());
--- /dev/null
+module baz {
+ yang-version 1.1;
+ namespace "baz";
+ prefix baz;
+
+ import foo {
+ prefix foo;
+ }
+
+ container baz-cont {
+ uses foo:foo-grp {
+ augment foo-act/input {
+ leaf baz-aug-leaf {
+ type string;
+ }
+ }
+ }
+ }
+}