This is straightforward conversion to new methods.
Change-Id: I9ddb943ad73a0b131f910ffcbc4a99d3d87e261c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
import org.xmlunit.builder.DiffBuilder;
import org.xmlunit.diff.DefaultNodeMatcher;
public void testWriteNormalizedNode() throws Exception {
final var context = BindingRuntimeHelpers.createEffectiveModel(List.of(YangModuleInfoImpl.getInstance()));
final var result = new DOMResult(XmlUtil.newDocument());
- NormalizedDataUtil.writeNormalizedNode(Builders.containerBuilder()
+ NormalizedDataUtil.writeNormalizedNode(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(Sessions.QNAME))
- .withChild(Builders.mapBuilder()
+ .withChild(ImmutableNodes.newSystemMapBuilder()
.withNodeIdentifier(new NodeIdentifier(Session.QNAME))
- .withChild(Builders.mapEntryBuilder()
+ .withChild(ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(
NodeIdentifierWithPredicates.of(Session.QNAME, QName.create(Session.QNAME, "session-id"), 1L))
.withChild(ImmutableNodes.leafNode(QName.create(Session.QNAME, "username"), "admin"))
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-model-export</artifactId>
</dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-repo-api</artifactId>
- </dependency>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
import java.io.PushbackInputStream;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.restconf.server.api.OperationsPostPath;
+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.stream.NormalizedNodeStreamWriter;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeStreamWriter;
import org.opendaylight.yangtools.yang.data.impl.schema.NormalizationResultHolder;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
/**
* Access to an {code rpc}'s or an {@code action}'s input.
try (var is = new PushbackInputStream(acquireStream())) {
final var firstByte = is.read();
if (firstByte == -1) {
- return ImmutableNodes.containerNode(path.inputQName());
+ return ImmutableNodes.newContainerBuilder()
+ .withNodeIdentifier(new NodeIdentifier(path.inputQName()))
+ .build();
}
is.unread(firstByte);
import org.opendaylight.restconf.nb.rfc8040.jersey.providers.api.RestconfNormalizedNodeWriter;
import org.opendaylight.restconf.nb.rfc8040.legacy.QueryParameters;
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.MapEntryNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
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.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack;
import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack.Inference;
// RESTCONF allows returning one list item. We need to wrap it in map node in order to serialize it properly
final var toSerialize = data instanceof MapEntryNode mapEntry
- ? ImmutableNodes.mapNodeBuilder(data.name().getNodeType()).withChild(mapEntry).build() : data;
+ ? ImmutableNodes.newSystemMapBuilder()
+ .withNodeIdentifier(new NodeIdentifier(data.name().getNodeType()))
+ .withChild(mapEntry)
+ .build()
+ : data;
try (var jsonWriter = createJsonWriter(entityStream, writerParameters.prettyPrint())) {
jsonWriter.beginObject();
import org.opendaylight.restconf.nb.rfc8040.jersey.providers.api.RestconfNormalizedNodeWriter;
import org.opendaylight.restconf.nb.rfc8040.legacy.QueryParameters;
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.MapEntryNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.codec.xml.XMLStreamNormalizedNodeStreamWriter;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack;
import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack.Inference;
if (data instanceof MapEntryNode mapEntry) {
// Restconf allows returning one list item. We need to wrap it
// in map node in order to serialize it properly
- nnWriter.write(ImmutableNodes.mapNodeBuilder(data.name().getNodeType()).addChild(mapEntry).build());
+ nnWriter.write(ImmutableNodes.newSystemMapBuilder()
+ .withNodeIdentifier(new NodeIdentifier(data.name().getNodeType()))
+ .addChild(mapEntry)
+ .build());
} else if (isRoot) {
if (data instanceof ContainerNode container && container.isEmpty()) {
writeEmptyDataNode(xmlWriter, container);
import static com.google.common.base.Verify.verifyNotNull;
import static org.opendaylight.mdsal.common.api.LogicalDatastoreType.CONFIGURATION;
+import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.fromInstanceId;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.Optional;
import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Override
void createImpl(final YangInstanceIdentifier path, final NormalizedNode data) {
if (data instanceof MapNode || data instanceof LeafSetNode) {
- final var emptySubTree = ImmutableNodes.fromInstanceId(modelContext, path);
+ final var emptySubTree = fromInstanceId(modelContext, path);
merge(YangInstanceIdentifier.of(emptySubTree.name()), emptySubTree);
ensureParentsByMerge(path);
@Override
void replaceImpl(final YangInstanceIdentifier path, final NormalizedNode data) {
if (data instanceof MapNode || data instanceof LeafSetNode) {
- final var emptySubtree = ImmutableNodes.fromInstanceId(modelContext, path);
+ final var emptySubtree = fromInstanceId(modelContext, path);
merge(YangInstanceIdentifier.of(emptySubtree.name()), emptySubtree);
ensureParentsByMerge(path);
import static java.util.Objects.requireNonNull;
import static org.opendaylight.mdsal.common.api.LogicalDatastoreType.CONFIGURATION;
+import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.fromInstanceId;
import com.google.common.collect.ImmutableList;
import com.google.common.util.concurrent.FutureCallback;
import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Override
void createImpl(final YangInstanceIdentifier path, final NormalizedNode data) {
if (data instanceof MapNode || data instanceof LeafSetNode) {
- final var emptySubTree = ImmutableNodes.fromInstanceId(modelContext, path);
+ final var emptySubTree = fromInstanceId(modelContext, path);
merge(YangInstanceIdentifier.of(emptySubTree.name()), emptySubTree);
for (var child : ((NormalizedNodeContainer<?>) data).body()) {
@Override
void replaceImpl(final YangInstanceIdentifier path, final NormalizedNode data) {
if (data instanceof MapNode || data instanceof LeafSetNode) {
- final var emptySubTree = ImmutableNodes.fromInstanceId(modelContext, path);
+ final var emptySubTree = fromInstanceId(modelContext, path);
merge(YangInstanceIdentifier.of(emptySubTree.name()), emptySubTree);
for (var child : ((NormalizedNodeContainer<?>) data).body()) {
import static com.google.common.base.Verify.verifyNotNull;
import static java.util.Objects.requireNonNull;
+import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.fromInstanceId;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableMap;
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.NormalizedNodeContainerBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
import org.opendaylight.yangtools.yang.data.util.DataSchemaContext;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
}
int lastInsertedPosition = 0;
- final var emptySubtree = ImmutableNodes.fromInstanceId(modelContext(), path.getParent());
+ final var emptySubtree = fromInstanceId(modelContext(), path.getParent());
tx.merge(YangInstanceIdentifier.of(emptySubtree.name()), emptySubtree);
for (var nodeChild : readList.body()) {
if (lastInsertedPosition == lastItemPosition) {
}
int lastInsertedPosition = 0;
- final var emptySubtree = ImmutableNodes.fromInstanceId(modelContext(), grandParentPath);
+ final var emptySubtree = fromInstanceId(modelContext(), grandParentPath);
tx.merge(YangInstanceIdentifier.of(emptySubtree.name()), emptySubtree);
for (var nodeChild : readList.body()) {
if (lastInsertedPosition == lastItemPosition) {
// FIXME: we have this readily available in InstanceIdentifierContext
final var ctxNode = databind.schemaTree().findChild(path).orElseThrow();
if (readData instanceof ContainerNode container) {
- final var builder = Builders.containerBuilder().withNodeIdentifier(container.name());
+ final var builder = ImmutableNodes.newContainerBuilder().withNodeIdentifier(container.name());
buildCont(builder, container.body(), ctxNode, trim);
return builder.build();
} else if (readData instanceof MapEntryNode mapEntry) {
throw new IllegalStateException("Input " + mapEntry + " does not match " + ctxNode);
}
- final var builder = Builders.mapEntryBuilder().withNodeIdentifier(mapEntry.name());
+ final var builder = ImmutableNodes.newMapEntryBuilder().withNodeIdentifier(mapEntry.name());
buildMapEntryBuilder(builder, mapEntry.body(), ctxNode, trim, listSchema.getKeyDefinition());
return builder.build();
} else {
private static void appendContainer(final DataContainerNodeBuilder<?, ?> builder, final ContainerNode container,
final DataSchemaContext ctxNode, final boolean trim) {
- final var childBuilder = Builders.containerBuilder().withNodeIdentifier(container.name());
+ final var childBuilder = ImmutableNodes.newContainerBuilder().withNodeIdentifier(container.name());
buildCont(childBuilder, container.body(), ctxNode, trim);
builder.withChild(childBuilder.build());
}
}
final var childBuilder = switch (map.ordering()) {
- case SYSTEM -> Builders.mapBuilder();
- case USER -> Builders.orderedMapBuilder();
+ case SYSTEM -> ImmutableNodes.newSystemMapBuilder();
+ case USER -> ImmutableNodes.newUserMapBuilder();
};
buildList(childBuilder.withNodeIdentifier(map.name()), map.body(), childCtx, trim,
listSchema.getKeyDefinition());
final List<@NonNull QName> keys) {
for (var entry : entries) {
final var childCtx = getChildContext(ctxNode, entry);
- final var mapEntryBuilder = Builders.mapEntryBuilder().withNodeIdentifier(entry.name());
+ final var mapEntryBuilder = ImmutableNodes.newMapEntryBuilder().withNodeIdentifier(entry.name());
buildMapEntryBuilder(mapEntryBuilder, entry.body(), childCtx, trim, keys);
builder.withChild(mapEntryBuilder.build());
}
*/
private static @NonNull NormalizedNode prepareRpcData(final @NonNull NormalizedNode configDataNode,
final @NonNull NormalizedNode stateDataNode) {
- final var mapEntryBuilder = Builders.mapEntryBuilder()
+ final var mapEntryBuilder = ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier((NodeIdentifierWithPredicates) configDataNode.name());
// MAP CONFIG DATA
// MAP STATE DATA
mapRpcDataNode(stateDataNode, mapEntryBuilder);
- return Builders.mapBuilder()
+ return ImmutableNodes.newSystemMapBuilder()
.withNodeIdentifier(NodeIdentifier.create(configDataNode.name().getNodeType()))
.addChild(mapEntryBuilder.build())
.build();
private static @NonNull NormalizedNode prepareData(final @NonNull NormalizedNode configDataNode,
final @NonNull NormalizedNode stateDataNode) {
if (configDataNode instanceof UserMapNode configMap) {
- final var builder = Builders.orderedMapBuilder().withNodeIdentifier(configMap.name());
+ final var builder = ImmutableNodes.newUserMapBuilder().withNodeIdentifier(configMap.name());
mapValueToBuilder(configMap.body(), ((UserMapNode) stateDataNode).body(), builder);
return builder.build();
} else if (configDataNode instanceof SystemMapNode configMap) {
- final var builder = Builders.mapBuilder().withNodeIdentifier(configMap.name());
+ final var builder = ImmutableNodes.newSystemMapBuilder().withNodeIdentifier(configMap.name());
mapValueToBuilder(configMap.body(), ((SystemMapNode) stateDataNode).body(), builder);
return builder.build();
} else if (configDataNode instanceof MapEntryNode configEntry) {
- final var builder = Builders.mapEntryBuilder().withNodeIdentifier(configEntry.name());
+ final var builder = ImmutableNodes.newMapEntryBuilder().withNodeIdentifier(configEntry.name());
mapValueToBuilder(configEntry.body(), ((MapEntryNode) stateDataNode).body(), builder);
return builder.build();
} else if (configDataNode instanceof ContainerNode configContaienr) {
- final var builder = Builders.containerBuilder().withNodeIdentifier(configContaienr.name());
+ final var builder = ImmutableNodes.newContainerBuilder().withNodeIdentifier(configContaienr.name());
mapValueToBuilder(configContaienr.body(), ((ContainerNode) stateDataNode).body(), builder);
return builder.build();
} else if (configDataNode instanceof ChoiceNode configChoice) {
- final var builder = Builders.choiceBuilder().withNodeIdentifier(configChoice.name());
+ final var builder = ImmutableNodes.newChoiceBuilder().withNodeIdentifier(configChoice.name());
mapValueToBuilder(configChoice.body(), ((ChoiceNode) stateDataNode).body(), builder);
return builder.build();
} else if (configDataNode instanceof LeafNode configLeaf) {
return configLeaf;
} else if (configDataNode instanceof UserLeafSetNode) {
final var configLeafSet = (UserLeafSetNode<Object>) configDataNode;
- final var builder = Builders.<Object>orderedLeafSetBuilder().withNodeIdentifier(configLeafSet.name());
+ final var builder = ImmutableNodes.<Object>newUserLeafSetBuilder().withNodeIdentifier(configLeafSet.name());
mapValueToBuilder(configLeafSet.body(), ((UserLeafSetNode<Object>) stateDataNode).body(), builder);
return builder.build();
} else if (configDataNode instanceof SystemLeafSetNode) {
final var configLeafSet = (SystemLeafSetNode<Object>) configDataNode;
- final var builder = Builders.<Object>leafSetBuilder().withNodeIdentifier(configLeafSet.name());
+ final var builder = ImmutableNodes.<Object>newSystemLeafSetBuilder()
+ .withNodeIdentifier(configLeafSet.name());
mapValueToBuilder(configLeafSet.body(), ((SystemLeafSetNode<Object>) stateDataNode).body(), builder);
return builder.build();
} else if (configDataNode instanceof LeafSetEntryNode<?> configEntry) {
// config trumps oper
return configEntry;
} else if (configDataNode instanceof UnkeyedListNode configList) {
- final var builder = Builders.unkeyedListBuilder().withNodeIdentifier(configList.name());
+ final var builder = ImmutableNodes.newUnkeyedListBuilder().withNodeIdentifier(configList.name());
mapValueToBuilder(configList.body(), ((UnkeyedListNode) stateDataNode).body(), builder);
return builder.build();
} else if (configDataNode instanceof UnkeyedListEntryNode configEntry) {
- final var builder = Builders.unkeyedListEntryBuilder().withNodeIdentifier(configEntry.name());
+ final var builder = ImmutableNodes.newUnkeyedListEntryBuilder().withNodeIdentifier(configEntry.name());
mapValueToBuilder(configEntry.body(), ((UnkeyedListEntryNode) stateDataNode).body(), builder);
return builder.build();
} else {
package org.opendaylight.restconf.nb.rfc8040.rests.transactions;
import static java.util.Objects.requireNonNull;
+import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.fromInstanceId;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.ArrayList;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
}
merge(rootNormalizedPath,
- ImmutableNodes.fromInstanceId(modelContext, YangInstanceIdentifier.of(normalizedPathWithoutChildArgs)));
+ fromInstanceId(modelContext, YangInstanceIdentifier.of(normalizedPathWithoutChildArgs)));
}
}
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.Revision;
import org.opendaylight.yangtools.yang.common.YangNames;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
import org.opendaylight.yangtools.yang.model.api.source.SourceRepresentation;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
import org.osgi.service.component.annotations.Reference;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* A RESTCONF server implemented on top of MD-SAL.
@Singleton
@Component(service = { RestconfServer.class, DatabindProvider.class })
public final class MdsalRestconfServer implements RestconfServer, DatabindProvider, AutoCloseable {
- private static final Logger LOG = LoggerFactory.getLogger(MdsalRestconfServer.class);
private static final QName YANG_LIBRARY_VERSION = QName.create(Restconf.QNAME, "yang-library-version").intern();
private static final VarHandle LOCAL_STRATEGY;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
return streamRegistry.createStream(restconfURI, new DeviceNotificationSource(mountPointService, path),
"All YANG notifications occuring on mount point /"
+ new YangInstanceIdentifierSerializer(input.databind()).serializePath(path))
- .transform(stream -> input.newOperationOutput(Builders.containerBuilder()
+ .transform(stream -> input.newOperationOutput(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(SubscribeDeviceNotificationOutput.QNAME))
.withChild(ImmutableNodes.leafNode(DEVICE_NOTIFICATION_STREAM_PATH_NODEID, stream.name()))
.build()));
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
new DataTreeChangeSource(databindProvider, changeService, datastore, path),
"Events occuring in " + datastore + " datastore under /"
+ new YangInstanceIdentifierSerializer(input.databind()).serializePath(path))
- .transform(stream -> input.newOperationOutput(Builders.containerBuilder()
+ .transform(stream -> input.newOperationOutput(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(OUTPUT_NODEID)
.withChild(ImmutableNodes.leafNode(STREAM_NAME_NODEID, stream.name()))
.build()));
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate;
import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode;
import org.opendaylight.yangtools.yang.data.util.DataSchemaContext;
static final @Nullable NormalizedNode getDataAfter(final DataTreeCandidateNode candidate) {
final var data = candidate.dataAfter();
if (data instanceof MapEntryNode mapEntry) {
- return ImmutableNodes.mapNodeBuilder(data.name().getNodeType()).withChild(mapEntry).build();
+ return ImmutableNodes.newSystemMapBuilder()
+ .withNodeIdentifier(new NodeIdentifier(data.name().getNodeType()))
+ .withChild(mapEntry)
+ .build();
}
return data;
}
import java.util.List;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.mdsal.dom.api.ClusteredDOMDataTreeChangeListener;
import org.opendaylight.mdsal.dom.api.DOMDataBroker.DataTreeChangeExtension;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
import org.opendaylight.restconf.server.spi.DatabindProvider;
import org.opendaylight.restconf.server.spi.RestconfStream;
@Override
protected Registration start(final Sink<List<DataTreeCandidate>> sink) {
- return changeService.registerDataTreeChangeListener(new DOMDataTreeIdentifier(datastore, path),
- new ClusteredDOMDataTreeChangeListener() {
+ return changeService.registerTreeChangeListener(DOMDataTreeIdentifier.of(datastore, path),
+ new DOMDataTreeChangeListener() {
@Override
public void onDataTreeChanged(final List<DataTreeCandidate> changes) {
// FIXME: format one change at a time?
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
import org.opendaylight.yangtools.yang.model.api.stmt.NotificationEffectiveStatement;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
return streamRegistry.createStream(restconfURI,
new NotificationSource(databindProvider, notificationService, qnames), description.toString())
- .transform(stream -> input.newOperationOutput(Builders.containerBuilder()
+ .transform(stream -> input.newOperationOutput(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(SAL_REMOTE_OUTPUT_NODEID)
.withChild(ImmutableNodes.leafNode(STREAM_NAME_NODEID, stream.name()))
.build()));
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@VisibleForTesting
public static final @NonNull MapEntryNode streamEntry(final String name, final String description,
final String baseStreamLocation, final Set<EncodingName> encodings) {
- final var accessBuilder = Builders.mapBuilder().withNodeIdentifier(new NodeIdentifier(Access.QNAME));
+ final var accessBuilder = ImmutableNodes.newSystemMapBuilder()
+ .withNodeIdentifier(new NodeIdentifier(Access.QNAME));
for (var encoding : encodings) {
final var encodingName = encoding.name();
- accessBuilder.withChild(Builders.mapEntryBuilder()
+ accessBuilder.withChild(ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(NodeIdentifierWithPredicates.of(Access.QNAME, ENCODING_QNAME, encodingName))
.withChild(ImmutableNodes.leafNode(ENCODING_QNAME, encodingName))
.withChild(ImmutableNodes.leafNode(LOCATION_QNAME,
.build());
}
- return Builders.mapEntryBuilder()
+ return ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(NodeIdentifierWithPredicates.of(Stream.QNAME, NAME_QNAME, name))
.withChild(ImmutableNodes.leafNode(NAME_QNAME, name))
.withChild(ImmutableNodes.leafNode(DESCRIPTION_QNAME, description))
import org.opendaylight.restconf.server.mdsal.MdsalRestconfServer;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
@ExtendWith(MockitoExtension.class)
@Test
void testInvokeAction() throws Exception {
doReturn(Futures.immediateFuture(new SimpleDOMActionResult(
- Builders.containerBuilder().withNodeIdentifier(NodeIdentifier.create(OUTPUT_QNAME)).build())))
+ ImmutableNodes.newContainerBuilder().withNodeIdentifier(NodeIdentifier.create(OUTPUT_QNAME)).build())))
.when(actionService).invokeAction(eq(Absolute.of(CONT_QNAME, CONT1_QNAME, RESET_QNAME)), any(), any());
final var restconf = new JaxRsRestconf(new MdsalRestconfServer(new FixedDOMSchemaService(IID_SCHEMA),
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.DataContainerChild;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
@ExtendWith(MockitoExtension.class)
private static final NodeIdentifier LIBRARY_NID = new NodeIdentifier(LIBRARY_QNAME);
// config contains one child the same as in operational and one additional
- private static final ContainerNode CONFIG_JUKEBOX = Builders.containerBuilder()
+ private static final ContainerNode CONFIG_JUKEBOX = ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(JUKEBOX_QNAME))
.withChild(CONT_PLAYER)
- .withChild(Builders.containerBuilder().withNodeIdentifier(LIBRARY_NID).build())
+ .withChild(ImmutableNodes.newContainerBuilder().withNodeIdentifier(LIBRARY_NID).build())
.build();
// operational contains one child the same as in config and one additional
- private static final ContainerNode OPER_JUKEBOX = Builders.containerBuilder()
+ private static final ContainerNode OPER_JUKEBOX = ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(JUKEBOX_QNAME))
.withChild(CONT_PLAYER)
- .withChild(Builders.mapBuilder().withNodeIdentifier(PLAYLIST_NID).build())
+ .withChild(ImmutableNodes.newSystemMapBuilder().withNodeIdentifier(PLAYLIST_NID).build())
.build();
@Mock
}
private static ContainerNode wrapNodeByDataRootContainer(final DataContainerChild data) {
- return Builders.containerBuilder()
+ return ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(NodeIdentifier.create(SchemaContext.NAME))
.withChild(data)
.build();
import org.opendaylight.yangtools.yang.common.ErrorTag;
import org.opendaylight.yangtools.yang.common.ErrorType;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
@ExtendWith(MockitoExtension.class)
class RestconfDataPostTest extends AbstractRestconfTest {
doReturn(new MultivaluedHashMap<>()).when(uriInfo).getQueryParameters();
doReturn(immediateFalseFluentFuture()).when(tx).exists(LogicalDatastoreType.CONFIGURATION, JUKEBOX_IID);
doNothing().when(tx).put(LogicalDatastoreType.CONFIGURATION, JUKEBOX_IID,
- Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(JUKEBOX_QNAME)).build());
+ ImmutableNodes.newContainerBuilder().withNodeIdentifier(new NodeIdentifier(JUKEBOX_QNAME)).build());
doReturn(UriBuilder.fromUri("http://localhost:8181/rests/")).when(uriInfo).getBaseUriBuilder();
assertEquals(URI.create("http://localhost:8181/rests/data/example-jukebox:jukebox"),
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.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
@ExtendWith(MockitoExtension.class)
class RestconfOperationsPostTest extends AbstractRestconfTest {
private static final QName RPC = QName.create("invoke:rpc:module", "2013-12-03", "rpc-test");
- private static final ContainerNode INPUT = Builders.containerBuilder()
+ private static final ContainerNode INPUT = ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(QName.create(RPC, "input")))
- .withChild(Builders.containerBuilder()
+ .withChild(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(QName.create(RPC, "cont")))
.withChild(ImmutableNodes.leafNode(QName.create(RPC, "lf"), "test"))
.build())
.build();
- private static final ContainerNode OUTPUT = Builders.containerBuilder()
+ private static final ContainerNode OUTPUT = ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(QName.create(RPC, "output")))
.withChild(ImmutableNodes.leafNode(QName.create(RPC, "content"), "operation result"))
.build();
import org.mockito.junit.jupiter.MockitoExtension;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.rev170126.Restconf;
import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
import org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
YangInstanceIdentifier.of(JUKEBOX_QNAME, PLAYER_QNAME, GAP_QNAME);
protected static final LeafNode<?> GAP_LEAF = ImmutableNodes.leafNode(GAP_QNAME, Decimal64.valueOf("0.2"));
- protected static final ContainerNode CONT_PLAYER = Builders.containerBuilder()
+ protected static final ContainerNode CONT_PLAYER = ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(PLAYER_QNAME))
.withChild(GAP_LEAF)
.build();
- protected static final ContainerNode EMPTY_JUKEBOX = Builders.containerBuilder()
+ protected static final ContainerNode EMPTY_JUKEBOX = ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(JUKEBOX_QNAME))
.withChild(CONT_PLAYER)
.build();
- protected static final MapEntryNode BAND_ENTRY = Builders.mapEntryBuilder()
+ protected static final MapEntryNode BAND_ENTRY = ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(NodeIdentifierWithPredicates.of(PLAYLIST_QNAME, NAME_QNAME, "name of band"))
.withChild(ImmutableNodes.leafNode(NAME_QNAME, "name of band"))
.withChild(ImmutableNodes.leafNode(DESCRIPTION_QNAME, "band description"))
.build();
- protected static final MapEntryNode SONG1 = Builders.mapEntryBuilder()
+ protected static final MapEntryNode SONG1 = ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(YangInstanceIdentifier.NodeIdentifierWithPredicates.of(SONG_QNAME, SONG_INDEX_QNAME,
"1"))
.withChild(ImmutableNodes.leafNode(SONG_ID_QNAME, "A"))
.build();
- protected static final MapEntryNode SONG2 = Builders.mapEntryBuilder()
+ protected static final MapEntryNode SONG2 = ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(YangInstanceIdentifier.NodeIdentifierWithPredicates.of(SONG_QNAME, SONG_INDEX_QNAME,
"2"))
.withChild(ImmutableNodes.leafNode(SONG_ID_QNAME, "B"))
.build();
- protected static final SystemMapNode PLAYLIST_WITH_SONGS = Builders.mapBuilder()
+ protected static final SystemMapNode PLAYLIST_WITH_SONGS = ImmutableNodes.newSystemMapBuilder()
.withNodeIdentifier(new NodeIdentifier(JUKEBOX_QNAME))
- .withChild(Builders.mapEntryBuilder()
+ .withChild(ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(YangInstanceIdentifier.NodeIdentifierWithPredicates.of(PLAYLIST_QNAME, NAME_QNAME,
"0"))
- .withChild(Builders.orderedMapBuilder()
+ .withChild(ImmutableNodes.newUserMapBuilder()
.withNodeIdentifier(new NodeIdentifier(SONG_QNAME))
.withChild(SONG1)
.withChild(SONG2)
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.Uint32;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
public final void moduleSubContainerDataPostActionTest() throws Exception {
final var body = moduleSubContainerDataPostActionBody();
- assertEquals(Builders.containerBuilder()
+ assertEquals(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(INPUT_NID)
.withChild(ImmutableNodes.leafNode(DELAY_QNAME, Uint32.valueOf(600)))
.build(), body.toContainerNode(RESET_PATH));
@Test
public final void testEmpty() throws Exception {
final var body = testEmptyBody();
- assertEquals(Builders.containerBuilder().withNodeIdentifier(INPUT_NID).build(),
+ assertEquals(ImmutableNodes.newContainerBuilder().withNodeIdentifier(INPUT_NID).build(),
body.toContainerNode(RESET_PATH));
}
final var body = testRpcModuleInputBody();
- assertEquals(Builders.containerBuilder()
+ assertEquals(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(QName.create(rpcTest, "input")))
- .withChild(Builders.containerBuilder()
+ .withChild(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(QName.create(rpcTest, "cont")))
.withChild(ImmutableNodes.leafNode(QName.create(rpcTest, "lf"), "lf-test"))
.build())
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack.Inference;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
final var lflst11 = QName.create("augment:module:leaf:list", "2014-01-27", "lflst11");
assertEquals(List.of(new NodeIdentifier(CONT1_QNAME)), payload.prefix());
- assertEquals(Builders.containerBuilder()
+ assertEquals(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(CONT1_QNAME))
.withChild(ImmutableNodes.leafNode(QName.create("augment:module:leaf:list", "2014-01-27", "lf11"),
YangInstanceIdentifier.of(
final var contAugment = QName.create("augment:module", "2014-01-17", "cont-augment");
assertEquals(List.of(new NodeIdentifier(contAugment)), payload.prefix());
- assertEquals(Builders.containerBuilder()
+ assertEquals(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(contAugment))
.withChild(ImmutableNodes.leafNode(QName.create(contAugment, "leaf1"), "stryng"))
.build(), payload.body());
new NodeIdentifier(QName.create(container1, "augment-choice1")),
new NodeIdentifier(QName.create(container1, "augment-choice2")),
new NodeIdentifier(container1)), payload.prefix());
- assertEquals(Builders.containerBuilder()
+ assertEquals(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(container1))
.withChild(ImmutableNodes.leafNode(QName.create(container1, "case-choice-case-leaf1"), "stryng"))
.build(), payload.body());
import org.opendaylight.yangtools.yang.common.ErrorTag;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
public class JsonPatchBodyTest extends AbstractPatchBodyTest {
public JsonPatchBodyTest() {
}
}""");
checkPatchContext(returnValue);
- assertEquals(Builders.containerBuilder()
+ assertEquals(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(PATCH_CONT_QNAME))
- .withChild(Builders.mapBuilder()
+ .withChild(ImmutableNodes.newSystemMapBuilder()
.withNodeIdentifier(new NodeIdentifier(MY_LIST1_QNAME))
- .withChild(Builders.mapEntryBuilder()
+ .withChild(ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(NodeIdentifierWithPredicates.of(MY_LIST1_QNAME, LEAF_NAME_QNAME, "my-leaf-set"))
.withChild(ImmutableNodes.leafNode(LEAF_NAME_QNAME, "my-leaf-set"))
.withChild(ImmutableNodes.leafNode(MY_LEAF11_QNAME, "leaf-a"))
}
}""");
checkPatchContext(returnValue);
- assertEquals(Builders.mapBuilder()
+ assertEquals(ImmutableNodes.newSystemMapBuilder()
.withNodeIdentifier(new NodeIdentifier(MY_LIST1_QNAME))
- .withChild(Builders.mapEntryBuilder()
+ .withChild(ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(NodeIdentifierWithPredicates.of(
MY_LIST1_QNAME, LEAF_NAME_QNAME, "my-leaf-set"))
.withChild(ImmutableNodes.leafNode(LEAF_NAME_QNAME, "my-leaf-set"))
}
}""");
checkPatchContext(returnValue);
- assertEquals(Builders.containerBuilder()
+ assertEquals(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(CONT_AUG_QNAME))
.withChild(ImmutableNodes.leafNode(LEAF_AUG_QNAME, "data"))
.build(), returnValue.entities().get(0).getNode());
}
}""");
checkPatchContext(returnValue);
- assertEquals(Builders.mapBuilder()
+ assertEquals(ImmutableNodes.newSystemMapBuilder()
.withNodeIdentifier(new NodeIdentifier(MAP_CONT_QNAME))
- .withChild(Builders.mapEntryBuilder()
+ .withChild(ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(NodeIdentifierWithPredicates.of(MAP_CONT_QNAME, KEY_LEAF_QNAME, "key"))
.withChild(ImmutableNodes.leafNode(KEY_LEAF_QNAME, "key"))
.withChild(ImmutableNodes.leafNode(DATA_LEAF_QNAME, "data"))
}
}""");
checkPatchContext(returnValue);
- assertEquals(Builders.leafSetBuilder()
+ assertEquals(ImmutableNodes.newSystemLeafSetBuilder()
.withNodeIdentifier(new NodeIdentifier(LEAF_SET_QNAME))
- .withChild(Builders.leafSetEntryBuilder()
- .withNodeIdentifier(new NodeWithValue<>(LEAF_SET_QNAME, "data1"))
- .withValue("data1")
- .build())
+ .withChildValue("data1")
.build(), returnValue.entities().get(0).getNode());
}
}
}""");
checkPatchContext(returnValue);
- assertEquals(Builders.unkeyedListBuilder()
+ assertEquals(ImmutableNodes.newUnkeyedListBuilder()
.withNodeIdentifier(new NodeIdentifier(LIST_QNAME))
- .withChild(Builders.unkeyedListEntryBuilder()
+ .withChild(ImmutableNodes.newUnkeyedListEntryBuilder()
.withNodeIdentifier(new NodeIdentifier(LIST_QNAME))
.withChild(ImmutableNodes.leafNode(LIST_LEAF1_QNAME, "data1"))
.withChild(ImmutableNodes.leafNode(LIST_LEAF2_QNAME, "data2"))
}
}""");
checkPatchContext(returnValue);
- assertEquals(Builders.containerBuilder()
+ assertEquals(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(CHOICE_CONT_QNAME))
.withChild(ImmutableNodes.leafNode(CASE_LEAF1_QNAME, "data"))
.build(), returnValue.entities().get(0).getNode());
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
class JsonResourceBodyTest extends AbstractResourceBodyTest {
JsonResourceBodyTest() {
final var entryId = NodeIdentifierWithPredicates.of(LST11,
Map.of(KEYVALUE111, "value1", KEYVALUE112, "value2"));
- assertEquals(Builders.containerBuilder()
+ assertEquals(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(CONT_NID)
- .withChild(Builders.containerBuilder()
+ .withChild(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(CONT1_NID)
- .withChild(Builders.mapBuilder()
+ .withChild(ImmutableNodes.newSystemMapBuilder()
.withNodeIdentifier(new NodeIdentifier(LST11))
- .withChild(Builders.mapEntryBuilder()
+ .withChild(ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(entryId)
.withChild(ImmutableNodes.leafNode(KEYVALUE111, "value1"))
.withChild(ImmutableNodes.leafNode(KEYVALUE112, "value2"))
@Test
void moduleSubContainerDataPutTest() throws Exception {
- assertEquals(Builders.containerBuilder()
+ assertEquals(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(CONT1_NID)
.withChild(ImmutableNodes.leafNode(LF11, YangInstanceIdentifier.of(CONT_NID, CONT1_NID,
new NodeIdentifier(LFLST11), new NodeWithValue<>(LFLST11, "lflst11_1"))))
final var one = QName.create("urn:nested:module", "2014-06-03", "depth3-lf1-key");
final var two = QName.create("urn:nested:module", "2014-06-03", "depth3-lf2-key");
- assertEquals(Builders.mapEntryBuilder()
+ assertEquals(ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(NodeIdentifierWithPredicates.of(
QName.create("urn:nested:module", "2014-06-03", "depth2-list2"), Map.of(one, "one", two, "two")))
.withChild(ImmutableNodes.leafNode(one, "one"))
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack.Inference;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
final var entryId = NodeIdentifierWithPredicates.of(TOP_LEVEL_LIST,
QName.create(TOP_LEVEL_LIST, "key-leaf"), "key-value");
assertEquals(List.of(new NodeIdentifier(TOP_LEVEL_LIST), entryId), payload.prefix());
- assertEquals(Builders.mapEntryBuilder()
+ assertEquals(ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(entryId)
.withChild(ImmutableNodes.leafNode(QName.create(TOP_LEVEL_LIST, "key-leaf"), "key-value"))
.withChild(ImmutableNodes.leafNode(QName.create(TOP_LEVEL_LIST, "ordinary-leaf"), "leaf-value"))
final var lflst11 = QName.create("augment:module:leaf:list", "2014-01-27", "lflst11");
assertEquals(List.of(new NodeIdentifier(CONT1_QNAME)), payload.prefix());
- assertEquals(Builders.containerBuilder()
+ assertEquals(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(CONT1_QNAME))
- .withChild(Builders.leafSetBuilder()
+ .withChild(ImmutableNodes.newSystemLeafSetBuilder()
.withNodeIdentifier(new NodeIdentifier(lflst11))
.withChildValue("lflst11_1")
.withChildValue("lflst11_2")
final var contAugment = QName.create("augment:module", "2014-01-17", "cont-augment");
assertEquals(List.of(new NodeIdentifier(contAugment)), payload.prefix());
- assertEquals(Builders.containerBuilder()
+ assertEquals(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(contAugment))
.withChild(ImmutableNodes.leafNode(QName.create(contAugment, "leaf1"), "stryng"))
.build(), payload.body());
new NodeIdentifier(QName.create(container1, "augment-choice1")),
new NodeIdentifier(QName.create(container1, "augment-choice2")),
new NodeIdentifier(container1)), payload.prefix());
- assertEquals(Builders.containerBuilder()
+ assertEquals(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(container1))
.withChild(ImmutableNodes.leafNode(QName.create(container1, "case-choice-case-leaf1"), "stryng"))
.build(), payload.body());
final var fooBarContainer = new NodeIdentifier(QName.create("foo:module", "2016-09-29", "foo-bar-container"));
assertEquals(List.of(fooBarContainer), payload.prefix());
- assertEquals(Builders.containerBuilder().withNodeIdentifier(fooBarContainer).build(),
+ assertEquals(ImmutableNodes.newContainerBuilder().withNodeIdentifier(fooBarContainer).build(),
payload.body());
}
final var fooBarContainer = new NodeIdentifier(QName.create("bar:module", "2016-09-29", "foo-bar-container"));
assertEquals(List.of(fooBarContainer), payload.prefix());
- assertEquals(Builders.containerBuilder().withNodeIdentifier(fooBarContainer).build(),
+ assertEquals(ImmutableNodes.newContainerBuilder().withNodeIdentifier(fooBarContainer).build(),
payload.body());
}
}
import org.opendaylight.yangtools.yang.common.ErrorTag;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
public class XmlPatchBodyTest extends AbstractPatchBodyTest {
public XmlPatchBodyTest() {
</edit>
</yang-patch>""");
checkPatchContext(returnValue);
- assertEquals(Builders.containerBuilder()
+ assertEquals(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(PATCH_CONT_QNAME))
- .withChild(Builders.mapBuilder()
+ .withChild(ImmutableNodes.newSystemMapBuilder()
.withNodeIdentifier(new NodeIdentifier(MY_LIST1_QNAME))
- .withChild(Builders.mapEntryBuilder()
+ .withChild(ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(NodeIdentifierWithPredicates.of(MY_LIST1_QNAME, LEAF_NAME_QNAME, "my-leaf-set"))
.withChild(ImmutableNodes.leafNode(LEAF_NAME_QNAME, "my-leaf-set"))
.withChild(ImmutableNodes.leafNode(MY_LEAF11_QNAME, "leaf-a"))
</edit>
</yang-patch>""");
checkPatchContext(returnValue);
- assertEquals(Builders.mapBuilder()
+ assertEquals(ImmutableNodes.newSystemMapBuilder()
.withNodeIdentifier(new NodeIdentifier(MY_LIST1_QNAME))
- .withChild(Builders.mapEntryBuilder()
+ .withChild(ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(NodeIdentifierWithPredicates.of(MY_LIST1_QNAME, LEAF_NAME_QNAME, "my-leaf-set"))
.withChild(ImmutableNodes.leafNode(LEAF_NAME_QNAME, "my-leaf-set"))
.withChild(ImmutableNodes.leafNode(MY_LEAF11_QNAME, "leaf-a"))
</edit>
</yang-patch>""");
checkPatchContext(returnValue);
- assertEquals(Builders.containerBuilder()
+ assertEquals(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(CONT_AUG_QNAME))
.withChild(ImmutableNodes.leafNode(LEAF_AUG_QNAME, "data"))
.build(), returnValue.entities().get(0).getNode());
</edit>
</yang-patch>""");
checkPatchContext(returnValue);
- assertEquals(Builders.mapBuilder()
+ assertEquals(ImmutableNodes.newSystemMapBuilder()
.withNodeIdentifier(new NodeIdentifier(MAP_CONT_QNAME))
- .withChild(Builders.mapEntryBuilder()
+ .withChild(ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(NodeIdentifierWithPredicates.of(MAP_CONT_QNAME, KEY_LEAF_QNAME, "key"))
.withChild(ImmutableNodes.leafNode(KEY_LEAF_QNAME, "key"))
.withChild(ImmutableNodes.leafNode(DATA_LEAF_QNAME, "data"))
</edit>
</yang-patch>""");
checkPatchContext(returnValue);
- assertEquals(Builders.leafSetBuilder()
+ assertEquals(ImmutableNodes.newSystemLeafSetBuilder()
.withNodeIdentifier(new NodeIdentifier(LEAF_SET_QNAME))
- .withChild(Builders.leafSetEntryBuilder()
- .withNodeIdentifier(new NodeWithValue<>(LEAF_SET_QNAME, "data1"))
- .withValue("data1")
- .build())
+ .withChildValue("data1")
.build(), returnValue.entities().get(0).getNode());
}
</edit>
</yang-patch>""");
checkPatchContext(returnValue);
- assertEquals(Builders.unkeyedListBuilder()
+ assertEquals(ImmutableNodes.newUnkeyedListBuilder()
.withNodeIdentifier(new NodeIdentifier(LIST_QNAME))
- .withChild(Builders.unkeyedListEntryBuilder()
+ .withChild(ImmutableNodes.newUnkeyedListEntryBuilder()
.withNodeIdentifier(new NodeIdentifier(LIST_QNAME))
.withChild(ImmutableNodes.leafNode(LIST_LEAF1_QNAME, "data1"))
.withChild(ImmutableNodes.leafNode(LIST_LEAF2_QNAME, "data2"))
</edit>
</yang-patch>""");
checkPatchContext(returnValue);
- assertEquals(Builders.containerBuilder()
+ assertEquals(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(CHOICE_CONT_QNAME))
.withChild(ImmutableNodes.leafNode(CASE_LEAF1_QNAME, "data"))
.build(), returnValue.entities().get(0).getNode());
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
class XmlResourceBodyTest extends AbstractResourceBodyTest {
private static final QName TOP_LEVEL_LIST = QName.create("foo", "2017-08-09", "top-level-list");
@Test
void putXmlTest() throws Exception {
final var keyName = QName.create(TOP_LEVEL_LIST, "key-leaf");
- assertEquals(Builders.mapEntryBuilder()
+ assertEquals(ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(NodeIdentifierWithPredicates.of(TOP_LEVEL_LIST, keyName, "key-value"))
.withChild(ImmutableNodes.leafNode(keyName, "key-value"))
.withChild(ImmutableNodes.leafNode(QName.create(keyName, "ordinary-leaf"), "leaf-value"))
final var entryId = NodeIdentifierWithPredicates.of(LST11,
Map.of(KEYVALUE111, "value1", KEYVALUE112, "value2"));
- assertEquals(Builders.containerBuilder()
+ assertEquals(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(CONT_NID)
- .withChild(Builders.containerBuilder()
+ .withChild(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(CONT1_NID)
- .withChild(Builders.mapBuilder()
+ .withChild(ImmutableNodes.newSystemMapBuilder()
.withNodeIdentifier(new NodeIdentifier(LST11))
- .withChild(Builders.mapEntryBuilder()
+ .withChild(ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(entryId)
.withChild(ImmutableNodes.leafNode(KEYVALUE111, "value1"))
.withChild(ImmutableNodes.leafNode(KEYVALUE112, "value2"))
}
private void testModuleSubContainerDataPut(final String uriPath) throws Exception {
- assertEquals(Builders.containerBuilder()
+ assertEquals(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(CONT1_NID)
- .withChild(Builders.leafSetBuilder()
+ .withChild(ImmutableNodes.newSystemLeafSetBuilder()
.withNodeIdentifier(new NodeIdentifier(LFLST11))
- .withChild(Builders.leafSetEntryBuilder()
+ .withChild(ImmutableNodes.newLeafSetEntryBuilder()
.withNodeIdentifier(new NodeWithValue<>(LFLST11, "lflst11_3"))
.withValue("lflst11_3")
.build())
- .withChild(Builders.leafSetEntryBuilder()
+ .withChild(ImmutableNodes.newLeafSetEntryBuilder()
.withNodeIdentifier(new NodeWithValue<>(LFLST11, "lflst11_1"))
.withValue("lflst11_1")
.build())
- .withChild(Builders.leafSetEntryBuilder()
+ .withChild(ImmutableNodes.newLeafSetEntryBuilder()
.withNodeIdentifier(new NodeWithValue<>(LFLST11, "lflst11_2"))
.withValue("lflst11_2")
.build())
import org.opendaylight.yangtools.yang.data.api.schema.SystemLeafSetNode;
import org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode;
import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
/**
* Unit test for {@link ParameterAwareNormalizedNodeWriter} used with depth parameter.
private final LeafNode<String> keyLeafNodeData = ImmutableNodes.leafNode(keyLeafNodeIdentifier, keyLeafNodeValue);
private final LeafNode<String> anotherLeafNodeData =
ImmutableNodes.leafNode(anotherLeafNodeIdentifier, anotherLeafNodeValue);
- private final LeafSetEntryNode<String> leafSetEntryNodeData = Builders.<String>leafSetEntryBuilder()
+ private final LeafSetEntryNode<String> leafSetEntryNodeData = ImmutableNodes.<String>newLeafSetEntryBuilder()
.withNodeIdentifier(leafSetEntryNodeIdentifier)
.withValue(leafSetEntryNodeValue)
.build();
- private final SystemLeafSetNode<String> leafSetNodeData = Builders.<String>leafSetBuilder()
+ private final SystemLeafSetNode<String> leafSetNodeData = ImmutableNodes.<String>newSystemLeafSetBuilder()
.withNodeIdentifier(leafSetNodeIdentifier)
.withChild(leafSetEntryNodeData)
.build();
- private final MapEntryNode mapEntryNodeData = Builders.mapEntryBuilder()
+ private final MapEntryNode mapEntryNodeData = ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(mapEntryNodeIdentifier)
.withChild(keyLeafNodeData)
.withChild(anotherLeafNodeData)
.build();
- private final SystemMapNode mapNodeData = Builders.mapBuilder()
+ private final SystemMapNode mapNodeData = ImmutableNodes.newSystemMapBuilder()
.withNodeIdentifier(mapNodeIdentifier)
.withChild(mapEntryNodeData)
.build();
- private final ContainerNode containerNodeData = Builders.containerBuilder()
+ private final ContainerNode containerNodeData = ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(containerNodeIdentifier)
.withChild(leafSetNodeData)
.build();
import org.opendaylight.yangtools.yang.data.api.schema.SystemLeafSetNode;
import org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode;
import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
/**
* Unit test for {@link ParameterAwareNormalizedNodeWriter} used with fields parameter.
private final NodeIdentifierWithPredicates mapEntryNodeIdentifier = NodeIdentifierWithPredicates.of(
QName.create("namespace", "list-entry"), keyLeafNodeIdentifier.getNodeType(), keyLeafNodeValue);
- private final LeafSetEntryNode<String> leafSetEntryNodeData = Builders.<String>leafSetEntryBuilder()
+ private final LeafSetEntryNode<String> leafSetEntryNodeData = ImmutableNodes.<String>newLeafSetEntryBuilder()
.withNodeIdentifier(leafSetEntryNodeIdentifier)
.withValue(leafSetEntryNodeValue)
.build();
- private final SystemLeafSetNode<String> leafSetNodeData = Builders.<String>leafSetBuilder()
+ private final SystemLeafSetNode<String> leafSetNodeData = ImmutableNodes.<String>newSystemLeafSetBuilder()
.withNodeIdentifier(leafSetNodeIdentifier)
.withChild(leafSetEntryNodeData)
.build();
- private final ContainerNode containerNodeData = Builders.containerBuilder()
+ private final ContainerNode containerNodeData = ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(containerNodeIdentifier)
.withChild(leafSetNodeData)
.build();
private final LeafNode<String> keyLeafNodeData = ImmutableNodes.leafNode(keyLeafNodeIdentifier, keyLeafNodeValue);
- private final MapEntryNode mapEntryNodeData = Builders.mapEntryBuilder()
+ private final MapEntryNode mapEntryNodeData = ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(mapEntryNodeIdentifier)
.withChild(keyLeafNodeData)
.build();
- private final SystemMapNode mapNodeData = Builders.mapBuilder()
+ private final SystemMapNode mapNodeData = ImmutableNodes.newSystemMapBuilder()
.withNodeIdentifier(mapNodeIdentifier)
.withChild(mapEntryNodeData)
.build();
import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
import org.opendaylight.yangtools.yang.data.api.schema.SystemLeafSetNode;
import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
/**
private final NodeWithValue<String> leafSetEntryNodeIdentifier =
new NodeWithValue<>(QName.create("namespace", "leaf-set-entry"), leafSetEntryNodeValue);
- private final LeafSetEntryNode<String> leafSetEntryNodeData = Builders.<String>leafSetEntryBuilder()
+ private final LeafSetEntryNode<String> leafSetEntryNodeData = ImmutableNodes.<String>newLeafSetEntryBuilder()
.withNodeIdentifier(leafSetEntryNodeIdentifier)
.withValue(leafSetEntryNodeValue)
.build();
- private final SystemLeafSetNode<String> leafSetNodeData = Builders.<String>leafSetBuilder()
+ private final SystemLeafSetNode<String> leafSetNodeData = ImmutableNodes.<String>newSystemLeafSetBuilder()
.withNodeIdentifier(leafSetNodeIdentifier)
.withChild(leafSetEntryNodeData)
.build();
- private final ContainerNode containerNodeData = Builders.containerBuilder()
+ private final ContainerNode containerNodeData = ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(containerNodeIdentifier)
.withChild(leafSetNodeData)
.build();
- private final ContainerNode rootDataContainerData = Builders.containerBuilder()
+ private final ContainerNode rootDataContainerData = ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(NodeIdentifier.create(
QName.create("urn:ietf:params:xml:ns:netconf:base:1.0", "data")))
.withChild(leafSetNodeData)
public void writeEmptyRootContainerTest() throws Exception {
final var parameterWriter = ParameterAwareNormalizedNodeWriter.forStreamWriter(writer, null, null);
- parameterWriter.write(Builders.containerBuilder()
+ parameterWriter.write(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(SchemaContext.NAME))
.build());
}
import org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack.Inference;
final EffectiveModelContext schemaContext = mock(EffectiveModelContext.class);
final NormalizedNodePayload nodePayload = new NormalizedNodePayload(Inference.ofDataTreePath(schemaContext),
- Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(SchemaContext.NAME)).build());
+ ImmutableNodes.newContainerBuilder().withNodeIdentifier(new NodeIdentifier(SchemaContext.NAME)).build());
final ByteArrayOutputStream output = new ByteArrayOutputStream();
final XmlNormalizedNodeBodyWriter xmlWriter = new XmlNormalizedNodeBodyWriter();
public void testRootContainerWrite() throws IOException {
final NormalizedNodePayload nodePayload = new NormalizedNodePayload(
Inference.ofDataTreePath(IID_SCHEMA),
- Builders.containerBuilder()
+ ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(SchemaContext.NAME))
- .withChild(Builders.containerBuilder()
+ .withChild(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(
QName.create("foo:module", "2016-09-29", "foo-bar-container")))
.build())
- .withChild(Builders.containerBuilder()
+ .withChild(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(
QName.create("bar:module", "2016-09-29", "foo-bar-container")))
.build())
final XmlNormalizedNodeBodyWriter xmlWriter = new XmlNormalizedNodeBodyWriter();
xmlWriter.writeTo(nodePayload, null, null, null, MediaType.APPLICATION_XML_TYPE, null, output);
- assertEquals("<data xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">"
- + "<foo-bar-container xmlns=\"bar:module\"></foo-bar-container>"
- + "<foo-bar-container xmlns=\"foo:module\"></foo-bar-container>"
- + "</data>", output.toString(StandardCharsets.UTF_8));
+ assertEquals("""
+ <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">\
+ <foo-bar-container xmlns="bar:module"></foo-bar-container>\
+ <foo-bar-container xmlns="foo:module"></foo-bar-container>\
+ </data>""", output.toString(StandardCharsets.UTF_8));
}
}
\ No newline at end of file
import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode;
import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode;
import org.opendaylight.yangtools.yang.data.api.schema.UserMapNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.w3c.dom.DOMException;
abstract class AbstractRestconfStrategyTest extends AbstractJukeboxTest {
- static final ContainerNode JUKEBOX_WITH_BANDS = Builders.containerBuilder()
+ static final ContainerNode JUKEBOX_WITH_BANDS = ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(JUKEBOX_QNAME))
- .withChild(Builders.mapBuilder()
+ .withChild(ImmutableNodes.newSystemMapBuilder()
.withNodeIdentifier(new NodeIdentifier(PLAYLIST_QNAME))
.withChild(BAND_ENTRY)
- .withChild(Builders.mapEntryBuilder()
+ .withChild(ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(NodeIdentifierWithPredicates.of(PLAYLIST_QNAME, NAME_QNAME, "name of band 2"))
.withChild(ImmutableNodes.leafNode(NAME_QNAME, "name of band 2"))
.withChild(ImmutableNodes.leafNode(DESCRIPTION_QNAME, "band description 2"))
.build())
.build())
.build();
- static final ContainerNode JUKEBOX_WITH_PLAYLIST = Builders.containerBuilder()
+ static final ContainerNode JUKEBOX_WITH_PLAYLIST = ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(JUKEBOX_QNAME))
- .withChild(Builders.mapBuilder()
+ .withChild(ImmutableNodes.newSystemMapBuilder()
.withNodeIdentifier(new NodeIdentifier(PLAYLIST_QNAME))
- .withChild(Builders.mapEntryBuilder()
+ .withChild(ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(NodeIdentifierWithPredicates.of(PLAYLIST_QNAME, NAME_QNAME, "MyFavoriteBand-A"))
.withChild(ImmutableNodes.leafNode(NAME_QNAME, "MyFavoriteBand-A"))
.withChild(ImmutableNodes.leafNode(DESCRIPTION_QNAME, "band description A"))
.build())
- .withChild(Builders.mapEntryBuilder()
+ .withChild(ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(NodeIdentifierWithPredicates.of(PLAYLIST_QNAME, NAME_QNAME, "MyFavoriteBand-B"))
.withChild(ImmutableNodes.leafNode(NAME_QNAME, "MyFavoriteBand-B"))
.withChild(ImmutableNodes.leafNode(DESCRIPTION_QNAME, "band description B"))
.build())
.build())
.build();
- static final MapNode PLAYLIST = Builders.mapBuilder()
+ static final MapNode PLAYLIST = ImmutableNodes.newSystemMapBuilder()
.withNodeIdentifier(new NodeIdentifier(PLAYLIST_QNAME))
.withChild(BAND_ENTRY)
.build();
.node(NODE_WITH_KEY_2)
.build();
static final YangInstanceIdentifier PATH_3 = YangInstanceIdentifier.of(CONT_QNAME, LIST_QNAME);
- private static final MapEntryNode DATA = Builders.mapEntryBuilder()
+ private static final MapEntryNode DATA = ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(NODE_WITH_KEY)
.withChild(CONTENT)
.build();
- static final MapEntryNode DATA_2 = Builders.mapEntryBuilder()
+ static final MapEntryNode DATA_2 = ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(NODE_WITH_KEY)
.withChild(CONTENT_2)
.build();
private static final LeafNode<?> CONTENT_LEAF = ImmutableNodes.leafNode(QName.create(BASE, "content"), "test");
private static final LeafNode<?> CONTENT_LEAF_2 = ImmutableNodes.leafNode(QName.create(BASE, "content2"), "test2");
- static final ContainerNode DATA_3 = Builders.containerBuilder()
+ static final ContainerNode DATA_3 = ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(QName.create(BASE, "container")))
.withChild(CONTENT_LEAF)
.build();
- static final ContainerNode DATA_4 = Builders.containerBuilder()
+ static final ContainerNode DATA_4 = ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(BASE, "container2")))
.withChild(CONTENT_LEAF_2)
.build();
- static final MapNode LIST_DATA = Builders.mapBuilder()
+ static final MapNode LIST_DATA = ImmutableNodes.newSystemMapBuilder()
.withNodeIdentifier(new NodeIdentifier(QName.create(LIST_QNAME, "list")))
.withChild(DATA)
.build();
- static final MapNode LIST_DATA_2 = Builders.mapBuilder()
+ static final MapNode LIST_DATA_2 = ImmutableNodes.newSystemMapBuilder()
.withNodeIdentifier(new NodeIdentifier(QName.create(LIST_QNAME, "list")))
.withChild(DATA)
.withChild(DATA_2)
.build();
- static final UserMapNode ORDERED_MAP_NODE_1 = Builders.orderedMapBuilder()
+ static final UserMapNode ORDERED_MAP_NODE_1 = ImmutableNodes.newUserMapBuilder()
.withNodeIdentifier(new NodeIdentifier(LIST_QNAME))
.withChild(DATA)
.build();
- static final UserMapNode ORDERED_MAP_NODE_2 = Builders.orderedMapBuilder()
+ static final UserMapNode ORDERED_MAP_NODE_2 = ImmutableNodes.newUserMapBuilder()
.withNodeIdentifier(new NodeIdentifier(LIST_QNAME))
.withChild(DATA)
.withChild(DATA_2)
.build();
- private static final MapEntryNode CHECK_DATA = Builders.mapEntryBuilder()
+ private static final MapEntryNode CHECK_DATA = ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(NODE_WITH_KEY)
.withChild(CONTENT_2)
.withChild(CONTENT)
.build();
- static final LeafSetNode<String> LEAF_SET_NODE_1 = Builders.<String>leafSetBuilder()
+ static final LeafSetNode<String> LEAF_SET_NODE_1 = ImmutableNodes.<String>newSystemLeafSetBuilder()
.withNodeIdentifier(new NodeIdentifier(LEAF_LIST_QNAME))
.withChildValue("one")
.withChildValue("two")
.build();
- static final LeafSetNode<String> LEAF_SET_NODE_2 = Builders.<String>leafSetBuilder()
+ static final LeafSetNode<String> LEAF_SET_NODE_2 = ImmutableNodes.<String>newSystemLeafSetBuilder()
.withNodeIdentifier(new NodeIdentifier(LEAF_LIST_QNAME))
.withChildValue("three")
.build();
- static final LeafSetNode<String> ORDERED_LEAF_SET_NODE_1 = Builders.<String>orderedLeafSetBuilder()
+ static final LeafSetNode<String> ORDERED_LEAF_SET_NODE_1 = ImmutableNodes.<String>newUserLeafSetBuilder()
.withNodeIdentifier(new NodeIdentifier(LEAF_LIST_QNAME))
.withChildValue("one")
.withChildValue("two")
.build();
- static final LeafSetNode<String> ORDERED_LEAF_SET_NODE_2 = Builders.<String>orderedLeafSetBuilder()
+ static final LeafSetNode<String> ORDERED_LEAF_SET_NODE_2 = ImmutableNodes.<String>newUserLeafSetBuilder()
.withNodeIdentifier(new NodeIdentifier(LEAF_LIST_QNAME))
.withChildValue("three")
.withChildValue("four")
.node(CONT_QNAME)
.node(LEAF_LIST_QNAME)
.build();
- private static final UnkeyedListEntryNode UNKEYED_LIST_ENTRY_NODE_1 = Builders.unkeyedListEntryBuilder()
+ private static final UnkeyedListEntryNode UNKEYED_LIST_ENTRY_NODE_1 = ImmutableNodes.newUnkeyedListEntryBuilder()
.withNodeIdentifier(new NodeIdentifier(LIST_QNAME))
.withChild(CONTENT)
.build();
- private static final UnkeyedListEntryNode UNKEYED_LIST_ENTRY_NODE_2 = Builders.unkeyedListEntryBuilder()
+ private static final UnkeyedListEntryNode UNKEYED_LIST_ENTRY_NODE_2 = ImmutableNodes.newUnkeyedListEntryBuilder()
.withNodeIdentifier(new NodeIdentifier(LIST_QNAME))
.withChild(CONTENT_2)
.build();
- static final UnkeyedListNode UNKEYED_LIST_NODE_1 = Builders.unkeyedListBuilder()
+ static final UnkeyedListNode UNKEYED_LIST_NODE_1 = ImmutableNodes.newUnkeyedListBuilder()
.withNodeIdentifier(new NodeIdentifier(LIST_QNAME))
.withChild(UNKEYED_LIST_ENTRY_NODE_1)
.build();
- static final UnkeyedListNode UNKEYED_LIST_NODE_2 = Builders.unkeyedListBuilder()
+ static final UnkeyedListNode UNKEYED_LIST_NODE_2 = ImmutableNodes.newUnkeyedListBuilder()
.withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(LIST_QNAME))
.withChild(UNKEYED_LIST_ENTRY_NODE_2)
.build();
@Test
public final void testPatchDataReplaceMergeAndRemove() {
- final var buildArtistList = Builders.mapBuilder()
+ final var buildArtistList = ImmutableNodes.newSystemMapBuilder()
.withNodeIdentifier(new NodeIdentifier(ARTIST_QNAME))
- .withChild(Builders.mapEntryBuilder()
+ .withChild(ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(NodeIdentifierWithPredicates.of(ARTIST_QNAME, NAME_QNAME, "name of artist"))
.withChild(ImmutableNodes.leafNode(NAME_QNAME, "name of artist"))
.withChild(ImmutableNodes.leafNode(DESCRIPTION_QNAME, "description of artist"))
@Test
public final void readContainerDataAllTest() {
- assertEquals(Builders.containerBuilder()
+ assertEquals(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(NODE_IDENTIFIER)
.withChild(CONTENT_LEAF)
.withChild(CONTENT_LEAF_2)
@Test
public final void readContainerDataConfigNoValueOfContentTest() {
- assertEquals(Builders.containerBuilder()
+ assertEquals(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(NODE_IDENTIFIER)
.withChild(CONTENT_LEAF)
.withChild(CONTENT_LEAF_2)
@Test
public final void readListDataAllTest() {
- assertEquals(Builders.mapBuilder()
+ assertEquals(ImmutableNodes.newSystemMapBuilder()
.withNodeIdentifier(new NodeIdentifier(QName.create("ns", "2016-02-28", "list")))
.withChild(CHECK_DATA)
.build(), readData(ContentParam.ALL, PATH_3, readListDataAllTestStrategy()));
@Test
public final void readOrderedListDataAllTest() {
- assertEquals(Builders.orderedMapBuilder()
+ assertEquals(ImmutableNodes.newUserMapBuilder()
.withNodeIdentifier(new NodeIdentifier(LIST_QNAME))
.withChild(CHECK_DATA)
.build(), readData(ContentParam.ALL, PATH_3, readOrderedListDataAllTestStrategy()));
@Test
public void readUnkeyedListDataAllTest() {
- assertEquals(Builders.unkeyedListBuilder()
+ assertEquals(ImmutableNodes.newUnkeyedListBuilder()
.withNodeIdentifier(new NodeIdentifier(LIST_QNAME))
- .withChild(Builders.unkeyedListEntryBuilder()
+ .withChild(ImmutableNodes.newUnkeyedListEntryBuilder()
.withNodeIdentifier(new NodeIdentifier(LIST_QNAME))
.withChild(UNKEYED_LIST_ENTRY_NODE_1.body().iterator().next())
.withChild(UNKEYED_LIST_ENTRY_NODE_2.body().iterator().next())
@Test
public final void readLeafListDataAllTest() {
- assertEquals(Builders.<String>leafSetBuilder()
+ assertEquals(ImmutableNodes.<String>newSystemLeafSetBuilder()
.withNodeIdentifier(new NodeIdentifier(LEAF_LIST_QNAME))
.withValue(ImmutableList.<LeafSetEntryNode<String>>builder()
.addAll(LEAF_SET_NODE_1.body())
@Test
public final void readOrderedLeafListDataAllTest() {
- assertEquals(Builders.<String>orderedLeafSetBuilder()
+ assertEquals(ImmutableNodes.<String>newUserLeafSetBuilder()
.withNodeIdentifier(new NodeIdentifier(LEAF_LIST_QNAME))
.withValue(ImmutableList.<LeafSetEntryNode<String>>builder()
.addAll(ORDERED_LEAF_SET_NODE_1.body())
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.MapEntryNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
import org.w3c.dom.DOMException;
@Test
public void readLeafWithDefaultParameters() {
- final var data = Builders.containerBuilder()
+ final var data = ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(CONT_QNAME))
.withChild(ImmutableNodes.leafNode(QName.create(BASE, "exampleLeaf"), "i am leaf"))
.build();
@Test
public void readContainerWithDefaultParameters() {
final var exampleList = new NodeIdentifier(QName.create(BASE, "exampleList"));
- final var data = Builders.containerBuilder()
+ final var data = ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(CONT_QNAME))
- .withChild(Builders.unkeyedListBuilder()
+ .withChild(ImmutableNodes.newUnkeyedListBuilder()
.withNodeIdentifier(exampleList)
- .withChild(Builders.unkeyedListEntryBuilder()
+ .withChild(ImmutableNodes.newUnkeyedListEntryBuilder()
.withNodeIdentifier(exampleList)
- .withChild(Builders.containerBuilder()
+ .withChild(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(QName.create(BASE, "containerBool")))
.withChild(ImmutableNodes.leafNode(QName.create(BASE, "leafBool"), true))
.build())
- .addChild(Builders.containerBuilder()
+ .addChild(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(QName.create(BASE, "containerInt")))
.withChild(ImmutableNodes.leafNode(QName.create(BASE, "leafInt"), 12))
.build())
@Test
public void readLeafInListWithDefaultParameters() {
final var exampleList = new NodeIdentifier(QName.create(BASE, "exampleList"));
- final var content = Builders.containerBuilder()
+ final var content = ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(CONT_QNAME))
- .withChild(Builders.unkeyedListBuilder()
+ .withChild(ImmutableNodes.newUnkeyedListBuilder()
.withNodeIdentifier(exampleList)
- .withChild(Builders.unkeyedListEntryBuilder()
+ .withChild(ImmutableNodes.newUnkeyedListEntryBuilder()
.withNodeIdentifier(exampleList)
.addChild(ImmutableNodes.leafNode(QName.create(BASE, "leafInList"), "I am leaf in list"))
.build())
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.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.stmt.RpcEffectiveStatement;
import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack;
new NodeIdentifier(QName.create(rcStream, "streams")),
new NodeIdentifier(rcStream),
streamId), pathCaptor.getValue());
- assertEquals(Builders.mapEntryBuilder()
+ assertEquals(ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(streamId)
.withChild(ImmutableNodes.leafNode(rcName, name))
.withChild(ImmutableNodes.leafNode(QName.create(rcStream, "description"),
"Events occuring in CONFIGURATION datastore under /toaster:toaster"))
- .withChild(Builders.mapBuilder()
+ .withChild(ImmutableNodes.newSystemMapBuilder()
.withNodeIdentifier(new NodeIdentifier(Access.QNAME))
- .withChild(Builders.mapEntryBuilder()
+ .withChild(ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(NodeIdentifierWithPredicates.of(Access.QNAME, rcEncoding, "json"))
.withChild(ImmutableNodes.leafNode(rcEncoding, "json"))
.withChild(ImmutableNodes.leafNode(rcLocation, "/rests/streams/json/" + name))
.build())
- .withChild(Builders.mapEntryBuilder()
+ .withChild(ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(NodeIdentifierWithPredicates.of(Access.QNAME, rcEncoding, "xml"))
.withChild(ImmutableNodes.leafNode(rcEncoding, "xml"))
.withChild(ImmutableNodes.leafNode(rcLocation, "/rests/streams/xml/" + name))
stack.enterSchemaTree(CreateDataChangeEventSubscription.QNAME));
final var inference = stack.toInference();
- final var builder = Builders.containerBuilder()
+ final var builder = ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(rpcStmt.input().argument()));
if (leafName != null) {
final var lfQName = QName.create(rpcStmt.argument(), leafName);
import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
@ExtendWith(MockitoExtension.class)
final var leaf = mockLeaf(QName.create(MODULE, "lf"));
final var entry = mockMapEntry(QName.create(MODULE, "lst"), leaf);
- final var notifiBody = mockCont(schemaPathNotifi, Builders.mapBuilder()
+ final var notifiBody = mockCont(schemaPathNotifi, ImmutableNodes.newSystemMapBuilder()
.withNodeIdentifier(NodeIdentifier.create(QName.create(MODULE, "lst")))
.withChild(entry)
.build());
}
private static MapEntryNode mockMapEntry(final QName entryQName, final LeafNode<String> leaf) {
- return Builders.mapEntryBuilder()
+ return ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(NodeIdentifierWithPredicates.of(entryQName, leaf.name().getNodeType(), leaf.body()))
.withChild(leaf)
.build();
}
private static ContainerNode mockCont(final QName contQName, final DataContainerChild child) {
- return Builders.containerBuilder()
+ return ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(NodeIdentifier.create(contQName))
.withChild(child)
.build();
import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
import org.xmlunit.assertj.XmlAssert;
final var leaf = mockLeaf(QName.create(MODULE, "lf"));
final var entry = mockMapEntry(QName.create(MODULE, "lst"), leaf);
- final var notifiBody = mockCont(schemaPathNotifi, Builders.mapBuilder()
+ final var notifiBody = mockCont(schemaPathNotifi, ImmutableNodes.newSystemMapBuilder()
.withNodeIdentifier(NodeIdentifier.create(QName.create(MODULE, "lst")))
.withChild(entry)
.build());
}
private static MapEntryNode mockMapEntry(final QName entryQName, final LeafNode<String> leaf) {
- return Builders.mapEntryBuilder()
+ return ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(NodeIdentifierWithPredicates.of(entryQName, leaf.name().getNodeType(), leaf.body()))
.withChild(leaf)
.build();
}
private static ContainerNode mockCont(final QName contQName, final DataContainerChild child) {
- return Builders.containerBuilder()
+ return ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(NodeIdentifier.create(contQName))
.withChild(child)
.build();