diff options
Diffstat (limited to 'netconf')
45 files changed, 421 insertions, 269 deletions
diff --git a/netconf/features/pom.xml b/netconf/features/pom.xml index ee58476..0d15d85 100644 --- a/netconf/features/pom.xml +++ b/netconf/features/pom.xml @@ -11,7 +11,7 @@ <parent> <groupId>org.opendaylight.odlparent</groupId> <artifactId>odlparent-lite</artifactId> - <version>11.0.3</version> + <version>12.0.7</version> <relativePath/> </parent> diff --git a/netconf/features/restconf/odl-restconf-nb-bierman02/pom.xml b/netconf/features/restconf/odl-restconf-nb-bierman02/pom.xml index 2f9bc75..aef68dd 100644 --- a/netconf/features/restconf/odl-restconf-nb-bierman02/pom.xml +++ b/netconf/features/restconf/odl-restconf-nb-bierman02/pom.xml @@ -12,8 +12,8 @@ <parent> <groupId>org.opendaylight.netconf</groupId> <artifactId>feature-parent</artifactId> - <version>4.0.4</version> - <relativePath>../../parent</relativePath> + <version>5.0.7</version> + <relativePath/> </parent> <groupId>org.onap.ccsdk.odl-legacy.netconf</groupId> diff --git a/netconf/features/restconf/pom.xml b/netconf/features/restconf/pom.xml index 67ac4f6..3ae613d 100644 --- a/netconf/features/restconf/pom.xml +++ b/netconf/features/restconf/pom.xml @@ -11,7 +11,7 @@ <parent> <groupId>org.opendaylight.odlparent</groupId> <artifactId>odlparent-lite</artifactId> - <version>11.0.3</version> + <version>12.0.7</version> <relativePath/> </parent> diff --git a/netconf/pom.xml b/netconf/pom.xml index 457649c..3cf7509 100644 --- a/netconf/pom.xml +++ b/netconf/pom.xml @@ -13,7 +13,7 @@ <parent> <groupId>org.opendaylight.odlparent</groupId> <artifactId>odlparent-lite</artifactId> - <version>11.0.3</version> + <version>12.0.7</version> <relativePath/> </parent> diff --git a/netconf/restconf/pom.xml b/netconf/restconf/pom.xml index ca9d232..b46a766 100644 --- a/netconf/restconf/pom.xml +++ b/netconf/restconf/pom.xml @@ -12,7 +12,7 @@ <parent> <groupId>org.opendaylight.odlparent</groupId> <artifactId>odlparent-lite</artifactId> - <version>11.0.3</version> + <version>12.0.7</version> <relativePath/> </parent> diff --git a/netconf/restconf/restconf-common/pom.xml b/netconf/restconf/restconf-common/pom.xml index 61d5c91..1671045 100644 --- a/netconf/restconf/restconf-common/pom.xml +++ b/netconf/restconf/restconf-common/pom.xml @@ -14,7 +14,7 @@ <parent> <groupId>org.opendaylight.netconf</groupId> <artifactId>netconf-parent</artifactId> - <version>4.0.4</version> + <version>5.0.7</version> <relativePath/> </parent> diff --git a/netconf/restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/util/AbstractOperationsModule.java b/netconf/restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/util/AbstractOperationsModule.java index 68b7fe5..615badb 100644 --- a/netconf/restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/util/AbstractOperationsModule.java +++ b/netconf/restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/util/AbstractOperationsModule.java @@ -9,13 +9,10 @@ package org.opendaylight.restconf.common.util; import java.util.Collection; import java.util.Collections; -import java.util.Map; import java.util.Optional; import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.yangtools.concepts.SemVer; import org.opendaylight.yangtools.yang.common.QNameModule; -import org.opendaylight.yangtools.yang.common.UnresolvedQName; -import org.opendaylight.yangtools.yang.common.UnresolvedQName.Unqualified; import org.opendaylight.yangtools.yang.common.YangVersion; import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode; import org.opendaylight.yangtools.yang.model.api.Deviation; @@ -31,7 +28,6 @@ import org.opendaylight.yangtools.yang.model.api.Submodule; import org.opendaylight.yangtools.yang.model.api.TypeDefinition; import org.opendaylight.yangtools.yang.model.api.UsesNode; import org.opendaylight.yangtools.yang.model.api.YangStmtMapping; -import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace; import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition; import org.opendaylight.yangtools.yang.model.api.meta.StatementOrigin; import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement; @@ -53,21 +49,6 @@ abstract class AbstractOperationsModule implements Module, ModuleEffectiveStatem return StatementOrigin.CONTEXT; } - @Override - public final <K, V, N extends IdentifierNamespace<K, V>> Optional<V> get(final Class<N> namespace, - final K identifier) { - return Optional.empty(); - } - - @Override - public final <K, V, N extends IdentifierNamespace<K, V>> Map<K, V> getAll(final Class<N> namespace) { - return Map.of(); - } - - @Override - public final Unqualified argument() { - return UnresolvedQName.unqualified(getName()); - } @Override public final QNameModule localQNameModule() { diff --git a/netconf/restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/util/OperationsImportedModule.java b/netconf/restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/util/OperationsImportedModule.java index 5551326..6f4c3c2 100644 --- a/netconf/restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/util/OperationsImportedModule.java +++ b/netconf/restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/util/OperationsImportedModule.java @@ -11,11 +11,22 @@ import static java.util.Objects.requireNonNull; import java.util.Collection; import java.util.List; +import java.util.Map.Entry; +import java.util.Optional; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.QNameModule; +import org.opendaylight.yangtools.yang.common.UnresolvedQName.Unqualified; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; +import org.opendaylight.yangtools.yang.model.api.stmt.DataTreeEffectiveStatement; +import org.opendaylight.yangtools.yang.model.api.stmt.ExtensionEffectiveStatement; +import org.opendaylight.yangtools.yang.model.api.stmt.FeatureEffectiveStatement; +import org.opendaylight.yangtools.yang.model.api.stmt.IdentityEffectiveStatement; +import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement; +import org.opendaylight.yangtools.yang.model.api.stmt.SchemaTreeEffectiveStatement; +import org.opendaylight.yangtools.yang.model.api.stmt.SubmoduleEffectiveStatement; final class OperationsImportedModule extends AbstractOperationsModule { private final Module original; @@ -53,4 +64,82 @@ final class OperationsImportedModule extends AbstractOperationsModule { public List<EffectiveStatement<?, ?>> effectiveSubstatements() { return List.of(); } + + @Override + public @NonNull Optional<ExtensionEffectiveStatement> findExtension(@NonNull QName arg0) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'findExtension'"); + } + + @Override + public @NonNull Optional<FeatureEffectiveStatement> findFeature(@NonNull QName arg0) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'findFeature'"); + } + + @Override + public @NonNull Optional<IdentityEffectiveStatement> findIdentity(@NonNull QName arg0) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'findIdentity'"); + } + + @Override + public @NonNull Optional<SubmoduleEffectiveStatement> findSubmodule(@NonNull Unqualified arg0) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'findSubmodule'"); + } + + @Override + public @NonNull Collection<DataTreeEffectiveStatement<?>> dataTreeNodes() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'dataTreeNodes'"); + } + + @Override + public @NonNull Optional<DataTreeEffectiveStatement<?>> findDataTreeNode(@NonNull QName arg0) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'findDataTreeNode'"); + } + + @Override + public @NonNull Optional<SchemaTreeEffectiveStatement<?>> findSchemaTreeNode(@NonNull QName arg0) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'findSchemaTreeNode'"); + } + + @Override + public @NonNull Collection<SchemaTreeEffectiveStatement<?>> schemaTreeNodes() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'schemaTreeNodes'"); + } + + @Override + public @NonNull Unqualified argument() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'argument'"); + } + + @Override + public @NonNull Optional<String> findNamespacePrefix(@NonNull QNameModule arg0) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'findNamespacePrefix'"); + } + + @Override + public @NonNull Optional<ModuleEffectiveStatement> findReachableModule(@NonNull String arg0) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'findReachableModule'"); + } + + @Override + public Collection<Entry<QNameModule, String>> namespacePrefixes() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'namespacePrefixes'"); + } + + @Override + public @NonNull Collection<Entry<String, ModuleEffectiveStatement>> reachableModules() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'reachableModules'"); + } } diff --git a/netconf/restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/util/OperationsRestconfModule.java b/netconf/restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/util/OperationsRestconfModule.java index 467db9b..9145598 100644 --- a/netconf/restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/util/OperationsRestconfModule.java +++ b/netconf/restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/util/OperationsRestconfModule.java @@ -11,12 +11,22 @@ import static java.util.Objects.requireNonNull; import java.util.Collection; import java.util.List; +import java.util.Map.Entry; +import java.util.Optional; import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.QNameModule; +import org.opendaylight.yangtools.yang.common.UnresolvedQName.Unqualified; import org.opendaylight.yangtools.yang.common.XMLNamespace; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; +import org.opendaylight.yangtools.yang.model.api.stmt.DataTreeEffectiveStatement; +import org.opendaylight.yangtools.yang.model.api.stmt.ExtensionEffectiveStatement; +import org.opendaylight.yangtools.yang.model.api.stmt.FeatureEffectiveStatement; +import org.opendaylight.yangtools.yang.model.api.stmt.IdentityEffectiveStatement; +import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement; +import org.opendaylight.yangtools.yang.model.api.stmt.SchemaTreeEffectiveStatement; +import org.opendaylight.yangtools.yang.model.api.stmt.SubmoduleEffectiveStatement; final class OperationsRestconfModule extends AbstractOperationsModule { // There is no need to intern this nor add a revision, as we are providing the corresponding context anyway @@ -59,4 +69,82 @@ final class OperationsRestconfModule extends AbstractOperationsModule { // This is not accurate, but works for now return List.of(); } + + @Override + public @NonNull Optional<ExtensionEffectiveStatement> findExtension(@NonNull QName arg0) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'findExtension'"); + } + + @Override + public @NonNull Optional<FeatureEffectiveStatement> findFeature(@NonNull QName arg0) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'findFeature'"); + } + + @Override + public @NonNull Optional<IdentityEffectiveStatement> findIdentity(@NonNull QName arg0) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'findIdentity'"); + } + + @Override + public @NonNull Optional<SubmoduleEffectiveStatement> findSubmodule(@NonNull Unqualified arg0) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'findSubmodule'"); + } + + @Override + public @NonNull Collection<DataTreeEffectiveStatement<?>> dataTreeNodes() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'dataTreeNodes'"); + } + + @Override + public @NonNull Optional<DataTreeEffectiveStatement<?>> findDataTreeNode(@NonNull QName arg0) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'findDataTreeNode'"); + } + + @Override + public @NonNull Optional<SchemaTreeEffectiveStatement<?>> findSchemaTreeNode(@NonNull QName arg0) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'findSchemaTreeNode'"); + } + + @Override + public @NonNull Collection<SchemaTreeEffectiveStatement<?>> schemaTreeNodes() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'schemaTreeNodes'"); + } + + @Override + public @NonNull Unqualified argument() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'argument'"); + } + + @Override + public @NonNull Optional<String> findNamespacePrefix(@NonNull QNameModule arg0) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'findNamespacePrefix'"); + } + + @Override + public @NonNull Optional<ModuleEffectiveStatement> findReachableModule(@NonNull String arg0) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'findReachableModule'"); + } + + @Override + public Collection<Entry<QNameModule, String>> namespacePrefixes() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'namespacePrefixes'"); + } + + @Override + public @NonNull Collection<Entry<String, ModuleEffectiveStatement>> reachableModules() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'reachableModules'"); + } } diff --git a/netconf/restconf/restconf-nb-bierman02-installer/pom.xml b/netconf/restconf/restconf-nb-bierman02-installer/pom.xml index daa45ee..fcae0ae 100755 --- a/netconf/restconf/restconf-nb-bierman02-installer/pom.xml +++ b/netconf/restconf/restconf-nb-bierman02-installer/pom.xml @@ -27,7 +27,7 @@ <parent> <groupId>org.opendaylight.netconf</groupId> <artifactId>netconf-parent</artifactId> - <version>4.0.4</version> + <version>5.0.7</version> <relativePath/> </parent> diff --git a/netconf/restconf/restconf-nb-bierman02/pom.xml b/netconf/restconf/restconf-nb-bierman02/pom.xml index 31b2c71..470bc4c 100644 --- a/netconf/restconf/restconf-nb-bierman02/pom.xml +++ b/netconf/restconf/restconf-nb-bierman02/pom.xml @@ -11,7 +11,7 @@ <parent> <groupId>org.opendaylight.netconf</groupId> <artifactId>netconf-parent</artifactId> - <version>4.0.4</version> + <version>5.0.7</version> <relativePath/> </parent> diff --git a/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/md/sal/rest/schema/SchemaExportContentYangBodyWriter.java b/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/md/sal/rest/schema/SchemaExportContentYangBodyWriter.java index 679cf02..82442cf 100644 --- a/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/md/sal/rest/schema/SchemaExportContentYangBodyWriter.java +++ b/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/md/sal/rest/schema/SchemaExportContentYangBodyWriter.java @@ -45,7 +45,7 @@ public class SchemaExportContentYangBodyWriter implements MessageBodyWriter<Sche final MultivaluedMap<String, Object> httpHeaders, final OutputStream entityStream) throws IOException, WebApplicationException { final SourceIdentifier sourceId = new SourceIdentifier(context.getModule().getName(), - context.getModule().getQNameModule().getRevision().get()); + context.getModule().getQNameModule().getRevision().orElseThrow()); final YangTextSchemaSource yangTextSchemaSource; try { yangTextSchemaSource = context.getSourceProvider().getSource(sourceId).get(); diff --git a/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/md/sal/rest/schema/SchemaExportContentYinBodyWriter.java b/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/md/sal/rest/schema/SchemaExportContentYinBodyWriter.java index 9f4f8be..5fbb8b3 100644 --- a/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/md/sal/rest/schema/SchemaExportContentYinBodyWriter.java +++ b/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/md/sal/rest/schema/SchemaExportContentYinBodyWriter.java @@ -43,7 +43,7 @@ public class SchemaExportContentYinBodyWriter implements MessageBodyWriter<Schem final MultivaluedMap<String, Object> httpHeaders, final OutputStream entityStream) throws WebApplicationException { try { - YinExportUtils.writeModuleAsYinText(context.getModule(), entityStream); + YinExportUtils.writeModuleAsYinText(context.getModule().asEffectiveStatement(), entityStream); } catch (final XMLStreamException e) { throw new IllegalStateException(e); } diff --git a/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/DepthAwareNormalizedNodeWriter.java b/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/DepthAwareNormalizedNodeWriter.java index b9d7a7a..842fb74 100644 --- a/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/DepthAwareNormalizedNodeWriter.java +++ b/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/DepthAwareNormalizedNodeWriter.java @@ -279,7 +279,7 @@ public class DepthAwareNormalizedNodeWriter implements RestconfNormalizedNodeWri for (final QName qname : qnames) { final Optional<? extends NormalizedNode> child = node.findChildByArg(new NodeIdentifier(qname)); if (child.isPresent()) { - write(child.get()); + write(child.orElseThrow()); } else { LOG.info("No child for key element {} found", qname); } diff --git a/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/JsonNormalizedNodeBodyReader.java b/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/JsonNormalizedNodeBodyReader.java index aecea7a..4f02a08 100644 --- a/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/JsonNormalizedNodeBodyReader.java +++ b/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/JsonNormalizedNodeBodyReader.java @@ -125,7 +125,7 @@ public class JsonNormalizedNodeBodyReader final JsonParserStream jsonParser = JsonParserStream.create(writer, JSONCodecFactorySupplier.DRAFT_LHOTKA_NETMOD_YANG_JSON_02.getShared(path.getSchemaContext()), parentInference); - final JsonReader reader = new JsonReader(new InputStreamReader(nonEmptyInputStreamOptional.get(), + final JsonReader reader = new JsonReader(new InputStreamReader(nonEmptyInputStreamOptional.orElseThrow(), StandardCharsets.UTF_8)); jsonParser.parse(reader); diff --git a/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/JsonToPatchBodyReader.java b/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/JsonToPatchBodyReader.java index ce5a8c4..3fe1233 100644 --- a/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/JsonToPatchBodyReader.java +++ b/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/JsonToPatchBodyReader.java @@ -114,7 +114,7 @@ public class JsonToPatchBodyReader extends AbstractIdentifierAwareJaxRsProvider return new PatchContext(path, null, null); } - final JsonReader jsonReader = new JsonReader(new InputStreamReader(nonEmptyInputStreamOptional.get(), + final JsonReader jsonReader = new JsonReader(new InputStreamReader(nonEmptyInputStreamOptional.orElseThrow(), StandardCharsets.UTF_8)); AtomicReference<String> patchId = new AtomicReference<>(); final List<PatchEntity> resultList = read(jsonReader, path, patchId); diff --git a/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/RestconfDocumentedExceptionMapper.java b/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/RestconfDocumentedExceptionMapper.java index ff0be39..19d93f0 100644 --- a/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/RestconfDocumentedExceptionMapper.java +++ b/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/RestconfDocumentedExceptionMapper.java @@ -54,8 +54,8 @@ import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier; import org.opendaylight.yangtools.yang.data.codec.gson.JSONNormalizedNodeStreamWriter; import org.opendaylight.yangtools.yang.data.codec.gson.JsonWriterFactory; import org.opendaylight.yangtools.yang.data.codec.xml.XMLStreamNormalizedNodeStreamWriter; +import org.opendaylight.yangtools.yang.data.impl.schema.Builders; import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.data.impl.schema.SchemaAwareBuilders; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; import org.opendaylight.yangtools.yang.model.api.ListSchemaNode; @@ -123,14 +123,14 @@ public class RestconfDocumentedExceptionMapper implements ExceptionMapper<Restco final var errorsSchemaNode = errorsEntry.getValue(); final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> errContBuild = - SchemaAwareBuilders.containerBuilder(errorsSchemaNode); + Builders.containerBuilder(); final var schemaList = ControllerContext.findInstanceDataChildrenByName(errorsSchemaNode, Draft02.RestConfModule.ERROR_LIST_SCHEMA_NODE); final DataSchemaNode errListSchemaNode = ControllerContext.getFirst(schemaList); checkState(errListSchemaNode instanceof ListSchemaNode, "Found Error SchemaNode isn't ListSchemaNode"); - final CollectionNodeBuilder<MapEntryNode, SystemMapNode> listErorsBuilder = SchemaAwareBuilders - .mapBuilder((ListSchemaNode) errListSchemaNode); + final CollectionNodeBuilder<MapEntryNode, SystemMapNode> listErorsBuilder = Builders + .mapBuilder(); for (final RestconfError error : errors) { @@ -155,21 +155,21 @@ public class RestconfDocumentedExceptionMapper implements ExceptionMapper<Restco checkArgument(errListSchemaNode instanceof ListSchemaNode, "errListSchemaNode has to be of type ListSchemaNode"); final ListSchemaNode listStreamSchemaNode = (ListSchemaNode) errListSchemaNode; - final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> errNodeValues = SchemaAwareBuilders - .mapEntryBuilder(listStreamSchemaNode); + final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> errNodeValues = Builders + .mapEntryBuilder(); var lsChildDataSchemaNode = ControllerContext.findInstanceDataChildrenByName( listStreamSchemaNode, "error-type"); final DataSchemaNode errTypSchemaNode = ControllerContext.getFirst(lsChildDataSchemaNode); checkState(errTypSchemaNode instanceof LeafSchemaNode); - errNodeValues.withChild(SchemaAwareBuilders.leafBuilder((LeafSchemaNode) errTypSchemaNode) + errNodeValues.withChild(Builders.leafBuilder() .withValue(error.getErrorType().elementBody()).build()); lsChildDataSchemaNode = ControllerContext.findInstanceDataChildrenByName( listStreamSchemaNode, "error-tag"); final DataSchemaNode errTagSchemaNode = ControllerContext.getFirst(lsChildDataSchemaNode); checkState(errTagSchemaNode instanceof LeafSchemaNode); - errNodeValues.withChild(SchemaAwareBuilders.leafBuilder((LeafSchemaNode) errTagSchemaNode) + errNodeValues.withChild(Builders.leafBuilder() .withValue(error.getErrorTag().elementBody()).build()); if (error.getErrorAppTag() != null) { @@ -177,7 +177,7 @@ public class RestconfDocumentedExceptionMapper implements ExceptionMapper<Restco listStreamSchemaNode, "error-app-tag"); final DataSchemaNode errAppTagSchemaNode = ControllerContext.getFirst(lsChildDataSchemaNode); checkState(errAppTagSchemaNode instanceof LeafSchemaNode); - errNodeValues.withChild(SchemaAwareBuilders.leafBuilder((LeafSchemaNode) errAppTagSchemaNode) + errNodeValues.withChild(Builders.leafBuilder() .withValue(error.getErrorAppTag()).build()); } @@ -185,7 +185,7 @@ public class RestconfDocumentedExceptionMapper implements ExceptionMapper<Restco listStreamSchemaNode, "error-message"); final DataSchemaNode errMsgSchemaNode = ControllerContext.getFirst(lsChildDataSchemaNode); checkState(errMsgSchemaNode instanceof LeafSchemaNode); - errNodeValues.withChild(SchemaAwareBuilders.leafBuilder((LeafSchemaNode) errMsgSchemaNode) + errNodeValues.withChild(Builders.leafBuilder() .withValue(error.getErrorMessage()).build()); if (error.getErrorInfo() != null) { diff --git a/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/XmlNormalizedNodeBodyReader.java b/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/XmlNormalizedNodeBodyReader.java index 84a7978..cc03aa6 100644 --- a/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/XmlNormalizedNodeBodyReader.java +++ b/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/XmlNormalizedNodeBodyReader.java @@ -107,7 +107,7 @@ public class XmlNormalizedNodeBodyReader extends AbstractIdentifierAwareJaxRsPro return new NormalizedNodeContext(path, null); } - final Document doc = UntrustedXML.newDocumentBuilder().parse(nonEmptyInputStreamOptional.get()); + final Document doc = UntrustedXML.newDocumentBuilder().parse(nonEmptyInputStreamOptional.orElseThrow()); return parse(path, doc); } diff --git a/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/XmlToPatchBodyReader.java b/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/XmlToPatchBodyReader.java index 9cc4766..7716cea 100644 --- a/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/XmlToPatchBodyReader.java +++ b/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/XmlToPatchBodyReader.java @@ -107,7 +107,7 @@ public class XmlToPatchBodyReader extends AbstractIdentifierAwareJaxRsProvider i return new PatchContext(path, null, null); } - final Document doc = UntrustedXML.newDocumentBuilder().parse(nonEmptyInputStreamOptional.get()); + final Document doc = UntrustedXML.newDocumentBuilder().parse(nonEmptyInputStreamOptional.orElseThrow()); return parse(path, doc); } catch (final RestconfDocumentedException e) { throw e; diff --git a/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/BrokerFacade.java b/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/BrokerFacade.java index ca867cb..60ab9ab 100644 --- a/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/BrokerFacade.java +++ b/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/BrokerFacade.java @@ -81,11 +81,10 @@ import org.opendaylight.yangtools.yang.data.api.schema.UserMapNode; import org.opendaylight.yangtools.yang.data.api.schema.builder.CollectionNodeBuilder; import org.opendaylight.yangtools.yang.data.api.schema.builder.DataContainerNodeBuilder; import org.opendaylight.yangtools.yang.data.api.schema.builder.NormalizedNodeBuilder; +import org.opendaylight.yangtools.yang.data.impl.schema.Builders; import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.data.impl.schema.SchemaAwareBuilders; import org.opendaylight.yangtools.yang.data.util.DataSchemaContextNode; import org.opendaylight.yangtools.yang.data.util.DataSchemaContextTree; -import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode; @@ -186,7 +185,7 @@ public class BrokerFacade implements Closeable { final String withDefa) { final Optional<DOMDataBroker> domDataBrokerService = mountPoint.getService(DOMDataBroker.class); if (domDataBrokerService.isPresent()) { - try (DOMDataTreeReadTransaction tx = domDataBrokerService.get().newReadOnlyTransaction()) { + try (DOMDataTreeReadTransaction tx = domDataBrokerService.orElseThrow().newReadOnlyTransaction()) { return readDataViaTransaction(tx, CONFIGURATION, path, withDefa); } } @@ -218,7 +217,7 @@ public class BrokerFacade implements Closeable { public NormalizedNode readOperationalData(final DOMMountPoint mountPoint, final YangInstanceIdentifier path) { final Optional<DOMDataBroker> domDataBrokerService = mountPoint.getService(DOMDataBroker.class); if (domDataBrokerService.isPresent()) { - try (DOMDataTreeReadTransaction tx = domDataBrokerService.get().newReadOnlyTransaction()) { + try (DOMDataTreeReadTransaction tx = domDataBrokerService.orElseThrow().newReadOnlyTransaction()) { return readDataViaTransaction(tx, OPERATIONAL, path); } } @@ -290,7 +289,7 @@ public class BrokerFacade implements Closeable { final Optional<DOMDataBroker> domDataBrokerService = mountPoint.getService(DOMDataBroker.class); if (domDataBrokerService.isPresent()) { final DOMDataTreeReadWriteTransaction newReadWriteTransaction = - domDataBrokerService.get().newReadWriteTransaction(); + domDataBrokerService.orElseThrow().newReadWriteTransaction(); final Status status = readDataViaTransaction(newReadWriteTransaction, CONFIGURATION, path) != null ? Status.OK : Status.CREATED; final FluentFuture<? extends CommitInfo> future = putDataViaTransaction( @@ -318,7 +317,7 @@ public class BrokerFacade implements Closeable { final Optional<DOMDataBroker> optional = mountPoint.getService(DOMDataBroker.class); if (optional.isPresent()) { - patchTransaction = optional.get().newReadWriteTransaction(); + patchTransaction = optional.orElseThrow().newReadWriteTransaction(); } else { // if mount point does not have broker it is not possible to continue and global error is reported LOG.error("Http Patch {} has failed - device {} does not support broker service", @@ -474,7 +473,8 @@ public class BrokerFacade implements Closeable { final Optional<DOMDataBroker> domDataBrokerService = mountPoint.getService(DOMDataBroker.class); if (domDataBrokerService.isPresent()) { FluentFuture<? extends CommitInfo> future = - postDataViaTransaction(domDataBrokerService.get().newReadWriteTransaction(), CONFIGURATION, path, + postDataViaTransaction(domDataBrokerService.orElseThrow().newReadWriteTransaction(), + CONFIGURATION, path, payload, modelContext(mountPoint), insert, point); isMounted.remove(); return future; @@ -492,14 +492,15 @@ public class BrokerFacade implements Closeable { final DOMMountPoint mountPoint, final YangInstanceIdentifier path) { final Optional<DOMDataBroker> domDataBrokerService = mountPoint.getService(DOMDataBroker.class); if (domDataBrokerService.isPresent()) { - return deleteDataViaTransaction(domDataBrokerService.get().newReadWriteTransaction(), CONFIGURATION, path); + return deleteDataViaTransaction(domDataBrokerService.orElseThrow().newReadWriteTransaction(), + CONFIGURATION, path); } throw dataBrokerUnavailable(path); } // RPC public ListenableFuture<? extends DOMRpcResult> invokeRpc(final @NonNull QName type, - final @NonNull NormalizedNode input) { + final @NonNull ContainerNode input) { if (rpcService == null) { throw new RestconfDocumentedException(Status.SERVICE_UNAVAILABLE); } @@ -568,13 +569,13 @@ public class BrokerFacade implements Closeable { final DataSchemaNode baseSchemaNode = baseSchemaCtxTree.findChild(path).orElseThrow().getDataSchemaNode(); if (result instanceof ContainerNode) { final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> builder = - SchemaAwareBuilders.containerBuilder((ContainerSchemaNode) baseSchemaNode); + Builders.containerBuilder(); buildCont(builder, (ContainerNode) result, baseSchemaCtxTree, path, trim); return builder.build(); } final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> builder = - SchemaAwareBuilders.mapEntryBuilder((ListSchemaNode) baseSchemaNode); + Builders.mapEntryBuilder(); buildMapEntryBuilder(builder, (MapEntryNode) result, baseSchemaCtxTree, path, trim, ((ListSchemaNode) baseSchemaNode).getKeyDefinition()); return builder.build(); @@ -589,12 +590,12 @@ public class BrokerFacade implements Closeable { final DataSchemaNode childSchema = baseSchemaCtxTree.findChild(path).orElseThrow().getDataSchemaNode(); if (child instanceof ContainerNode) { final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> childBuilder = - SchemaAwareBuilders.containerBuilder((ContainerSchemaNode) childSchema); + Builders.containerBuilder(); buildCont(childBuilder, (ContainerNode) child, baseSchemaCtxTree, path, trim); builder.withChild(childBuilder.build()); } else if (child instanceof MapNode) { final CollectionNodeBuilder<MapEntryNode, SystemMapNode> childBuilder = - SchemaAwareBuilders.mapBuilder((ListSchemaNode) childSchema); + Builders.mapBuilder(); buildList(childBuilder, (MapNode) child, baseSchemaCtxTree, path, trim, ((ListSchemaNode) childSchema).getKeyDefinition()); builder.withChild(childBuilder.build()); @@ -602,7 +603,7 @@ public class BrokerFacade implements Closeable { final Object defaultVal = ((LeafSchemaNode) childSchema).getType().getDefaultValue().orElse(null); final Object nodeVal = child.body(); final NormalizedNodeBuilder<NodeIdentifier, Object, LeafNode<Object>> leafBuilder = - SchemaAwareBuilders.leafBuilder((LeafSchemaNode) childSchema); + Builders.leafBuilder(); if (keys.contains(child.getIdentifier().getNodeType())) { leafBuilder.withValue(child.body()); builder.withChild(leafBuilder.build()); @@ -628,10 +629,10 @@ public class BrokerFacade implements Closeable { final List<QName> keys) { for (final MapEntryNode mapEntryNode : result.body()) { final YangInstanceIdentifier actualNode = path.node(mapEntryNode.getIdentifier()); - final DataSchemaNode childSchema = baseSchemaCtxTree.findChild(actualNode).orElseThrow() - .getDataSchemaNode(); + // final DataSchemaNode childSchema = baseSchemaCtxTree.findChild(actualNode).orElseThrow() + // .getDataSchemaNode(); final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> mapEntryBuilder = - SchemaAwareBuilders.mapEntryBuilder((ListSchemaNode) childSchema); + Builders.mapEntryBuilder(); buildMapEntryBuilder(mapEntryBuilder, mapEntryNode, baseSchemaCtxTree, actualNode, trim, keys); builder.withChild(mapEntryBuilder.build()); } @@ -645,12 +646,12 @@ public class BrokerFacade implements Closeable { final DataSchemaNode childSchema = baseSchemaCtxTree.findChild(path).orElseThrow().getDataSchemaNode(); if (child instanceof ContainerNode) { final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> builderChild = - SchemaAwareBuilders.containerBuilder((ContainerSchemaNode) childSchema); + Builders.containerBuilder(); buildCont(builderChild, result, baseSchemaCtxTree, actualPath, trim); builder.withChild(builderChild.build()); } else if (child instanceof MapNode) { final CollectionNodeBuilder<MapEntryNode, SystemMapNode> childBuilder = - SchemaAwareBuilders.mapBuilder((ListSchemaNode) childSchema); + Builders.mapBuilder(); buildList(childBuilder, (MapNode) child, baseSchemaCtxTree, path, trim, ((ListSchemaNode) childSchema).getKeyDefinition()); builder.withChild(childBuilder.build()); @@ -658,7 +659,7 @@ public class BrokerFacade implements Closeable { final Object defaultVal = ((LeafSchemaNode) childSchema).getType().getDefaultValue().orElse(null); final Object nodeVal = child.body(); final NormalizedNodeBuilder<NodeIdentifier, Object, LeafNode<Object>> leafBuilder = - SchemaAwareBuilders.leafBuilder((LeafSchemaNode) childSchema); + Builders.leafBuilder(); if (trim) { if (defaultVal == null || !defaultVal.equals(nodeVal)) { leafBuilder.withValue(child.body()); diff --git a/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/ControllerContext.java b/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/ControllerContext.java index bd79377..2e191e0 100644 --- a/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/ControllerContext.java +++ b/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/ControllerContext.java @@ -573,7 +573,7 @@ public final class ControllerContext implements EffectiveModelContextListener, C throw new RestconfDocumentedException("Mount point does not exist.", ErrorType.PROTOCOL, ErrorTag.DATA_MISSING); } - final DOMMountPoint mount = mountOpt.get(); + final DOMMountPoint mount = mountOpt.orElseThrow(); final EffectiveModelContext mountPointSchema = getModelContext(mount); if (mountPointSchema == null) { diff --git a/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/JSONRestconfServiceImpl.java b/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/JSONRestconfServiceImpl.java index 296fd91..1716f8f 100644 --- a/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/JSONRestconfServiceImpl.java +++ b/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/JSONRestconfServiceImpl.java @@ -137,7 +137,7 @@ public class JSONRestconfServiceImpl implements JSONRestconfService { final Optional<String> result = Optional.of(toJson(readData)); - LOG.debug("get returning: {}", result.get()); + LOG.debug("get returning: {}", result.orElseThrow()); return result; } catch (final Exception e) { @@ -157,7 +157,7 @@ public class JSONRestconfServiceImpl implements JSONRestconfService { throws OperationFailedException { requireNonNull(uriPath, "uriPath can't be null"); - final String actualInput = input.isPresent() ? input.get() : null; + final String actualInput = input.isPresent() ? input.orElseThrow() : null; LOG.debug("invokeRpc: uriPath: {}, input: {}", uriPath, actualInput); diff --git a/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/RestconfImpl.java b/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/RestconfImpl.java index b3a1a9c..377f0e5 100644 --- a/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/RestconfImpl.java +++ b/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/RestconfImpl.java @@ -67,7 +67,6 @@ import org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult; import org.opendaylight.netconf.sal.rest.api.Draft02; import org.opendaylight.netconf.sal.rest.api.RestconfService; import org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext; -import org.opendaylight.netconf.sal.restconf.impl.ControllerContext.FoundChild; import org.opendaylight.netconf.sal.streams.listeners.ListenerAdapter; import org.opendaylight.netconf.sal.streams.listeners.NotificationListenerAdapter; import org.opendaylight.netconf.sal.streams.listeners.Notificator; @@ -109,14 +108,11 @@ import org.opendaylight.yangtools.yang.data.api.schema.builder.DataContainerNode import org.opendaylight.yangtools.yang.data.api.schema.builder.ListNodeBuilder; import org.opendaylight.yangtools.yang.data.impl.schema.Builders; import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.data.impl.schema.SchemaAwareBuilders; import org.opendaylight.yangtools.yang.data.tree.api.ModifiedNodeDoesNotExistException; import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.FeatureDefinition; -import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode; -import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; import org.opendaylight.yangtools.yang.model.api.ListSchemaNode; import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.NotificationDefinition; @@ -217,7 +213,7 @@ public final class RestconfImpl implements RestconfService { checkState(modulesSchemaNode instanceof ContainerSchemaNode); final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> moduleContainerBuilder = - SchemaAwareBuilders.containerBuilder((ContainerSchemaNode) modulesSchemaNode); + Builders.containerBuilder(); moduleContainerBuilder.withChild(makeModuleMapNode(controllerContext.getAllModules())); return new NormalizedNodeContext(InstanceIdentifierContext.ofStack(stack, null), @@ -253,7 +249,7 @@ public final class RestconfImpl implements RestconfService { checkState(modulesSchemaNode instanceof ContainerSchemaNode); final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> moduleContainerBuilder = - SchemaAwareBuilders.containerBuilder((ContainerSchemaNode) modulesSchemaNode); + Builders.containerBuilder(); moduleContainerBuilder.withChild(mountPointModulesMap); return new NormalizedNodeContext(InstanceIdentifierContext.ofStack(stack, null), @@ -306,7 +302,7 @@ public final class RestconfImpl implements RestconfService { checkState(streamSchemaNode instanceof ListSchemaNode); final CollectionNodeBuilder<MapEntryNode, SystemMapNode> listStreamsBuilder = - SchemaAwareBuilders.mapBuilder((ListSchemaNode) streamSchemaNode); + Builders.mapBuilder(); for (final String streamName : availableStreams) { listStreamsBuilder.withChild(toStreamEntryNode(streamName, streamSchemaNode)); @@ -322,7 +318,7 @@ public final class RestconfImpl implements RestconfService { checkState(streamsContainerSchemaNode instanceof ContainerSchemaNode); final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> streamsContainerBuilder = - SchemaAwareBuilders.containerBuilder((ContainerSchemaNode) streamsContainerSchemaNode); + Builders.containerBuilder(); streamsContainerBuilder.withChild(listStreamsBuilder.build()); return new NormalizedNodeContext(InstanceIdentifierContext.ofStack(stack), @@ -411,7 +407,7 @@ public final class RestconfImpl implements RestconfService { final SchemaNode schema = payload.getInstanceIdentifierContext().getSchemaNode(); final ListenableFuture<? extends DOMRpcResult> response; final DOMMountPoint mountPoint = payload.getInstanceIdentifierContext().getMountPoint(); - final NormalizedNode input = nonnullInput(schema, payload.getData()); + final ContainerNode input = nonnullInput(schema, (ContainerNode) payload.getData()); final EffectiveModelContext schemaContext; if (mountPoint != null) { @@ -421,7 +417,7 @@ public final class RestconfImpl implements RestconfService { throw new RestconfDocumentedException("Rpc service is missing."); } schemaContext = modelContext(mountPoint); - response = mountRpcServices.get().invokeRpc(schema.getQName(), input); + response = mountRpcServices.orElseThrow().invokeRpc(schema.getQName(), input); } else { final XMLNamespace namespace = schema.getQName().getNamespace(); if (namespace.toString().equals(SAL_REMOTE_NAMESPACE)) { @@ -512,7 +508,7 @@ public final class RestconfImpl implements RestconfService { if (mountRpcServices.isEmpty()) { throw new RestconfDocumentedException("Rpc service is missing."); } - response = mountRpcServices.get().invokeRpc(rpc.getQName(), input); + response = mountRpcServices.orElseThrow().invokeRpc(rpc.getQName(), input); } else { response = broker.invokeRpc(rpc.getQName(), input); } @@ -534,7 +530,7 @@ public final class RestconfImpl implements RestconfService { return new NormalizedNodeContext(iic, result, QueryParametersParser.parseWriterParameters(uriInfo)); } - private static @NonNull NormalizedNode nonnullInput(final SchemaNode rpc, final NormalizedNode input) { + private static @NonNull ContainerNode nonnullInput(final SchemaNode rpc, final ContainerNode input) { return input != null ? input : defaultInput(rpc.getQName()); } @@ -599,7 +595,7 @@ public final class RestconfImpl implements RestconfService { final QName rpcQName = payload.getInstanceIdentifierContext().getSchemaNode().getQName(); final Optional<DataContainerChild> path = value.findChildByArg(new NodeIdentifier(QName.create(rpcQName, "path"))); - final Object pathValue = path.isPresent() ? path.get().body() : null; + final Object pathValue = path.isPresent() ? path.orElseThrow().body() : null; if (!(pathValue instanceof YangInstanceIdentifier)) { LOG.debug("Instance identifier {} was not normalized correctly", rpcQName); @@ -1312,7 +1308,7 @@ public final class RestconfImpl implements RestconfService { if (optAugNode.isEmpty()) { return null; } - final DataContainerChild augNode = optAugNode.get(); + final DataContainerChild augNode = optAugNode.orElseThrow(); if (!(augNode instanceof AugmentationNode)) { return null; } @@ -1321,7 +1317,7 @@ public final class RestconfImpl implements RestconfService { if (enumNode.isEmpty()) { return null; } - final Object rawValue = enumNode.get().body(); + final Object rawValue = enumNode.orElseThrow().body(); if (!(rawValue instanceof String)) { return null; } @@ -1375,7 +1371,7 @@ public final class RestconfImpl implements RestconfService { checkState(moduleSchemaNode instanceof ListSchemaNode); final CollectionNodeBuilder<MapEntryNode, SystemMapNode> listModuleBuilder = - SchemaAwareBuilders.mapBuilder((ListSchemaNode) moduleSchemaNode); + Builders.mapBuilder(); for (final Module module : modules) { listModuleBuilder.withChild(toModuleEntryNode(module, moduleSchemaNode)); @@ -1386,38 +1382,38 @@ public final class RestconfImpl implements RestconfService { private static MapEntryNode toModuleEntryNode(final Module module, final DataSchemaNode moduleSchemaNode) { checkArgument(moduleSchemaNode instanceof ListSchemaNode, "moduleSchemaNode has to be of type ListSchemaNode"); - final ListSchemaNode listModuleSchemaNode = (ListSchemaNode) moduleSchemaNode; + // final ListSchemaNode listModuleSchemaNode = (ListSchemaNode) moduleSchemaNode; final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> moduleNodeValues = - SchemaAwareBuilders.mapEntryBuilder(listModuleSchemaNode); + Builders.mapEntryBuilder(); - var instanceDataChildrenByName = - ControllerContext.findInstanceDataChildrenByName(listModuleSchemaNode, "name"); - final LeafSchemaNode nameSchemaNode = getFirstLeaf(instanceDataChildrenByName); + // var instanceDataChildrenByName = + // ControllerContext.findInstanceDataChildrenByName(listModuleSchemaNode, "name"); + // final LeafSchemaNode nameSchemaNode = getFirstLeaf(instanceDataChildrenByName); moduleNodeValues.withChild( - SchemaAwareBuilders.leafBuilder(nameSchemaNode).withValue(module.getName()).build()); + Builders.leafBuilder().withValue(module.getName()).build()); final QNameModule qNameModule = module.getQNameModule(); - instanceDataChildrenByName = - ControllerContext.findInstanceDataChildrenByName(listModuleSchemaNode, "revision"); - final LeafSchemaNode revisionSchemaNode = getFirstLeaf(instanceDataChildrenByName); + // instanceDataChildrenByName = + // ControllerContext.findInstanceDataChildrenByName(listModuleSchemaNode, "revision"); + // final LeafSchemaNode revisionSchemaNode = getFirstLeaf(instanceDataChildrenByName); final Optional<Revision> revision = qNameModule.getRevision(); - moduleNodeValues.withChild(SchemaAwareBuilders.leafBuilder(revisionSchemaNode) + moduleNodeValues.withChild(Builders.leafBuilder() .withValue(revision.map(Revision::toString).orElse("")).build()); - instanceDataChildrenByName = - ControllerContext.findInstanceDataChildrenByName(listModuleSchemaNode, "namespace"); - final LeafSchemaNode namespaceSchemaNode = getFirstLeaf(instanceDataChildrenByName); - moduleNodeValues.withChild(SchemaAwareBuilders.leafBuilder(namespaceSchemaNode) + // instanceDataChildrenByName = + // ControllerContext.findInstanceDataChildrenByName(listModuleSchemaNode, "namespace"); + // final LeafSchemaNode namespaceSchemaNode = getFirstLeaf(instanceDataChildrenByName); + moduleNodeValues.withChild(Builders.leafBuilder() .withValue(qNameModule.getNamespace().toString()).build()); - instanceDataChildrenByName = - ControllerContext.findInstanceDataChildrenByName(listModuleSchemaNode, "feature"); - final LeafListSchemaNode featureSchemaNode = getFirst(instanceDataChildrenByName, LeafListSchemaNode.class); + // instanceDataChildrenByName = + // ControllerContext.findInstanceDataChildrenByName(listModuleSchemaNode, "feature"); + // final LeafListSchemaNode featureSchemaNode = getFirst(instanceDataChildrenByName, LeafListSchemaNode.class); final ListNodeBuilder<Object, SystemLeafSetNode<Object>> featuresBuilder = - SchemaAwareBuilders.leafSetBuilder(featureSchemaNode); + Builders.leafSetBuilder(); for (final FeatureDefinition feature : module.getFeatures()) { - featuresBuilder.withChild(SchemaAwareBuilders.leafSetEntryBuilder(featureSchemaNode) + featuresBuilder.withChild(Builders.leafSetEntryBuilder() .withValue(feature.getQName().getLocalName()).build()); } moduleNodeValues.withChild(featuresBuilder.build()); @@ -1428,39 +1424,40 @@ public final class RestconfImpl implements RestconfService { protected MapEntryNode toStreamEntryNode(final String streamName, final DataSchemaNode streamSchemaNode) { checkArgument(streamSchemaNode instanceof ListSchemaNode, "streamSchemaNode has to be of type ListSchemaNode"); - final ListSchemaNode listStreamSchemaNode = (ListSchemaNode) streamSchemaNode; + // final ListSchemaNode listStreamSchemaNode = (ListSchemaNode) streamSchemaNode; final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> streamNodeValues = - SchemaAwareBuilders.mapEntryBuilder(listStreamSchemaNode); + Builders.mapEntryBuilder(); - var instanceDataChildrenByName = - ControllerContext.findInstanceDataChildrenByName(listStreamSchemaNode, "name"); - final LeafSchemaNode nameSchemaNode = getFirstLeaf(instanceDataChildrenByName); + // var instanceDataChildrenByName = + // ControllerContext.findInstanceDataChildrenByName(listStreamSchemaNode, "name"); + // final LeafSchemaNode nameSchemaNode = getFirstLeaf(instanceDataChildrenByName); streamNodeValues.withChild( - SchemaAwareBuilders.leafBuilder(nameSchemaNode).withValue(streamName).build()); + Builders.leafBuilder().withValue(streamName).build()); - instanceDataChildrenByName = - ControllerContext.findInstanceDataChildrenByName(listStreamSchemaNode, "description"); - final LeafSchemaNode descriptionSchemaNode = getFirstLeaf(instanceDataChildrenByName); - streamNodeValues.withChild(SchemaAwareBuilders.leafBuilder(descriptionSchemaNode) + // instanceDataChildrenByName = + // ControllerContext.findInstanceDataChildrenByName(listStreamSchemaNode, "description"); + // final LeafSchemaNode descriptionSchemaNode = getFirstLeaf(instanceDataChildrenByName); + streamNodeValues.withChild(Builders.leafBuilder() .withValue("DESCRIPTION_PLACEHOLDER") .build()); - instanceDataChildrenByName = - ControllerContext.findInstanceDataChildrenByName(listStreamSchemaNode, "replay-support"); - final LeafSchemaNode replaySupportSchemaNode = getFirstLeaf(instanceDataChildrenByName); - streamNodeValues.withChild(SchemaAwareBuilders.leafBuilder(replaySupportSchemaNode) + // instanceDataChildrenByName = + // ControllerContext.findInstanceDataChildrenByName(listStreamSchemaNode, "replay-support"); + // final LeafSchemaNode replaySupportSchemaNode = getFirstLeaf(instanceDataChildrenByName); + streamNodeValues.withChild(Builders.leafBuilder() .withValue(Boolean.TRUE).build()); - instanceDataChildrenByName = - ControllerContext.findInstanceDataChildrenByName(listStreamSchemaNode, "replay-log-creation-time"); - final LeafSchemaNode replayLogCreationTimeSchemaNode = getFirstLeaf(instanceDataChildrenByName); + // instanceDataChildrenByName = + // ControllerContext.findInstanceDataChildrenByName(listStreamSchemaNode, "replay-log-creation-time"); + // final LeafSchemaNode replayLogCreationTimeSchemaNode = getFirstLeaf(instanceDataChildrenByName); streamNodeValues.withChild( - SchemaAwareBuilders.leafBuilder(replayLogCreationTimeSchemaNode).withValue("").build()); + Builders.leafBuilder().withValue("").build()); - instanceDataChildrenByName = ControllerContext.findInstanceDataChildrenByName(listStreamSchemaNode, "events"); - final LeafSchemaNode eventsSchemaNode = getFirstLeaf(instanceDataChildrenByName); + // instanceDataChildrenByName = + // ControllerContext.findInstanceDataChildrenByName(listStreamSchemaNode, "events"); + // final LeafSchemaNode eventsSchemaNode = getFirstLeaf(instanceDataChildrenByName); streamNodeValues.withChild( - SchemaAwareBuilders.leafBuilder(eventsSchemaNode).withValue(Empty.value()).build()); + Builders.leafBuilder().withValue(Empty.value()).build()); return streamNodeValues.build(); } @@ -1527,10 +1524,12 @@ public final class RestconfImpl implements RestconfService { .build())); } + /* private static LeafSchemaNode getFirstLeaf(final List<FoundChild> children) { return getFirst(children, LeafSchemaNode.class); } + private static <T extends DataSchemaNode> T getFirst(final List<FoundChild> children, final Class<T> expected) { checkState(!children.isEmpty()); final var first = children.get(0); @@ -1538,6 +1537,8 @@ public final class RestconfImpl implements RestconfService { return expected.cast(first.child); } + */ + private static EffectiveModelContext modelContext(final DOMMountPoint mountPoint) { return mountPoint.getService(DOMSchemaService.class) .flatMap(svc -> Optional.ofNullable(svc.getGlobalContext())) diff --git a/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/web/WebInitializer.java b/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/web/WebInitializer.java index 1f9b5f4..ab52d60 100644 --- a/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/web/WebInitializer.java +++ b/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/web/WebInitializer.java @@ -16,7 +16,7 @@ import org.opendaylight.aaa.filterchain.filters.CustomFilterAdapter; import org.opendaylight.aaa.web.FilterDetails; import org.opendaylight.aaa.web.ServletDetails; import org.opendaylight.aaa.web.WebContext; -import org.opendaylight.aaa.web.WebContextBuilder; +import org.opendaylight.aaa.web.WebContext.Builder; import org.opendaylight.aaa.web.WebContextSecurer; import org.opendaylight.aaa.web.WebServer; import org.opendaylight.aaa.web.servlet.ServletSupport; @@ -37,14 +37,13 @@ public class WebInitializer { public WebInitializer(final WebServer webServer, final WebContextSecurer webContextSecurer, final ServletSupport servletSupport, final RestconfApplication webApp, final CustomFilterAdapterConfiguration customFilterAdapterConfig) throws ServletException { + Builder webContextBuilder = WebContext.builder().contextPath("/restconf").supportsSessions(false) + .addServlet(ServletDetails.builder().servlet(servletSupport.createHttpServletBuilder(webApp).build()) + .addUrlPattern("/*").build()) - WebContextBuilder webContextBuilder = WebContext.builder().contextPath("restconf").supportsSessions(false) - .addServlet(ServletDetails.builder().servlet(servletSupport.createHttpServletBuilder(webApp).build()) - .addUrlPattern("/*").build()) - - // Allows user to add javax.servlet.Filter(s) in front of REST services - .addFilter(FilterDetails.builder().filter(new CustomFilterAdapter(customFilterAdapterConfig)) - .addUrlPattern("/*").build()); + // Allows user to add javax.servlet.Filter(s) in front of REST services + .addFilter(FilterDetails.builder().filter(new CustomFilterAdapter(customFilterAdapterConfig)) + .addUrlPattern("/*").build()); webContextSecurer.requireAuthentication(webContextBuilder, "/*"); diff --git a/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/streams/listeners/ListenerAdapter.java b/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/streams/listeners/ListenerAdapter.java index fc85862..041e645 100644 --- a/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/streams/listeners/ListenerAdapter.java +++ b/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/streams/listeners/ListenerAdapter.java @@ -222,7 +222,7 @@ public class ListenerAdapter extends AbstractCommonSubscriber implements Cluster return; } - NormalizedNode normalizedNode = optionalNormalizedNode.get(); + NormalizedNode normalizedNode = optionalNormalizedNode.orElseThrow(); YangInstanceIdentifier yiid = YangInstanceIdentifier.builder(parentYiid) .append(normalizedNode.getIdentifier()).build(); @@ -402,7 +402,7 @@ public class ListenerAdapter extends AbstractCommonSubscriber implements Cluster private void writeIdentifierWithNamespacePrefix(final Element element, final StringBuilder textContent, final QName qualifiedName) { final Module module = controllerContext.getGlobalSchema().findModule(qualifiedName.getModule()) - .get(); + .orElseThrow(); textContent.append(module.getName()); textContent.append(":"); diff --git a/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/streams/listeners/Notificator.java b/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/streams/listeners/Notificator.java index 5bfa79f..1ba4255 100644 --- a/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/streams/listeners/Notificator.java +++ b/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/streams/listeners/Notificator.java @@ -136,8 +136,6 @@ public final class Notificator { /** * Delete {@link ListenerAdapter} listener specified in parameter. * - * @param <T> - * * @param listener * ListenerAdapter */ diff --git a/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/restconf/rev131019/DatastoreIdentifierBuilder.java b/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/restconf/rev131019/DatastoreIdentifierBuilder.java index 42defe5..b01c2f4 100644 --- a/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/restconf/rev131019/DatastoreIdentifierBuilder.java +++ b/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/restconf/rev131019/DatastoreIdentifierBuilder.java @@ -6,15 +6,17 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ package org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.rev131019; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.rev131019.DatastoreIdentifier.Enumeration; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.data.api.DatastoreIdentifier; /** **/ public class DatastoreIdentifierBuilder { public static DatastoreIdentifier getDefaultInstance(final String defaultValue) { - return new DatastoreIdentifier(Enumeration.valueOf(defaultValue)); + QName qName = QName.create(defaultValue); + return DatastoreIdentifier.of(qName); } } diff --git a/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/restconf/rev131019/restconf/restconf/modules/ModuleRevisionBuilder.java b/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/restconf/rev131019/restconf/restconf/modules/ModuleRevisionBuilder.java index dfd0aeb..cc447f2 100644 --- a/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/restconf/rev131019/restconf/restconf/modules/ModuleRevisionBuilder.java +++ b/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/restconf/rev131019/restconf/restconf/modules/ModuleRevisionBuilder.java @@ -7,7 +7,7 @@ */ package org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.rev131019.restconf.restconf.modules; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.rev131019.restconf.restconf.modules.Module.Revision; +import org.opendaylight.yangtools.yang.common.Revision; /** * The purpose of generated class in src/main/java for Union types is to create diff --git a/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/restconf/rev131019/restconf/restconf/modules/RevisionBuilder.java b/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/restconf/rev131019/restconf/restconf/modules/RevisionBuilder.java index d09646a..4df5da8 100644 --- a/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/restconf/rev131019/restconf/restconf/modules/RevisionBuilder.java +++ b/netconf/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/restconf/rev131019/restconf/restconf/modules/RevisionBuilder.java @@ -9,8 +9,8 @@ package org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.r import java.util.regex.Pattern; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.rev131019.RevisionIdentifier; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.rev131019.restconf.restconf.modules.Module.Revision; + +import org.opendaylight.yangtools.yang.common.Revision; /** **/ @@ -26,11 +26,10 @@ public class RevisionBuilder { if (defaultValue != null) { if (REVISION_PATTERN.matcher(defaultValue).matches()) { - RevisionIdentifier id = new RevisionIdentifier(defaultValue); - return new Revision(id); + return Revision.of(defaultValue); } if (defaultValue.isEmpty()) { - return new Revision(defaultValue); + return Revision.of(defaultValue); } } diff --git a/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestJsonBodyReader.java b/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestJsonBodyReader.java index fe50c68..0274253 100644 --- a/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestJsonBodyReader.java +++ b/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestJsonBodyReader.java @@ -168,13 +168,13 @@ public class TestJsonBodyReader extends AbstractBodyReaderTest { QName.create(inputNode.getIdentifier().getNodeType(), "cont")); final Optional<DataContainerChild> contDataNode = inputNode.findChildByArg(yangCont.getLastPathArgument()); assertTrue(contDataNode.isPresent()); - assertTrue(contDataNode.get() instanceof ContainerNode); + assertTrue(contDataNode.orElseThrow() instanceof ContainerNode); final YangInstanceIdentifier yangleaf = YangInstanceIdentifier.of( QName.create(inputNode.getIdentifier().getNodeType(), "lf")); - final Optional<DataContainerChild> leafDataNode = ((ContainerNode) contDataNode.get()) + final Optional<DataContainerChild> leafDataNode = ((ContainerNode) contDataNode.orElseThrow()) .findChildByArg(yangleaf.getLastPathArgument()); assertTrue(leafDataNode.isPresent()); - assertTrue("lf-test".equalsIgnoreCase(leafDataNode.get().body().toString())); + assertTrue("lf-test".equalsIgnoreCase(leafDataNode.orElseThrow().body().toString())); } private static void checkExpectValueNormalizeNodeContext(final DataSchemaNode dataSchemaNode, diff --git a/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestJsonBodyReaderMountPoint.java b/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestJsonBodyReaderMountPoint.java index e8776c8..5fed159 100644 --- a/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestJsonBodyReaderMountPoint.java +++ b/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestJsonBodyReaderMountPoint.java @@ -117,13 +117,13 @@ public class TestJsonBodyReaderMountPoint extends AbstractBodyReaderTest { QName.create(inputNode.getIdentifier().getNodeType(), "cont")); final Optional<DataContainerChild> contDataNode = inputNode.findChildByArg(yangCont.getLastPathArgument()); assertTrue(contDataNode.isPresent()); - assertTrue(contDataNode.get() instanceof ContainerNode); + assertTrue(contDataNode.orElseThrow() instanceof ContainerNode); final YangInstanceIdentifier yangleaf = YangInstanceIdentifier.of( QName.create(inputNode.getIdentifier().getNodeType(), "lf")); final Optional<DataContainerChild> leafDataNode = - ((ContainerNode) contDataNode.get()).findChildByArg(yangleaf.getLastPathArgument()); + ((ContainerNode) contDataNode.orElseThrow()).findChildByArg(yangleaf.getLastPathArgument()); assertTrue(leafDataNode.isPresent()); - assertTrue("lf-test".equalsIgnoreCase(leafDataNode.get().body().toString())); + assertTrue("lf-test".equalsIgnoreCase(leafDataNode.orElseThrow().body().toString())); } private void checkExpectValueNormalizeNodeContext(final DataSchemaNode dataSchemaNode, diff --git a/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestXmlBodyReader.java b/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestXmlBodyReader.java index 7ff353e..193a710 100644 --- a/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestXmlBodyReader.java +++ b/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestXmlBodyReader.java @@ -207,11 +207,11 @@ public class TestXmlBodyReader extends AbstractBodyReaderTest { final Optional<DataContainerChild> contDataNodePotential = contNode.findChildByArg(new NodeIdentifier( QName.create(contNode.getIdentifier().getNodeType(), "cont"))); assertTrue(contDataNodePotential.isPresent()); - final ContainerNode contDataNode = (ContainerNode) contDataNodePotential.get(); + final ContainerNode contDataNode = (ContainerNode) contDataNodePotential.orElseThrow(); final Optional<DataContainerChild> leafDataNode = contDataNode.findChildByArg(new NodeIdentifier( QName.create(contDataNode.getIdentifier().getNodeType(), "lf"))); assertTrue(leafDataNode.isPresent()); - assertTrue("lf-test".equalsIgnoreCase(leafDataNode.get().body().toString())); + assertTrue("lf-test".equalsIgnoreCase(leafDataNode.orElseThrow().body().toString())); } private static void checkExpectValueNormalizeNodeContext(final DataSchemaNode dataSchemaNode, diff --git a/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/input/to/cnsn/test/RestPutListDataTest.java b/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/input/to/cnsn/test/RestPutListDataTest.java index 71406ca..573810b 100644 --- a/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/input/to/cnsn/test/RestPutListDataTest.java +++ b/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/input/to/cnsn/test/RestPutListDataTest.java @@ -46,7 +46,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.api.schema.builder.DataContainerNodeBuilder; import org.opendaylight.yangtools.yang.data.api.schema.builder.NormalizedNodeBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.SchemaAwareBuilders; +import org.opendaylight.yangtools.yang.data.impl.schema.Builders; import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.valid.DataValidationException; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; @@ -176,7 +176,7 @@ public class RestPutListDataTest { assertTrue(testNodeSchemaNode != null); assertTrue(testNodeSchemaNode instanceof ListSchemaNode); final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> testNodeContainer = - SchemaAwareBuilders.mapEntryBuilder((ListSchemaNode) testNodeSchemaNode); + Builders.mapEntryBuilder(); var testChildren = ControllerContext.findInstanceDataChildrenByName( (ListSchemaNode) testNodeSchemaNode, key1.getLocalName()); @@ -185,7 +185,7 @@ public class RestPutListDataTest { assertTrue(testLeafKey1SchemaNode != null); assertTrue(testLeafKey1SchemaNode instanceof LeafSchemaNode); final NormalizedNodeBuilder<NodeIdentifier, Object, LeafNode<Object>> leafKey1 = - SchemaAwareBuilders.leafBuilder((LeafSchemaNode) testLeafKey1SchemaNode); + Builders.leafBuilder(); leafKey1.withValue(payloadKey1); testNodeContainer.withChild(leafKey1.build()); @@ -197,7 +197,7 @@ public class RestPutListDataTest { assertNotNull(testLeafKey2SchemaNode); assertTrue(testLeafKey2SchemaNode instanceof LeafSchemaNode); final NormalizedNodeBuilder<NodeIdentifier, Object, LeafNode<Object>> leafKey2 = - SchemaAwareBuilders.leafBuilder((LeafSchemaNode) testLeafKey2SchemaNode); + Builders.leafBuilder(); leafKey2.withValue(payloadKey2); testNodeContainer.withChild(leafKey2.build()); } diff --git a/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/xml/test/NnInstanceIdentifierToXmlTest.java b/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/xml/test/NnInstanceIdentifierToXmlTest.java index 2ab6476..d118110 100644 --- a/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/xml/test/NnInstanceIdentifierToXmlTest.java +++ b/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/xml/test/NnInstanceIdentifierToXmlTest.java @@ -32,14 +32,11 @@ import org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode; import org.opendaylight.yangtools.yang.data.api.schema.builder.CollectionNodeBuilder; import org.opendaylight.yangtools.yang.data.api.schema.builder.DataContainerNodeBuilder; import org.opendaylight.yangtools.yang.data.api.schema.builder.ListNodeBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.SchemaAwareBuilders; +import org.opendaylight.yangtools.yang.data.impl.schema.Builders; import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; -import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode; -import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; -import org.opendaylight.yangtools.yang.model.api.ListSchemaNode; import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack; public class NnInstanceIdentifierToXmlTest extends AbstractBodyReaderTest { @@ -105,22 +102,22 @@ public class NnInstanceIdentifierToXmlTest extends AbstractBodyReaderTest { final DataSchemaNode schemaCont = schemaContext.getDataChildByName(cont); - final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> dataCont = SchemaAwareBuilders - .containerBuilder((ContainerSchemaNode) schemaCont); + final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> dataCont = Builders + .containerBuilder(); final DataSchemaNode schemaCont1 = ((ContainerSchemaNode) schemaCont).getDataChildByName(cont1); - final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> dataCont1 = SchemaAwareBuilders - .containerBuilder((ContainerSchemaNode) schemaCont1); + final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> dataCont1 = Builders + .containerBuilder(); final var instanceLfLst11 = ControllerContext.findInstanceDataChildrenByName( (DataNodeContainer) schemaCont1, lflst11.getLocalName()); final DataSchemaNode lfLst11Schema = instanceLfLst11.get(0).child; - final ListNodeBuilder<Object, SystemLeafSetNode<Object>> lfLst11Data = SchemaAwareBuilders - .leafSetBuilder((LeafListSchemaNode) lfLst11Schema); + final ListNodeBuilder<Object, SystemLeafSetNode<Object>> lfLst11Data = Builders + .leafSetBuilder(); - lfLst11Data.withChild(SchemaAwareBuilders.leafSetEntryBuilder((LeafListSchemaNode) lfLst11Schema) + lfLst11Data.withChild(Builders.leafSetEntryBuilder() .withValue("lflst11 value").build()); dataCont1.withChild(lfLst11Data.build()); @@ -128,7 +125,7 @@ public class NnInstanceIdentifierToXmlTest extends AbstractBodyReaderTest { (DataNodeContainer) schemaCont1, lf11.getLocalName()); final DataSchemaNode lf11Schema = instanceLf11.get(0).child; - dataCont1.withChild(SchemaAwareBuilders.leafBuilder((LeafSchemaNode) lf11Schema) + dataCont1.withChild(Builders.leafBuilder() .withValue("/instanceidentifier/").build()); dataCont.withChild(dataCont1.build()); @@ -196,24 +193,24 @@ public class NnInstanceIdentifierToXmlTest extends AbstractBodyReaderTest { final DataSchemaNode schemaCont = schemaContext.getDataChildByName(cont); - final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> dataCont = SchemaAwareBuilders - .containerBuilder((ContainerSchemaNode) schemaCont); + final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> dataCont = Builders + .containerBuilder(); final DataSchemaNode schemaCont1 = ((ContainerSchemaNode) schemaCont) .getDataChildByName(cont1); - final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> dataCont1 = SchemaAwareBuilders - .containerBuilder((ContainerSchemaNode) schemaCont1); + final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> dataCont1 = Builders + .containerBuilder(); final var instanceLst11 = ControllerContext.findInstanceDataChildrenByName( (DataNodeContainer) schemaCont1, lst11.getLocalName()); final DataSchemaNode lst11Schema = instanceLst11.get(0).child; - final CollectionNodeBuilder<MapEntryNode, SystemMapNode> dataLst11 = SchemaAwareBuilders - .mapBuilder((ListSchemaNode) lst11Schema); + final CollectionNodeBuilder<MapEntryNode, SystemMapNode> dataLst11 = Builders + .mapBuilder(); - final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> dataLst11Vaule = SchemaAwareBuilders - .mapEntryBuilder((ListSchemaNode) lst11Schema); + final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> dataLst11Vaule = Builders + .mapEntryBuilder(); dataLst11Vaule.withChild(buildLeaf(lst11Schema, keyvalue111, dataLst11, "keyvalue111")); @@ -240,7 +237,7 @@ public class NnInstanceIdentifierToXmlTest extends AbstractBodyReaderTest { (DataNodeContainer) lst11Schema, qname.getLocalName()); final DataSchemaNode schemaLf = instanceLf.get(0).child; - return SchemaAwareBuilders.leafBuilder((LeafSchemaNode) schemaLf).withValue(value).build(); + return Builders.leafBuilder().withValue(value).build(); } @Override diff --git a/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/xml/test/NnToXmlTest.java b/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/xml/test/NnToXmlTest.java index b1385d9..9785863 100644 --- a/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/xml/test/NnToXmlTest.java +++ b/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/xml/test/NnToXmlTest.java @@ -32,12 +32,11 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdent import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.data.api.schema.builder.DataContainerNodeBuilder; import org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodec; -import org.opendaylight.yangtools.yang.data.impl.schema.SchemaAwareBuilders; +import org.opendaylight.yangtools.yang.data.impl.schema.Builders; import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; -import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition; import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition; import org.opendaylight.yangtools.yang.model.ri.type.BaseTypes; @@ -294,14 +293,14 @@ public class NnToXmlTest extends AbstractBodyReaderTest { final DataSchemaNode contSchema = schemaContext.getDataChildByName(cont); - final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> contData = SchemaAwareBuilders - .containerBuilder((ContainerSchemaNode) contSchema); + final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> contData = Builders + .containerBuilder(); final var instanceLf = ControllerContext .findInstanceDataChildrenByName((DataNodeContainer) contSchema, lf.getLocalName()); final DataSchemaNode schemaLf = instanceLf.get(0).child; - contData.withChild(SchemaAwareBuilders.leafBuilder((LeafSchemaNode) schemaLf).withValue(object).build()); + contData.withChild(Builders.leafBuilder().withValue(object).build()); return new NormalizedNodeContext( InstanceIdentifierContext.ofStack(SchemaInferenceStack.ofDataTreePath(schemaContext, cont)), @@ -325,20 +324,20 @@ public class NnToXmlTest extends AbstractBodyReaderTest { final DataSchemaNode contSchema = schemaContext.getDataChildByName(cont); - final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> contData = SchemaAwareBuilders - .containerBuilder((ContainerSchemaNode) contSchema); + final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> contData = Builders + .containerBuilder(); var instanceLf = ControllerContext .findInstanceDataChildrenByName((DataNodeContainer) contSchema, lfBoolean.getLocalName()); DataSchemaNode schemaLf = instanceLf.get(0).child; - contData.withChild(SchemaAwareBuilders.leafBuilder((LeafSchemaNode) schemaLf).withValue(Boolean.TRUE).build()); + contData.withChild(Builders.leafBuilder().withValue(Boolean.TRUE).build()); instanceLf = ControllerContext.findInstanceDataChildrenByName((DataNodeContainer) contSchema, lfLfref.getLocalName()); schemaLf = instanceLf.get(0).child; - contData.withChild(SchemaAwareBuilders.leafBuilder((LeafSchemaNode) schemaLf).withValue("true").build()); + contData.withChild(Builders.leafBuilder().withValue("true").build()); return new NormalizedNodeContext( InstanceIdentifierContext.ofStack(SchemaInferenceStack.ofDataTreePath(schemaContext, cont)), @@ -350,14 +349,14 @@ public class NnToXmlTest extends AbstractBodyReaderTest { final QName lfLfref = QName.create("basic:module", "2013-12-02", "lfLfrefNegative"); final DataSchemaNode contSchema = schemaContext.getDataChildByName(cont); - final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> contData = SchemaAwareBuilders - .containerBuilder((ContainerSchemaNode) contSchema); + final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> contData = Builders + .containerBuilder(); final var instanceLf = ControllerContext.findInstanceDataChildrenByName((DataNodeContainer) contSchema, lfLfref.getLocalName()); final DataSchemaNode schemaLf = instanceLf.get(0).child; - contData.withChild(SchemaAwareBuilders.leafBuilder((LeafSchemaNode) schemaLf).withValue("value").build()); + contData.withChild(Builders.leafBuilder().withValue("value").build()); return new NormalizedNodeContext( InstanceIdentifierContext.ofStack(SchemaInferenceStack.ofDataTreePath(schemaContext, cont)), @@ -371,13 +370,13 @@ public class NnToXmlTest extends AbstractBodyReaderTest { final DataSchemaNode contSchema = schemaContext.getDataChildByName(cont); - final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> contData = SchemaAwareBuilders - .containerBuilder((ContainerSchemaNode) contSchema); + final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> contData = Builders + .containerBuilder(); final DataSchemaNode cont1Schema = ((ContainerSchemaNode) contSchema).getDataChildByName(cont1); - final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> cont1Data = SchemaAwareBuilders - .containerBuilder((ContainerSchemaNode) cont1Schema); + final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> cont1Data = Builders + .containerBuilder(); Object value = null; if (valueAsQName) { @@ -390,7 +389,7 @@ public class NnToXmlTest extends AbstractBodyReaderTest { .findInstanceDataChildrenByName((DataNodeContainer) cont1Schema, lf11.getLocalName()); final DataSchemaNode schemaLf = instanceLf.get(0).child; - cont1Data.withChild(SchemaAwareBuilders.leafBuilder((LeafSchemaNode) schemaLf).withValue(value).build()); + cont1Data.withChild(Builders.leafBuilder().withValue(value).build()); contData.withChild(cont1Data.build()); diff --git a/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/xml/test/NnToXmlWithChoiceTest.java b/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/xml/test/NnToXmlWithChoiceTest.java index 9d2954d..1272638 100644 --- a/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/xml/test/NnToXmlWithChoiceTest.java +++ b/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/xml/test/NnToXmlWithChoiceTest.java @@ -24,13 +24,12 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdent import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.data.api.schema.builder.DataContainerNodeBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.SchemaAwareBuilders; +import org.opendaylight.yangtools.yang.data.impl.schema.Builders; import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode; import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; -import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack; public class NnToXmlWithChoiceTest extends AbstractBodyReaderTest { @@ -74,22 +73,22 @@ public class NnToXmlWithChoiceTest extends AbstractBodyReaderTest { final DataSchemaNode contSchemaNode = schemaContext .getDataChildByName(contQname); - final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> dataContainerNodeAttrBuilder = SchemaAwareBuilders - .containerBuilder((ContainerSchemaNode) contSchemaNode); + final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> dataContainerNodeAttrBuilder = Builders + .containerBuilder(); final DataSchemaNode choiceSchemaNode = ((ContainerSchemaNode) contSchemaNode) .getDataChildByName(choA); assertTrue(choiceSchemaNode instanceof ChoiceSchemaNode); - final DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> dataChoice = SchemaAwareBuilders - .choiceBuilder((ChoiceSchemaNode) choiceSchemaNode); + final DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> dataChoice = Builders + .choiceBuilder(); final var instanceLf = ControllerContext .findInstanceDataChildrenByName( (DataNodeContainer) contSchemaNode, lf.getLocalName()); final DataSchemaNode schemaLf = instanceLf.get(0).child; - dataChoice.withChild(SchemaAwareBuilders.leafBuilder((LeafSchemaNode) schemaLf) + dataChoice.withChild(Builders.leafBuilder() .withValue(value).build()); dataContainerNodeAttrBuilder.withChild(dataChoice.build()); diff --git a/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/xml/test/NnToXmlWithDataFromSeveralModulesTest.java b/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/xml/test/NnToXmlWithDataFromSeveralModulesTest.java index a9cf7a6..95b75ea 100644 --- a/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/xml/test/NnToXmlWithDataFromSeveralModulesTest.java +++ b/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/xml/test/NnToXmlWithDataFromSeveralModulesTest.java @@ -27,12 +27,11 @@ import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.data.api.schema.builder.DataContainerNodeBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.SchemaAwareBuilders; +import org.opendaylight.yangtools.yang.data.impl.schema.Builders; import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; -import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; public class NnToXmlWithDataFromSeveralModulesTest extends AbstractBodyReaderTest { @@ -92,8 +91,8 @@ public class NnToXmlWithDataFromSeveralModulesTest extends private static NormalizedNodeContext prepareNormalizedNodeContext() { final String rev = "2014-01-17"; - final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> dataContSchemaContNode = SchemaAwareBuilders - .containerBuilder(schemaContext); + final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> dataContSchemaContNode = Builders + .containerBuilder(); final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> modul1 = buildContBuilderMod1( "module:one", rev, "cont_m1", "contB_m1", "lf1_m1", @@ -121,23 +120,23 @@ public class NnToXmlWithDataFromSeveralModulesTest extends final DataSchemaNode contSchemaNode = schemaContext .getDataChildByName(contQname); - final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> dataContainerNodeAttrBuilder = SchemaAwareBuilders - .containerBuilder((ContainerSchemaNode) contSchemaNode); + final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> dataContainerNodeAttrBuilder = Builders + .containerBuilder(); Preconditions.checkState(contSchemaNode instanceof ContainerSchemaNode); final var instanceLf1_m1 = ControllerContext.findInstanceDataChildrenByName( (DataNodeContainer) contSchemaNode, lf1Qname.getLocalName()); final DataSchemaNode schemaLf1_m1 = instanceLf1_m1.get(0).child; - dataContainerNodeAttrBuilder.withChild(SchemaAwareBuilders - .leafBuilder((LeafSchemaNode) schemaLf1_m1) + dataContainerNodeAttrBuilder.withChild(Builders + .leafBuilder() .withValue(lf1Value).build()); final DataSchemaNode contBSchemaNode = ((ContainerSchemaNode) contSchemaNode) .getDataChildByName(contBQname); - final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> dataContainerB = SchemaAwareBuilders - .containerBuilder((ContainerSchemaNode) contBSchemaNode); + final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> dataContainerB = Builders + .containerBuilder(); return dataContainerNodeAttrBuilder.withChild(dataContainerB.build()); } diff --git a/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/BrokerFacadeTest.java b/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/BrokerFacadeTest.java index 8443712..25cc678 100644 --- a/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/BrokerFacadeTest.java +++ b/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/BrokerFacadeTest.java @@ -77,6 +77,7 @@ import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; +import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.impl.schema.Builders; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; @@ -183,10 +184,10 @@ public class BrokerFacadeTest { @Test public void testInvokeRpc() throws Exception { final DOMRpcResult expResult = mock(DOMRpcResult.class); - doReturn(immediateFluentFuture(expResult)).when(mockRpcService).invokeRpc(qname, dummyNode); + doReturn(immediateFluentFuture(expResult)).when(mockRpcService).invokeRpc(qname, (ContainerNode) dummyNode); final ListenableFuture<? extends DOMRpcResult> actualFuture = brokerFacade.invokeRpc(qname, - dummyNode); + (ContainerNode) dummyNode); assertNotNull("Future is null", actualFuture); final DOMRpcResult actualResult = actualFuture.get(); assertSame("invokeRpc", expResult, actualResult); diff --git a/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/InvokeRpcMethodTest.java b/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/InvokeRpcMethodTest.java index 19386a1..40df8bc 100644 --- a/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/InvokeRpcMethodTest.java +++ b/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/InvokeRpcMethodTest.java @@ -55,10 +55,9 @@ import org.opendaylight.yangtools.yang.common.XMLNamespace; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.data.api.schema.LeafNode; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.api.schema.builder.DataContainerNodeBuilder; import org.opendaylight.yangtools.yang.data.api.schema.builder.NormalizedNodeBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.SchemaAwareBuilders; +import org.opendaylight.yangtools.yang.data.impl.schema.Builders; import org.opendaylight.yangtools.yang.model.api.ContainerLike; import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; @@ -131,19 +130,19 @@ public class InvokeRpcMethodTest { assertNotNull(rpcSchemaNode); final InputSchemaNode rpcInputSchemaNode = rpcSchemaNode.getInput(); final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> container = - SchemaAwareBuilders.containerBuilder(rpcInputSchemaNode); + Builders.containerBuilder(); final QName contQName = QName.create(rpcModule.getQNameModule(), "cont"); final DataSchemaNode contSchemaNode = rpcInputSchemaNode.getDataChildByName(contQName); assertTrue(contSchemaNode instanceof ContainerSchemaNode); final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> contNode = - SchemaAwareBuilders.containerBuilder((ContainerSchemaNode) contSchemaNode); + Builders.containerBuilder(); final QName lfQName = QName.create(rpcModule.getQNameModule(), "lf"); final DataSchemaNode lfSchemaNode = ((ContainerSchemaNode) contSchemaNode).getDataChildByName(lfQName); assertTrue(lfSchemaNode instanceof LeafSchemaNode); final LeafNode<Object> lfNode = - SchemaAwareBuilders.leafBuilder((LeafSchemaNode) lfSchemaNode).withValue("any value").build(); + Builders.leafBuilder().withValue("any value").build(); contNode.withChild(lfNode); container.withChild(contNode.build()); @@ -178,11 +177,11 @@ public class InvokeRpcMethodTest { assertNotNull("getErrorMessage is null", actual.getErrorMessage()); if (expErrorMsg.isPresent()) { - assertEquals("getErrorMessage", expErrorMsg.get(), actual.getErrorMessage()); + assertEquals("getErrorMessage", expErrorMsg.orElseThrow(), actual.getErrorMessage()); } if (expAppTag.isPresent()) { - assertEquals("getErrorAppTag", expAppTag.get(), actual.getErrorAppTag()); + assertEquals("getErrorAppTag", expAppTag.orElseThrow(), actual.getErrorAppTag()); } } @@ -211,7 +210,7 @@ public class InvokeRpcMethodTest { @Test public void testInvokeRpcWithNoPayload_Success() { - final NormalizedNode resultObj = null; + final ContainerNode resultObj = null; final DOMRpcResult expResult = new DefaultDOMRpcResult(resultObj); final QName qname = QName.create("(http://netconfcentral.org/ns/toaster?revision=2009-11-20)cancel-toast"); @@ -270,9 +269,9 @@ public class InvokeRpcMethodTest { final NormalizedNodeContext payload = new NormalizedNodeContext( InstanceIdentifierContext.ofLocalRpcInput(schemaContext, rpcDef), - SchemaAwareBuilders.containerBuilder(rpcDef.getInput()).build()); + Builders.containerBuilder().build()); - doReturn(immediateFluentFuture(expResult)).when(brokerFacade).invokeRpc(eq(path), any(NormalizedNode.class)); + doReturn(immediateFluentFuture(expResult)).when(brokerFacade).invokeRpc(eq(path), any(ContainerNode.class)); final NormalizedNodeContext output = restconfImpl.invokeRpc("toaster:make-toast", payload, uriInfo); assertNotNull(output); @@ -309,12 +308,12 @@ public class InvokeRpcMethodTest { assertNotNull(rpcDef); assertNotNull(rpcOutputSchemaNode); final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> containerBuilder = - SchemaAwareBuilders.containerBuilder(rpcOutputSchemaNode); + Builders.containerBuilder(); final DataSchemaNode leafSchema = rpcOutputSchemaNode .getDataChildByName(QName.create(rpcModule.getQNameModule(), "textOut")); assertTrue(leafSchema instanceof LeafSchemaNode); final NormalizedNodeBuilder<NodeIdentifier, Object, LeafNode<Object>> leafBuilder = - SchemaAwareBuilders.leafBuilder((LeafSchemaNode) leafSchema); + Builders.leafBuilder(); leafBuilder.withValue("brm"); containerBuilder.withChild(leafBuilder.build()); final ContainerNode container = containerBuilder.build(); diff --git a/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/JSONRestconfServiceImplTest.java b/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/JSONRestconfServiceImplTest.java index 48db5de..d177439 100644 --- a/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/JSONRestconfServiceImplTest.java +++ b/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/JSONRestconfServiceImplTest.java @@ -237,14 +237,15 @@ public class JSONRestconfServiceImplTest { final java.util.Optional<DataContainerChild> mapChild = actualNode.findChildByArg( new NodeIdentifier(INTERFACE_QNAME)); assertEquals(INTERFACE_QNAME.toString() + " present", true, mapChild.isPresent()); - assertTrue("Expected MapNode. Actual " + mapChild.get().getClass(), mapChild.get() instanceof MapNode); - final MapNode mapNode = (MapNode)mapChild.get(); + assertTrue("Expected MapNode. Actual " + mapChild.orElseThrow().getClass(), + mapChild.orElseThrow() instanceof MapNode); + final MapNode mapNode = (MapNode)mapChild.orElseThrow(); final NodeIdentifierWithPredicates entryNodeID = NodeIdentifierWithPredicates.of( INTERFACE_QNAME, NAME_QNAME, "eth0"); final java.util.Optional<MapEntryNode> entryChild = mapNode.findChildByArg(entryNodeID); assertEquals(entryNodeID.toString() + " present", true, entryChild.isPresent()); - final MapEntryNode entryNode = entryChild.get(); + final MapEntryNode entryNode = entryChild.orElseThrow(); verifyLeafNode(entryNode, NAME_QNAME, "eth0"); verifyLeafNode(entryNode, TYPE_QNAME, "ethernetCsmacd"); verifyLeafNode(entryNode, ENABLED_QNAME, Boolean.FALSE); @@ -308,7 +309,7 @@ public class JSONRestconfServiceImplTest { final String payload = loadData("/parts/ietf-interfaces_interfaces_patch.json"); final Optional<String> patchResult = service.patch(uriPath, payload); - assertTrue(patchResult.get().contains("\"ok\":[null]")); + assertTrue(patchResult.orElseThrow().contains("\"ok\":[null]")); } @Test @@ -325,7 +326,7 @@ public class JSONRestconfServiceImplTest { final Optional<String> patchResult = service.patch(uriPath, payload); - assertTrue(patchResult.get().contains("\"ok\":[null]")); + assertTrue(patchResult.orElseThrow().contains("\"ok\":[null]")); } @Test(expected = OperationFailedException.class) @@ -341,7 +342,7 @@ public class JSONRestconfServiceImplTest { final Optional<String> patchResult = service.patch(uriPath, payload); assertTrue("Patch output is not null", patchResult.isPresent()); - String patch = patchResult.get(); + String patch = patchResult.orElseThrow(); assertTrue(patch.contains("TransactionCommitFailedException")); } @@ -394,9 +395,9 @@ public class JSONRestconfServiceImplTest { @Test public void testInvokeRpcWithInput() throws Exception { - final DOMRpcResult expResult = new DefaultDOMRpcResult((NormalizedNode)null); + final DOMRpcResult expResult = new DefaultDOMRpcResult((ContainerNode)null); doReturn(immediateFluentFuture(expResult)).when(brokerFacade).invokeRpc(eq(MAKE_TOAST_QNAME), - any(NormalizedNode.class)); + any(ContainerNode.class)); final String uriPath = "toaster:make-toast"; final String input = loadData("/full-versions/make-toast-rpc-input.json"); @@ -405,7 +406,7 @@ public class JSONRestconfServiceImplTest { assertEquals("Output present", false, output.isPresent()); - final ArgumentCaptor<NormalizedNode> capturedNode = ArgumentCaptor.forClass(NormalizedNode.class); + final ArgumentCaptor<ContainerNode> capturedNode = ArgumentCaptor.forClass(ContainerNode.class); verify(brokerFacade).invokeRpc(eq(MAKE_TOAST_QNAME), capturedNode.capture()); assertTrue("Expected ContainerNode. Actual " + capturedNode.getValue().getClass(), @@ -417,7 +418,7 @@ public class JSONRestconfServiceImplTest { @Test public void testInvokeRpcWithNoInput() throws Exception { - final DOMRpcResult expResult = new DefaultDOMRpcResult((NormalizedNode)null); + final DOMRpcResult expResult = new DefaultDOMRpcResult((ContainerNode)null); doReturn(immediateFluentFuture(expResult)).when(brokerFacade).invokeRpc(any(QName.class), any()); final String uriPath = "toaster:cancel-toast"; @@ -431,7 +432,7 @@ public class JSONRestconfServiceImplTest { @Test public void testInvokeRpcWithOutput() throws Exception { - final NormalizedNode outputNode = ImmutableContainerNodeBuilder.create() + final ContainerNode outputNode = ImmutableContainerNodeBuilder.create() .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TEST_OUTPUT_QNAME)) .withChild(ImmutableNodes.leafNode(TEXT_OUT_QNAME, "foo")).build(); final DOMRpcResult expResult = new DefaultDOMRpcResult(outputNode); @@ -442,8 +443,8 @@ public class JSONRestconfServiceImplTest { final Optional<String> output = service.invokeRpc(uriPath, Optional.empty()); assertEquals("Output present", true, output.isPresent()); - assertNotNull("Returned null response", output.get()); - assertThat("Missing \"textOut\"", output.get(), containsString("\"textOut\":\"foo\"")); + assertNotNull("Returned null response", output.orElseThrow()); + assertThat("Missing \"textOut\"", output.orElseThrow(), containsString("\"textOut\":\"foo\"")); verify(brokerFacade).invokeRpc(eq(TEST_OUTPUT_QNAME), any()); } @@ -452,7 +453,7 @@ public class JSONRestconfServiceImplTest { public void testInvokeRpcFailure() throws Exception { final DOMRpcException exception = new DOMRpcImplementationNotAvailableException("testExeption"); doReturn(immediateFailedFluentFuture(exception)).when(brokerFacade).invokeRpc(any(QName.class), - any(NormalizedNode.class)); + any(ContainerNode.class)); final String uriPath = "toaster:cancel-toast"; @@ -478,7 +479,7 @@ public class JSONRestconfServiceImplTest { final Optional<String> optionalResp = service.get(uriPath, datastoreType); assertEquals("Response present", true, optionalResp.isPresent()); - final String jsonResp = optionalResp.get(); + final String jsonResp = optionalResp.orElseThrow(); assertNotNull("Returned null response", jsonResp); assertThat("Missing \"name\"", jsonResp, containsString("\"name\":\"eth0\"")); @@ -501,7 +502,7 @@ public class JSONRestconfServiceImplTest { void verifyLeafNode(final DataContainerNode parent, final QName leafType, final Object leafValue) { final java.util.Optional<DataContainerChild> leafChild = parent.findChildByArg(new NodeIdentifier(leafType)); assertTrue(leafType.toString() + " present", leafChild.isPresent()); - assertEquals(leafType.toString() + " value", leafValue, leafChild.get().body()); + assertEquals(leafType.toString() + " value", leafValue, leafChild.orElseThrow().body()); } void verifyPath(final YangInstanceIdentifier path, final Object... expArgs) { diff --git a/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestGetOperationTest.java b/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestGetOperationTest.java index 65fa8e0..013f4fa 100644 --- a/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestGetOperationTest.java +++ b/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestGetOperationTest.java @@ -305,7 +305,7 @@ public class RestGetOperationTest extends JerseyTest { assertEquals("module2", qname.getLocalName()); assertEquals("module:2", qname.getNamespace().toString()); - assertEquals("2014-01-02", qname.getRevision().get().toString()); + assertEquals("2014-01-02", qname.getRevision().orElseThrow().toString()); response = target(uri).request("application/yang.api+json").get(); assertEquals(200, response.getStatus()); @@ -453,7 +453,7 @@ public class RestGetOperationTest extends JerseyTest { final QName module = assertedModuleXmlToModuleQName(responseXml.getDocumentElement()); assertEquals("module1-behind-mount-point", module.getLocalName()); - assertEquals("2014-02-03", module.getRevision().get().toString()); + assertEquals("2014-02-03", module.getRevision().orElseThrow().toString()); assertEquals("module:1:behind:mount:point", module.getNamespace().toString()); } diff --git a/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestconfImplTest.java b/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestconfImplTest.java index 3174908..263c229 100644 --- a/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestconfImplTest.java +++ b/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestconfImplTest.java @@ -67,11 +67,10 @@ import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode; import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.api.schema.builder.DataContainerNodeBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.SchemaAwareBuilders; +import org.opendaylight.yangtools.yang.data.impl.schema.Builders; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.InputSchemaNode; -import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; import org.opendaylight.yangtools.yang.model.api.ListSchemaNode; import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.OutputSchemaNode; @@ -189,7 +188,7 @@ public class RestconfImplTest { final DOMRpcService rpcService = mock(DOMRpcService.class); doReturn(Optional.of(rpcService)).when(mount).getService(DOMRpcService.class); doReturn(immediateFluentFuture(mock(DOMRpcResult.class))).when(rpcService) - .invokeRpc(any(QName.class), any(NormalizedNode.class)); + .invokeRpc(any(QName.class), any(ContainerNode.class)); restconfImpl.invokeRpc("randomId", ctx, uriInfo); restconfImpl.invokeRpc("ietf-netconf", ctx, uriInfo); verify(rpcService, times(2)).invokeRpc(any(QName.class), any()); @@ -240,18 +239,18 @@ public class RestconfImplTest { .getRestconfModuleRestConfSchemaNode(restconfModule, Draft02.RestConfModule.STREAM_LIST_SCHEMA_NODE); final ListSchemaNode listStreamSchemaNode = (ListSchemaNode) streamSchemaNode; final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> streamNodeValues = - SchemaAwareBuilders.mapEntryBuilder(listStreamSchemaNode); + Builders.mapEntryBuilder(); var instanceDataChildrenByName = ControllerContext.findInstanceDataChildrenByName(listStreamSchemaNode, "name"); final DataSchemaNode nameSchemaNode = instanceDataChildrenByName.get(0).child; - streamNodeValues.withChild(SchemaAwareBuilders.leafBuilder((LeafSchemaNode) nameSchemaNode) + streamNodeValues.withChild(Builders.leafBuilder() .withValue("") .build()); instanceDataChildrenByName = ControllerContext.findInstanceDataChildrenByName(listStreamSchemaNode, "description"); final DataSchemaNode descriptionSchemaNode = instanceDataChildrenByName.get(0).child; - streamNodeValues.withChild(SchemaAwareBuilders.leafBuilder((LeafSchemaNode) nameSchemaNode) + streamNodeValues.withChild(Builders.leafBuilder() .withValue("DESCRIPTION_PLACEHOLDER") .build()); @@ -259,17 +258,17 @@ public class RestconfImplTest { ControllerContext.findInstanceDataChildrenByName(listStreamSchemaNode, "replay-support"); final DataSchemaNode replaySupportSchemaNode = instanceDataChildrenByName.get(0).child; streamNodeValues.withChild( - SchemaAwareBuilders.leafBuilder((LeafSchemaNode) replaySupportSchemaNode).withValue(Boolean.TRUE).build()); + Builders.leafBuilder().withValue(Boolean.TRUE).build()); instanceDataChildrenByName = ControllerContext.findInstanceDataChildrenByName(listStreamSchemaNode, "replay-log-creation-time"); final DataSchemaNode replayLogCreationTimeSchemaNode = instanceDataChildrenByName.get(0).child; streamNodeValues.withChild( - SchemaAwareBuilders.leafBuilder((LeafSchemaNode) replayLogCreationTimeSchemaNode).withValue("").build()); + Builders.leafBuilder().withValue("").build()); instanceDataChildrenByName = ControllerContext.findInstanceDataChildrenByName(listStreamSchemaNode, "events"); final DataSchemaNode eventsSchemaNode = instanceDataChildrenByName.get(0).child; streamNodeValues.withChild( - SchemaAwareBuilders.leafBuilder((LeafSchemaNode) eventsSchemaNode).withValue(Empty.value()).build()); + Builders.leafBuilder().withValue(Empty.value()).build()); assertNotNull(streamNodeValues.build()); } diff --git a/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/URIParametersParsing.java b/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/URIParametersParsing.java index 1b61ea1..e4bebaa 100644 --- a/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/URIParametersParsing.java +++ b/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/URIParametersParsing.java @@ -42,7 +42,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.data.api.schema.LeafNode; import org.opendaylight.yangtools.yang.data.api.schema.builder.DataContainerNodeBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.SchemaAwareBuilders; +import org.opendaylight.yangtools.yang.data.impl.schema.Builders; import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode; import org.opendaylight.yangtools.yang.model.api.ContainerLike; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; @@ -110,7 +110,7 @@ public class URIParametersParsing { private NormalizedNodeContext prepareDomRpcNode(final String datastore, final String scope) { final EffectiveModelContext schema = controllerContext.getGlobalSchema(); - final Module rpcSalRemoteModule = schema.findModule("sal-remote", Revision.of("2014-01-14")).get(); + final Module rpcSalRemoteModule = schema.findModule("sal-remote", Revision.of("2014-01-14")).orElseThrow(); final QName rpcQName = QName.create(rpcSalRemoteModule.getQNameModule(), "create-data-change-event-subscription"); final RpcDefinition rpcDef = Mockito.mock(RpcDefinition.class); @@ -124,13 +124,13 @@ public class URIParametersParsing { assertNotNull("RPC ContainerSchemaNode was not found!", rpcInputSchemaNode); final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> container = - SchemaAwareBuilders.containerBuilder(rpcInputSchemaNode); + Builders.containerBuilder(); final QName pathQName = QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote", "2014-01-14", "path"); final DataSchemaNode pathSchemaNode = rpcInputSchemaNode.getDataChildByName(pathQName); assertTrue(pathSchemaNode instanceof LeafSchemaNode); - final LeafNode<Object> pathNode = SchemaAwareBuilders.leafBuilder((LeafSchemaNode) pathSchemaNode) + final LeafNode<Object> pathNode = Builders.leafBuilder() .withValue(YangInstanceIdentifier.builder() .node(QName.create("urn:opendaylight:inventory", "2013-08-19", "nodes")).build()).build(); container.withChild(pathNode); @@ -138,19 +138,19 @@ public class URIParametersParsing { final AugmentationSchemaNode augmentationSchema = requireNonNull(rpcInputSchemaNode.getAvailableAugmentations() .iterator().next()); final DataContainerNodeBuilder<AugmentationIdentifier, AugmentationNode> augmentationBuilder = - SchemaAwareBuilders.augmentationBuilder(augmentationSchema); + Builders.augmentationBuilder(); final QName dataStoreQName = QName.create("urn:sal:restconf:event:subscription", "2014-07-08", "datastore"); final DataSchemaNode dsSchemaNode = augmentationSchema.getDataChildByName(dataStoreQName); assertTrue(dsSchemaNode instanceof LeafSchemaNode); - final LeafNode<Object> dsNode = SchemaAwareBuilders.leafBuilder((LeafSchemaNode) dsSchemaNode) + final LeafNode<Object> dsNode = Builders.leafBuilder() .withValue(datastore).build(); augmentationBuilder.withChild(dsNode); final QName scopeQName = QName.create("urn:sal:restconf:event:subscription", "2014-07-08", "scope"); final DataSchemaNode scopeSchemaNode = augmentationSchema.getDataChildByName(scopeQName); assertTrue(scopeSchemaNode instanceof LeafSchemaNode); - final LeafNode<Object> scopeNode = SchemaAwareBuilders.leafBuilder((LeafSchemaNode) scopeSchemaNode) + final LeafNode<Object> scopeNode = Builders.leafBuilder() .withValue(scope).build(); augmentationBuilder.withChild(scopeNode); @@ -159,7 +159,7 @@ public class URIParametersParsing { final DataSchemaNode outputSchemaNode = augmentationSchema.getDataChildByName(outputQName); assertTrue(outputSchemaNode instanceof LeafSchemaNode); final LeafNode<Object> outputNode = - SchemaAwareBuilders.leafBuilder((LeafSchemaNode) outputSchemaNode).withValue("XML").build(); + Builders.leafBuilder().withValue("XML").build(); augmentationBuilder.withChild(outputNode); container.withChild(augmentationBuilder.build()); diff --git a/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/restconf/rev131019/restconf/restconf/modules/ModuleRevisionBuilderTest.java b/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/restconf/rev131019/restconf/restconf/modules/ModuleRevisionBuilderTest.java index 578d2dd..7bc19e0 100644 --- a/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/restconf/rev131019/restconf/restconf/modules/ModuleRevisionBuilderTest.java +++ b/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/restconf/rev131019/restconf/restconf/modules/ModuleRevisionBuilderTest.java @@ -12,7 +12,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import org.junit.Test; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.rev131019.restconf.restconf.modules.Module.Revision; +import org.opendaylight.yangtools.yang.common.Revision; + public class ModuleRevisionBuilderTest { @@ -22,7 +23,6 @@ public class ModuleRevisionBuilderTest { assertNotNull(moduleRevisionBuilder); final Revision revision = ModuleRevisionBuilder.getDefaultInstance(""); assertNotNull(revision); - assertEquals("", revision.getString()); - assertEquals(null, revision.getRevisionIdentifier()); + assertEquals("", revision.toString()); } }
\ No newline at end of file diff --git a/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/restconf/rev131019/restconf/restconf/modules/RevisionBuilderTest.java b/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/restconf/rev131019/restconf/restconf/modules/RevisionBuilderTest.java index 5c2eba1..2a219f8 100644 --- a/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/restconf/rev131019/restconf/restconf/modules/RevisionBuilderTest.java +++ b/netconf/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/restconf/rev131019/restconf/restconf/modules/RevisionBuilderTest.java @@ -11,8 +11,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import org.junit.Test; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.rev131019.RevisionIdentifier; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.rev131019.restconf.restconf.modules.Module.Revision; +import org.opendaylight.yangtools.yang.common.Revision; + public class RevisionBuilderTest { @Test @@ -27,7 +27,7 @@ public class RevisionBuilderTest { public void testValidDataString() { final String dateString = "2014-04-23"; final Revision revision = RevisionBuilder.getDefaultInstance(dateString); - validate(revision, null, new RevisionIdentifier(dateString)); + validate(revision, null, dateString); } @Test(expected = IllegalArgumentException.class) @@ -41,9 +41,9 @@ public class RevisionBuilderTest { } private static void validate(final Revision revisionUnderTest, final String expectedRevisionString, - final RevisionIdentifier expectedRevisionIdentifier) { + final String expectedRevisionIdentifier) { assertNotNull(revisionUnderTest); - assertEquals(expectedRevisionString, revisionUnderTest.getString()); - assertEquals(expectedRevisionIdentifier, revisionUnderTest.getRevisionIdentifier()); + assertEquals(expectedRevisionString, revisionUnderTest); + assertEquals(expectedRevisionIdentifier, revisionUnderTest); } }
\ No newline at end of file |