Add DataSchemaNode.effectiveConfig() 00/86900/8
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 4 Dec 2020 11:48:42 +0000 (12:48 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 4 Dec 2020 14:20:49 +0000 (15:20 +0100)
DataSchemaNode.isConfiguration()'s boolean return is inaccurate
modeling: a DataSchemaNode can be inside a top-level grouping, in
which case it does not have its 'config' defined.

Add effectiveConfig() which accurately reflects whether there is
a 'config' statement in effect or not.

JIRA: YANGTOOLS-1063
Change-Id: I2314aaa169a591cce419b925a965cbed118f249e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
30 files changed:
yang/odlext-parser-support/src/main/java/org/opendaylight/yangtools/odlext/parser/YangModeledAnyxmlEffectiveStatementImpl.java
yang/rfc8040-parser-support/src/test/java/org/opendaylight/yangtools/rfc8040/parser/YangDataExtensionTest.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/YangModeledAnyXMLDeserializationTest.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/SchemaAwareApplyOperation.java
yang/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/ContainerSchemaNodes.java
yang/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/OperationAsContainer.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/DataSchemaNode.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/SchemaContext.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/EffectiveStatementMixins.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/anydata/AnydataStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/anyxml/AnyxmlStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/case_/AbstractCaseStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/choice/AbstractChoiceStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/container/AbstractContainerStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/leaf/LeafStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/leaf_list/AbstractLeafListStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/list/AbstractListStatementSupport.java
yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug9244Test.java
yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/CaseStmtTest.java
yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/DeviationResolutionTest.java
yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveSchemaContextTest.java
yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveUsesRefineAndConstraintsTest.java
yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/GroupingTest.java
yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/ListTest.java
yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT911Test.java
yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserSimpleTest.java
yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserTest.java
yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserWithContextTest.java
yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileChoiceStmtTest.java
yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/EffectiveStmtCtx.java

index b9090bef97189ddcd1a6ea2d2ce294d8d2b58e9d..cc07e4cc5ecb09a4b36f4465f704a36b8aaa451a 100644 (file)
@@ -52,8 +52,8 @@ final class YangModeledAnyxmlEffectiveStatementImpl
     }
 
     @Override
-    public boolean isConfiguration() {
-        return delegateSchemaNode().isConfiguration();
+    public Optional<Boolean> effectiveConfig() {
+        return delegateSchemaNode().effectiveConfig();
     }
 
     @Override
index 61a75b93459bfbdb8ef26e1f1da69396ceb92c72..6dd3a60904ddc62246a10a890299f5bee8a022b3 100644 (file)
@@ -19,6 +19,7 @@ import com.google.common.collect.ImmutableSet;
 import java.io.IOException;
 import java.net.URI;
 import java.util.Collection;
+import java.util.Optional;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -130,15 +131,15 @@ public class YangDataExtensionTest {
 
         final ContainerSchemaNode contInYangData = myYangDataNode.getContainerSchemaNode();
         assertNotNull(contInYangData);
-        assertTrue(contInYangData.isConfiguration());
+        assertEquals(Optional.empty(), contInYangData.effectiveConfig());
         final ContainerSchemaNode innerCont = (ContainerSchemaNode) contInYangData.findDataChildByName(
                 QName.create(baz.getQNameModule(), "inner-cont")).get();
         assertNotNull(innerCont);
-        assertTrue(innerCont.isConfiguration());
+        assertEquals(Optional.empty(), innerCont.effectiveConfig());
         final ContainerSchemaNode grpCont = (ContainerSchemaNode) contInYangData.findDataChildByName(
                 QName.create(baz.getQNameModule(), "grp-cont")).get();
         assertNotNull(grpCont);
-        assertTrue(grpCont.isConfiguration());
+        assertEquals(Optional.empty(), grpCont.effectiveConfig());
     }
 
     @Test
index f0a21911b558950ebe379e78bea870b1d0cb6242..2ef94daa306ab468f525a693b56b8f15eaf63435 100644 (file)
@@ -182,8 +182,8 @@ public class YangModeledAnyXMLDeserializationTest {
         }
 
         @Override
-        public boolean isConfiguration() {
-            return false;
+        public Optional<Boolean> effectiveConfig() {
+            return Optional.of(Boolean.FALSE);
         }
 
         @Override
index bc7dd85056dd979aad5c39798ccd550c47ece7a3..c9ff42e2cdca7b16f1462134eccad2bdd8c61cdb 100644 (file)
@@ -315,6 +315,6 @@ abstract class SchemaAwareApplyOperation<T extends WithStatus> extends Modificat
      * @return {@code true} if the node matches the tree type, {@code false} otherwise.
      */
     static final boolean belongsToTree(final TreeType treeType, final DataSchemaNode node) {
-        return treeType == TreeType.OPERATIONAL || node.isConfiguration();
+        return treeType == TreeType.OPERATIONAL || node.effectiveConfig().orElse(Boolean.TRUE);
     }
 }
index 8e44c535cbcdd729ff85c55326de270815206a02..337928f7241ea38bb2b0a3485055e1d84178bfa9 100644 (file)
@@ -73,8 +73,8 @@ public final class ContainerSchemaNodes {
         }
 
         @Override
-        public boolean isConfiguration() {
-            return false;
+        public Optional<Boolean> effectiveConfig() {
+            return Optional.empty();
         }
 
         @Override
index 0b15424aae29c741a61c9449bf25f60035c2515d..0aa9b414d8843a5c7c17ea54f27b77f328731323 100644 (file)
@@ -150,8 +150,8 @@ public class OperationAsContainer extends ForwardingObject implements ContainerL
     }
 
     @Override
-    public final boolean isConfiguration() {
-        return false;
+    public final Optional<Boolean> effectiveConfig() {
+        return Optional.empty();
     }
 
     @Override
index cf9e60fc95cc2b02cc71793784f9915b10f3b860..f125231f7405dda67a1f6e14b70054bda97d7621 100644 (file)
@@ -7,6 +7,8 @@
  */
 package org.opendaylight.yangtools.yang.model.api;
 
+import java.util.Optional;
+
 /**
  * Data Schema Node represents abstract supertype from which all data tree definitions are derived. Unlike what
  * the name would suggest, this interface corresponds more to RFC7950 {@code data definition statement} than to
@@ -28,11 +30,20 @@ package org.opendaylight.yangtools.yang.model.api;
  */
 public interface DataSchemaNode extends SchemaNode, CopyableNode, WhenConditionAware {
     /**
-     * Returns <code>true</code> if the data represents configuration data,
-     * otherwise returns <code>false</code>.
+     * Returns {@code true} if the data represents configuration data, otherwise returns {@code false}.
+     *
+     * @return {@code true} if the data represents configuration data, otherwise returns {@code false}
+     * @deprecated Use {@link #effectiveConfig()} instead.
+     */
+    @Deprecated(forRemoval = true)
+    default boolean isConfiguration() {
+        return effectiveConfig().orElse(Boolean.TRUE);
+    }
+
+    /**
+     * Return the effective value of {@code config} substatement, if applicable.
      *
-     * @return <code>true</code> if the data represents configuration data,
-     *         otherwise returns <code>false</code>
+     * @return Effective {@code config} value, or {@link Optional#empty()} not applicable.
      */
-    boolean isConfiguration();
+    Optional<Boolean> effectiveConfig();
 }
index 0e74f13f519d45145d601308d31baf84fb9612d2..9198dde5b1b415506925d07502165411d47e1efc 100644 (file)
@@ -252,8 +252,8 @@ public interface SchemaContext extends ContainerLike, Immutable {
 
     @Override
     @Deprecated
-    default boolean isConfiguration() {
-        return false;
+    default Optional<Boolean> effectiveConfig() {
+        return Optional.empty();
     }
 
     @Override
index 91af95ff5e44724076ccb9d7a83396709eb36975..752b15e952e33c4ee80baccc0fca842c9442f155 100644 (file)
@@ -16,6 +16,7 @@ import java.util.Collection;
 import java.util.Optional;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.yangtools.concepts.Mutable;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ActionDefinition;
@@ -97,6 +98,7 @@ public final class EffectiveStatementMixins {
     public interface AddedByUsesMixin<A, D extends DeclaredStatement<A>>
             extends EffectiveStatementWithFlags<A, D>, AddedByUsesAware {
         @Override
+        @Deprecated
         default boolean isAddedByUses() {
             return (flags() & FlagsBuilder.ADDED_BY_USES) != 0;
         }
@@ -151,6 +153,7 @@ public final class EffectiveStatementMixins {
      */
     public interface CopyableMixin<A, D extends DeclaredStatement<A>> extends AddedByUsesMixin<A, D>, CopyableNode {
         @Override
+        @Deprecated
         default boolean isAugmenting() {
             return (flags() & FlagsBuilder.AUGMENTING) != 0;
         }
@@ -193,8 +196,18 @@ public final class EffectiveStatementMixins {
     public interface DataSchemaNodeMixin<A, D extends DeclaredStatement<A>>
             extends DataSchemaNode, CopyableMixin<A, D>, SchemaNodeMixin<A, D>, WhenConditionMixin<A, D> {
         @Override
-        default boolean isConfiguration() {
-            return (flags() & FlagsBuilder.CONFIGURATION) != 0;
+        default Optional<Boolean> effectiveConfig() {
+            final int fl = flags() & FlagsBuilder.MASK_CONFIG;
+            switch (fl) {
+                case FlagsBuilder.CONFIG_FALSE:
+                    return Optional.of(Boolean.FALSE);
+                case FlagsBuilder.CONFIG_TRUE:
+                    return Optional.of(Boolean.TRUE);
+                case FlagsBuilder.CONFIG_UNDEF:
+                    return Optional.empty();
+                default:
+                    throw new IllegalStateException("Unhandled effective config flags " + fl);
+            }
         }
     }
 
@@ -381,8 +394,8 @@ public final class EffectiveStatementMixins {
         }
 
         @Override
-        default boolean isConfiguration() {
-            return false;
+        default Optional<Boolean> effectiveConfig() {
+            return Optional.empty();
         }
 
         default String defaultToString() {
@@ -454,14 +467,13 @@ public final class EffectiveStatementMixins {
 
         @NonNullByDefault
         final class FlagsBuilder implements Mutable {
-            // We still have 24 flags remaining
+            // We still have 23 flags remaining
             static final int STATUS_CURRENT       = 0x0001;
             static final int STATUS_DEPRECATED    = 0x0002;
             static final int STATUS_OBSOLETE      = 0x0003;
             static final int MASK_STATUS          = 0x0003;
 
-            static final int CONFIGURATION        = 0x0004;
-            static final int MANDATORY            = 0x0008;
+            static final int MANDATORY            = 0x0004;
 
             static final int AUGMENTING           = 0x0010;
             static final int ADDED_BY_USES        = 0x0020;
@@ -470,14 +482,21 @@ public final class EffectiveStatementMixins {
             static final int USER_ORDERED         = 0x0040;
             static final int PRESENCE             = 0x0080;
 
+            static final int CONFIG_UNDEF         = 0x0100;
+            static final int CONFIG_FALSE         = 0x0200;
+            static final int CONFIG_TRUE          = 0x0300;
+            static final int MASK_CONFIG          = CONFIG_TRUE;
+
             private int flags;
 
-            public FlagsBuilder setConfiguration(final boolean config) {
-                if (config) {
-                    flags |= CONFIGURATION;
+            public FlagsBuilder setConfiguration(final @Nullable Boolean config) {
+                final int fl;
+                if (config != null) {
+                    fl = config ? CONFIG_TRUE : CONFIG_FALSE;
                 } else {
-                    flags &= ~CONFIGURATION;
+                    fl = CONFIG_UNDEF;
                 }
+                flags = flags & ~MASK_CONFIG | fl;
                 return this;
             }
 
index 23899723a9b164b67e2bf2a174def0bb58ce225e..f6e69025edaff2d8309bc43fa9084de05092a522 100644 (file)
@@ -71,7 +71,7 @@ public final class AnydataStatementSupport
         final int flags = new FlagsBuilder()
             .setHistory(stmt.history())
             .setStatus(findFirstArgument(substatements, StatusEffectiveStatement.class, Status.CURRENT))
-            .setConfiguration(stmt.effectiveConfig().asLegacy())
+            .setConfiguration(stmt.effectiveConfig().asNullable())
             .setMandatory(findFirstArgument(substatements, MandatoryEffectiveStatement.class, Boolean.FALSE))
             .toFlags();
         final SchemaPath path = stmt.wrapSchemaPath();
index 74c8d0df525310857674afd5293894ebe80f1809..e78b7e74b8ba07a64eebf16d21004dca7dc96122 100644 (file)
@@ -71,7 +71,7 @@ public final class AnyxmlStatementSupport
         final int flags = new FlagsBuilder()
             .setHistory(stmt.history())
             .setStatus(findFirstArgument(substatements, StatusEffectiveStatement.class, Status.CURRENT))
-            .setConfiguration(stmt.effectiveConfig().asLegacy())
+            .setConfiguration(stmt.effectiveConfig().asNullable())
             .setMandatory(findFirstArgument(substatements, MandatoryEffectiveStatement.class, Boolean.FALSE))
             .toFlags();
         final SchemaPath path = stmt.wrapSchemaPath();
index c0bf68e1f62de59a7ae4fbad8ffb0920adcb1dca..dae37aa6404426264ead7dd68d043bc722adb0aa 100644 (file)
@@ -8,6 +8,8 @@
 package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.case_;
 
 import com.google.common.collect.ImmutableList;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import java.util.Optional;
 import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.CaseSchemaNode;
@@ -24,6 +26,7 @@ import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseImplicitStatement
 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.EffectiveStatementWithFlags.FlagsBuilder;
 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.SubstatementIndexingException;
 import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
+import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Parent.EffectiveConfig;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
 
@@ -88,11 +91,44 @@ abstract class AbstractCaseStatementSupport
 
     private static int computeFlags(final Current<?, ?> stmt,
             final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+        final Boolean config;
+        final EffectiveConfig effective = stmt.effectiveConfig();
+        switch (effective) {
+            case FALSE:
+                config = Boolean.FALSE;
+                break;
+            case IGNORED:
+                config = null;
+                break;
+            case TRUE:
+                final Boolean sub = substatementEffectiveConfig(substatements);
+                config = sub != null ? sub : Boolean.TRUE;
+                break;
+            case UNDETERMINED:
+                config = substatementEffectiveConfig(substatements);
+                break;
+            default:
+                throw new IllegalStateException("Unhandled effective config " + effective);
+        }
+
         return new FlagsBuilder()
                 .setHistory(stmt.history())
                 .setStatus(findFirstArgument(substatements, StatusEffectiveStatement.class, Status.CURRENT))
-                .setConfiguration(stmt.effectiveConfig().asLegacy() && substatements.stream().anyMatch(
-                    sub -> sub instanceof DataSchemaNode && ((DataSchemaNode) sub).isConfiguration()))
+                .setConfiguration(config)
                 .toFlags();
     }
-}
\ No newline at end of file
+
+    @SuppressFBWarnings(value = "NP_BOOLEAN_RETURN_NULL", justification = "Internal use tagged with @Nullable")
+    private static @Nullable Boolean substatementEffectiveConfig(
+            final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+        for (EffectiveStatement<?, ?> stmt : substatements) {
+            if (stmt instanceof DataSchemaNode) {
+                final Optional<Boolean> opt = ((DataSchemaNode) stmt).effectiveConfig();
+                if (opt.isPresent()) {
+                    return opt.orElseThrow();
+                }
+            }
+        }
+        return null;
+    }
+}
index 7e1c6b5886193f0201ab2cabaafb1d38690d90da..774bdab0c3a0324cb490f0586d5b3835364e1aa7 100644 (file)
@@ -81,7 +81,7 @@ abstract class AbstractChoiceStatementSupport
         final int flags = new FlagsBuilder()
                 .setHistory(stmt.history())
                 .setStatus(findFirstArgument(substatements, StatusEffectiveStatement.class, Status.CURRENT))
-                .setConfiguration(stmt.effectiveConfig().asLegacy())
+                .setConfiguration(stmt.effectiveConfig().asNullable())
                 .setMandatory(findFirstArgument(substatements, MandatoryEffectiveStatement.class, Boolean.FALSE))
                 .toFlags();
         try {
index e3340072bf4f29b8df05ec4543974c6410b890e9..95aca9f8f7e45cdc6347c51a2a0c4bf54ae09ef7 100644 (file)
@@ -51,7 +51,7 @@ abstract class AbstractContainerStatementSupport
         final int flags = new FlagsBuilder()
                 .setHistory(stmt.history())
                 .setStatus(findFirstArgument(substatements, StatusEffectiveStatement.class, Status.CURRENT))
-                .setConfiguration(stmt.effectiveConfig().asLegacy())
+                .setConfiguration(stmt.effectiveConfig().asNullable())
                 .setPresence(findFirstStatement(substatements, PresenceEffectiveStatement.class) != null)
                 .toFlags();
 
index bb0f464d9b7d0dda0f1de85996b43763d4558ff0..961d14f4ad940fce32fed3d1ecd40380a86a7bce 100644 (file)
@@ -93,7 +93,7 @@ public final class LeafStatementSupport extends BaseSchemaTreeStatementSupport<L
         final int flags = new FlagsBuilder()
                 .setHistory(stmt.history())
                 .setStatus(findFirstArgument(substatements, StatusEffectiveStatement.class, Status.CURRENT))
-                .setConfiguration(stmt.effectiveConfig().asLegacy())
+                .setConfiguration(stmt.effectiveConfig().asNullable())
                 .setMandatory(findFirstArgument(substatements, MandatoryEffectiveStatement.class, Boolean.FALSE))
                 .toFlags();
 
index be211b919e4d5f6e761abe1e7fd71ae09a9403ab..25addd12f26e01cae1ea90696f9fc99216c0bae0 100644 (file)
@@ -61,7 +61,7 @@ abstract class AbstractLeafListStatementSupport
         final int flags = new FlagsBuilder()
                 .setHistory(stmt.history())
                 .setStatus(findFirstArgument(substatements, StatusEffectiveStatement.class, Status.CURRENT))
-                .setConfiguration(stmt.effectiveConfig().asLegacy())
+                .setConfiguration(stmt.effectiveConfig().asNullable())
                 .setUserOrdered(findFirstArgument(substatements, OrderedByEffectiveStatement.class, Ordering.SYSTEM)
                     .equals(Ordering.USER))
                 .toFlags();
index 586991e5ca0b9d08e22eb568f056d7b8697f5549..04236ecc1d9c2531ca2035b214df04577aba97cc 100644 (file)
@@ -103,7 +103,7 @@ abstract class AbstractListStatementSupport extends
         final int flags = new FlagsBuilder()
                 .setHistory(stmt.history())
                 .setStatus(findFirstArgument(substatements, StatusEffectiveStatement.class, Status.CURRENT))
-                .setConfiguration(configuration.asLegacy())
+                .setConfiguration(configuration.asNullable())
                 .setUserOrdered(findFirstArgument(substatements, OrderedByEffectiveStatement.class, Ordering.SYSTEM)
                     .equals(Ordering.USER))
                 .toFlags();
index 2f959bb5b62e133a8741dbc8beb981c7bb30394b..e4a81c1bc89421762c2f7b98d1b878ffcc87841a 100644 (file)
@@ -8,10 +8,10 @@
 package org.opendaylight.yangtools.yang.stmt;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
+import java.util.Optional;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.Revision;
@@ -33,7 +33,7 @@ public class Bug9244Test {
         final ContainerSchemaNode barCont = (ContainerSchemaNode) barModule.getDataChildByName(
                 QName.create(barModule.getQNameModule(), "bar-cont"));
         assertNotNull(barCont);
-        assertFalse(barCont.isConfiguration());
+        assertEquals(Optional.of(Boolean.FALSE), barCont.effectiveConfig());
 
         final LeafListSchemaNode barLeafList = (LeafListSchemaNode) barModule.getDataChildByName(
                 QName.create(barModule.getQNameModule(), "bar-leaf-list"));
index db083b8fe1adfe7bd9a9155ca9d0c97665cd3634..7b321752c35dacaf9655a5b2834104c74eeea6de 100644 (file)
@@ -7,12 +7,12 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertThrows;
-import static org.junit.Assert.assertTrue;
 
 import java.net.URI;
+import java.util.Optional;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -27,6 +27,9 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 
 public class CaseStmtTest {
+    private static final Optional<Boolean> OPT_FALSE = Optional.of(Boolean.FALSE);
+    private static final Optional<Boolean> OPT_TRUE = Optional.of(Boolean.TRUE);
+
     private SchemaContext schema;
     private Module rootFoo;
     private Module rootBar;
@@ -55,474 +58,474 @@ public class CaseStmtTest {
     public void caseTest() {
         tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-fff"));
         assertNotNull(tempChild);
-        assertFalse(tempChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempChild.effectiveConfig());
         tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
         assertNotNull(tempSecondChild);
-        assertFalse(tempSecondChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
         tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
         assertNotNull(tempChoice);
-        assertFalse(tempChoice.isConfiguration());
+        assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
         tempThirdChild = tempChoice.getChildNodes().iterator().next();
         assertNotNull(tempThirdChild);
-        assertFalse(tempThirdChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
 
         tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-ffn"));
         assertNotNull(tempChild);
-        assertFalse(tempChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempChild.effectiveConfig());
         tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
         assertNotNull(tempSecondChild);
-        assertFalse(tempSecondChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
         tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
         assertNotNull(tempChoice);
-        assertFalse(tempChoice.isConfiguration());
+        assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
         tempThirdChild = tempChoice.getChildNodes().iterator().next();
         assertNotNull(tempThirdChild);
-        assertFalse(tempThirdChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
 
         tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-fnf"));
         assertNotNull(tempChild);
-        assertFalse(tempChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempChild.effectiveConfig());
         tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
         assertNotNull(tempSecondChild);
-        assertFalse(tempSecondChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
         tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
         assertNotNull(tempChoice);
-        assertFalse(tempChoice.isConfiguration());
+        assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
         tempThirdChild = tempChoice.getChildNodes().iterator().next();
         assertNotNull(tempThirdChild);
-        assertFalse(tempThirdChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
 
         tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-nff"));
         assertNotNull(tempChild);
-        assertTrue(tempChild.isConfiguration());
+        assertEquals(Optional.empty(), tempChild.effectiveConfig());
         tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
         assertNotNull(tempSecondChild);
-        assertFalse(tempSecondChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
         tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
         assertNotNull(tempChoice);
-        assertFalse(tempChoice.isConfiguration());
+        assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
         tempThirdChild = tempChoice.getChildNodes().iterator().next();
         assertNotNull(tempThirdChild);
-        assertFalse(tempThirdChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
 
         tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-nnf"));
         assertNotNull(tempChild);
-        assertTrue(tempChild.isConfiguration());
+        assertEquals(Optional.empty(), tempChild.effectiveConfig());
         tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
         assertNotNull(tempSecondChild);
-        assertTrue(tempSecondChild.isConfiguration());
+        assertEquals(Optional.empty(), tempSecondChild.effectiveConfig());
         tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
         assertNotNull(tempChoice);
-        assertFalse(tempChoice.isConfiguration());
+        assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
         tempThirdChild = tempChoice.getChildNodes().iterator().next();
         assertNotNull(tempThirdChild);
-        assertFalse(tempThirdChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
 
         tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-nfn"));
         assertNotNull(tempChild);
-        assertTrue(tempChild.isConfiguration());
+        assertEquals(Optional.empty(), tempChild.effectiveConfig());
         tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
         assertNotNull(tempSecondChild);
-        assertFalse(tempSecondChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
         tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
         assertNotNull(tempChoice);
-        assertFalse(tempChoice.isConfiguration());
+        assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
         tempThirdChild = tempChoice.getChildNodes().iterator().next();
         assertNotNull(tempThirdChild);
-        assertFalse(tempThirdChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
 
         tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-fnn"));
         assertNotNull(tempChild);
-        assertFalse(tempChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempChild.effectiveConfig());
         tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
         assertNotNull(tempSecondChild);
-        assertFalse(tempSecondChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
         tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
         assertNotNull(tempChoice);
-        assertFalse(tempChoice.isConfiguration());
+        assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
         tempThirdChild = tempChoice.getChildNodes().iterator().next();
         assertNotNull(tempThirdChild);
-        assertFalse(tempThirdChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
 
         tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-ttt"));
         assertNotNull(tempChild);
-        assertTrue(tempChild.isConfiguration());
+        assertEquals(OPT_TRUE, tempChild.effectiveConfig());
         tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
         assertNotNull(tempSecondChild);
-        assertTrue(tempSecondChild.isConfiguration());
+        assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
         tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
         assertNotNull(tempChoice);
-        assertTrue(tempChoice.isConfiguration());
+        assertEquals(OPT_TRUE, tempChoice.effectiveConfig());
         tempThirdChild = tempChoice.getChildNodes().iterator().next();
         assertNotNull(tempThirdChild);
-        assertTrue(tempThirdChild.isConfiguration());
+        assertEquals(OPT_TRUE, tempThirdChild.effectiveConfig());
 
         tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-ttn"));
         assertNotNull(tempChild);
-        assertTrue(tempChild.isConfiguration());
+        assertEquals(OPT_TRUE, tempChild.effectiveConfig());
         tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
         assertNotNull(tempSecondChild);
-        assertTrue(tempSecondChild.isConfiguration());
+        assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
         tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
         assertNotNull(tempChoice);
-        assertTrue(tempChoice.isConfiguration());
+        assertEquals(OPT_TRUE, tempChoice.effectiveConfig());
         tempThirdChild = tempChoice.getChildNodes().iterator().next();
         assertNotNull(tempThirdChild);
-        assertTrue(tempThirdChild.isConfiguration());
+        assertEquals(OPT_TRUE, tempThirdChild.effectiveConfig());
 
         tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-tnt"));
         assertNotNull(tempChild);
-        assertTrue(tempChild.isConfiguration());
+        assertEquals(OPT_TRUE, tempChild.effectiveConfig());
         tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
         assertNotNull(tempSecondChild);
-        assertTrue(tempSecondChild.isConfiguration());
+        assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
         tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
         assertNotNull(tempChoice);
-        assertTrue(tempChoice.isConfiguration());
+        assertEquals(OPT_TRUE, tempChoice.effectiveConfig());
         tempThirdChild = tempChoice.getChildNodes().iterator().next();
         assertNotNull(tempThirdChild);
-        assertTrue(tempThirdChild.isConfiguration());
+        assertEquals(OPT_TRUE, tempThirdChild.effectiveConfig());
 
         tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-ntt"));
         assertNotNull(tempChild);
-        assertTrue(tempChild.isConfiguration());
+        assertEquals(Optional.empty(), tempChild.effectiveConfig());
         tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
         assertNotNull(tempSecondChild);
-        assertTrue(tempSecondChild.isConfiguration());
+        assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
         tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
         assertNotNull(tempChoice);
-        assertTrue(tempChoice.isConfiguration());
+        assertEquals(OPT_TRUE, tempChoice.effectiveConfig());
         tempThirdChild = tempChoice.getChildNodes().iterator().next();
         assertNotNull(tempThirdChild);
-        assertTrue(tempThirdChild.isConfiguration());
+        assertEquals(OPT_TRUE, tempThirdChild.effectiveConfig());
 
         tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-nnt"));
         assertNotNull(tempChild);
-        assertTrue(tempChild.isConfiguration());
+        assertEquals(Optional.empty(), tempChild.effectiveConfig());
         tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
         assertNotNull(tempSecondChild);
-        assertTrue(tempSecondChild.isConfiguration());
+        assertEquals(Optional.empty(), tempSecondChild.effectiveConfig());
         tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
         assertNotNull(tempChoice);
-        assertTrue(tempChoice.isConfiguration());
+        assertEquals(OPT_TRUE, tempChoice.effectiveConfig());
         tempThirdChild = tempChoice.getChildNodes().iterator().next();
         assertNotNull(tempThirdChild);
-        assertTrue(tempThirdChild.isConfiguration());
+        assertEquals(OPT_TRUE, tempThirdChild.effectiveConfig());
 
         tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-ntn"));
         assertNotNull(tempChild);
-        assertTrue(tempChild.isConfiguration());
+        assertEquals(Optional.empty(), tempChild.effectiveConfig());
         tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
         assertNotNull(tempSecondChild);
-        assertTrue(tempSecondChild.isConfiguration());
+        assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
         tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
         assertNotNull(tempChoice);
-        assertTrue(tempChoice.isConfiguration());
+        assertEquals(OPT_TRUE, tempChoice.effectiveConfig());
         tempThirdChild = tempChoice.getChildNodes().iterator().next();
         assertNotNull(tempThirdChild);
-        assertTrue(tempThirdChild.isConfiguration());
+        assertEquals(OPT_TRUE, tempThirdChild.effectiveConfig());
 
         tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-tnn"));
         assertNotNull(tempChild);
-        assertTrue(tempChild.isConfiguration());
+        assertEquals(OPT_TRUE, tempChild.effectiveConfig());
         tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
         assertNotNull(tempSecondChild);
-        assertTrue(tempSecondChild.isConfiguration());
+        assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
         tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
         assertNotNull(tempChoice);
-        assertTrue(tempChoice.isConfiguration());
+        assertEquals(OPT_TRUE, tempChoice.effectiveConfig());
         tempThirdChild = tempChoice.getChildNodes().iterator().next();
         assertNotNull(tempThirdChild);
-        assertTrue(tempThirdChild.isConfiguration());
+        assertEquals(OPT_TRUE, tempThirdChild.effectiveConfig());
 
         tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-tff"));
         assertNotNull(tempChild);
-        assertTrue(tempChild.isConfiguration());
+        assertEquals(OPT_TRUE, tempChild.effectiveConfig());
         tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
         assertNotNull(tempSecondChild);
-        assertFalse(tempSecondChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
         tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
         assertNotNull(tempChoice);
-        assertFalse(tempChoice.isConfiguration());
+        assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
         tempThirdChild = tempChoice.getChildNodes().iterator().next();
         assertNotNull(tempThirdChild);
-        assertFalse(tempThirdChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
 
         tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-tnf"));
         assertNotNull(tempChild);
-        assertTrue(tempChild.isConfiguration());
+        assertEquals(OPT_TRUE, tempChild.effectiveConfig());
         tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
         assertNotNull(tempSecondChild);
-        assertTrue(tempSecondChild.isConfiguration());
+        assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
         tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
         assertNotNull(tempChoice);
-        assertFalse(tempChoice.isConfiguration());
+        assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
         tempThirdChild = tempChoice.getChildNodes().iterator().next();
         assertNotNull(tempThirdChild);
-        assertFalse(tempThirdChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
 
         tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-tfn"));
         assertNotNull(tempChild);
-        assertTrue(tempChild.isConfiguration());
+        assertEquals(OPT_TRUE, tempChild.effectiveConfig());
         tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
         assertNotNull(tempSecondChild);
-        assertFalse(tempSecondChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
         tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
         assertNotNull(tempChoice);
-        assertFalse(tempChoice.isConfiguration());
+        assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
         tempThirdChild = tempChoice.getChildNodes().iterator().next();
         assertNotNull(tempThirdChild);
-        assertFalse(tempThirdChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
 
         tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-ntf"));
         assertNotNull(tempChild);
-        assertTrue(tempChild.isConfiguration());
+        assertEquals(Optional.empty(), tempChild.effectiveConfig());
         tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
         assertNotNull(tempSecondChild);
-        assertTrue(tempSecondChild.isConfiguration());
+        assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
         tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
         assertNotNull(tempChoice);
-        assertFalse(tempChoice.isConfiguration());
+        assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
         tempThirdChild = tempChoice.getChildNodes().iterator().next();
         assertNotNull(tempThirdChild);
-        assertFalse(tempThirdChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
     }
 
     @Test
     public void shortCaseTest() {
         tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-fff"));
         assertNotNull(tempChild);
-        assertFalse(tempChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempChild.effectiveConfig());
         tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
         assertNotNull(tempSecondChild);
-        assertFalse(tempSecondChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
         tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
         assertNotNull(tempChoice);
-        assertFalse(tempChoice.isConfiguration());
+        assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
         tempThirdChild = tempChoice.getChildNodes().iterator().next();
         assertNotNull(tempThirdChild);
-        assertFalse(tempThirdChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
 
         tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-ffn"));
         assertNotNull(tempChild);
-        assertFalse(tempChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempChild.effectiveConfig());
         tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
         assertNotNull(tempSecondChild);
-        assertFalse(tempSecondChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
         tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
         assertNotNull(tempChoice);
-        assertFalse(tempChoice.isConfiguration());
+        assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
         tempThirdChild = tempChoice.getChildNodes().iterator().next();
         assertNotNull(tempThirdChild);
-        assertFalse(tempThirdChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
 
         tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-fnf"));
         assertNotNull(tempChild);
-        assertFalse(tempChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempChild.effectiveConfig());
         tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
         assertNotNull(tempSecondChild);
-        assertFalse(tempSecondChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
         tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
         assertNotNull(tempChoice);
-        assertFalse(tempChoice.isConfiguration());
+        assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
         tempThirdChild = tempChoice.getChildNodes().iterator().next();
         assertNotNull(tempThirdChild);
-        assertFalse(tempThirdChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
 
         tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-nff"));
         assertNotNull(tempChild);
-        assertTrue(tempChild.isConfiguration());
+        assertEquals(Optional.empty(), tempChild.effectiveConfig());
         tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
         assertNotNull(tempSecondChild);
-        assertFalse(tempSecondChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
         tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
         assertNotNull(tempChoice);
-        assertFalse(tempChoice.isConfiguration());
+        assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
         tempThirdChild = tempChoice.getChildNodes().iterator().next();
         assertNotNull(tempThirdChild);
-        assertFalse(tempThirdChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
 
         tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-nnf"));
         assertNotNull(tempChild);
-        assertTrue(tempChild.isConfiguration());
+        assertEquals(Optional.empty(), tempChild.effectiveConfig());
         tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
         assertNotNull(tempSecondChild);
-        assertTrue(tempSecondChild.isConfiguration());
+        assertEquals(Optional.empty(), tempSecondChild.effectiveConfig());
         tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
         assertNotNull(tempChoice);
-        assertFalse(tempChoice.isConfiguration());
+        assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
         tempThirdChild = tempChoice.getChildNodes().iterator().next();
         assertNotNull(tempThirdChild);
-        assertFalse(tempThirdChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
 
         tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-nfn"));
         assertNotNull(tempChild);
-        assertTrue(tempChild.isConfiguration());
+        assertEquals(Optional.empty(), tempChild.effectiveConfig());
         tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
         assertNotNull(tempSecondChild);
-        assertFalse(tempSecondChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
         tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
         assertNotNull(tempChoice);
-        assertFalse(tempChoice.isConfiguration());
+        assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
         tempThirdChild = tempChoice.getChildNodes().iterator().next();
         assertNotNull(tempThirdChild);
-        assertFalse(tempThirdChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
 
         tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-fnn"));
         assertNotNull(tempChild);
-        assertFalse(tempChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempChild.effectiveConfig());
         tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
         assertNotNull(tempSecondChild);
-        assertFalse(tempSecondChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
         tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
         assertNotNull(tempChoice);
-        assertFalse(tempChoice.isConfiguration());
+        assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
         tempThirdChild = tempChoice.getChildNodes().iterator().next();
         assertNotNull(tempThirdChild);
-        assertFalse(tempThirdChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
 
         tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-ttt"));
         assertNotNull(tempChild);
-        assertTrue(tempChild.isConfiguration());
+        assertEquals(OPT_TRUE, tempChild.effectiveConfig());
         tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
         assertNotNull(tempSecondChild);
-        assertTrue(tempSecondChild.isConfiguration());
+        assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
         tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
         assertNotNull(tempChoice);
-        assertTrue(tempChoice.isConfiguration());
+        assertEquals(OPT_TRUE, tempChoice.effectiveConfig());
         tempThirdChild = tempChoice.getChildNodes().iterator().next();
         assertNotNull(tempThirdChild);
-        assertTrue(tempThirdChild.isConfiguration());
+        assertEquals(OPT_TRUE, tempThirdChild.effectiveConfig());
 
         tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-ttn"));
         assertNotNull(tempChild);
-        assertTrue(tempChild.isConfiguration());
+        assertEquals(OPT_TRUE, tempChild.effectiveConfig());
         tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
         assertNotNull(tempSecondChild);
-        assertTrue(tempSecondChild.isConfiguration());
+        assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
         tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
         assertNotNull(tempChoice);
-        assertTrue(tempChoice.isConfiguration());
+        assertEquals(OPT_TRUE, tempChoice.effectiveConfig());
         tempThirdChild = tempChoice.getChildNodes().iterator().next();
         assertNotNull(tempThirdChild);
-        assertTrue(tempThirdChild.isConfiguration());
+        assertEquals(OPT_TRUE, tempThirdChild.effectiveConfig());
 
         tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-tnt"));
         assertNotNull(tempChild);
-        assertTrue(tempChild.isConfiguration());
+        assertEquals(OPT_TRUE, tempChild.effectiveConfig());
         tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
         assertNotNull(tempSecondChild);
-        assertTrue(tempSecondChild.isConfiguration());
+        assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
         tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
         assertNotNull(tempChoice);
-        assertTrue(tempChoice.isConfiguration());
+        assertEquals(OPT_TRUE, tempChoice.effectiveConfig());
         tempThirdChild = tempChoice.getChildNodes().iterator().next();
         assertNotNull(tempThirdChild);
-        assertTrue(tempThirdChild.isConfiguration());
+        assertEquals(OPT_TRUE, tempThirdChild.effectiveConfig());
 
         tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-ntt"));
         assertNotNull(tempChild);
-        assertTrue(tempChild.isConfiguration());
+        assertEquals(Optional.empty(), tempChild.effectiveConfig());
         tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
         assertNotNull(tempSecondChild);
-        assertTrue(tempSecondChild.isConfiguration());
+        assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
         tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
         assertNotNull(tempChoice);
-        assertTrue(tempChoice.isConfiguration());
+        assertEquals(OPT_TRUE, tempChoice.effectiveConfig());
         tempThirdChild = tempChoice.getChildNodes().iterator().next();
         assertNotNull(tempThirdChild);
-        assertTrue(tempThirdChild.isConfiguration());
+        assertEquals(OPT_TRUE, tempThirdChild.effectiveConfig());
 
         tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-nnt"));
         assertNotNull(tempChild);
-        assertTrue(tempChild.isConfiguration());
+        assertEquals(Optional.empty(), tempChild.effectiveConfig());
         tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
         assertNotNull(tempSecondChild);
-        assertTrue(tempSecondChild.isConfiguration());
+        assertEquals(Optional.empty(), tempSecondChild.effectiveConfig());
         tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
         assertNotNull(tempChoice);
-        assertTrue(tempChoice.isConfiguration());
+        assertEquals(OPT_TRUE, tempChoice.effectiveConfig());
         tempThirdChild = tempChoice.getChildNodes().iterator().next();
         assertNotNull(tempThirdChild);
-        assertTrue(tempThirdChild.isConfiguration());
+        assertEquals(OPT_TRUE, tempThirdChild.effectiveConfig());
 
         tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-ntn"));
         assertNotNull(tempChild);
-        assertTrue(tempChild.isConfiguration());
+        assertEquals(Optional.empty(), tempChild.effectiveConfig());
         tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
         assertNotNull(tempSecondChild);
-        assertTrue(tempSecondChild.isConfiguration());
+        assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
         tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
         assertNotNull(tempChoice);
-        assertTrue(tempChoice.isConfiguration());
+        assertEquals(OPT_TRUE, tempChoice.effectiveConfig());
         tempThirdChild = tempChoice.getChildNodes().iterator().next();
         assertNotNull(tempThirdChild);
-        assertTrue(tempThirdChild.isConfiguration());
+        assertEquals(OPT_TRUE, tempThirdChild.effectiveConfig());
 
         tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-tnn"));
         assertNotNull(tempChild);
-        assertTrue(tempChild.isConfiguration());
+        assertEquals(OPT_TRUE, tempChild.effectiveConfig());
         tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
         assertNotNull(tempSecondChild);
-        assertTrue(tempSecondChild.isConfiguration());
+        assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
         tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
         assertNotNull(tempChoice);
-        assertTrue(tempChoice.isConfiguration());
+        assertEquals(OPT_TRUE, tempChoice.effectiveConfig());
         tempThirdChild = tempChoice.getChildNodes().iterator().next();
         assertNotNull(tempThirdChild);
-        assertTrue(tempThirdChild.isConfiguration());
+        assertEquals(OPT_TRUE, tempThirdChild.effectiveConfig());
 
         tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-tff"));
         assertNotNull(tempChild);
-        assertTrue(tempChild.isConfiguration());
+        assertEquals(OPT_TRUE, tempChild.effectiveConfig());
         tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
         assertNotNull(tempSecondChild);
-        assertFalse(tempSecondChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
         tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
         assertNotNull(tempChoice);
-        assertFalse(tempChoice.isConfiguration());
+        assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
         tempThirdChild = tempChoice.getChildNodes().iterator().next();
         assertNotNull(tempThirdChild);
-        assertFalse(tempThirdChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
 
         tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-tnf"));
         assertNotNull(tempChild);
-        assertTrue(tempChild.isConfiguration());
+        assertEquals(OPT_TRUE, tempChild.effectiveConfig());
         tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
         assertNotNull(tempSecondChild);
-        assertTrue(tempSecondChild.isConfiguration());
+        assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
         tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
         assertNotNull(tempChoice);
-        assertFalse(tempChoice.isConfiguration());
+        assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
         tempThirdChild = tempChoice.getChildNodes().iterator().next();
         assertNotNull(tempThirdChild);
-        assertFalse(tempThirdChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
 
         tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-tfn"));
         assertNotNull(tempChild);
-        assertTrue(tempChild.isConfiguration());
+        assertEquals(OPT_TRUE, tempChild.effectiveConfig());
         tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
         assertNotNull(tempSecondChild);
-        assertFalse(tempSecondChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
         tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
         assertNotNull(tempChoice);
-        assertFalse(tempChoice.isConfiguration());
+        assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
         tempThirdChild = tempChoice.getChildNodes().iterator().next();
         assertNotNull(tempThirdChild);
-        assertFalse(tempThirdChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
 
         tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-ntf"));
         assertNotNull(tempChild);
-        assertTrue(tempChild.isConfiguration());
+        assertEquals(Optional.empty(), tempChild.effectiveConfig());
         tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
         assertNotNull(tempSecondChild);
-        assertTrue(tempSecondChild.isConfiguration());
+        assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
         tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
         assertNotNull(tempChoice);
-        assertFalse(tempChoice.isConfiguration());
+        assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
         tempThirdChild = tempChoice.getChildNodes().iterator().next();
         assertNotNull(tempThirdChild);
-        assertFalse(tempThirdChild.isConfiguration());
+        assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
     }
 
     @Test
index 77170fe94b9463d4e6453940b14ea8b43de9608e..e87e20a14b5684ea502ac7f4b102f98e760f3774 100644 (file)
@@ -86,7 +86,7 @@ public class DeviationResolutionTest {
                 QName.create(barModule.getQNameModule(), "my-leaf-list"));
         assertNotNull(myLeafList);
 
-        assertFalse(myLeafList.isConfiguration());
+        assertEquals(Optional.of(Boolean.FALSE), myLeafList.effectiveConfig());
         assertEquals(3, myLeafList.getDefaults().size());
 
         final ElementCountConstraint constraint = myLeafList.getElementCountConstraint().get();
@@ -151,7 +151,7 @@ public class DeviationResolutionTest {
         final ElementCountConstraint constraint = myLeafList.getElementCountConstraint().get();
         assertEquals((Object) 6, constraint.getMaxElements());
         assertEquals((Object) 3, constraint.getMinElements());
-        assertTrue(myLeafList.isConfiguration());
+        assertEquals(Optional.of(Boolean.TRUE), myLeafList.effectiveConfig());
 
         final ChoiceSchemaNode myChoice = (ChoiceSchemaNode) barModule.getDataChildByName(
                 QName.create(barModule.getQNameModule(), "my-choice"));
index d202952d8855a56345002b5b9af667ba1c61cae1..ff484c63f9b9a6d60c9179822c1cefdcb9021c79 100644 (file)
@@ -18,6 +18,7 @@ import java.net.URI;
 import java.net.URISyntaxException;
 import java.text.ParseException;
 import java.util.Collection;
+import java.util.Optional;
 import java.util.Set;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -73,7 +74,7 @@ public class EffectiveSchemaContextTest {
 
         assertFalse(schemaContext.isAugmenting());
         assertFalse(schemaContext.isAddedByUses());
-        assertFalse(schemaContext.isConfiguration());
+        assertEquals(Optional.empty(), schemaContext.effectiveConfig());
         assertFalse(schemaContext.getWhenCondition().isPresent());
         assertEquals(0, schemaContext.getMustConstraints().size());
         assertFalse(schemaContext.getDescription().isPresent());
index ef6dcd8758647e3b7452aac3a034beae254f24b9..83dbcb7e88d5e421db9c1670028dee61dbf4ada9 100644 (file)
@@ -13,7 +13,7 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
 
-import java.util.Collection;
+import com.google.common.collect.Iterables;
 import java.util.Optional;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -22,7 +22,6 @@ import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ElementCountConstraint;
 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
@@ -39,13 +38,7 @@ public class EffectiveUsesRefineAndConstraintsTest {
                 .buildEffective();
         assertNotNull(result);
 
-        Collection<? extends Module> modules = result.getModules();
-        assertNotNull(modules);
-        assertEquals(1, modules.size());
-
-        Module module = modules.iterator().next();
-
-        final QNameModule qnameModule = module.getQNameModule();
+        final QNameModule qnameModule = Iterables.getOnlyElement(result.getModules()).getQNameModule();
         final QName rootContainer = QName.create(qnameModule, "root-container");
         final QName grp1 = QName.create(qnameModule, "grp-1");
 
@@ -82,7 +75,7 @@ public class EffectiveUsesRefineAndConstraintsTest {
         ContainerSchemaNode containerSchemaNode = (ContainerSchemaNode) containerInContainerNode;
         assertFalse(containerSchemaNode.getReference().isPresent());
         assertFalse(containerSchemaNode.getDescription().isPresent());
-        assertTrue(containerSchemaNode.isConfiguration());
+        assertEquals(Optional.empty(), containerSchemaNode.effectiveConfig());
         assertFalse(containerSchemaNode.isPresenceContainer());
 
         assertEquals(0, containerSchemaNode.getMustConstraints().size());
@@ -103,7 +96,7 @@ public class EffectiveUsesRefineAndConstraintsTest {
         ListSchemaNode listSchemaNode = (ListSchemaNode) listInContainerNode;
         assertEquals(Optional.of("original reference"), listSchemaNode.getReference());
         assertEquals(Optional.of("original description"), listSchemaNode.getDescription());
-        assertFalse(listSchemaNode.isConfiguration());
+        assertEquals(Optional.of(Boolean.FALSE), listSchemaNode.effectiveConfig());
 
         ElementCountConstraint listConstraints = listSchemaNode.getElementCountConstraint().get();
         assertEquals((Object) 10, listConstraints.getMinElements());
@@ -118,7 +111,7 @@ public class EffectiveUsesRefineAndConstraintsTest {
         ContainerSchemaNode containerSchemaNode = (ContainerSchemaNode) containerInContainerNode;
         assertEquals(Optional.of("new reference"), containerSchemaNode.getReference());
         assertEquals(Optional.of("new description"), containerSchemaNode.getDescription());
-        assertTrue(containerSchemaNode.isConfiguration());
+        assertEquals(Optional.of(Boolean.TRUE), containerSchemaNode.effectiveConfig());
         assertTrue(containerSchemaNode.isPresenceContainer());
         assertEquals(1, containerSchemaNode.getMustConstraints().size());
     }
@@ -138,7 +131,7 @@ public class EffectiveUsesRefineAndConstraintsTest {
         ListSchemaNode listSchemaNode = (ListSchemaNode) listInContainerNode;
         assertEquals(Optional.of("new reference"), listSchemaNode.getReference());
         assertEquals(Optional.of("new description"), listSchemaNode.getDescription());
-        assertTrue(listSchemaNode.isConfiguration());
+        assertEquals(Optional.of(Boolean.TRUE), listSchemaNode.effectiveConfig());
 
         ElementCountConstraint listConstraints = listSchemaNode.getElementCountConstraint().get();
         assertEquals((Object) 5, listConstraints.getMinElements());
index 75e53e5a5e63d19579d899faf339c7bb353a1054..86727671464b4f6b732240a94d0f3867605b5902 100644 (file)
@@ -101,7 +101,7 @@ public class GroupingTest {
         assertNotNull(refineLeaf);
         assertEquals(Optional.of("IP address of target node"), refineLeaf.getDescription());
         assertEquals(Optional.of("address reference added by refine"), refineLeaf.getReference());
-        assertFalse(refineLeaf.isConfiguration());
+        assertEquals(Optional.of(Boolean.FALSE), refineLeaf.effectiveConfig());
         assertFalse(refineLeaf.isMandatory());
         final Collection<? extends MustDefinition> leafMustConstraints = refineLeaf.getMustConstraints();
         assertEquals(1, leafMustConstraints.size());
@@ -115,13 +115,13 @@ public class GroupingTest {
         assertTrue(mustConstraints.isEmpty());
         assertEquals(Optional.of("description of port defined by refine"), refineContainer.getDescription());
         assertEquals(Optional.of("port reference added by refine"), refineContainer.getReference());
-        assertFalse(refineContainer.isConfiguration());
+        assertEquals(Optional.of(Boolean.FALSE), refineContainer.effectiveConfig());
         assertTrue(refineContainer.isPresenceContainer());
 
         // list addresses
         assertEquals(Optional.of("description of addresses defined by refine"), refineList.getDescription());
         assertEquals(Optional.of("addresses reference added by refine"), refineList.getReference());
-        assertFalse(refineList.isConfiguration());
+        assertEquals(Optional.of(Boolean.FALSE), refineList.effectiveConfig());
 
         final ElementCountConstraint constraint = refineList.getElementCountConstraint().get();
         assertEquals((Object) 2, constraint.getMinElements());
@@ -196,7 +196,7 @@ public class GroupingTest {
         assertEquals(Optional.of("1.2.3.4"), address_u.getType().getDefaultValue());
         assertEquals(Optional.of("IP address of target node"), address_u.getDescription());
         assertEquals(Optional.of("address reference added by refine"), address_u.getReference());
-        assertFalse(address_u.isConfiguration());
+        assertEquals(Optional.of(Boolean.FALSE), address_u.effectiveConfig());
         assertTrue(address_u.isAddedByUses());
         assertFalse(address_u.isMandatory());
 
@@ -207,7 +207,7 @@ public class GroupingTest {
         assertEquals(Optional.empty(), address_g.getType().getDefaultValue());
         assertEquals(Optional.of("Target IP address"), address_g.getDescription());
         assertFalse(address_g.getReference().isPresent());
-        assertTrue(address_g.isConfiguration());
+        assertEquals(Optional.empty(), address_g.effectiveConfig());
         assertFalse(address_u.equals(address_g));
         assertTrue(address_g.isMandatory());
         assertEquals(address_g, SchemaNodeUtils.getRootOriginalIfPossible(address_u));
@@ -314,7 +314,7 @@ public class GroupingTest {
         assertEquals(Optional.empty(), address_u.getType().getDefaultValue());
         assertEquals(Optional.of("Target IP address"), address_u.getDescription());
         assertFalse(address_u.getReference().isPresent());
-        assertTrue(address_u.isConfiguration());
+        assertEquals(Optional.empty(), address_u.effectiveConfig());
         assertTrue(address_u.isAddedByUses());
 
         final LeafSchemaNode address_g = (LeafSchemaNode) grouping.getDataChildByName(QName.create(
@@ -324,7 +324,7 @@ public class GroupingTest {
         assertEquals(Optional.empty(), address_g.getType().getDefaultValue());
         assertEquals(Optional.of("Target IP address"), address_g.getDescription());
         assertFalse(address_g.getReference().isPresent());
-        assertTrue(address_g.isConfiguration());
+        assertEquals(Optional.empty(), address_g.effectiveConfig());
         assertFalse(address_u.equals(address_g));
         assertEquals(address_g, SchemaNodeUtils.getRootOriginalIfPossible(address_u));
 
index 2a4c44ca761e2028adb587176f9b09f4ff0680ff..32f79bbb940c1cc746263a6782ac0dfb0b4e2912 100644 (file)
@@ -43,7 +43,7 @@ public class ListTest {
         assertNotNull(list);
 
         assertTrue(list.isUserOrdered());
-        assertTrue(list.isConfiguration());
+        assertEquals(Optional.of(Boolean.TRUE), list.effectiveConfig());
         final List<QName> keys = list.getKeyDefinition();
         assertEquals(2, keys.size());
 
index d475d517968e4151402b4768d0edffe0a4efc666..9b8e303b9300f65a64d1c8916216933376fecf0d 100644 (file)
@@ -7,9 +7,10 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
+import java.util.Optional;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
@@ -25,18 +26,18 @@ public class YT911Test {
     public void testAugmentationConfig() throws Exception {
         final SchemaContext context = StmtTestUtils.parseYangSource("/bugs/YT911/foo.yang");
         final DataSchemaNode foo = context.findDataChildByName(FOO).get();
-        assertFalse(foo.isConfiguration());
+        assertEquals(Optional.of(Boolean.FALSE), foo.effectiveConfig());
         assertTrue(foo instanceof ContainerSchemaNode);
 
         // Instantiated node
         final DataSchemaNode bar = ((ContainerSchemaNode) foo).findDataTreeChild(BAR).get();
-        assertFalse(bar.isConfiguration());
+        assertEquals(Optional.of(Boolean.FALSE), bar.effectiveConfig());
         assertTrue(foo instanceof ContainerSchemaNode);
 
         // Original augmentation node
         final AugmentationSchemaNode aug = ((ContainerSchemaNode) foo).getAvailableAugmentations().iterator().next();
         final DataSchemaNode augBar = aug.findDataTreeChild(BAR).get();
-        assertTrue(augBar.isConfiguration());
+        assertEquals(Optional.empty(), augBar.effectiveConfig());
         assertTrue(foo instanceof ContainerSchemaNode);
     }
 }
index 64896a638d947c4d59b71be76234ed97fa034044..5f38ca5f7c2c17fb401fbd2f00b8cef194103b05 100644 (file)
@@ -69,7 +69,7 @@ public class YangParserSimpleTest {
         assertEquals(0, data.getUnknownSchemaNodes().size());
         // test DataSchemaNode args
         assertFalse(data.isAugmenting());
-        assertFalse(data.isConfiguration());
+        assertEquals(Optional.of(Boolean.FALSE), data.effectiveConfig());
 
         assertTrue(data.isMandatory());
         assertEquals("class != 'wheel'", data.getWhenCondition().orElseThrow().toString());
@@ -115,7 +115,7 @@ public class YangParserSimpleTest {
         assertEquals(0, anydata.getUnknownSchemaNodes().size());
         // test DataSchemaNode args
         assertFalse(anydata.isAugmenting());
-        assertFalse(anydata.isConfiguration());
+        assertEquals(Optional.of(Boolean.FALSE), anydata.effectiveConfig());
 
         assertTrue(anydata.isMandatory());
         assertTrue(anydata.getWhenCondition().isPresent());
@@ -157,7 +157,7 @@ public class YangParserSimpleTest {
         assertEquals(0, nodes.getUnknownSchemaNodes().size());
         // test DataSchemaNode args
         assertFalse(nodes.isAugmenting());
-        assertFalse(nodes.isConfiguration());
+        assertEquals(Optional.of(Boolean.FALSE), nodes.effectiveConfig());
 
         // constraints
         assertEquals("class != 'wheel'", nodes.getWhenCondition().orElseThrow().toString());
index 517e58fb733d464279379d124b81879a8743fa39..fbde7a56847720f60ab1f9135c9e87f3d9d14648 100644 (file)
@@ -133,7 +133,7 @@ public class YangParserTest {
         assertEquals(0, ifEntry.getUnknownSchemaNodes().size());
         // test DataSchemaNode args
         assertFalse(ifEntry.isAugmenting());
-        assertTrue(ifEntry.isConfiguration());
+        assertEquals(Optional.of(Boolean.TRUE), ifEntry.effectiveConfig());
         // :TODO augment to ifEntry have when condition and so in consequence
         // ifEntry should be a context node ?
         // assertNull(constraints.getWhenCondition());
index d10119b1e946c03a551d97da59644cabb1fe699b..795f8708c295a9d98d036c8e9591dcfadbf3fdfa 100644 (file)
@@ -246,7 +246,7 @@ public class YangParserWithContextTest {
         assertEquals("address", refineLeaf.getQName().getLocalName());
         assertEquals(Optional.of("description of address defined by refine"), refineLeaf.getDescription());
         assertEquals(Optional.of("address reference added by refine"), refineLeaf.getReference());
-        assertFalse(refineLeaf.isConfiguration());
+        assertEquals(Optional.of(Boolean.FALSE), refineLeaf.effectiveConfig());
         assertTrue(refineLeaf.isMandatory());
         final Collection<? extends MustDefinition> leafMustConstraints = refineLeaf.getMustConstraints();
         assertEquals(1, leafMustConstraints.size());
@@ -259,14 +259,14 @@ public class YangParserWithContextTest {
         assertTrue(mustConstraints.isEmpty());
         assertEquals(Optional.of("description of port defined by refine"), refineContainer.getDescription());
         assertEquals(Optional.of("port reference added by refine"), refineContainer.getReference());
-        assertFalse(refineContainer.isConfiguration());
+        assertEquals(Optional.of(Boolean.FALSE), refineContainer.effectiveConfig());
         assertTrue(refineContainer.isPresenceContainer());
 
         // list addresses
         assertNotNull(refineList);
         assertEquals(Optional.of("description of addresses defined by refine"), refineList.getDescription());
         assertEquals(Optional.of("addresses reference added by refine"), refineList.getReference());
-        assertFalse(refineList.isConfiguration());
+        assertEquals(Optional.of(Boolean.FALSE), refineList.effectiveConfig());
         final ElementCountConstraint constraint = refineList.getElementCountConstraint().get();
         assertEquals((Object) 2, constraint.getMinElements());
         assertEquals((Object) 12, constraint.getMaxElements());
index 0867cb9f53a8d11975fe17ceb16e3a2a550e9a15..818e35870122fa71d8c5f3eb2fd9badcd430b24c 100644 (file)
@@ -13,6 +13,7 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 import java.util.Iterator;
+import java.util.Optional;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.CaseSchemaNode;
@@ -37,7 +38,7 @@ public class YinFileChoiceStmtTest extends AbstractYinModulesTest {
 
         assertEquals("configuration", choice.getQName().getLocalName());
         assertTrue(choice.isMandatory());
-        assertTrue(choice.isConfiguration());
+        assertEquals(Optional.of(Boolean.TRUE), choice.effectiveConfig());
         assertEquals(1, choice.getCases().size());
 
         // this choice is augmented (see main-impl.yang.xml)
@@ -52,7 +53,7 @@ public class YinFileChoiceStmtTest extends AbstractYinModulesTest {
 
         assertEquals("state", choice.getQName().getLocalName());
         assertFalse(choice.isMandatory());
-        assertFalse(choice.isConfiguration());
+        assertEquals(Optional.of(Boolean.FALSE), choice.effectiveConfig());
         assertTrue(choice.getCases().isEmpty());
     }
 }
index 6b0b7d544b14362c787c442001540ab0869c4da1..db76b1cbdeefb5fb6ce339a0cfdf3b7a5912e0de 100644 (file)
@@ -78,23 +78,13 @@ public interface EffectiveStmtCtx extends CommonStmtCtx, StmtContextCompat, Immu
             }
 
             /**
-             * Return this value as a legacy boolean for use with {@link DataSchemaNode#isConfiguration()}.
+             * Return this value as a {@link Boolean} for use with {@link DataSchemaNode#effectiveConfig()}.
              *
-             * @return A simple boolean
-             * @deprecated This method is only for transition and should be eliminated once DataSchemaNode is fixed.
+             * @return A boolean or null
              */
-            @Deprecated
-            public boolean asLegacy() {
-                return config == null || config;
-            }
-
             public @Nullable Boolean asNullable() {
                 return config;
             }
-
-            public Optional<Boolean> asOptional() {
-                return Optional.ofNullable(config);
-            }
         }
 
         /**