From a1659168cb72dafbb6dad2c4096893959543d421 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 27 Oct 2017 20:05:33 +0200 Subject: [PATCH] Cleanup DocumentedNode Make description/reference work on Optional and fixup users. Change-Id: I744b9c59c8c3cc160636ef8c3ff18298c66a275a Signed-off-by: Robert Varga --- .../YangModeledAnyXMLDeserializationTest.java | 8 +- .../yang/data/util/ContainerSchemaNodes.java | 7 +- .../yang/data/util/RpcAsContainer.java | 4 +- .../yang/model/api/DocumentedNode.java | 20 ++--- .../yangtools/yang/model/api/Module.java | 20 ----- .../yang/model/api/SchemaContext.java | 10 +++ .../model/export/SchemaContextEmitter.java | 82 +++++++----------- .../model/util/AbstractSchemaContext.java | 10 --- .../util/EffectiveAugmentationSchema.java | 5 +- .../model/util/PatternConstraintImpl.java | 8 +- .../yang/model/util/RangeConstraintImpl.java | 8 +- .../model/util/type/AbstractBaseType.java | 9 +- .../model/util/type/AbstractDerivedType.java | 9 +- .../util/type/AbstractRestrictedType.java | 5 +- .../yang/model/util/type/BitImpl.java | 9 +- .../model/util/type/ConcreteTypeBuilder.java | 12 +-- .../yang/model/util/type/EnumPairImpl.java | 9 +- .../util/type/JavaLengthConstraints.java | 8 +- .../util/type/RangeRestrictedTypeBuilder.java | 11 +-- .../util/type/ResolvedLengthConstraint.java | 4 +- .../yang/model/util/BitsTypeTest.java | 5 +- .../yang/model/util/BooleanTypeTest.java | 3 +- .../yang/model/util/EmptyTypeTest.java | 6 +- .../yang/model/util/LeafrefTest.java | 4 +- .../model/util/PatternConstraintImplTest.java | 4 +- .../model/util/SchemaContextProxyTest.java | 10 +++ .../yang/model/util/type/BitImplTest.java | 5 +- .../model/util/type/EnumPairImplTest.java | 5 +- .../yang/model/util/type/TypeTest.java | 6 +- .../impl/util/YangModelDependencyInfo.java | 10 +++ .../yang/parser/repo/DependencyResolver.java | 10 +++ .../AbstractEffectiveDocumentedNode.java | 9 +- .../rfc6020/effective/CaseShorthandImpl.java | 4 +- .../DeviationEffectiveStatementImpl.java | 9 +- .../ImportEffectiveStatementImpl.java | 15 ++-- .../effective/MustEffectiveStatementImpl.java | 8 +- .../RevisionEffectiveStatementImpl.java | 9 +- .../AbstractConstraintEffectiveStatement.java | 8 +- ...tsSpecificationEffectiveStatementImpl.java | 19 +++-- .../type/BitsTypeEffectiveStatementImpl.java | 11 ++- ...umSpecificationEffectiveStatementImpl.java | 15 ++-- .../type/EnumTypeEffectiveStatementImpl.java | 10 +-- .../type/PatternConstraintEffectiveImpl.java | 8 +- .../type/PatternEffectiveStatementImpl.java | 4 +- .../type/RangeConstraintEffectiveImpl.java | 8 +- .../type/RangeEffectiveStatementImpl.java | 3 +- .../yang/parser/stmt/rfc7950/Bug6874Test.java | 7 +- .../yang/parser/stmt/rfc7950/Bug6883Test.java | 3 +- .../yangtools/yang/stmt/Bug5481Test.java | 10 +-- .../yangtools/yang/stmt/Bug5942Test.java | 5 +- .../yangtools/yang/stmt/Bug6180Test.java | 5 +- .../yangtools/yang/stmt/Bug7879Test.java | 3 +- .../yangtools/yang/stmt/Bug8597Test.java | 9 +- .../yangtools/yang/stmt/Bug8922Test.java | 3 +- .../yang/stmt/DeviationStmtTest.java | 7 +- .../yang/stmt/EffectiveModuleTest.java | 6 +- .../EffectiveModulesAndSubmodulesTest.java | 3 +- .../yang/stmt/EffectiveSchemaContextTest.java | 4 +- .../yang/stmt/EffectiveStatementTypeTest.java | 83 ++++++++++--------- ...EffectiveUsesRefineAndConstraintsTest.java | 18 ++-- .../yangtools/yang/stmt/GroupingTest.java | 33 ++++---- .../yang/stmt/TypesResolutionTest.java | 30 +++---- .../yang/stmt/YangParserSimpleTest.java | 20 ++--- .../yangtools/yang/stmt/YangParserTest.java | 19 +++-- .../yang/stmt/YangParserWithContextTest.java | 15 ++-- .../stmt/yin/YinFileExtensionStmtTest.java | 22 ++--- .../stmt/yin/YinFileGroupingStmtTest.java | 5 +- .../stmt/yin/YinFileLeafListStmtTest.java | 3 +- .../yang/stmt/yin/YinFileListStmtTest.java | 3 +- .../yang/stmt/yin/YinFileMetaStmtsTest.java | 4 +- .../yang/stmt/yin/YinFileRpcStmtTest.java | 5 +- .../yang/stmt/yin/YinFileTypeDefStmtTest.java | 3 +- 72 files changed, 397 insertions(+), 397 deletions(-) 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 d98c808b0a..a3a817e507 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 @@ -213,13 +213,13 @@ public class YangModeledAnyXMLDeserializationTest { } @Override - public String getDescription() { - return null; + public Optional getDescription() { + return Optional.empty(); } @Override - public String getReference() { - return null; + public Optional getReference() { + return Optional.empty(); } @Nonnull 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 9222f3dbc5..b646a63a6c 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 @@ -19,7 +19,6 @@ import java.util.Map; import java.util.Optional; import java.util.Set; import javax.annotation.Nonnull; -import javax.annotation.Nullable; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.model.api.ActionDefinition; import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode; @@ -102,15 +101,13 @@ public final class ContainerSchemaNodes { return schemaNode.getPath(); } - @Nullable @Override - public String getDescription() { + public Optional getDescription() { return schemaNode.getDescription(); } - @Nullable @Override - public String getReference() { + public Optional getReference() { return schemaNode.getReference(); } diff --git a/yang/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/RpcAsContainer.java b/yang/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/RpcAsContainer.java index ec4616fa4a..f437906d61 100644 --- a/yang/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/RpcAsContainer.java +++ b/yang/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/RpcAsContainer.java @@ -34,12 +34,12 @@ public final class RpcAsContainer implements ContainerSchemaNode { private final RpcDefinition delegate; @Override - public String getDescription() { + public Optional getDescription() { return delegate.getDescription(); } @Override - public String getReference() { + public Optional getReference() { return delegate.getReference(); } diff --git a/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/DocumentedNode.java b/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/DocumentedNode.java index 07ae031d93..b66e447587 100644 --- a/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/DocumentedNode.java +++ b/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/DocumentedNode.java @@ -9,8 +9,8 @@ package org.opendaylight.yangtools.yang.model.api; import com.google.common.collect.ImmutableList; import java.util.List; +import java.util.Optional; import javax.annotation.Nonnull; -import javax.annotation.Nullable; /** * Node which can have documentation assigned. @@ -19,29 +19,23 @@ public interface DocumentedNode { /** * Returns the value of the argument of YANG description keyword. * - * @return string with the description, or null if description was not provided. + * @return string with the description, or empty if description was not provided. */ - // FIXME: version 2.0.0: make this method non-default - @Nullable default String getDescription() { - return null; - } + Optional getDescription(); /** * Returns the value of the argument of YANG reference keyword. * - * @return string with reference to some other document, or null if reference was not provided. + * @return string with reference to some other document, or empty if reference was not provided. */ - // FIXME: version 2.0.0: make this method non-default - @Nullable default String getReference() { - return null; - } + Optional getReference(); /** - * Returns unknown schema nodes which belongs to this instance. + * Returns unknown schema nodes which belongs to this instance. Default implementation returns an empty list. * * @return list of unknown schema nodes defined under this node. */ - default @Nonnull List getUnknownSchemaNodes() { + @Nonnull default List getUnknownSchemaNodes() { return ImmutableList.of(); } diff --git a/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/Module.java b/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/Module.java index 3a4ea43c6b..90daf966ce 100644 --- a/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/Module.java +++ b/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/Module.java @@ -137,26 +137,6 @@ public interface Module extends DataNodeContainer, DocumentedNode, NotificationN */ YangVersion getYangVersion(); - /** - * Returns the module description. - * - * @return string with the module description which is specified as argument - * of YANG {@link Module description} keyword - */ - @Override - String getDescription(); - - /** - * Returns the module reference. - * - * @return string with the module reference which is specified as argument - * of YANG {@link Module reference} keyword - */ - @Override - String getReference(); - /** * Returns the module organization. * 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 d7644eb91b..71437d4f72 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 @@ -148,4 +148,14 @@ public interface SchemaContext extends ContainerSchemaNode { default Set getActions() { return ImmutableSet.of(); } + + @Override + default Optional getDescription() { + return Optional.empty(); + } + + @Override + default Optional getReference() { + return Optional.empty(); + } } diff --git a/yang/yang-model-export/src/main/java/org/opendaylight/yangtools/yang/model/export/SchemaContextEmitter.java b/yang/yang-model-export/src/main/java/org/opendaylight/yangtools/yang/model/export/SchemaContextEmitter.java index b094017021..84c0caccd6 100644 --- a/yang/yang-model-export/src/main/java/org/opendaylight/yangtools/yang/model/export/SchemaContextEmitter.java +++ b/yang/yang-model-export/src/main/java/org/opendaylight/yangtools/yang/model/export/SchemaContextEmitter.java @@ -1171,8 +1171,7 @@ abstract class SchemaContextEmitter { private void emitMetaNodes(final Module input) { input.getOrganization().ifPresent(this::emitOrganizationNode); input.getContact().ifPresent(this::emitContact); - emitDescriptionNode(input.getDescription()); - emitReferenceNode(input.getReference()); + emitDocumentedNode(input); } private void emitLinkageNodes(final Module input) { @@ -1266,10 +1265,8 @@ abstract class SchemaContextEmitter { private void emitImport(final ModuleImport importNode) { super.writer.startImportNode(importNode.getModuleName()); - emitDescriptionNode(importNode.getDescription()); - emitReferenceNode(importNode.getReference()); + emitDocumentedNode(importNode); emitPrefixNode(importNode.getPrefix()); - importNode.getRevision().ifPresent(this::emitRevisionDateNode); super.writer.endNode(); } @@ -1324,18 +1321,14 @@ abstract class SchemaContextEmitter { super.writer.endNode(); } - private void emitDescriptionNode(@Nullable final String input) { - if (!Strings.isNullOrEmpty(input)) { - super.writer.startDescriptionNode(input); - super.writer.endNode(); - } + private void emitDescriptionNode(final String input) { + super.writer.startDescriptionNode(input); + super.writer.endNode(); } - private void emitReferenceNode(@Nullable final String input) { - if (!Strings.isNullOrEmpty(input)) { - super.writer.startReferenceNode(input); - super.writer.endNode(); - } + private void emitReferenceNode(final String input) { + super.writer.startReferenceNode(input); + super.writer.endNode(); } private void emitUnitsNode(@Nullable final String input) { @@ -1365,9 +1358,7 @@ abstract class SchemaContextEmitter { private void emitExtension(final ExtensionDefinition extension) { super.writer.startExtensionNode(extension.getQName()); emitArgument(extension.getArgument(), extension.isYinElement()); - emitStatusNode(extension.getStatus()); - emitDescriptionNode(extension.getDescription()); - emitReferenceNode(extension.getReference()); + emitDocumentedNode(extension); emitUnknownStatementNodes(extension.getUnknownSchemaNodes()); super.writer.endNode(); @@ -1391,9 +1382,7 @@ abstract class SchemaContextEmitter { private void emitIdentity(final IdentitySchemaNode identity) { super.writer.startIdentityNode(identity.getQName()); emitBaseIdentities(identity.getBaseIdentities()); - emitStatusNode(identity.getStatus()); - emitDescriptionNode(identity.getDescription()); - emitReferenceNode(identity.getReference()); + emitDocumentedNode(identity); super.writer.endNode(); } @@ -1413,11 +1402,8 @@ abstract class SchemaContextEmitter { // FIXME: BUG-2444: FIXME: BUG-2444: Expose ifFeature // *(ifFeatureNode ) - emitStatusNode(definition.getStatus()); - emitDescriptionNode(definition.getDescription()); - emitReferenceNode(definition.getReference()); + emitDocumentedNode(definition); super.writer.endNode(); - } @SuppressWarnings("unused") @@ -1436,12 +1422,9 @@ abstract class SchemaContextEmitter { emitTypeNodeDerived(typedef); emitUnitsNode(typedef.getUnits()); emitDefaultNode(typedef.getDefaultValue()); - emitStatusNode(typedef.getStatus()); - emitDescriptionNode(typedef.getDescription()); - emitReferenceNode(typedef.getReference()); + emitDocumentedNode(typedef); emitUnknownStatementNodes(typedef.getUnknownSchemaNodes()); super.writer.endNode(); - } private void emitTypeNode(final SchemaPath parentPath, final TypeDefinition subtype) { @@ -1516,8 +1499,7 @@ abstract class SchemaContextEmitter { final RangeConstraint first = list.iterator().next(); first.getErrorMessage().ifPresent(this::emitErrorMessageNode); first.getErrorAppTag().ifPresent(this::emitErrorAppTagNode); - emitDescriptionNode(first.getDescription()); - emitReferenceNode(first.getReference()); + emitDocumentedNode(first); super.writer.endNode(); } @@ -1526,7 +1508,6 @@ abstract class SchemaContextEmitter { private void emitDecimal64Specification(final DecimalTypeDefinition typeDefinition) { emitFranctionDigitsNode(typeDefinition.getFractionDigits()); emitRangeNodeOptional(typeDefinition.getRangeConstraints()); - } private void emitFranctionDigitsNode(final Integer fractionDigits) { @@ -1546,8 +1527,7 @@ abstract class SchemaContextEmitter { super.writer.startLengthNode(toLengthString(constraint.getAllowedRanges())); constraint.getErrorMessage().ifPresent(this::emitErrorMessageNode); constraint.getErrorAppTag().ifPresent(this::emitErrorAppTagNode); - emitDescriptionNode(constraint.getDescription()); - emitReferenceNode(constraint.getReference()); + emitDocumentedNode(constraint); super.writer.endNode(); } @@ -1601,7 +1581,7 @@ abstract class SchemaContextEmitter { super.writer.startPatternNode(pattern.getRawRegularExpression()); pattern.getErrorMessage().ifPresent(this::emitErrorMessageNode); pattern.getErrorAppTag().ifPresent(this::emitErrorAppTagNode); - emitDescriptionNode(pattern.getDescription()); + emitDocumentedNode(pattern); emitModifier(pattern.getModifier()); super.writer.endNode(); } @@ -1635,9 +1615,7 @@ abstract class SchemaContextEmitter { private void emitEnumNode(final EnumPair enumValue) { super.writer.startEnumNode(enumValue.getName()); emitValueNode(enumValue.getValue()); - emitStatusNode(enumValue.getStatus()); - emitDescriptionNode(enumValue.getDescription()); - emitReferenceNode(enumValue.getReference()); + emitDocumentedNode(enumValue); super.writer.endNode(); } @@ -1683,9 +1661,7 @@ abstract class SchemaContextEmitter { private void emitBit(final Bit bit) { super.writer.startBitNode(bit.getName()); emitPositionNode(bit.getPosition()); - emitStatusNode(bit.getStatus()); - emitDescriptionNode(bit.getDescription()); - emitReferenceNode(bit.getReference()); + emitDocumentedNode(bit); super.writer.endNode(); } @@ -1732,11 +1708,9 @@ abstract class SchemaContextEmitter { super.writer.startMustNode(mustCondition.getXpath()); mustCondition.getErrorMessage().ifPresent(this::emitErrorMessageNode); mustCondition.getErrorAppTag().ifPresent(this::emitErrorAppTagNode); - emitDescriptionNode(mustCondition.getDescription()); - emitReferenceNode(mustCondition.getReference()); + emitDocumentedNode(mustCondition); super.writer.endNode(); } - } private void emitErrorMessageNode(@Nullable final String input) { @@ -1770,10 +1744,14 @@ abstract class SchemaContextEmitter { } } + private void emitDocumentedNode(final DocumentedNode input) { + input.getDescription().ifPresent(this::emitDescriptionNode); + input.getReference().ifPresent(this::emitReferenceNode); + } + private void emitDocumentedNode(final DocumentedNode.WithStatus input) { emitStatusNode(input.getStatus()); - emitDescriptionNode(input.getDescription()); - emitReferenceNode(input.getReference()); + emitDocumentedNode((DocumentedNode) input); } private void emitGrouping(final GroupingDefinition grouping) { @@ -1995,10 +1973,10 @@ abstract class SchemaContextEmitter { private void emitDocumentedNodeRefine(final DocumentedNode original, final DocumentedNode value) { if (Objects.deepEquals(original.getDescription(), value.getDescription())) { - emitDescriptionNode(value.getDescription()); + value.getDescription().ifPresent(this::emitDescriptionNode); } if (Objects.deepEquals(original.getReference(), value.getReference())) { - emitReferenceNode(value.getReference()); + value.getReference().ifPresent(this::emitReferenceNode); } } @@ -2119,9 +2097,7 @@ abstract class SchemaContextEmitter { // FIXME: BUG-2444: whenNode //Optional // FIXME: BUG-2444: *(ifFeatureNode ) - emitStatusNode(augmentation.getStatus()); - emitDescriptionNode(augmentation.getDescription()); - emitReferenceNode(augmentation.getReference()); + emitDocumentedNode(augmentation); for (final UsesNode uses : augmentation.getUses()) { emitUsesNode(uses); } @@ -2183,9 +2159,7 @@ abstract class SchemaContextEmitter { private void emitOperationBody(final OperationDefinition rpc) { // FIXME: BUG-2444: *(ifFeatureNode ) - emitStatusNode(rpc.getStatus()); - emitDescriptionNode(rpc.getDescription()); - emitReferenceNode(rpc.getReference()); + emitDocumentedNode(rpc); for (final TypeDefinition typedef : rpc.getTypeDefinitions()) { emitTypedefNode(typedef); diff --git a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/AbstractSchemaContext.java b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/AbstractSchemaContext.java index b379152ee6..cd2c598553 100644 --- a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/AbstractSchemaContext.java +++ b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/AbstractSchemaContext.java @@ -147,16 +147,6 @@ public abstract class AbstractSchemaContext implements SchemaContext { return SchemaPath.ROOT; } - @Override - public String getDescription() { - return null; - } - - @Override - public String getReference() { - return null; - } - @Nonnull @Override public Status getStatus() { diff --git a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/EffectiveAugmentationSchema.java b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/EffectiveAugmentationSchema.java index 7120e9d25c..0ccc8036d2 100644 --- a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/EffectiveAugmentationSchema.java +++ b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/EffectiveAugmentationSchema.java @@ -30,7 +30,6 @@ import org.opendaylight.yangtools.yang.model.api.UsesNode; /** * Proxy for AugmentationSchema. Child node schemas are replaced with actual schemas from parent. - * */ public final class EffectiveAugmentationSchema implements AugmentationSchemaNode { private final AugmentationSchemaNode delegate; @@ -56,12 +55,12 @@ public final class EffectiveAugmentationSchema implements AugmentationSchemaNode } @Override - public String getDescription() { + public Optional getDescription() { return delegate.getDescription(); } @Override - public String getReference() { + public Optional getReference() { return delegate.getReference(); } diff --git a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/PatternConstraintImpl.java b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/PatternConstraintImpl.java index bb10b18389..2c986fdd35 100644 --- a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/PatternConstraintImpl.java +++ b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/PatternConstraintImpl.java @@ -52,8 +52,8 @@ final class PatternConstraintImpl implements PatternConstraint, Immutable { } @Override - public String getDescription() { - return description; + public Optional getDescription() { + return Optional.ofNullable(description); } @Override @@ -67,8 +67,8 @@ final class PatternConstraintImpl implements PatternConstraint, Immutable { } @Override - public String getReference() { - return reference; + public Optional getReference() { + return Optional.ofNullable(reference); } @Override diff --git a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/RangeConstraintImpl.java b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/RangeConstraintImpl.java index a25051a654..ce06bfed82 100644 --- a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/RangeConstraintImpl.java +++ b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/RangeConstraintImpl.java @@ -53,8 +53,8 @@ final class RangeConstraintImpl implements RangeConstraint, Immutable { } @Override - public String getDescription() { - return description; + public Optional getDescription() { + return Optional.ofNullable(description); } @Override @@ -68,8 +68,8 @@ final class RangeConstraintImpl implements RangeConstraint, Immutable { } @Override - public String getReference() { - return reference; + public Optional getReference() { + return Optional.ofNullable(reference); } @Override diff --git a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/AbstractBaseType.java b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/AbstractBaseType.java index ef9f97d0d1..3d05a9b4ba 100644 --- a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/AbstractBaseType.java +++ b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/AbstractBaseType.java @@ -9,6 +9,7 @@ package org.opendaylight.yangtools.yang.model.util.type; import com.google.common.collect.ImmutableList; import java.util.List; +import java.util.Optional; import javax.annotation.Nonnull; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.model.api.SchemaPath; @@ -41,13 +42,13 @@ abstract class AbstractBaseType> extends AbstractTyp } @Override - public final String getDescription() { - return null; + public final Optional getDescription() { + return Optional.empty(); } @Override - public final String getReference() { - return null; + public final Optional getReference() { + return Optional.empty(); } @Nonnull diff --git a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/AbstractDerivedType.java b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/AbstractDerivedType.java index c195878b71..eefc4a68b5 100644 --- a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/AbstractDerivedType.java +++ b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/AbstractDerivedType.java @@ -10,6 +10,7 @@ package org.opendaylight.yangtools.yang.model.util.type; import com.google.common.base.MoreObjects; import com.google.common.base.Preconditions; import java.util.Collection; +import java.util.Optional; import javax.annotation.Nonnull; import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.opendaylight.yangtools.yang.model.api.Status; @@ -54,13 +55,13 @@ abstract class AbstractDerivedType> extends Abstract } @Override - public final String getDescription() { - return description; + public final Optional getDescription() { + return Optional.ofNullable(description); } @Override - public final String getReference() { - return reference; + public final Optional getReference() { + return Optional.ofNullable(reference); } @Nonnull diff --git a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/AbstractRestrictedType.java b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/AbstractRestrictedType.java index d40fdd6577..89d5d129ad 100644 --- a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/AbstractRestrictedType.java +++ b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/AbstractRestrictedType.java @@ -9,6 +9,7 @@ package org.opendaylight.yangtools.yang.model.util.type; import com.google.common.base.Preconditions; import java.util.Collection; +import java.util.Optional; import javax.annotation.Nonnull; import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.opendaylight.yangtools.yang.model.api.Status; @@ -40,12 +41,12 @@ abstract class AbstractRestrictedType> extends Abstr } @Override - public final String getDescription() { + public final Optional getDescription() { return baseType.getDescription(); } @Override - public final String getReference() { + public final Optional getReference() { return baseType.getReference(); } diff --git a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/BitImpl.java b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/BitImpl.java index 08246d9a09..579c69f827 100644 --- a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/BitImpl.java +++ b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/BitImpl.java @@ -10,6 +10,7 @@ package org.opendaylight.yangtools.yang.model.util.type; import com.google.common.base.Preconditions; import java.util.List; import java.util.Objects; +import java.util.Optional; import javax.annotation.Nonnull; import org.opendaylight.yangtools.concepts.Immutable; import org.opendaylight.yangtools.yang.common.QName; @@ -51,13 +52,13 @@ final class BitImpl implements Bit, Immutable { } @Override - public String getDescription() { - return description; + public Optional getDescription() { + return Optional.ofNullable(description); } @Override - public String getReference() { - return reference; + public Optional getReference() { + return Optional.ofNullable(reference); } @Nonnull diff --git a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/ConcreteTypeBuilder.java b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/ConcreteTypeBuilder.java index 4a9b6d9b94..e61d0f4a6c 100644 --- a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/ConcreteTypeBuilder.java +++ b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/ConcreteTypeBuilder.java @@ -26,15 +26,9 @@ public abstract class ConcreteTypeBuilder> extends D ConcreteTypeBuilder(final T baseType, final SchemaPath path) { super(baseType, path); - if (baseType.getDescription() != null) { - setDescription(baseType.getDescription()); - } - if (baseType.getReference() != null) { - setReference(baseType.getReference()); - } - if (baseType.getStatus() != null) { - setStatus(baseType.getStatus()); - } + setStatus(baseType.getStatus()); + baseType.getDescription().ifPresent(this::setDescription); + baseType.getReference().ifPresent(this::setReference); } /** diff --git a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/EnumPairImpl.java b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/EnumPairImpl.java index 07deab72c1..a0fd036802 100644 --- a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/EnumPairImpl.java +++ b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/EnumPairImpl.java @@ -11,6 +11,7 @@ import com.google.common.base.MoreObjects; import com.google.common.base.Preconditions; import java.util.List; import java.util.Objects; +import java.util.Optional; import javax.annotation.Nonnull; import org.opendaylight.yangtools.concepts.Immutable; import org.opendaylight.yangtools.yang.model.api.Status; @@ -42,13 +43,13 @@ final class EnumPairImpl implements EnumPair, Immutable { } @Override - public String getDescription() { - return description; + public Optional getDescription() { + return Optional.ofNullable(description); } @Override - public String getReference() { - return reference; + public Optional getReference() { + return Optional.ofNullable(reference); } @Nonnull diff --git a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/JavaLengthConstraints.java b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/JavaLengthConstraints.java index 216728f9d1..1f9ea4b59e 100644 --- a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/JavaLengthConstraints.java +++ b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/JavaLengthConstraints.java @@ -23,8 +23,8 @@ final class JavaLengthConstraints { static final LengthConstraint INTEGER_SIZE_CONSTRAINTS = new LengthConstraint() { @Override - public String getReference() { - return null; + public Optional getReference() { + return Optional.empty(); } @Override @@ -38,8 +38,8 @@ final class JavaLengthConstraints { } @Override - public String getDescription() { - return null; + public Optional getDescription() { + return Optional.empty(); } @Override diff --git a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/RangeRestrictedTypeBuilder.java b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/RangeRestrictedTypeBuilder.java index 03bd31bdb9..7fa9863e89 100644 --- a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/RangeRestrictedTypeBuilder.java +++ b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/RangeRestrictedTypeBuilder.java @@ -13,7 +13,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList.Builder; import java.util.Collection; import java.util.List; -import java.util.Optional; import java.util.function.Function; import javax.annotation.Nonnull; import org.opendaylight.yangtools.yang.model.api.SchemaPath; @@ -64,9 +63,8 @@ public abstract class RangeRestrictedTypeBuilder getDescription() { return meta.getDescription(); } @@ -40,7 +40,7 @@ final class ResolvedLengthConstraint implements LengthConstraint { } @Override - public String getReference() { + public Optional getReference() { return meta.getReference(); } diff --git a/yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/BitsTypeTest.java b/yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/BitsTypeTest.java index cc541dffe2..399c24d7eb 100644 --- a/yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/BitsTypeTest.java +++ b/yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/BitsTypeTest.java @@ -8,6 +8,7 @@ package org.opendaylight.yangtools.yang.model.util; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNull; import static org.mockito.Mockito.doReturn; @@ -37,11 +38,11 @@ public class BitsTypeTest { BitsTypeDefinition bitsType = BaseTypes.bitsTypeBuilder(schemaPath).addBit(bit).build(); - assertNull("Description is not null", bitsType.getDescription()); + assertFalse(bitsType.getDescription().isPresent()); assertEquals("QName", qname, bitsType.getQName()); assertNull("Should be null", bitsType.getUnits()); assertNotEquals("Description should not be null", null, bitsType.toString()); - assertNull("Reference is not null", bitsType.getReference()); + assertFalse(bitsType.getReference().isPresent()); assertNull("BaseType should be null", bitsType.getBaseType()); assertNull("Default value should be null", bitsType.getDefaultValue()); assertEquals("getPath should equal schemaPath", schemaPath, bitsType.getPath()); diff --git a/yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/BooleanTypeTest.java b/yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/BooleanTypeTest.java index 7c57e81947..7c32cdfe16 100644 --- a/yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/BooleanTypeTest.java +++ b/yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/BooleanTypeTest.java @@ -8,6 +8,7 @@ package org.opendaylight.yangtools.yang.model.util; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.opendaylight.yangtools.yang.model.util.type.BaseTypes.booleanType; @@ -27,7 +28,7 @@ public class BooleanTypeTest { assertEquals("getPath gives List of BOOLEAN_QNAME", Collections.singletonList(BaseTypes.BOOLEAN_QNAME), boolType.getPath().getPathFromRoot()); assertEquals("getQName gives BOOLEAN_QNAME", BaseTypes.BOOLEAN_QNAME, boolType.getQName()); - assertNull(boolType.getDescription()); + assertFalse(boolType.getDescription().isPresent()); final String strPath = boolType.getPath().toString(); assertTrue("Should contain string of getPath", stringBoolType.contains(strPath)); diff --git a/yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/EmptyTypeTest.java b/yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/EmptyTypeTest.java index 366e81b912..cb2ec8777a 100644 --- a/yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/EmptyTypeTest.java +++ b/yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/EmptyTypeTest.java @@ -8,7 +8,7 @@ package org.opendaylight.yangtools.yang.model.util; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.opendaylight.yangtools.yang.model.util.type.BaseTypes.emptyType; @@ -29,9 +29,9 @@ public class EmptyTypeTest { assertEquals("BaseType", null, emptyType.getBaseType()); assertEquals("DefaultValue", null, emptyType.getDefaultValue()); assertEquals("Status", Status.CURRENT, emptyType.getStatus()); - assertNull("Reference", emptyType.getReference()); + assertFalse(emptyType.getReference().isPresent()); assertEquals("Units", null, emptyType.getUnits()); - assertNull("Description is not null", emptyType.getDescription()); + assertFalse(emptyType.getDescription().isPresent()); assertEquals("UnknownSchemaNodes", Collections.EMPTY_LIST, emptyType.getUnknownSchemaNodes()); assertTrue("toString", emptyType.toString().contains("empty")); } diff --git a/yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/LeafrefTest.java b/yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/LeafrefTest.java index 3dfe84a8ce..f3d8d25889 100644 --- a/yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/LeafrefTest.java +++ b/yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/LeafrefTest.java @@ -46,8 +46,8 @@ public class LeafrefTest { assertNull("Leafref does not have a default value", leafref.getDefaultValue()); assertEquals(QName.create("test", "List1"), leafref.getQName()); assertEquals("SchemaPath of 'leafref' is '/Cont1/List1'.", schemaPath, leafref.getPath()); - assertNull(leafref.getDescription()); - assertNull(leafref.getReference()); + assertFalse(leafref.getDescription().isPresent()); + assertFalse(leafref.getReference().isPresent()); assertEquals("Status of 'leafref' is current.", Status.CURRENT, leafref.getStatus()); assertTrue("Object 'leafref' shouldn't have any unknown schema nodes.", leafref.getUnknownSchemaNodes().isEmpty()); diff --git a/yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/PatternConstraintImplTest.java b/yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/PatternConstraintImplTest.java index a2b1f8fdf7..de067db4a9 100644 --- a/yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/PatternConstraintImplTest.java +++ b/yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/PatternConstraintImplTest.java @@ -33,11 +33,11 @@ public class PatternConstraintImplTest { final PatternConstraintImpl patternConstraint5 = new PatternConstraintImpl(regexExp2, description2, reference2); assertNotNull("Object of PatternConstraintImpl shouldn't be null.", patternConstraint); - assertEquals("Description should be 'test description'.", "test description", + assertEquals("Description should be 'test description'.", Optional.of("test description"), patternConstraint.getDescription()); assertEquals(Optional.of("invalid-regular-expression"), patternConstraint.getErrorAppTag()); assertTrue(patternConstraint.getErrorMessage().isPresent()); - assertEquals("Reference should be equals 'RFC 6020'.", "RFC 6020", patternConstraint.getReference()); + assertEquals(Optional.of("RFC 6020"), patternConstraint.getReference()); assertEquals("Regular expression should be equls '\\D'.", "\\D", patternConstraint.getRegularExpression()); assertNotEquals("Hash codes shouldn't be equals.", patternConstraint.hashCode(), patternConstraint2.hashCode()); assertFalse("String representation shouldn't be empty.", patternConstraint.toString().isEmpty()); diff --git a/yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/SchemaContextProxyTest.java b/yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/SchemaContextProxyTest.java index a60ccfb130..26ab38275e 100644 --- a/yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/SchemaContextProxyTest.java +++ b/yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/SchemaContextProxyTest.java @@ -607,6 +607,16 @@ public class SchemaContextProxyTest { return module.getSemanticVersion(); } + @Override + public Optional getDescription() { + return module.getDescription(); + } + + @Override + public Optional getReference() { + return module.getReference(); + } + @Override public String toString() { return String.format("Module: %s, revision:%s", module.getName(), module.getRevision()); diff --git a/yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/type/BitImplTest.java b/yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/type/BitImplTest.java index 4a2c575adf..9b2ac4b5c6 100644 --- a/yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/type/BitImplTest.java +++ b/yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/type/BitImplTest.java @@ -13,6 +13,7 @@ import static org.junit.Assert.assertFalse; import java.net.URI; import java.net.URISyntaxException; +import java.util.Optional; import org.junit.Test; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.Revision; @@ -68,8 +69,8 @@ public class BitImplTest { // test of getter methods assertEquals("Incorrect value for qname.", qnameA2, biA.getQName()); assertEquals("Incorrect value for schema path.", schemaPathA, biA.getPath()); - assertEquals("Incorrect value for description.", "description", biA.getDescription()); - assertEquals("Incorrect value for reference.", "reference", biA.getReference()); + assertEquals("Incorrect value for description.", Optional.of("description"), biA.getDescription()); + assertEquals("Incorrect value for reference.", Optional.of("reference"), biA.getReference()); assertEquals("Incorrect value for status.", Status.CURRENT, biA.getStatus()); assertEquals("Incorrect value for unknown nodes.", emptyList(), biA.getUnknownSchemaNodes()); diff --git a/yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/type/EnumPairImplTest.java b/yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/type/EnumPairImplTest.java index 2d173741e4..694e9f2931 100644 --- a/yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/type/EnumPairImplTest.java +++ b/yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/type/EnumPairImplTest.java @@ -16,6 +16,7 @@ import static org.mockito.Mockito.mock; import com.google.common.collect.ImmutableList; import java.util.Collection; +import java.util.Optional; import org.junit.Test; import org.opendaylight.yangtools.yang.model.api.Status; import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode; @@ -37,8 +38,8 @@ public class EnumPairImplTest { assertNotNull(enumPair); assertEquals(unknownSchemaNodes, enumPair.getUnknownSchemaNodes()); - assertEquals("enum description", enumPair.getDescription()); - assertEquals("enum reference", enumPair.getReference()); + assertEquals(Optional.of("enum description"), enumPair.getDescription()); + assertEquals(Optional.of("enum reference"), enumPair.getReference()); assertEquals(Status.DEPRECATED, enumPair.getStatus()); final EnumPair enumPair2 = EnumPairBuilder.create("enum-zero", 0).setStatus(Status.DEPRECATED) diff --git a/yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/type/TypeTest.java b/yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/type/TypeTest.java index 38dfc759af..a6957fac44 100644 --- a/yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/type/TypeTest.java +++ b/yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/type/TypeTest.java @@ -384,9 +384,9 @@ public class TypeTest { final BaseBinaryType baseBinaryType1 = BaseBinaryType.INSTANCE; final AbstractDerivedType abstractDerivedType = (AbstractDerivedType) DerivedTypes.derivedTypeBuilder(baseBinaryType1, SCHEMA_PATH).build(); - assertEquals(abstractDerivedType.getDescription(), null); - assertEquals(abstractDerivedType.getReference(), null); - assertEquals(abstractDerivedType.getStatus().toString(), "CURRENT"); + assertEquals(Optional.empty(), abstractDerivedType.getDescription()); + assertEquals(Optional.empty(), abstractDerivedType.getReference()); + assertEquals(Status.CURRENT, abstractDerivedType.getStatus()); assertFalse(DerivedTypes.isInt8(baseBinaryType1)); assertFalse(DerivedTypes.isUint8(baseBinaryType1)); assertFalse(DerivedTypes.isInt16(baseBinaryType1)); diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/util/YangModelDependencyInfo.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/util/YangModelDependencyInfo.java index b97edabb1a..fdabf9029e 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/util/YangModelDependencyInfo.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/util/YangModelDependencyInfo.java @@ -410,6 +410,16 @@ public abstract class YangModelDependencyInfo { return null; } + @Override + public Optional getDescription() { + return Optional.empty(); + } + + @Override + public Optional getReference() { + return Optional.empty(); + } + @Override public int hashCode() { final int prime = 31; diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/repo/DependencyResolver.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/repo/DependencyResolver.java index f1edb2d920..662e7b90ca 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/repo/DependencyResolver.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/repo/DependencyResolver.java @@ -166,6 +166,16 @@ abstract class DependencyResolver { return Optional.empty(); } + @Override + public Optional getDescription() { + return Optional.empty(); + } + + @Override + public Optional getReference() { + return Optional.empty(); + } + @Override public String getPrefix() { return null; diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/AbstractEffectiveDocumentedNode.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/AbstractEffectiveDocumentedNode.java index a2e62f20a0..f058b44b1d 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/AbstractEffectiveDocumentedNode.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/AbstractEffectiveDocumentedNode.java @@ -7,6 +7,7 @@ */ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective; +import java.util.Optional; import javax.annotation.Nonnull; import org.opendaylight.yangtools.yang.model.api.DocumentedNode; import org.opendaylight.yangtools.yang.model.api.Status; @@ -52,13 +53,13 @@ public abstract class AbstractEffectiveDocumentedNode getDescription() { + return Optional.ofNullable(description); } @Override - public final String getReference() { - return reference; + public final Optional getReference() { + return Optional.ofNullable(reference); } @Nonnull diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/CaseShorthandImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/CaseShorthandImpl.java index 35b3a41be9..2b6b325c02 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/CaseShorthandImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/CaseShorthandImpl.java @@ -86,12 +86,12 @@ final class CaseShorthandImpl implements ChoiceCaseNode, DerivableSchemaNode { } @Override - public String getDescription() { + public Optional getDescription() { return caseShorthandNode.getDescription(); } @Override - public String getReference() { + public Optional getReference() { return caseShorthandNode.getReference(); } diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/DeviationEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/DeviationEffectiveStatementImpl.java index d2086a5b07..fb232bd40b 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/DeviationEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/DeviationEffectiveStatementImpl.java @@ -11,6 +11,7 @@ import com.google.common.collect.ImmutableList; import java.util.ArrayList; import java.util.List; import java.util.Objects; +import java.util.Optional; import org.opendaylight.yangtools.concepts.Immutable; import org.opendaylight.yangtools.yang.model.api.DeviateDefinition; import org.opendaylight.yangtools.yang.model.api.Deviation; @@ -62,13 +63,13 @@ public class DeviationEffectiveStatementImpl } @Override - public String getDescription() { - return description; + public Optional getDescription() { + return Optional.ofNullable(description); } @Override - public String getReference() { - return reference; + public Optional getReference() { + return Optional.ofNullable(reference); } @Override diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ImportEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ImportEffectiveStatementImpl.java index 86cf7d9c95..d3feaad3de 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ImportEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ImportEffectiveStatementImpl.java @@ -96,13 +96,13 @@ public class ImportEffectiveStatementImpl extends DeclaredEffectiveStatementBase } @Override - public String getDescription() { - return description; + public Optional getDescription() { + return Optional.ofNullable(description); } @Override - public String getReference() { - return reference; + public Optional getReference() { + return Optional.ofNullable(reference); } @Override @@ -129,9 +129,8 @@ public class ImportEffectiveStatementImpl extends DeclaredEffectiveStatementBase @Override public String toString() { - return MoreObjects.toStringHelper(this).add("moduleName", getModuleName()) - .add("revision", getRevision()).add("semantic version", getSemanticVersion()) - .add("prefix", getPrefix()).add("description", getDescription()) - .add("reference", getReference()).toString(); + return MoreObjects.toStringHelper(this).omitNullValues().add("moduleName", getModuleName()) + .add("revision", revision).add("version", semVer).add("prefix", getPrefix()) + .add("description", description).add("reference", reference).toString(); } } diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/MustEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/MustEffectiveStatementImpl.java index b6a3af42cd..b03f416be2 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/MustEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/MustEffectiveStatementImpl.java @@ -46,8 +46,8 @@ public class MustEffectiveStatementImpl extends DeclaredEffectiveStatementBase getDescription() { + return Optional.ofNullable(description); } @Override @@ -61,8 +61,8 @@ public class MustEffectiveStatementImpl extends DeclaredEffectiveStatementBase getReference() { + return Optional.ofNullable(reference); } @Override diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/RevisionEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/RevisionEffectiveStatementImpl.java index e2dd62e671..38c4c256f3 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/RevisionEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/RevisionEffectiveStatementImpl.java @@ -7,6 +7,7 @@ */ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective; +import java.util.Optional; import org.opendaylight.yangtools.yang.common.Revision; import org.opendaylight.yangtools.yang.model.api.DocumentedNode; import org.opendaylight.yangtools.yang.model.api.stmt.RevisionStatement; @@ -37,12 +38,12 @@ public final class RevisionEffectiveStatementImpl extends DeclaredEffectiveState } @Override - public String getDescription() { - return this.description; + public Optional getDescription() { + return Optional.ofNullable(description); } @Override - public String getReference() { - return this.reference; + public Optional getReference() { + return Optional.ofNullable(reference); } } diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/AbstractConstraintEffectiveStatement.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/AbstractConstraintEffectiveStatement.java index b936e6a363..324c9ea7bb 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/AbstractConstraintEffectiveStatement.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/AbstractConstraintEffectiveStatement.java @@ -74,8 +74,8 @@ abstract class AbstractConstraintEffectiveStatement getDescription() { + return Optional.ofNullable(description); } public final ModifierKind getModifier() { @@ -83,8 +83,8 @@ abstract class AbstractConstraintEffectiveStatement getReference() { + return Optional.ofNullable(reference); } @Override diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/BitsSpecificationEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/BitsSpecificationEffectiveStatementImpl.java index c3be36971b..da37904bfd 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/BitsSpecificationEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/BitsSpecificationEffectiveStatementImpl.java @@ -49,19 +49,20 @@ public final class BitsSpecificationEffectiveStatementImpl extends effectivePos = bitSubStmt.getDeclaredPosition(); } - final Bit b = BitBuilder.create(bitSubStmt.getPath(), effectivePos) - .setDescription(bitSubStmt.getDescription()).setReference(bitSubStmt.getReference()) - .setStatus(bitSubStmt.getStatus()).setUnknownSchemaNodes(bitSubStmt.getUnknownSchemaNodes()) - .build(); + final BitBuilder bitBuilder = BitBuilder.create(bitSubStmt.getPath(), effectivePos) + .setStatus(bitSubStmt.getStatus()); + bitSubStmt.getDescription().ifPresent(bitBuilder::setDescription); + bitSubStmt.getReference().ifPresent(bitBuilder::setReference); - SourceException.throwIf(b.getPosition() < 0L && b.getPosition() > 4294967295L, - ctx.getStatementSourceReference(), "Bit %s has illegal position", b); + final Bit bit = bitBuilder.build(); + SourceException.throwIf(bit.getPosition() < 0L && bit.getPosition() > 4294967295L, + ctx.getStatementSourceReference(), "Bit %s has illegal position", bit); - if (highestPosition == null || highestPosition < b.getPosition()) { - highestPosition = b.getPosition(); + if (highestPosition == null || highestPosition < bit.getPosition()) { + highestPosition = bit.getPosition(); } - builder.addBit(b); + builder.addBit(bit); } if (stmt instanceof UnknownEffectiveStatementImpl) { builder.addUnknownSchemaNode((UnknownEffectiveStatementImpl) stmt); diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/BitsTypeEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/BitsTypeEffectiveStatementImpl.java index 6d775b12c9..9154554e53 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/BitsTypeEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/BitsTypeEffectiveStatementImpl.java @@ -49,12 +49,11 @@ public final class BitsTypeEffectiveStatementImpl extends DeclaredEffectiveState effectivePos = bitSubStmt.getDeclaredPosition(); } - final Bit b = BitBuilder.create(bitSubStmt.getPath(), effectivePos) - .setDescription(bitSubStmt.getDescription()).setReference(bitSubStmt.getReference()) - .setStatus(bitSubStmt.getStatus()).setUnknownSchemaNodes(bitSubStmt.getUnknownSchemaNodes()) - .build(); - - builder.addBit(b); + final BitBuilder bitBuilder = BitBuilder.create(bitSubStmt.getPath(), effectivePos) + .setStatus(bitSubStmt.getStatus()); + bitSubStmt.getDescription().ifPresent(bitBuilder::setDescription); + bitSubStmt.getReference().ifPresent(bitBuilder::setReference); + builder.addBit(bitBuilder.build()); } else if (stmt instanceof UnknownEffectiveStatementImpl) { builder.addUnknownSchemaNode((UnknownEffectiveStatementImpl) stmt); } diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/EnumSpecificationEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/EnumSpecificationEffectiveStatementImpl.java index 1b4efe16fa..82f918c14c 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/EnumSpecificationEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/EnumSpecificationEffectiveStatementImpl.java @@ -50,16 +50,17 @@ public final class EnumSpecificationEffectiveStatementImpl extends effectiveValue = enumSubStmt.getDeclaredValue(); } - final EnumPair p = EnumPairBuilder.create(enumSubStmt.getName(), effectiveValue) - .setDescription(enumSubStmt.getDescription()).setReference(enumSubStmt.getReference()) - .setStatus(enumSubStmt.getStatus()).setUnknownSchemaNodes(enumSubStmt.getUnknownSchemaNodes()) - .build(); + final EnumPairBuilder pairBuilder = EnumPairBuilder.create(enumSubStmt.getName(), effectiveValue) + .setStatus(enumSubStmt.getStatus()).setUnknownSchemaNodes(enumSubStmt.getUnknownSchemaNodes()); + enumSubStmt.getDescription().ifPresent(pairBuilder::setDescription); + enumSubStmt.getReference().ifPresent(pairBuilder::setReference); - if (highestValue == null || highestValue < p.getValue()) { - highestValue = p.getValue(); + final EnumPair pair = pairBuilder.build(); + if (highestValue == null || highestValue < pair.getValue()) { + highestValue = pair.getValue(); } - builder.addEnum(p); + builder.addEnum(pair); } if (stmt instanceof UnknownEffectiveStatementImpl) { builder.addUnknownSchemaNode((UnknownEffectiveStatementImpl) stmt); diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/EnumTypeEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/EnumTypeEffectiveStatementImpl.java index 9408310214..be9e835c8f 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/EnumTypeEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/EnumTypeEffectiveStatementImpl.java @@ -51,12 +51,12 @@ public final class EnumTypeEffectiveStatementImpl extends DeclaredEffectiveState effectiveValue = enumSubStmt.getDeclaredValue(); } - final EnumPair p = EnumPairBuilder.create(enumSubStmt.getName(), effectiveValue) - .setDescription(enumSubStmt.getDescription()).setReference(enumSubStmt.getReference()) - .setStatus(enumSubStmt.getStatus()).setUnknownSchemaNodes(enumSubStmt.getUnknownSchemaNodes()) - .build(); + final EnumPairBuilder pairBuilder = EnumPairBuilder.create(enumSubStmt.getName(), effectiveValue) + .setStatus(enumSubStmt.getStatus()).setUnknownSchemaNodes(enumSubStmt.getUnknownSchemaNodes()); + enumSubStmt.getDescription().ifPresent(pairBuilder::setDescription); + enumSubStmt.getReference().ifPresent(pairBuilder::setReference); - builder.addEnum(p); + builder.addEnum(pairBuilder.build()); } else if (stmt instanceof UnknownEffectiveStatementImpl) { builder.addUnknownSchemaNode((UnknownEffectiveStatementImpl) stmt); } diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/PatternConstraintEffectiveImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/PatternConstraintEffectiveImpl.java index cb664d9693..971dd2be58 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/PatternConstraintEffectiveImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/PatternConstraintEffectiveImpl.java @@ -53,8 +53,8 @@ public class PatternConstraintEffectiveImpl implements PatternConstraint { } @Override - public String getDescription() { - return description; + public Optional getDescription() { + return Optional.ofNullable(description); } @Override @@ -73,8 +73,8 @@ public class PatternConstraintEffectiveImpl implements PatternConstraint { } @Override - public String getReference() { - return reference; + public Optional getReference() { + return Optional.ofNullable(reference); } @Override diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/PatternEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/PatternEffectiveStatementImpl.java index 8cfbbba08b..14a5aad109 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/PatternEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/PatternEffectiveStatementImpl.java @@ -24,7 +24,7 @@ public class PatternEffectiveStatementImpl extends } return new PatternConstraintEffectiveImpl(argument.getRegularExpression(), argument.getRawRegularExpression(), - getDescription(), getReference(), getErrorAppTag().orElse(null), getErrorMessage().orElse(null), - getModifier()); + getDescription().orElse(null), getReference().orElse(null), getErrorAppTag().orElse(null), + getErrorMessage().orElse(null), getModifier()); } } diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/RangeConstraintEffectiveImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/RangeConstraintEffectiveImpl.java index 89e277d3c4..a5fedd5b9a 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/RangeConstraintEffectiveImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/RangeConstraintEffectiveImpl.java @@ -43,8 +43,8 @@ public class RangeConstraintEffectiveImpl implements RangeConstraint { } @Override - public String getDescription() { - return description; + public Optional getDescription() { + return Optional.ofNullable(description); } @Override @@ -58,8 +58,8 @@ public class RangeConstraintEffectiveImpl implements RangeConstraint { } @Override - public String getReference() { - return reference; + public Optional getReference() { + return Optional.ofNullable(reference); } @Override diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/RangeEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/RangeEffectiveStatementImpl.java index 416f6295f4..974464b15f 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/RangeEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/RangeEffectiveStatementImpl.java @@ -21,6 +21,7 @@ public class RangeEffectiveStatementImpl extends @Override final RangeConstraint createCustomizedConstraint(final RangeConstraint rangeConstraint) { return new RangeConstraintEffectiveImpl(rangeConstraint.getMin(), rangeConstraint.getMax(), - getDescription(), getReference(), getErrorAppTag().orElse(null), getErrorMessage().orElse(null)); + getDescription().orElse(null), getReference().orElse(null), getErrorAppTag().orElse(null), + getErrorMessage().orElse(null)); } } diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6874Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6874Test.java index 22a7535277..95198e45c4 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6874Test.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6874Test.java @@ -13,6 +13,7 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource; +import java.util.Optional; import org.junit.Test; import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.ModuleImport; @@ -52,8 +53,10 @@ public class Bug6874Test { // Test for valid import statement ModuleImport importStmt = testModule.getImports().iterator().next(); - assertEquals("Yang 1.1: Allow description and reference in include and import.", importStmt.getDescription()); - assertEquals("https://tools.ietf.org/html/rfc7950 section-7.1.5/6", importStmt.getReference()); + assertEquals(Optional.of("Yang 1.1: Allow description and reference in include and import."), + importStmt.getDescription()); + assertEquals(Optional.of("https://tools.ietf.org/html/rfc7950 section-7.1.5/6"), + importStmt.getReference()); } @Test diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6883Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6883Test.java index 00a51c738e..bc5c6dd6fa 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6883Test.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6883Test.java @@ -14,6 +14,7 @@ import static org.junit.Assert.assertTrue; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; +import java.util.Optional; import org.junit.Test; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.model.api.AnyDataSchemaNode; @@ -34,7 +35,7 @@ public class Bug6883Test { final AnyDataSchemaNode topAnyData = assertAnyData(schemaContext, ImmutableList.of("top")); assertEquals(Status.DEPRECATED, topAnyData.getStatus()); - assertEquals("top anydata", topAnyData.getDescription()); + assertEquals(Optional.of("top anydata"), topAnyData.getDescription()); assertAnyData(schemaContext, ImmutableList.of("root", "root-anydata")); assertAnyData(schemaContext, ImmutableList.of("root", "aug-anydata")); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug5481Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug5481Test.java index dd4e0889ab..921fc445f8 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug5481Test.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug5481Test.java @@ -11,9 +11,9 @@ 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.assertNull; 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.ContainerSchemaNode; @@ -43,8 +43,8 @@ public class Bug5481Test { assertFalse(topContainer.getConstraints().getWhenCondition().isPresent()); assertEquals(Status.CURRENT, topContainer.getStatus()); - assertNull(topContainer.getDescription()); - assertNull(topContainer.getReference()); + assertFalse(topContainer.getDescription().isPresent()); + assertFalse(topContainer.getReference().isPresent()); return topContainer; } @@ -58,7 +58,7 @@ public class Bug5481Test { assertEquals(new RevisionAwareXPathImpl("module1:top = 'extended'", false), whenConditionExtendedLeaf); assertEquals(Status.DEPRECATED, extendedLeaf.getStatus()); - assertEquals("text", extendedLeaf.getDescription()); - assertEquals("ref", extendedLeaf.getReference()); + assertEquals(Optional.of("text"), extendedLeaf.getDescription()); + assertEquals(Optional.of("ref"), extendedLeaf.getReference()); } } diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug5942Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug5942Test.java index 05a80e1017..5c7b541529 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug5942Test.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug5942Test.java @@ -13,6 +13,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.util.List; +import java.util.Optional; import java.util.Set; import org.junit.Test; import org.opendaylight.yangtools.yang.common.QName; @@ -37,8 +38,8 @@ public class Bug5942Test { assertEquals(1, uses.size()); final UsesNode usesNode = uses.iterator().next(); - assertEquals("uses description", usesNode.getDescription()); - assertEquals("uses reference", usesNode.getReference()); + assertEquals(Optional.of("uses description"), usesNode.getDescription()); + assertEquals(Optional.of("uses reference"), usesNode.getReference()); assertEquals(Status.DEPRECATED, usesNode.getStatus()); assertEquals(new RevisionAwareXPathImpl("0!=1", false), usesNode.getWhenCondition().get()); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6180Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6180Test.java index 2700ef44f1..a3a4080e0f 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6180Test.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6180Test.java @@ -14,6 +14,7 @@ import static org.junit.Assert.assertTrue; import java.io.File; import java.util.List; +import java.util.Optional; import java.util.Set; import java.util.regex.Pattern; import org.junit.Test; @@ -36,10 +37,10 @@ public class Bug6180Test { assertNotNull(schemaContext); assertEquals(1, schemaContext.getModules().size()); final Module module = schemaContext.getModules().iterator().next(); - assertEquals(" 1. this text contains \"string enclosed in double quotes\" and" + assertEquals(Optional.of(" 1. this text contains \"string enclosed in double quotes\" and" + " special characters: \\,\n,\t 2. this text contains \"string enclosed in double quotes\"" + " and special characters: \\,\n,\n, 3. this text contains \"string enclosed in" - + " double quotes\" and special characters: \\,\n,\t ", module.getDescription()); + + " double quotes\" and special characters: \\,\n,\t "), module.getDescription()); } @Test diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug7879Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug7879Test.java index fe79eb6592..687d0855e5 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug7879Test.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug7879Test.java @@ -11,6 +11,7 @@ import static org.junit.Assert.assertEquals; 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.model.api.ContainerSchemaNode; @@ -32,7 +33,7 @@ public class Bug7879Test { instanceof ContainerSchemaNode); final SchemaNode myEventValueLeaf = findNode(context, qN("my-alarm"), qN("my-content"), qN("my-event-value")); assertTrue(myEventValueLeaf instanceof LeafSchemaNode); - assertEquals("new description", myEventValueLeaf.getDescription()); + assertEquals(Optional.of("new description"), myEventValueLeaf.getDescription()); } private static SchemaNode findNode(final SchemaContext context, final QName... qnames) { diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug8597Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug8597Test.java index 14931f5908..c3dd3c270f 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug8597Test.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug8597Test.java @@ -11,6 +11,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; +import java.util.Optional; import java.util.Set; import org.junit.Test; import org.opendaylight.yangtools.yang.common.Revision; @@ -31,13 +32,13 @@ public class Bug8597Test { switch (moduleImport.getModuleName()) { case "bar": assertEquals(Revision.ofNullable("1970-01-01"), moduleImport.getRevision()); - assertEquals("bar-ref", moduleImport.getReference()); - assertEquals("bar-desc", moduleImport.getDescription()); + assertEquals(Optional.of("bar-ref"), moduleImport.getReference()); + assertEquals(Optional.of("bar-desc"), moduleImport.getDescription()); break; case "baz": assertEquals(Revision.ofNullable("2010-10-10"), moduleImport.getRevision()); - assertEquals("baz-ref", moduleImport.getReference()); - assertEquals("baz-desc", moduleImport.getDescription()); + assertEquals(Optional.of("baz-ref"), moduleImport.getReference()); + assertEquals(Optional.of("baz-desc"), moduleImport.getDescription()); break; default: fail("Module 'foo' should only contains import of module 'bar' and 'baz'"); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug8922Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug8922Test.java index 6f5fc5de74..cf23539042 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug8922Test.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug8922Test.java @@ -13,6 +13,7 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import com.google.common.collect.ImmutableSet; +import java.util.Optional; import org.junit.Test; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; @@ -30,7 +31,7 @@ public class Bug8922Test { assertNotNull(context); final SchemaNode findNode = findNode(context, qN("target"), qN("my-con")); assertTrue(findNode instanceof ContainerSchemaNode); - assertEquals("New description", ((ContainerSchemaNode) findNode).getDescription()); + assertEquals(Optional.of("New description"), ((ContainerSchemaNode) findNode).getDescription()); } @Test diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/DeviationStmtTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/DeviationStmtTest.java index fca033d250..6da3c70dfb 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/DeviationStmtTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/DeviationStmtTest.java @@ -16,6 +16,7 @@ import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResour import java.text.ParseException; import java.util.List; +import java.util.Optional; import java.util.Set; import org.junit.Test; import org.opendaylight.yangtools.yang.common.Revision; @@ -53,7 +54,7 @@ public class DeviationStmtTest { final List deviates = deviation.getDeviates(); final String targetLocalName = deviation.getTargetPath().getLastComponent().getLocalName(); if ("test-leaf".equals(targetLocalName)) { - assertEquals("test-leaf is not supported", deviation.getDescription()); + assertEquals(Optional.of("test-leaf is not supported"), deviation.getDescription()); assertEquals(1, deviates.size()); assertEquals(DeviateKind.NOT_SUPPORTED, deviates.iterator().next().getDeviateType()); } else if ("test-leaf-2".equals(targetLocalName)) { @@ -114,7 +115,7 @@ public class DeviationStmtTest { } if ("bar-leaf-1".equals(targetLocalName)) { - if ("desc".equals(deviation.getDescription())) { + if (Optional.of("desc").equals(deviation.getDescription())) { deviation4 = deviation; } else { deviation5 = deviation; @@ -122,7 +123,7 @@ public class DeviationStmtTest { } if ("bar-leaf-2".equals(targetLocalName)) { - if ("ref".equals(deviation.getReference())) { + if (Optional.of("ref").equals(deviation.getReference())) { deviation6 = deviation; } else { deviation7 = deviation; diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveModuleTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveModuleTest.java index c96fccc457..7a5a4482b6 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveModuleTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveModuleTest.java @@ -112,7 +112,7 @@ public class EffectiveModuleTest { final SchemaPath importedContSchemaPath = SchemaPath.create(true, importedContQName); assertEquals(importedContSchemaPath, deviationStmt.getTargetPath()); assertEquals(DeviateKind.ADD, deviationStmt.getDeviates().iterator().next().getDeviateType()); - assertEquals("deviate reference", deviationStmt.getReference()); + assertEquals(Optional.of("deviate reference"), deviationStmt.getReference()); final Set identities = rootModule.getIdentities(); assertEquals(1, identities.size()); @@ -124,8 +124,8 @@ public class EffectiveModuleTest { assertNotNull(featureStmt); assertEquals(FEATURE1, featureStmt.getQName()); assertEquals(FEATURE1_SCHEMA_PATH, featureStmt.getPath()); - assertEquals("feature1 description", featureStmt.getDescription()); - assertEquals("feature1 reference", featureStmt.getReference()); + assertEquals(Optional.of("feature1 description"), featureStmt.getDescription()); + assertEquals(Optional.of("feature1 reference"), featureStmt.getReference()); assertEquals(Status.CURRENT, featureStmt.getStatus()); final List extensionSchemaNodes = rootModule.getExtensionSchemaNodes(); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveModulesAndSubmodulesTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveModulesAndSubmodulesTest.java index 10f09dbd84..0197038fdc 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveModulesAndSubmodulesTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveModulesAndSubmodulesTest.java @@ -15,6 +15,7 @@ import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResour import java.net.URI; import java.util.Collection; +import java.util.Optional; import java.util.Set; import org.junit.Test; import org.opendaylight.yangtools.yang.common.QName; @@ -163,7 +164,7 @@ public class EffectiveModulesAndSubmodulesTest { final DataSchemaNode containerInRoot = result.getDataChildByName(QName .create(root.getQNameModule(), "container-in-root-module")); assertNotNull(containerInRoot); - assertEquals("desc", containerInRoot.getDescription()); + assertEquals(Optional.of("desc"), containerInRoot.getDescription()); } private static void findModulesSubTest(final SchemaContext result, final Module root, final Module imported) { diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveSchemaContextTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveSchemaContextTest.java index 176ed80a9f..702081e2f8 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveSchemaContextTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveSchemaContextTest.java @@ -87,8 +87,8 @@ public class EffectiveSchemaContextTest { assertFalse(schemaContext.isConfiguration()); assertFalse(schemaContext.isPresenceContainer()); assertNull(schemaContext.getConstraints()); - assertNull(schemaContext.getDescription()); - assertNull(schemaContext.getReference()); + assertFalse(schemaContext.getDescription().isPresent()); + assertFalse(schemaContext.getReference().isPresent()); assertEquals(SchemaContext.NAME, schemaContext.getQName()); assertEquals(SchemaPath.ROOT, schemaContext.getPath()); assertEquals(Status.CURRENT, schemaContext.getStatus()); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveStatementTypeTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveStatementTypeTest.java index df387ffb25..dc9072d5f7 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveStatementTypeTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveStatementTypeTest.java @@ -24,6 +24,7 @@ import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.model.api.Status; import org.opendaylight.yangtools.yang.model.api.stmt.TypeEffectiveStatement; import org.opendaylight.yangtools.yang.model.api.type.BinaryTypeDefinition; import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition; @@ -83,11 +84,11 @@ public class EffectiveStatementTypeTest { assertNull(binaryEff.getDefaultValue()); assertEquals("binary", binaryEff.getQName().getLocalName()); assertFalse(binaryEff.getLengthConstraint().isPresent()); - assertEquals("CURRENT", binaryEff.getStatus().toString()); + assertEquals(Status.CURRENT, binaryEff.getStatus()); assertEquals("binary", binaryEff.getPath().getPathFromRoot().iterator().next().getLocalName()); assertNotNull(binaryEff.getUnknownSchemaNodes()); - assertNull(binaryEff.getDescription()); - assertNull(binaryEff.getReference()); + assertFalse(binaryEff.getDescription().isPresent()); + assertFalse(binaryEff.getReference().isPresent()); } @Test @@ -108,9 +109,9 @@ public class EffectiveStatementTypeTest { assertEquals("bits", bitsEff.getQName().getLocalName()); assertEquals("bits", bitsEff.getPath().getLastComponent().getLocalName()); assertNotNull(bitsEff.getUnknownSchemaNodes()); - assertNull(bitsEff.getDescription()); - assertNull(bitsEff.getReference()); - assertEquals("CURRENT", bitsEff.getStatus().toString()); + assertFalse(bitsEff.getDescription().isPresent()); + assertFalse(bitsEff.getReference().isPresent()); + assertEquals(Status.CURRENT, bitsEff.getStatus()); assertNull(bitsEff.getUnits()); assertNotNull(bitsEff.toString()); assertNotNull(bitsEff.hashCode()); @@ -122,9 +123,9 @@ public class EffectiveStatementTypeTest { assertNotNull(bitEff.getPath()); assertNotNull(bitEff.getUnknownSchemaNodes()); - assertEquals("test bit", bitEff.getDescription()); - assertEquals("test bit ref", bitEff.getReference()); - assertEquals("CURRENT", bitEff.getStatus().toString()); + assertEquals(Optional.of("test bit"), bitEff.getDescription()); + assertEquals(Optional.of("test bit ref"), bitEff.getReference()); + assertEquals(Status.CURRENT, bitEff.getStatus()); assertNotNull(bitEff.hashCode()); assertFalse(bitEff.equals(null)); assertFalse(bitEff.equals("test")); @@ -149,9 +150,9 @@ public class EffectiveStatementTypeTest { assertEquals("boolean", booleanEff.getQName().getLocalName()); assertNull(booleanEff.getPath().getParent().getParent()); assertNotNull(booleanEff.getUnknownSchemaNodes()); - assertNull(booleanEff.getDescription()); - assertNull(booleanEff.getReference()); - assertEquals("CURRENT", booleanEff.getStatus().toString()); + assertFalse(booleanEff.getDescription().isPresent()); + assertFalse(booleanEff.getReference().isPresent()); + assertEquals(Status.CURRENT, booleanEff.getStatus()); assertNotNull(booleanEff.toString()); } @@ -172,9 +173,9 @@ public class EffectiveStatementTypeTest { // FIXME: The yang model api is wrong: description/reference/status are not allowed under 'type', how come we // parse it? // allowed under 'type', how come we parse it? - assertNull(decimal64Eff.getDescription()); - assertNull(decimal64Eff.getReference()); - assertEquals("CURRENT", decimal64Eff.getStatus().toString()); + assertFalse(decimal64Eff.getDescription().isPresent()); + assertFalse(decimal64Eff.getReference().isPresent()); + assertEquals(Status.CURRENT, decimal64Eff.getStatus()); assertEquals(3, decimal64Eff.getRangeConstraints().size()); assertNotNull(decimal64Eff.toString()); @@ -200,8 +201,8 @@ public class EffectiveStatementTypeTest { assertEquals("empty", emptyEff.getQName().getLocalName()); assertNull(emptyEff.getPath().getParent().getParent()); assertNotNull(emptyEff.getUnknownSchemaNodes()); - assertNull(emptyEff.getDescription()); - assertNull(emptyEff.getReference()); + assertFalse(emptyEff.getDescription().isPresent()); + assertFalse(emptyEff.getReference().isPresent()); assertEquals("CURRENT", emptyEff.getStatus().toString()); assertNotNull(emptyEff.toString()); } @@ -223,9 +224,9 @@ public class EffectiveStatementTypeTest { assertEquals(3, enumSpecEff.getValues().size()); assertNull(enumSpecEff.getBaseType()); assertNotNull(enumSpecEff.getUnknownSchemaNodes()); - assertEquals("CURRENT", enumSpecEff.getStatus().toString()); - assertNull(enumSpecEff.getDescription()); - assertNull(enumSpecEff.getReference()); + assertEquals(Status.CURRENT, enumSpecEff.getStatus()); + assertFalse(enumSpecEff.getDescription().isPresent()); + assertFalse(enumSpecEff.getReference().isPresent()); assertNull(enumSpecEff.getUnits()); assertNotNull(enumSpecEff.toString()); assertNotNull(enumSpecEff.hashCode()); @@ -235,9 +236,9 @@ public class EffectiveStatementTypeTest { assertEquals("zero", enumEff.getName()); assertNotNull(enumEff.getUnknownSchemaNodes()); - assertEquals("test enum", enumEff.getDescription()); - assertEquals("test enum ref", enumEff.getReference()); - assertEquals("CURRENT", enumEff.getStatus().toString()); + assertEquals(Optional.of("test enum"), enumEff.getDescription()); + assertEquals(Optional.of("test enum ref"), enumEff.getReference()); + assertEquals(Status.CURRENT, enumEff.getStatus()); assertEquals(0, enumEff.getValue()); } @@ -255,10 +256,10 @@ public class EffectiveStatementTypeTest { assertEquals("identityref", identityRefEff.getPath().getLastComponent().getLocalName()); assertNull(identityRefEff.getBaseType()); assertNotNull(identityRefEff.getUnknownSchemaNodes()); - assertEquals("CURRENT", identityRefEff.getStatus().toString()); + assertEquals(Status.CURRENT, identityRefEff.getStatus()); assertEquals("test-identity", identityRefEff.getIdentity().getQName().getLocalName()); - assertNull(identityRefEff.getDescription()); - assertNull(identityRefEff.getReference()); + assertFalse(identityRefEff.getDescription().isPresent()); + assertFalse(identityRefEff.getReference().isPresent()); assertNotNull(identityRefEff.toString()); // FIXME: the model is wrong, but we accept units in 'type' statement @@ -281,10 +282,10 @@ public class EffectiveStatementTypeTest { assertNull(instanceIdentEff.getBaseType()); assertNull(instanceIdentEff.getDefaultValue()); assertNotNull(instanceIdentEff.getUnknownSchemaNodes()); - assertNull(instanceIdentEff.getDescription()); - assertNull(instanceIdentEff.getReference()); + assertFalse(instanceIdentEff.getDescription().isPresent()); + assertFalse(instanceIdentEff.getReference().isPresent()); assertNull(instanceIdentEff.getUnits()); - assertEquals("CURRENT", instanceIdentEff.getStatus().toString()); + assertEquals(Status.CURRENT, instanceIdentEff.getStatus()); assertNotNull(instanceIdentEff.hashCode()); assertFalse(instanceIdentEff.equals(null)); assertFalse(instanceIdentEff.equals("test")); @@ -306,11 +307,11 @@ public class EffectiveStatementTypeTest { assertNull(leafrefEff.getDefaultValue()); assertNotNull(leafrefEff.toString()); assertEquals("leafref", leafrefEff.getQName().getLocalName()); - assertEquals("CURRENT", leafrefEff.getStatus().toString()); + assertEquals(Status.CURRENT, leafrefEff.getStatus()); assertNotNull(leafrefEff.getUnknownSchemaNodes()); assertEquals("leafref", leafrefEff.getPath().getLastComponent().getLocalName()); - assertNull(leafrefEff.getDescription()); - assertNull(leafrefEff.getReference()); + assertFalse(leafrefEff.getDescription().isPresent()); + assertFalse(leafrefEff.getReference().isPresent()); assertNotNull(leafrefEff.hashCode()); assertFalse(leafrefEff.equals(null)); assertFalse(leafrefEff.equals("test")); @@ -383,8 +384,8 @@ public class EffectiveStatementTypeTest { assertNull(unionEff.getBaseType()); assertNull(unionEff.getUnits()); assertNull(unionEff.getDefaultValue()); - assertNull(unionEff.getDescription()); - assertNull(unionEff.getReference()); + assertFalse(unionEff.getDescription().isPresent()); + assertFalse(unionEff.getReference().isPresent()); assertNotNull(unionEff.toString()); assertNotNull(unionEff.hashCode()); assertFalse(unionEff.equals(null)); @@ -405,8 +406,8 @@ public class EffectiveStatementTypeTest { final Range span = lengthConstraint.getAllowedRanges().span(); assertEquals(1, span.lowerEndpoint().intValue()); assertEquals(255, span.upperEndpoint().intValue()); - assertNull(lengthConstraint.getReference()); - assertNull(lengthConstraint.getDescription()); + assertFalse(lengthConstraint.getReference().isPresent()); + assertFalse(lengthConstraint.getDescription().isPresent()); assertFalse(lengthConstraint.getErrorMessage().isPresent()); assertFalse(lengthConstraint.getErrorAppTag().isPresent()); assertNotNull(lengthConstraint.toString()); @@ -438,8 +439,8 @@ public class EffectiveStatementTypeTest { ((StringTypeDefinition) currentLeaf.getType()).getPatternConstraints().get(0); assertEquals("^[0-9a-fA-F]*$", patternConstraint.getRegularExpression()); - assertNull(patternConstraint.getReference()); - assertNull(patternConstraint.getDescription()); + assertFalse(patternConstraint.getReference().isPresent()); + assertFalse(patternConstraint.getDescription().isPresent()); assertEquals(Optional.of("Supplied value does not match the regular expression ^[0-9a-fA-F]*$."), patternConstraint.getErrorMessage()); assertEquals(Optional.of("invalid-regular-expression"), patternConstraint.getErrorAppTag()); @@ -460,13 +461,13 @@ public class EffectiveStatementTypeTest { .getTypeDefinition(); assertEquals("string", stringEff.getQName().getLocalName()); - assertEquals("CURRENT", stringEff.getStatus().toString()); + assertEquals(Status.CURRENT, stringEff.getStatus()); assertNull(stringEff.getUnits()); assertNull(stringEff.getDefaultValue()); assertNotNull(stringEff.getUnknownSchemaNodes()); assertNull(stringEff.getBaseType()); - assertNull(stringEff.getDescription()); - assertNull(stringEff.getReference()); + assertFalse(stringEff.getDescription().isPresent()); + assertFalse(stringEff.getReference().isPresent()); assertNotNull(stringEff.toString()); assertNotNull(stringEff.hashCode()); assertFalse(stringEff.equals(null)); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveUsesRefineAndConstraintsTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveUsesRefineAndConstraintsTest.java index d5e28fd54a..ce2a075568 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveUsesRefineAndConstraintsTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveUsesRefineAndConstraintsTest.java @@ -11,10 +11,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.assertNull; import static org.junit.Assert.assertTrue; import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource; +import java.util.Optional; import java.util.Set; import org.junit.Test; import org.opendaylight.yangtools.yang.common.QName; @@ -88,8 +88,8 @@ public class EffectiveUsesRefineAndConstraintsTest { assertNotNull(containerInContainerNode); ContainerSchemaNode containerSchemaNode = (ContainerSchemaNode) containerInContainerNode; - assertNull(containerSchemaNode.getReference()); - assertNull(containerSchemaNode.getDescription()); + assertFalse(containerSchemaNode.getReference().isPresent()); + assertFalse(containerSchemaNode.getDescription().isPresent()); assertTrue(containerSchemaNode.isConfiguration()); assertFalse(containerSchemaNode.isPresenceContainer()); @@ -113,8 +113,8 @@ public class EffectiveUsesRefineAndConstraintsTest { assertNotNull(listInContainerNode); ListSchemaNode listSchemaNode = (ListSchemaNode) listInContainerNode; - assertEquals("original reference", listSchemaNode.getReference()); - assertEquals("original description", listSchemaNode.getDescription()); + assertEquals(Optional.of("original reference"), listSchemaNode.getReference()); + assertEquals(Optional.of("original description"), listSchemaNode.getDescription()); assertFalse(listSchemaNode.isConfiguration()); ConstraintDefinition listConstraints = listSchemaNode.getConstraints(); @@ -128,8 +128,8 @@ public class EffectiveUsesRefineAndConstraintsTest { assertNotNull(containerInContainerNode); ContainerSchemaNode containerSchemaNode = (ContainerSchemaNode) containerInContainerNode; - assertEquals("new reference", containerSchemaNode.getReference()); - assertEquals("new description", containerSchemaNode.getDescription()); + assertEquals(Optional.of("new reference"), containerSchemaNode.getReference()); + assertEquals(Optional.of("new description"), containerSchemaNode.getDescription()); assertTrue(containerSchemaNode.isConfiguration()); assertTrue(containerSchemaNode.isPresenceContainer()); @@ -153,8 +153,8 @@ public class EffectiveUsesRefineAndConstraintsTest { assertNotNull(listInContainerNode); ListSchemaNode listSchemaNode = (ListSchemaNode) listInContainerNode; - assertEquals("new reference", listSchemaNode.getReference()); - assertEquals("new description", listSchemaNode.getDescription()); + assertEquals(Optional.of("new reference"), listSchemaNode.getReference()); + assertEquals(Optional.of("new description"), listSchemaNode.getDescription()); assertTrue(listSchemaNode.isConfiguration()); ConstraintDefinition listConstraints = listSchemaNode.getConstraints(); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/GroupingTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/GroupingTest.java index c3b638a492..0dc25d73f0 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/GroupingTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/GroupingTest.java @@ -19,6 +19,7 @@ import java.text.ParseException; import java.util.Collection; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Set; import org.junit.Before; import org.junit.Test; @@ -98,8 +99,8 @@ public class GroupingTest { // leaf address assertNotNull(refineLeaf); - assertEquals("IP address of target node", refineLeaf.getDescription()); - assertEquals("address reference added by refine", refineLeaf.getReference()); + assertEquals(Optional.of("IP address of target node"), refineLeaf.getDescription()); + assertEquals(Optional.of("address reference added by refine"), refineLeaf.getReference()); assertFalse(refineLeaf.isConfiguration()); assertFalse(refineLeaf.getConstraints().isMandatory()); final Set leafMustConstraints = refineLeaf.getConstraints().getMustConstraints(); @@ -112,21 +113,21 @@ public class GroupingTest { assertNotNull(refineContainer); final Set mustConstraints = refineContainer.getConstraints().getMustConstraints(); assertTrue(mustConstraints.isEmpty()); - assertEquals("description of port defined by refine", refineContainer.getDescription()); - assertEquals("port reference added by refine", refineContainer.getReference()); + assertEquals(Optional.of("description of port defined by refine"), refineContainer.getDescription()); + assertEquals(Optional.of("port reference added by refine"), refineContainer.getReference()); assertFalse(refineContainer.isConfiguration()); assertTrue(refineContainer.isPresenceContainer()); // list addresses - assertEquals("description of addresses defined by refine", refineList.getDescription()); - assertEquals("addresses reference added by refine", refineList.getReference()); + 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(2, (int) refineList.getConstraints().getMinElements()); assertNull(refineList.getConstraints().getMaxElements()); // leaf id assertNotNull(refineInnerLeaf); - assertEquals("id of address", refineInnerLeaf.getDescription()); + assertEquals(Optional.of("id of address"), refineInnerLeaf.getDescription()); } @Test @@ -191,8 +192,8 @@ public class GroupingTest { foo.getQNameModule(), "address")); assertNotNull(address_u); assertEquals("1.2.3.4", address_u.getDefault()); - assertEquals("IP address of target node", address_u.getDescription()); - assertEquals("address reference added by refine", address_u.getReference()); + 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()); assertTrue(address_u.isAddedByUses()); assertFalse(address_u.getConstraints().isMandatory()); @@ -202,8 +203,8 @@ public class GroupingTest { assertNotNull(address_g); assertFalse(address_g.isAddedByUses()); assertNull(address_g.getDefault()); - assertEquals("Target IP address", address_g.getDescription()); - assertNull(address_g.getReference()); + assertEquals(Optional.of("Target IP address"), address_g.getDescription()); + assertFalse(address_g.getReference().isPresent()); assertTrue(address_g.isConfiguration()); assertFalse(address_u.equals(address_g)); assertTrue(address_g.getConstraints().isMandatory()); @@ -312,8 +313,8 @@ public class GroupingTest { "address")); assertNotNull(address_u); assertNull(address_u.getDefault()); - assertEquals("Target IP address", address_u.getDescription()); - assertNull(address_u.getReference()); + assertEquals(Optional.of("Target IP address"), address_u.getDescription()); + assertFalse(address_u.getReference().isPresent()); assertTrue(address_u.isConfiguration()); assertTrue(address_u.isAddedByUses()); @@ -322,8 +323,8 @@ public class GroupingTest { assertNotNull(address_g); assertFalse(address_g.isAddedByUses()); assertNull(address_g.getDefault()); - assertEquals("Target IP address", address_g.getDescription()); - assertNull(address_g.getReference()); + assertEquals(Optional.of("Target IP address"), address_g.getDescription()); + assertFalse(address_g.getReference().isPresent()); assertTrue(address_g.isConfiguration()); assertFalse(address_u.equals(address_g)); assertEquals(address_g, SchemaNodeUtils.getRootOriginalIfPossible(address_u)); @@ -380,7 +381,7 @@ public class GroupingTest { final Set usesAugments = un.getAugmentations(); assertEquals(1, usesAugments.size()); final AugmentationSchemaNode augment = usesAugments.iterator().next(); - assertEquals("inner augment", augment.getDescription()); + assertEquals(Optional.of("inner augment"), augment.getDescription()); final Collection children = augment.getChildNodes(); assertEquals(1, children.size()); final DataSchemaNode leaf = children.iterator().next(); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/TypesResolutionTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/TypesResolutionTest.java index 2a0cb193ab..444ad56848 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/TypesResolutionTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/TypesResolutionTest.java @@ -10,7 +10,6 @@ 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.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource; @@ -19,6 +18,7 @@ import com.google.common.collect.Iterables; import com.google.common.collect.Range; import java.net.URI; import java.util.List; +import java.util.Optional; import java.util.Set; import org.junit.Before; import org.junit.Test; @@ -67,8 +67,8 @@ public class TypesResolutionTest { assertEquals(14, typedefs.size()); TypeDefinition type = TestUtils.findTypedef(typedefs, "ip-version"); - assertTrue(type.getDescription().contains("This value represents the version of the IP protocol.")); - assertTrue(type.getReference().contains("RFC 2460: Internet Protocol, Version 6 (IPv6) Specification")); + assertTrue(type.getDescription().get().contains("This value represents the version of the IP protocol.")); + assertTrue(type.getReference().get().contains("RFC 2460: Internet Protocol, Version 6 (IPv6) Specification")); EnumTypeDefinition enumType = (EnumTypeDefinition) type.getBaseType(); List values = enumType.getValues(); @@ -77,17 +77,18 @@ public class TypesResolutionTest { EnumPair value0 = values.get(0); assertEquals("unknown", value0.getName()); assertEquals(0, value0.getValue()); - assertEquals("An unknown or unspecified version of the Internet protocol.", value0.getDescription()); + assertEquals(Optional.of("An unknown or unspecified version of the Internet protocol."), + value0.getDescription()); EnumPair value1 = values.get(1); assertEquals("ipv4", value1.getName()); assertEquals(1, value1.getValue()); - assertEquals("The IPv4 protocol as defined in RFC 791.", value1.getDescription()); + assertEquals(Optional.of("The IPv4 protocol as defined in RFC 791."), value1.getDescription()); EnumPair value2 = values.get(2); assertEquals("ipv6", value2.getName()); assertEquals(2, value2.getValue()); - assertEquals("The IPv6 protocol as defined in RFC 2460.", value2.getDescription()); + assertEquals(Optional.of("The IPv6 protocol as defined in RFC 2460."), value2.getDescription()); } @Test @@ -103,22 +104,23 @@ public class TypesResolutionTest { EnumPair value0 = values.get(0); assertEquals("unknown", value0.getName()); assertEquals(0, value0.getValue()); - assertEquals("An unknown or unspecified version of the Internet protocol.", value0.getDescription()); + assertEquals(Optional.of("An unknown or unspecified version of the Internet protocol."), + value0.getDescription()); EnumPair value1 = values.get(1); assertEquals("ipv4", value1.getName()); assertEquals(19, value1.getValue()); - assertEquals("The IPv4 protocol as defined in RFC 791.", value1.getDescription()); + assertEquals(Optional.of("The IPv4 protocol as defined in RFC 791."), value1.getDescription()); EnumPair value2 = values.get(2); assertEquals("ipv6", value2.getName()); assertEquals(7, value2.getValue()); - assertEquals("The IPv6 protocol as defined in RFC 2460.", value2.getDescription()); + assertEquals(Optional.of("The IPv6 protocol as defined in RFC 2460."), value2.getDescription()); EnumPair value3 = values.get(3); assertEquals("default", value3.getName()); assertEquals(20, value3.getValue()); - assertEquals("default ip", value3.getDescription()); + assertEquals(Optional.of("default ip"), value3.getDescription()); } @Test @@ -277,8 +279,8 @@ public class TypesResolutionTest { TypeDefinition testedType = TestUtils.findTypedef(typedefs, "iana-timezone"); String expectedDesc = "A timezone location as defined by the IANA timezone"; - assertTrue(testedType.getDescription().contains(expectedDesc)); - assertNull(testedType.getReference()); + assertTrue(testedType.getDescription().get().contains(expectedDesc)); + assertFalse(testedType.getReference().isPresent()); assertEquals(Status.CURRENT, testedType.getStatus()); QName testedTypeQName = testedType.getQName(); @@ -293,12 +295,12 @@ public class TypesResolutionTest { EnumPair enum168 = values.get(168); assertEquals("America/Danmarkshavn", enum168.getName()); assertEquals(168, enum168.getValue()); - assertEquals("east coast, north of Scoresbysund", enum168.getDescription()); + assertEquals(Optional.of("east coast, north of Scoresbysund"), enum168.getDescription()); EnumPair enum374 = values.get(374); assertEquals("America/Indiana/Winamac", enum374.getName()); assertEquals(374, enum374.getValue()); - assertEquals("Eastern Time - Indiana - Pulaski County", enum374.getDescription()); + assertEquals(Optional.of("Eastern Time - Indiana - Pulaski County"), enum374.getDescription()); } @Test diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserSimpleTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserSimpleTest.java index 25140285eb..4ea6c6d2bd 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserSimpleTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserSimpleTest.java @@ -64,8 +64,8 @@ public class YangParserSimpleTest { // test SchemaNode args assertEquals(QName.create(SN, "data"), data.getQName()); - assertEquals("anyxml desc", data.getDescription()); - assertEquals("data ref", data.getReference()); + assertEquals(Optional.of("anyxml desc"), data.getDescription()); + assertEquals(Optional.of("data ref"), data.getReference()); assertEquals(Status.OBSOLETE, data.getStatus()); assertEquals(0, data.getUnknownSchemaNodes().size()); // test DataSchemaNode args @@ -89,8 +89,8 @@ public class YangParserSimpleTest { found2 = true; assertEquals(Optional.of("An atm MTU must be 64 .. 17966"), must.getErrorMessage()); assertEquals(Optional.of("anyxml data error-app-tag"), must.getErrorAppTag()); - assertEquals("an error occured in data", must.getDescription()); - assertEquals("data must ref", must.getReference()); + assertEquals(Optional.of("an error occured in data"), must.getDescription()); + assertEquals(Optional.of("data must ref"), must.getReference()); } } assertTrue(found1); @@ -108,8 +108,8 @@ public class YangParserSimpleTest { // test SchemaNode args assertEquals(SN_NODES, nodes.getQName()); assertEquals(SN_NODES_PATH, nodes.getPath()); - assertEquals("nodes collection", nodes.getDescription()); - assertEquals("nodes ref", nodes.getReference()); + assertEquals(Optional.of("nodes collection"), nodes.getDescription()); + assertEquals(Optional.of("nodes ref"), nodes.getReference()); assertEquals(Status.CURRENT, nodes.getStatus()); assertEquals(0, nodes.getUnknownSchemaNodes().size()); // test DataSchemaNode args @@ -136,8 +136,8 @@ public class YangParserSimpleTest { found2 = true; assertFalse(must.getErrorMessage().isPresent()); assertFalse(must.getErrorAppTag().isPresent()); - assertNull(must.getDescription()); - assertNull(must.getReference()); + assertFalse(must.getDescription().isPresent()); + assertFalse(must.getReference().isPresent()); } } assertTrue(found1); @@ -155,8 +155,8 @@ public class YangParserSimpleTest { final QName typedefQName = QName.create(SN, "nodes-type"); assertEquals(typedefQName, nodesType.getQName()); assertEquals(SN_NODES_PATH.createChild(QName.create(SN, "nodes-type")), nodesType.getPath()); - assertNull(nodesType.getDescription()); - assertNull(nodesType.getReference()); + assertFalse(nodesType.getDescription().isPresent()); + assertFalse(nodesType.getReference().isPresent()); assertEquals(Status.CURRENT, nodesType.getStatus()); assertEquals(0, nodesType.getUnknownSchemaNodes().size()); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserTest.java index 42bc8ed3be..85439e2f36 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserTest.java @@ -111,7 +111,7 @@ public class YangParserTest { assertEquals(Optional.of("opendaylight"), foo.getOrganization()); assertEquals(Optional.of("http://www.opendaylight.org/"), foo.getContact()); assertEquals(Revision.ofNullable("2013-02-27"), foo.getRevision()); - assertNull(foo.getReference()); + assertFalse(foo.getReference().isPresent()); } @Test @@ -126,8 +126,8 @@ public class YangParserTest { final SchemaPath expectedPath = TestUtils.createPath(true, BAR, "interfaces", "ifEntry"); assertEquals(expectedPath, ifEntry.getPath()); - assertNull(ifEntry.getDescription()); - assertNull(ifEntry.getReference()); + assertFalse(ifEntry.getDescription().isPresent()); + assertFalse(ifEntry.getReference().isPresent()); assertEquals(Status.CURRENT, ifEntry.getStatus()); assertEquals(0, ifEntry.getUnknownSchemaNodes().size()); // test DataSchemaNode args @@ -538,7 +538,7 @@ public class YangParserTest { final Set deviations = foo.getDeviations(); assertEquals(1, deviations.size()); final Deviation dev = deviations.iterator().next(); - assertEquals("system/user ref", dev.getReference()); + assertEquals(Optional.of("system/user ref"), dev.getReference()); final SchemaPath expectedPath = SchemaPath.create(true, QName.create(BAR, "interfaces"), @@ -571,7 +571,8 @@ public class YangParserTest { assertEquals(1, extensions.size()); final ExtensionDefinition extension = extensions.get(0); assertEquals("name", extension.getArgument()); - assertEquals("Takes as argument a name string. Makes the code generator use the given name in the #define.", + assertEquals( + Optional.of("Takes as argument a name string. Makes the code generator use the given name in the #define."), extension.getDescription()); assertTrue(extension.isYinElement()); } @@ -586,8 +587,8 @@ public class YangParserTest { assertEquals(QName.create(BAZ, "event"), notification.getQName()); final SchemaPath expectedPath = SchemaPath.create(true, QName.create(BAZ, "event")); assertEquals(expectedPath, notification.getPath()); - assertNull(notification.getDescription()); - assertNull(notification.getReference()); + assertFalse(notification.getDescription().isPresent()); + assertFalse(notification.getReference().isPresent()); assertEquals(Status.CURRENT, notification.getStatus()); assertEquals(0, notification.getUnknownSchemaNodes().size()); // test DataNodeContainer args @@ -610,8 +611,8 @@ public class YangParserTest { assertEquals(1, rpcs.size()); final RpcDefinition rpc = rpcs.iterator().next(); - assertEquals("Retrieve all or part of a specified configuration.", rpc.getDescription()); - assertEquals("RFC 6241, Section 7.1", rpc.getReference()); + assertEquals(Optional.of("Retrieve all or part of a specified configuration."), rpc.getDescription()); + assertEquals(Optional.of("RFC 6241, Section 7.1"), rpc.getReference()); } @Test diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserWithContextTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserWithContextTest.java index 0bb6d75175..af378b1ee4 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserWithContextTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserWithContextTest.java @@ -18,6 +18,7 @@ import java.net.URI; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Set; import org.junit.Test; import org.opendaylight.yangtools.yang.common.QName; @@ -256,8 +257,8 @@ public class YangParserWithContextTest { // leaf address assertNotNull(refineLeaf); assertEquals("address", refineLeaf.getQName().getLocalName()); - assertEquals("description of address defined by refine", refineLeaf.getDescription()); - assertEquals("address reference added by refine", refineLeaf.getReference()); + assertEquals(Optional.of("description of address defined by refine"), refineLeaf.getDescription()); + assertEquals(Optional.of("address reference added by refine"), refineLeaf.getReference()); assertFalse(refineLeaf.isConfiguration()); assertTrue(refineLeaf.getConstraints().isMandatory()); final Set leafMustConstraints = refineLeaf.getConstraints().getMustConstraints(); @@ -269,15 +270,15 @@ public class YangParserWithContextTest { assertNotNull(refineContainer); final Set mustConstraints = refineContainer.getConstraints().getMustConstraints(); assertTrue(mustConstraints.isEmpty()); - assertEquals("description of port defined by refine", refineContainer.getDescription()); - assertEquals("port reference added by refine", refineContainer.getReference()); + assertEquals(Optional.of("description of port defined by refine"), refineContainer.getDescription()); + assertEquals(Optional.of("port reference added by refine"), refineContainer.getReference()); assertFalse(refineContainer.isConfiguration()); assertTrue(refineContainer.isPresenceContainer()); // list addresses assertNotNull(refineList); - assertEquals("description of addresses defined by refine", refineList.getDescription()); - assertEquals("addresses reference added by refine", refineList.getReference()); + 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(2, (int) refineList.getConstraints().getMinElements()); assertEquals(12, (int) refineList.getConstraints().getMaxElements()); @@ -392,7 +393,7 @@ public class YangParserWithContextTest { assertEquals(1, deviations.size()); final Deviation dev = deviations.iterator().next(); - assertEquals("system/user ref", dev.getReference()); + assertEquals(Optional.of("system/user ref"), dev.getReference()); final URI expectedNS = URI.create("urn:opendaylight.bar"); final Revision expectedRev = Revision.of("2013-07-03"); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileExtensionStmtTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileExtensionStmtTest.java index ec8879ffb2..60a34dbed0 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileExtensionStmtTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileExtensionStmtTest.java @@ -15,6 +15,7 @@ import java.io.IOException; import java.net.URISyntaxException; import java.util.Iterator; import java.util.List; +import java.util.Optional; import org.junit.Before; import org.junit.Test; import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition; @@ -46,14 +47,14 @@ public class YinFileExtensionStmtTest { ExtensionDefinition extension = extIterator.next(); assertEquals("name", extension.getArgument()); assertEquals("java-class", extension.getQName().getLocalName()); - assertEquals("YANG language extension carrying the fully-qualified name of\n" + assertEquals(Optional.of("YANG language extension carrying the fully-qualified name of\n" + "a Java class. Code generation tools use the provided reference\n" - + "to tie a specific construct to its Java representation.", extension.getDescription()); + + "to tie a specific construct to its Java representation."), extension.getDescription()); extension = extIterator.next(); assertEquals("name", extension.getArgument()); assertEquals("required-identity", extension.getQName().getLocalName()); - assertEquals("YANG language extension which indicates that a particular\n" + assertEquals(Optional.of("YANG language extension which indicates that a particular\n" + "leafref, which points to a identityref, should additionally\n" + "require the target node is actually set to a descendant to\n" + "of a particular identity.\n" @@ -65,32 +66,31 @@ public class YinFileExtensionStmtTest { + "This extension takes one argument, name, which MUST be the name\n" + "of an identity. Furthermore, that identity MUST be based,\n" + "directly or indirectly, on the identity, which is referenced by\n" - + "the leaf reference, which is annotated with this extension.", extension.getDescription()); + + "the leaf reference, which is annotated with this extension."), extension.getDescription()); extension = extIterator.next(); assertNull(extension.getArgument()); assertEquals("inner-state-bean", extension.getQName().getLocalName()); - assertEquals("YANG language extension which indicates that a particular\n" + assertEquals(Optional.of("YANG language extension which indicates that a particular\n" + "list located under module's state should be treated as a list\n" - + "of child state beans instead of just an ordinary list attribute", extension.getDescription()); + + "of child state beans instead of just an ordinary list attribute"), extension.getDescription()); extension = extIterator.next(); assertEquals("name", extension.getArgument()); assertEquals("provided-service", extension.getQName().getLocalName()); - assertEquals("YANG language extension which indicates that a particular\n" + assertEquals(Optional.of("YANG language extension which indicates that a particular\n" + "module provides certain service. This extension can be placed\n" + "on identities that are based on module-type. Zero or more services\n" + "can be provided.\n" + "This extension takes one argument - name - which MUST be the name\n" + "of an identity. Furthermore, this identity MUST be based on\n" - + "service-type.", extension.getDescription()); + + "service-type."), extension.getDescription()); extension = extIterator.next(); assertEquals("java-prefix", extension.getArgument()); assertEquals("java-name-prefix", extension.getQName().getLocalName()); - assertEquals("YANG language extension carrying java simple class name prefix\n" + assertEquals(Optional.of("YANG language extension carrying java simple class name prefix\n" + "that will be taken into account when generating java code from\n" - + "identities that are based on module-type.", extension.getDescription()); + + "identities that are based on module-type."), extension.getDescription()); } - } diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileGroupingStmtTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileGroupingStmtTest.java index c16104fd93..fe6ed76155 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileGroupingStmtTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileGroupingStmtTest.java @@ -15,6 +15,7 @@ import java.io.IOException; import java.net.URISyntaxException; import java.util.Collection; import java.util.Iterator; +import java.util.Optional; import java.util.Set; import org.junit.Before; import org.junit.Test; @@ -49,12 +50,12 @@ public class YinFileGroupingStmtTest { final Iterator groupingsIterator = groupings.iterator(); final GroupingDefinition grouping = groupingsIterator.next(); assertEquals("service-ref", grouping.getQName().getLocalName()); - assertEquals("Type of references to a particular service instance. This type\n" + assertEquals(Optional.of("Type of references to a particular service instance. This type\n" + "can be used when defining module configuration to refer to a\n" + "particular service instance. Containers using this grouping\n" + "should not define anything else. The run-time implementation\n" + "is expected to inject a reference to the service as the value\n" - + "of the container.", grouping.getDescription()); + + "of the container."), grouping.getDescription()); final Collection children = grouping.getChildNodes(); assertEquals(2, children.size()); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileLeafListStmtTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileLeafListStmtTest.java index b84ae68106..a642b0cdb3 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileLeafListStmtTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileLeafListStmtTest.java @@ -13,6 +13,7 @@ import static org.junit.Assert.assertNotNull; import java.io.IOException; import java.net.URISyntaxException; +import java.util.Optional; import org.junit.Before; import org.junit.Test; import org.opendaylight.yangtools.yang.common.QName; @@ -51,7 +52,7 @@ public class YinFileLeafListStmtTest { testModule.getQNameModule(), "capability")); assertNotNull(leafList); assertEquals("uri", leafList.getType().getQName().getLocalName()); - assertEquals("List of NETCONF capabilities supported by the server.", leafList.getDescription()); + assertEquals(Optional.of("List of NETCONF capabilities supported by the server."), leafList.getDescription()); assertFalse(leafList.isUserOrdered()); } } diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileListStmtTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileListStmtTest.java index 15b750a49e..135f3551db 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileListStmtTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileListStmtTest.java @@ -16,6 +16,7 @@ import java.net.URISyntaxException; import java.util.Collection; import java.util.Iterator; import java.util.List; +import java.util.Optional; import org.junit.Before; import org.junit.Test; import org.opendaylight.yangtools.yang.common.QName; @@ -64,7 +65,7 @@ public class YinFileListStmtTest { final Iterator childrenIterator = children.iterator(); LeafSchemaNode leaf = (LeafSchemaNode) childrenIterator.next(); assertEquals("name", leaf.getQName().getLocalName()); - assertEquals("Unique module instance name", leaf.getDescription()); + assertEquals(Optional.of("Unique module instance name"), leaf.getDescription()); assertEquals(BaseTypes.stringType(), leaf.getType()); assertTrue(leaf.getConstraints().isMandatory()); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileMetaStmtsTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileMetaStmtsTest.java index 7bc5c38c05..fdb0467cb7 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileMetaStmtsTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileMetaStmtsTest.java @@ -51,13 +51,13 @@ public class YinFileMetaStmtsTest { + "\n" + "Editor: Martin Bjorklund\n" + " "), testModule.getContact()); - assertEquals("NETCONF Monitoring Module.\n" + "All elements in this module are read-only.\n" + "\n" + assertEquals(Optional.of("NETCONF Monitoring Module.\n" + "All elements in this module are read-only.\n" + "\n" + "Copyright (c) 2010 IETF Trust and the persons identified as\n" + "authors of the code. All rights " + "reserved.\n" + "\n" + "Redistribution and use in source and binary forms, with or\n" + "without " + "modification, is permitted pursuant to, and subject\n" + "to the license terms contained in, the " + "Simplified BSD\n" + "License set forth in Section 4.c of the IETF Trust's\n" + "Legal Provisions " + "Relating to IETF Documents\n" + "(http://trustee.ietf.org/license-info).\n" + "\n" + "This version " - + "of this YANG module is part of RFC 6022; see\n" + "the RFC itself for full legal notices.", + + "of this YANG module is part of RFC 6022; see\n" + "the RFC itself for full legal notices."), testModule.getDescription()); } } diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileRpcStmtTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileRpcStmtTest.java index e405e3374e..97248a8dc3 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileRpcStmtTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileRpcStmtTest.java @@ -12,6 +12,7 @@ import static org.junit.Assert.assertNotNull; import java.io.IOException; import java.net.URISyntaxException; +import java.util.Optional; import java.util.Set; import org.junit.Before; import org.junit.Test; @@ -42,7 +43,7 @@ public class YinFileRpcStmtTest { RpcDefinition rpc = rpcs.iterator().next(); assertEquals("get-schema", rpc.getQName().getLocalName()); - assertEquals("This operation is used to retrieve a schema from the\n" + assertEquals(Optional.of("This operation is used to retrieve a schema from the\n" + "NETCONF server.\n" + "\n" + "Positive Response:\n" @@ -54,7 +55,7 @@ public class YinFileRpcStmtTest { + "\n" + "If more than one schema matches the requested parameters, the\n" + " is 'operation-failed', and is\n" - + "'data-not-unique'.", rpc.getDescription()); + + "'data-not-unique'."), rpc.getDescription()); ContainerSchemaNode input = rpc.getInput(); assertNotNull(input); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileTypeDefStmtTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileTypeDefStmtTest.java index e6be6abdd9..d6b1590749 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileTypeDefStmtTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileTypeDefStmtTest.java @@ -13,6 +13,7 @@ import static org.junit.Assert.assertNotNull; import java.io.IOException; import java.net.URISyntaxException; import java.util.Iterator; +import java.util.Optional; import java.util.Set; import org.junit.Before; import org.junit.Test; @@ -44,7 +45,7 @@ public class YinFileTypeDefStmtTest { Iterator> typeDefIterator = typeDefs.iterator(); TypeDefinition typeDef = typeDefIterator.next(); assertEquals("service-type-ref", typeDef.getQName().getLocalName()); - assertEquals("Internal type of references to service type identity.", typeDef.getDescription()); + assertEquals(Optional.of("Internal type of references to service type identity."), typeDef.getDescription()); assertEquals("identityref", typeDef.getBaseType().getQName().getLocalName()); } } -- 2.36.6