summary |
shortlog |
log |
commit | commitdiff |
review |
tree
raw |
patch |
inline | side by side (from parent 1:
9bd760d)
Proposed solution rejects this and parser throws exception
Change-Id: I3cca06a72cfa33245f05a81e62b6a696966697c4
Signed-off-by: Martin Ciglan <mciglan@cisco.com>
} else if (childNode instanceof Key_stmtContext) {
final Set<String> key = createListKey((Key_stmtContext) childNode);
builder.setKeys(key);
} else if (childNode instanceof Key_stmtContext) {
final Set<String> key = createListKey((Key_stmtContext) childNode);
builder.setKeys(key);
+ } else if (childNode instanceof YangParser.Identifier_stmtContext) {
+ if (childNode.getChild(0).toString().equals("union")) {
+ throw new YangParseException(moduleName, line, "Union statement is not allowed inside a list statement");
+ }
import org.opendaylight.yangtools.yang.model.util.IdentityrefType;
import org.opendaylight.yangtools.yang.model.util.InstanceIdentifierType;
import org.opendaylight.yangtools.yang.model.util.UnionType;
import org.opendaylight.yangtools.yang.model.util.IdentityrefType;
import org.opendaylight.yangtools.yang.model.util.InstanceIdentifierType;
import org.opendaylight.yangtools.yang.model.util.UnionType;
+import org.opendaylight.yangtools.yang.parser.util.YangParseException;
public class TypesResolutionTest {
private Set<Module> testedModules;
public class TypesResolutionTest {
private Set<Module> testedModules;
parser.parseFiles(Arrays.asList(unionbits));
}
parser.parseFiles(Arrays.asList(unionbits));
}
+ @Test(expected = YangParseException.class)
+ public void testUnionInList() throws Exception {
+ File unioninlist = new File(getClass().getResource("/types/union-in-list/unioninlisttest.yang").toURI());
+ YangContextParser parser = new YangParserImpl();
+ parser.parseFiles(Arrays.asList(unioninlist));
+ }
--- /dev/null
+module unioninlisttest {
+
+ namespace "urn:uilt";
+ prefix "uilt";
+
+ revision 2015-01-13 {
+ }
+
+ list foo {
+ key "name";
+ unique "ip port";
+
+ leaf name {
+ type string;
+ }
+
+ union {
+ type int32;
+ type enumeration {
+ enum "test";
+ }
+ }
+
+ leaf ip {
+ type string;
+ }
+
+ leaf port {
+ type string;
+ }
+ }
+}
\ No newline at end of file