*/
int getOrder();
+ /**
+ * Set true if target of augment is unsupported (e.g. node in body of extension).
+ * In such case, augmentation is skipped and AugmentationSchema is not built.
+ */
+ public void setUnsupportedTarget(boolean unsupportedTarget);
+
+ /**
+ * Return true if target of augment is unsupported (e.g. node in body of extension).
+ * In such case, augmentation is skipped and AugmentationSchema is not built.
+ */
+ public boolean isUnsupportedTarget();
+
}
private final SchemaPath targetPath;
private boolean resolved;
+ private boolean unsupportedTarget = false;
+
private AugmentationSchemaBuilder copyOf;
public AugmentationSchemaBuilderImpl(final String moduleName, final int line, final String augmentTargetStr,
this.resolved = resolved;
}
+ /**
+ * Set true if target of augment is unsupported (e.g. node in body of extension).
+ * In such case, augmentation is skipped and AugmentationSchema is not built.
+ */
+ @Override
+ public void setUnsupportedTarget(boolean unsupportedTarget) {
+ this.unsupportedTarget = unsupportedTarget;
+ }
+
+ /**
+ * Return true if target of augment is unsupported (e.g. node in body of extension).
+ * In such case, augmentation is skipped and AugmentationSchema is not built.
+ */
+ @Override
+ public boolean isUnsupportedTarget() {
+ return unsupportedTarget;
+ }
+
@Override
public String getWhenCondition() {
return whenCondition;
// AUGMENTATIONS
final Set<AugmentationSchema> augments = new HashSet<>();
for (AugmentationSchemaBuilder builder : augmentationBuilders) {
- augments.add(builder.build());
+ if (!builder.isUnsupportedTarget())
+ augments.add(builder.build());
}
instance.augmentations = ImmutableSet.copyOf(augments);
"Error in module {} at line {}: Unsupported augment target: {}. Augmentation process skipped.",
module.getName(), augment.getLine(), potentialTargetNode);
augment.setResolved(true);
+ augment.setUnsupportedTarget(true);
return true;
}
} else {
--- /dev/null
+/**
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ */
+package org.opendaylight.yangtools.yang.parser.impl;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.util.Set;
+
+import org.junit.Test;
+import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
+import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.UsesNode;
+import org.opendaylight.yangtools.yang.parser.util.YangParseException;
+
+public class AugmentToExtensionTest {
+ private Set<Module> modules;
+
+ @Test(expected = YangParseException.class)
+ public void testIncorrectPath() throws IOException, URISyntaxException {
+ modules = TestUtils.loadModules(getClass().getResource("/augment-to-extension-test/incorrect-path").toURI());
+
+ }
+
+ @Test
+ public void testCorrectPathIntoUnsupportedTarget() throws IOException, URISyntaxException {
+ modules = TestUtils.loadModules(getClass().getResource(
+ "/augment-to-extension-test/correct-path-into-unsupported-target").toURI());
+
+ Module devicesModul = TestUtils.findModule(modules, "augment-module");
+
+ ContainerSchemaNode devicesContainer = (ContainerSchemaNode) devicesModul.getDataChildByName("my-container");
+ Set<UsesNode> uses = devicesContainer.getUses();
+
+ boolean augmentationIsInContainer = false;
+ for (UsesNode usesNode : uses) {
+ Set<AugmentationSchema> augmentations = usesNode.getAugmentations();
+ for (AugmentationSchema augmentationSchema : augmentations) {
+ augmentationIsInContainer = true;
+ }
+ }
+
+ assertFalse(augmentationIsInContainer);
+ }
+
+ @Test
+ public void testCorrectAugment() throws IOException, URISyntaxException {
+ modules = TestUtils.loadModules(getClass().getResource("/augment-to-extension-test/correct-augment").toURI());
+
+ Module devicesModul = TestUtils.findModule(modules, "augment-module");
+
+ ContainerSchemaNode devicesContainer = (ContainerSchemaNode) devicesModul.getDataChildByName("my-container");
+ Set<UsesNode> uses = devicesContainer.getUses();
+
+ boolean augmentationIsInContainer = false;
+ for (UsesNode usesNode : uses) {
+ Set<AugmentationSchema> augmentations = usesNode.getAugmentations();
+ for (AugmentationSchema augmentationSchema : augmentations) {
+ augmentationIsInContainer = true;
+ }
+ }
+
+ assertTrue(augmentationIsInContainer);
+ }
+
+}
--- /dev/null
+module augment-module {
+ yang-version 1;
+ namespace "uri:augment-module";
+ prefix aug;
+
+ import extension-module { prefix ext; }
+
+ revision 2014-10-07 {
+ description
+ "Yang model with augment into extension";
+ }
+
+ grouping my-grouping {
+ ext:my-extension my-extension-name {
+ description
+ "Extension.";
+ input {
+ leaf my-leaf {
+ type string;
+ description
+ "my-leaf in extension body.";
+ }
+ }
+ }
+ container my-container-in-gruping {
+ }
+ }
+
+ container my-container {
+ uses my-grouping {
+ augment "my-container-in-gruping" {
+ leaf-list my-leaf-list {
+ type string;
+ }
+ }
+ }
+ }
+}
+
--- /dev/null
+module extension-module {
+ yang-version 1;
+ namespace "uri:extension-module";
+ prefix ext;
+
+ revision 2014-10-07 {
+ description
+ "Yang model with extension definition";
+ }
+
+ extension my-extension {
+ argument name {
+ }
+ }
+}
--- /dev/null
+module augment-module {
+ yang-version 1;
+ namespace "uri:augment-module";
+ prefix aug;
+
+ import extension-module { prefix ext; }
+
+ revision 2014-10-07 {
+ description
+ "Yang model with augment into extension";
+ }
+
+ grouping my-grouping {
+ ext:my-extension my-extension-name {
+ description
+ "Extension.";
+ input {
+ leaf my-leaf {
+ type string;
+ description
+ "my-leaf in extension body.";
+ }
+ }
+ }
+ container my-container-in-gruping {
+ }
+ }
+
+ container my-container {
+ uses my-grouping {
+ augment "my-extension-name/input" {
+ leaf-list my-leaf-list {
+ type string;
+ }
+ }
+ }
+ }
+}
+
--- /dev/null
+module extension-module {
+ yang-version 1;
+ namespace "uri:extension-module";
+ prefix ext;
+
+ revision 2014-10-07 {
+ description
+ "Yang model with extension definition";
+ }
+
+ extension my-extension {
+ argument name {
+ }
+ }
+}
--- /dev/null
+module augment-module {
+ yang-version 1;
+ namespace "uri:augment-module";
+ prefix aug;
+
+ import extension-module { prefix ext; }
+
+ revision 2014-10-07 {
+ description
+ "Yang model with augment into extension";
+ }
+
+ grouping my-grouping {
+ ext:my-extension my-extension-name {
+ description
+ "Extension.";
+ input {
+ leaf my-leaf {
+ type string;
+ description
+ "my-leaf in extension body.";
+ }
+ }
+ }
+ container my-container-in-gruping {
+ }
+ }
+
+ container my-container {
+ uses my-grouping {
+ augment "my-extension-name/input/a" {
+ leaf-list my-leaf-list {
+ type string;
+ }
+ }
+ }
+ }
+}
+
--- /dev/null
+module extension-module {
+ yang-version 1;
+ namespace "uri:extension-module";
+ prefix ext;
+
+ revision 2014-10-07 {
+ description
+ "Yang model with extension definition";
+ }
+
+ extension my-extension {
+ argument name {
+ }
+ }
+}