From 1e9cce8bcaaffeecede6dd676c69265650ecdcab Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 4 Dec 2020 12:48:42 +0100 Subject: [PATCH] Add DataSchemaNode.effectiveConfig() 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 --- ...ngModeledAnyxmlEffectiveStatementImpl.java | 4 +- .../rfc8040/parser/YangDataExtensionTest.java | 7 +- .../YangModeledAnyXMLDeserializationTest.java | 4 +- .../tree/SchemaAwareApplyOperation.java | 2 +- .../yang/data/util/ContainerSchemaNodes.java | 4 +- .../yang/data/util/OperationAsContainer.java | 4 +- .../yang/model/api/DataSchemaNode.java | 21 +- .../yang/model/api/SchemaContext.java | 4 +- .../stmt/EffectiveStatementMixins.java | 41 ++- .../stmt/anydata/AnydataStatementSupport.java | 2 +- .../stmt/anyxml/AnyxmlStatementSupport.java | 2 +- .../case_/AbstractCaseStatementSupport.java | 42 ++- .../AbstractChoiceStatementSupport.java | 2 +- .../AbstractContainerStatementSupport.java | 2 +- .../stmt/leaf/LeafStatementSupport.java | 2 +- .../AbstractLeafListStatementSupport.java | 2 +- .../list/AbstractListStatementSupport.java | 2 +- .../yangtools/yang/stmt/Bug9244Test.java | 4 +- .../yangtools/yang/stmt/CaseStmtTest.java | 295 +++++++++--------- .../yang/stmt/DeviationResolutionTest.java | 4 +- .../yang/stmt/EffectiveSchemaContextTest.java | 3 +- ...EffectiveUsesRefineAndConstraintsTest.java | 19 +- .../yangtools/yang/stmt/GroupingTest.java | 14 +- .../yangtools/yang/stmt/ListTest.java | 2 +- .../yangtools/yang/stmt/YT911Test.java | 9 +- .../yang/stmt/YangParserSimpleTest.java | 6 +- .../yangtools/yang/stmt/YangParserTest.java | 2 +- .../yang/stmt/YangParserWithContextTest.java | 6 +- .../yang/stmt/yin/YinFileChoiceStmtTest.java | 5 +- .../parser/spi/meta/EffectiveStmtCtx.java | 14 +- 30 files changed, 293 insertions(+), 237 deletions(-) diff --git a/yang/odlext-parser-support/src/main/java/org/opendaylight/yangtools/odlext/parser/YangModeledAnyxmlEffectiveStatementImpl.java b/yang/odlext-parser-support/src/main/java/org/opendaylight/yangtools/odlext/parser/YangModeledAnyxmlEffectiveStatementImpl.java index b9090bef97..cc07e4cc5e 100644 --- a/yang/odlext-parser-support/src/main/java/org/opendaylight/yangtools/odlext/parser/YangModeledAnyxmlEffectiveStatementImpl.java +++ b/yang/odlext-parser-support/src/main/java/org/opendaylight/yangtools/odlext/parser/YangModeledAnyxmlEffectiveStatementImpl.java @@ -52,8 +52,8 @@ final class YangModeledAnyxmlEffectiveStatementImpl } @Override - public boolean isConfiguration() { - return delegateSchemaNode().isConfiguration(); + public Optional effectiveConfig() { + return delegateSchemaNode().effectiveConfig(); } @Override diff --git a/yang/rfc8040-parser-support/src/test/java/org/opendaylight/yangtools/rfc8040/parser/YangDataExtensionTest.java b/yang/rfc8040-parser-support/src/test/java/org/opendaylight/yangtools/rfc8040/parser/YangDataExtensionTest.java index 61a75b9345..6dd3a60904 100644 --- a/yang/rfc8040-parser-support/src/test/java/org/opendaylight/yangtools/rfc8040/parser/YangDataExtensionTest.java +++ b/yang/rfc8040-parser-support/src/test/java/org/opendaylight/yangtools/rfc8040/parser/YangDataExtensionTest.java @@ -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 diff --git a/yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/YangModeledAnyXMLDeserializationTest.java b/yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/YangModeledAnyXMLDeserializationTest.java index f0a21911b5..2ef94daa30 100644 --- a/yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/YangModeledAnyXMLDeserializationTest.java +++ b/yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/YangModeledAnyXMLDeserializationTest.java @@ -182,8 +182,8 @@ public class YangModeledAnyXMLDeserializationTest { } @Override - public boolean isConfiguration() { - return false; + public Optional effectiveConfig() { + return Optional.of(Boolean.FALSE); } @Override diff --git a/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/SchemaAwareApplyOperation.java b/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/SchemaAwareApplyOperation.java index bc7dd85056..c9ff42e2cd 100644 --- a/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/SchemaAwareApplyOperation.java +++ b/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/SchemaAwareApplyOperation.java @@ -315,6 +315,6 @@ abstract class SchemaAwareApplyOperation 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); } } diff --git a/yang/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/ContainerSchemaNodes.java b/yang/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/ContainerSchemaNodes.java index 8e44c535cb..337928f724 100644 --- a/yang/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/ContainerSchemaNodes.java +++ b/yang/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/ContainerSchemaNodes.java @@ -73,8 +73,8 @@ public final class ContainerSchemaNodes { } @Override - public boolean isConfiguration() { - return false; + public Optional effectiveConfig() { + return Optional.empty(); } @Override diff --git a/yang/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/OperationAsContainer.java b/yang/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/OperationAsContainer.java index 0b15424aae..0aa9b414d8 100644 --- a/yang/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/OperationAsContainer.java +++ b/yang/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/OperationAsContainer.java @@ -150,8 +150,8 @@ public class OperationAsContainer extends ForwardingObject implements ContainerL } @Override - public final boolean isConfiguration() { - return false; + public final Optional effectiveConfig() { + return Optional.empty(); } @Override diff --git a/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/DataSchemaNode.java b/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/DataSchemaNode.java index cf9e60fc95..f125231f74 100644 --- a/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/DataSchemaNode.java +++ b/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/DataSchemaNode.java @@ -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 true if the data represents configuration data, - * otherwise returns false. + * 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 true if the data represents configuration data, - * otherwise returns false + * @return Effective {@code config} value, or {@link Optional#empty()} not applicable. */ - boolean isConfiguration(); + Optional effectiveConfig(); } diff --git a/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/SchemaContext.java b/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/SchemaContext.java index 0e74f13f51..9198dde5b1 100644 --- a/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/SchemaContext.java +++ b/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/SchemaContext.java @@ -252,8 +252,8 @@ public interface SchemaContext extends ContainerLike, Immutable { @Override @Deprecated - default boolean isConfiguration() { - return false; + default Optional effectiveConfig() { + return Optional.empty(); } @Override diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/EffectiveStatementMixins.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/EffectiveStatementMixins.java index 91af95ff5e..752b15e952 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/EffectiveStatementMixins.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/EffectiveStatementMixins.java @@ -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> extends EffectiveStatementWithFlags, AddedByUsesAware { @Override + @Deprecated default boolean isAddedByUses() { return (flags() & FlagsBuilder.ADDED_BY_USES) != 0; } @@ -151,6 +153,7 @@ public final class EffectiveStatementMixins { */ public interface CopyableMixin> extends AddedByUsesMixin, CopyableNode { @Override + @Deprecated default boolean isAugmenting() { return (flags() & FlagsBuilder.AUGMENTING) != 0; } @@ -193,8 +196,18 @@ public final class EffectiveStatementMixins { public interface DataSchemaNodeMixin> extends DataSchemaNode, CopyableMixin, SchemaNodeMixin, WhenConditionMixin { @Override - default boolean isConfiguration() { - return (flags() & FlagsBuilder.CONFIGURATION) != 0; + default Optional 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 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; } diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/anydata/AnydataStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/anydata/AnydataStatementSupport.java index 23899723a9..f6e69025ed 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/anydata/AnydataStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/anydata/AnydataStatementSupport.java @@ -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(); diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/anyxml/AnyxmlStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/anyxml/AnyxmlStatementSupport.java index 74c8d0df52..e78b7e74b8 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/anyxml/AnyxmlStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/anyxml/AnyxmlStatementSupport.java @@ -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(); diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/case_/AbstractCaseStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/case_/AbstractCaseStatementSupport.java index c0bf68e1f6..dae37aa640 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/case_/AbstractCaseStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/case_/AbstractCaseStatementSupport.java @@ -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> 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> substatements) { + for (EffectiveStatement stmt : substatements) { + if (stmt instanceof DataSchemaNode) { + final Optional opt = ((DataSchemaNode) stmt).effectiveConfig(); + if (opt.isPresent()) { + return opt.orElseThrow(); + } + } + } + return null; + } +} diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/choice/AbstractChoiceStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/choice/AbstractChoiceStatementSupport.java index 7e1c6b5886..774bdab0c3 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/choice/AbstractChoiceStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/choice/AbstractChoiceStatementSupport.java @@ -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 { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/container/AbstractContainerStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/container/AbstractContainerStatementSupport.java index e3340072bf..95aca9f8f7 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/container/AbstractContainerStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/container/AbstractContainerStatementSupport.java @@ -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(); diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/leaf/LeafStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/leaf/LeafStatementSupport.java index bb0f464d9b..961d14f4ad 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/leaf/LeafStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/leaf/LeafStatementSupport.java @@ -93,7 +93,7 @@ public final class LeafStatementSupport extends BaseSchemaTreeStatementSupport OPT_FALSE = Optional.of(Boolean.FALSE); + private static final Optional 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 diff --git a/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/DeviationResolutionTest.java b/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/DeviationResolutionTest.java index 77170fe94b..e87e20a14b 100644 --- a/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/DeviationResolutionTest.java +++ b/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/DeviationResolutionTest.java @@ -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")); diff --git a/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveSchemaContextTest.java b/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveSchemaContextTest.java index d202952d88..ff484c63f9 100644 --- a/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveSchemaContextTest.java +++ b/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveSchemaContextTest.java @@ -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()); diff --git a/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveUsesRefineAndConstraintsTest.java b/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveUsesRefineAndConstraintsTest.java index ef6dcd8758..83dbcb7e88 100644 --- a/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveUsesRefineAndConstraintsTest.java +++ b/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveUsesRefineAndConstraintsTest.java @@ -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 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()); diff --git a/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/GroupingTest.java b/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/GroupingTest.java index 75e53e5a5e..8672767146 100644 --- a/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/GroupingTest.java +++ b/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/GroupingTest.java @@ -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 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)); diff --git a/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/ListTest.java b/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/ListTest.java index 2a4c44ca76..32f79bbb94 100644 --- a/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/ListTest.java +++ b/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/ListTest.java @@ -43,7 +43,7 @@ public class ListTest { assertNotNull(list); assertTrue(list.isUserOrdered()); - assertTrue(list.isConfiguration()); + assertEquals(Optional.of(Boolean.TRUE), list.effectiveConfig()); final List keys = list.getKeyDefinition(); assertEquals(2, keys.size()); diff --git a/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT911Test.java b/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT911Test.java index d475d51796..9b8e303b93 100644 --- a/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT911Test.java +++ b/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT911Test.java @@ -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); } } diff --git a/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserSimpleTest.java b/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserSimpleTest.java index 64896a638d..5f38ca5f7c 100644 --- a/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserSimpleTest.java +++ b/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserSimpleTest.java @@ -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()); diff --git a/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserTest.java b/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserTest.java index 517e58fb73..fbde7a5684 100644 --- a/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserTest.java +++ b/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserTest.java @@ -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()); diff --git a/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserWithContextTest.java b/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserWithContextTest.java index d10119b1e9..795f8708c2 100644 --- a/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserWithContextTest.java +++ b/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserWithContextTest.java @@ -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 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()); diff --git a/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileChoiceStmtTest.java b/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileChoiceStmtTest.java index 0867cb9f53..818e358701 100644 --- a/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileChoiceStmtTest.java +++ b/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileChoiceStmtTest.java @@ -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()); } } diff --git a/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/EffectiveStmtCtx.java b/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/EffectiveStmtCtx.java index 6b0b7d544b..db76b1cbde 100644 --- a/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/EffectiveStmtCtx.java +++ b/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/EffectiveStmtCtx.java @@ -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 asOptional() { - return Optional.ofNullable(config); - } } /** -- 2.36.6