YangStmtMapping.MAX_ELEMENTS, YangStmtMapping.IF_FEATURE);
public static final Map<StatementDefinition, Set<StatementDefinition>> SUPPORTED_REFINE_TARGETS =
- ImmutableMap.<StatementDefinition, Set<StatementDefinition>>builder()
- .put(YangStmtMapping.DEFAULT, ImmutableSet.of(YangStmtMapping.LEAF, YangStmtMapping.CHOICE))
+ ImmutableMap.<StatementDefinition, Set<StatementDefinition>>builder()
+ .put(YangStmtMapping.DEFAULT, ImmutableSet.of(
+ YangStmtMapping.LEAF, YangStmtMapping.CHOICE, YangStmtMapping.LEAF_LIST))
.put(YangStmtMapping.MANDATORY, ImmutableSet.of(
- YangStmtMapping.LEAF, YangStmtMapping.CHOICE, YangStmtMapping.ANYXML, YangStmtMapping.ANYDATA))
- .put(YangStmtMapping.PRESENCE, ImmutableSet.of(YangStmtMapping.CONTAINER))
- .put(YangStmtMapping.MUST, ImmutableSet.of(
- YangStmtMapping.CONTAINER, YangStmtMapping.LIST, YangStmtMapping.LEAF,
- YangStmtMapping.LEAF_LIST, YangStmtMapping.ANYXML, YangStmtMapping.ANYDATA))
- .put(YangStmtMapping.MIN_ELEMENTS, ImmutableSet.of(YangStmtMapping.LIST, YangStmtMapping.LEAF_LIST))
- .put(YangStmtMapping.MAX_ELEMENTS, ImmutableSet.of(YangStmtMapping.LIST, YangStmtMapping.LEAF_LIST))
- .build();
+ YangStmtMapping.LEAF, YangStmtMapping.ANYDATA, YangStmtMapping.ANYXML, YangStmtMapping.CHOICE))
+ .put(YangStmtMapping.MAX_ELEMENTS, ImmutableSet.of(YangStmtMapping.LIST, YangStmtMapping.LEAF_LIST))
+ .put(YangStmtMapping.MIN_ELEMENTS, ImmutableSet.of(YangStmtMapping.LIST, YangStmtMapping.LEAF_LIST))
+ .put(YangStmtMapping.MUST, ImmutableSet.of(
+ YangStmtMapping.LEAF, YangStmtMapping.LEAF_LIST, YangStmtMapping.LIST, YangStmtMapping.CONTAINER,
+ YangStmtMapping.ANYDATA, YangStmtMapping.ANYXML))
+ .put(YangStmtMapping.PRESENCE, ImmutableSet.of(YangStmtMapping.CONTAINER))
+ .build();
private YangValidationBundles() {
// Hidden on purpose
--- /dev/null
+/*
+ * Copyright (c) 2021 PANTHEON.tech, s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.stmt;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotSame;
+
+import java.net.URI;
+import java.util.Optional;
+import org.junit.Test;
+import org.opendaylight.yangtools.yang.common.QNameModule;
+import org.opendaylight.yangtools.yang.model.api.stmt.DefaultEffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.GroupingEffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.LeafListEffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement;
+
+public class YT1312Test {
+ @Test
+ public void testRefineDefault() throws Exception {
+ final ModuleEffectiveStatement module = StmtTestUtils.parseYangSource("/bugs/YT1312/foo.yang")
+ .getModuleStatements().get(QNameModule.create(URI.create("foo")));
+
+ final LeafListEffectiveStatement grpFoo = module
+ .findFirstEffectiveSubstatement(GroupingEffectiveStatement.class).orElseThrow()
+ .findFirstEffectiveSubstatement(LeafListEffectiveStatement.class).orElseThrow();
+ final LeafListEffectiveStatement foo = module
+ .findFirstEffectiveSubstatement(LeafListEffectiveStatement.class).orElseThrow();
+
+ assertNotSame(foo, grpFoo);
+ assertEquals(Optional.empty(), grpFoo.findFirstEffectiveSubstatementArgument(DefaultEffectiveStatement.class));
+ assertEquals(Optional.of("abc"), foo.findFirstEffectiveSubstatementArgument(DefaultEffectiveStatement.class));
+ }
+}