Update references to use data.spi.node.ImmutableNodes.
Change-Id: Ide361652366ef8dc5ade34bb513219ce7cf448f3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
requires org.opendaylight.mdsal.dom.spi;
requires org.opendaylight.yangtools.concepts;
requires org.opendaylight.yangtools.yang.common;
+ requires org.opendaylight.yangtools.yang.data.spi;
requires org.opendaylight.yangtools.yang.model.api;
requires org.slf4j;
requires failureaccess;
import org.opendaylight.yangtools.yang.common.YangConstants;
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.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
sealed class RpcInvocationStrategy {
import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
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.Builders;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
@Beta
}
public static final class Builder {
- private final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> rootBuilder = Builders.containerBuilder()
- .withNodeIdentifier(new NodeIdentifier(SchemaContext.NAME));
+ private final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> rootBuilder =
+ ImmutableNodes.newContainerBuilder().withNodeIdentifier(new NodeIdentifier(SchemaContext.NAME));
private final BindingCodecTree codec;
Builder(final BindingCodecTree codec) {
import static org.opendaylight.yangtools.yang.common.YangConstants.operationInputQName;
import static org.opendaylight.yangtools.yang.common.YangConstants.operationOutputQName;
-import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.containerBuilder;
-import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.leafBuilder;
import org.opendaylight.yang.gen.v1.urn.odl.actions.norev.Cont;
import org.opendaylight.yang.gen.v1.urn.odl.actions.norev.Lstio;
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.spi.node.ImmutableNodes;
import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
public abstract class AbstractActionAdapterTest extends AbstractAdapterTest {
protected static final NodeIdentifier FOO_INPUT = new NodeIdentifier(operationInputQName(Foo.QNAME.getModule()));
protected static final NodeIdentifier FOO_OUTPUT = new NodeIdentifier(operationOutputQName(Foo.QNAME.getModule()));
protected static final NodeIdentifier FOO_XYZZY = new NodeIdentifier(QName.create(Foo.QNAME, "xyzzy"));
- protected static final ContainerNode DOM_FOO_INPUT = containerBuilder().withNodeIdentifier(FOO_INPUT)
- .withChild(leafBuilder().withNodeIdentifier(FOO_XYZZY).withValue("xyzzy").build())
- .build();
- protected static final ContainerNode DOM_FOO_OUTPUT = containerBuilder().withNodeIdentifier(FOO_OUTPUT).build();
+ protected static final ContainerNode DOM_FOO_INPUT = ImmutableNodes.newContainerBuilder()
+ .withNodeIdentifier(FOO_INPUT)
+ .withChild(ImmutableNodes.leafNode(FOO_XYZZY, "xyzzy"))
+ .build();
+ protected static final ContainerNode DOM_FOO_OUTPUT = ImmutableNodes.newContainerBuilder()
+ .withNodeIdentifier(FOO_OUTPUT)
+ .build();
protected static final FooInput BINDING_FOO_INPUT = new FooInputBuilder().setXyzzy("xyzzy").build();
protected static final FooOutput BINDING_FOO_OUTPUT = new FooOutputBuilder().build();
protected static final FooioInput BINDING_LSTIO_INPUT = new FooioInputBuilder().build();
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.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.YangTextSource;
}
private static ContainerNode prepareData(final EffectiveModelContext schemaCtx, final Object value) {
- return Builders.containerBuilder()
+ return ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(QName.create("urn:test", "2017-01-01", "cont")))
- .withChild(Builders.leafBuilder()
- .withNodeIdentifier(new NodeIdentifier(QName.create("urn:test", "2017-01-01", "vlan-id")))
- .withValue(value).build())
+ .withChild(ImmutableNodes.leafNode(QName.create("urn:test", "2017-01-01", "vlan-id"), value))
.build();
}
private static Entry<InstanceIdentifier<?>, DataObject> fromNormalizedNode(final NormalizedNode data,
final EffectiveModelContext schemaCtx) {
- final CurrentAdapterSerializer codec = new CurrentAdapterSerializer(
- ServiceLoader.load(BindingDOMCodecFactory.class).findFirst().orElseThrow().createBindingDOMCodec(
- new DefaultBindingRuntimeContext(new DefaultBindingRuntimeGenerator()
- .generateTypeMapping(schemaCtx), TestingModuleInfoSnapshot.INSTANCE)));
+ final var codec = new CurrentAdapterSerializer(
+ ServiceLoader.load(BindingDOMCodecFactory.class).findFirst().orElseThrow()
+ .createBindingDOMCodec(new DefaultBindingRuntimeContext(
+ new DefaultBindingRuntimeGenerator().generateTypeMapping(schemaCtx),
+ TestingModuleInfoSnapshot.INSTANCE)));
final YangInstanceIdentifier path = YangInstanceIdentifier.of(NodeIdentifier.create(QName.create(
"urn:test", "2017-01-01", "cont")));
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.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
public class LazySerializedContainerNodeTest {
@Test
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;
public class Mdsal298Test extends AbstractDataBrokerTest {
private static final InstanceIdentifier<Container> CONTAINER = InstanceIdentifier.create(Container.class);
final DOMDataTreeWriteTransaction domTx = getDomBroker().newWriteOnlyTransaction();
domTx.put(CONFIGURATION, YangInstanceIdentifier.of(CONTAINER_NID).node(Keyed.QNAME),
- Builders.orderedMapBuilder()
- .withNodeIdentifier(new NodeIdentifier(Keyed.QNAME))
- .addChild(Builders.mapEntryBuilder()
- .withNodeIdentifier(NodeIdentifierWithPredicates.of(Keyed.QNAME, FOO_QNAME, "foo"))
- .addChild(ImmutableNodes.leafNode(FOO_QNAME, "foo"))
- .build())
- .addChild(Builders.mapEntryBuilder()
- .withNodeIdentifier(NodeIdentifierWithPredicates.of(Keyed.QNAME, FOO_QNAME, "bar"))
- .addChild(ImmutableNodes.leafNode(FOO_QNAME, "bar"))
- .build())
- .build());
+ ImmutableNodes.newUserMapBuilder()
+ .withNodeIdentifier(new NodeIdentifier(Keyed.QNAME))
+ .addChild(ImmutableNodes.newMapEntryBuilder()
+ .withNodeIdentifier(NodeIdentifierWithPredicates.of(Keyed.QNAME, FOO_QNAME, "foo"))
+ .addChild(ImmutableNodes.leafNode(FOO_QNAME, "foo"))
+ .build())
+ .addChild(ImmutableNodes.newMapEntryBuilder()
+ .withNodeIdentifier(NodeIdentifierWithPredicates.of(Keyed.QNAME, FOO_QNAME, "bar"))
+ .addChild(ImmutableNodes.leafNode(FOO_QNAME, "bar"))
+ .build())
+ .build());
domTx.commit().get();
final var captor = ArgumentCaptor.forClass(Collection.class);
final DOMDataTreeWriteTransaction domTx = getDomBroker().newWriteOnlyTransaction();
domTx.put(CONFIGURATION, YangInstanceIdentifier.of(CONTAINER_NID).node(Unkeyed.QNAME),
- Builders.unkeyedListBuilder()
- .withNodeIdentifier(new NodeIdentifier(Unkeyed.QNAME))
- .withChild(Builders.unkeyedListEntryBuilder()
- .withNodeIdentifier(new NodeIdentifier(Unkeyed.QNAME))
- .addChild(ImmutableNodes.leafNode(FOO_QNAME, "foo"))
- .build())
- .withChild(Builders.unkeyedListEntryBuilder()
+ ImmutableNodes.newUnkeyedListBuilder()
.withNodeIdentifier(new NodeIdentifier(Unkeyed.QNAME))
- .addChild(ImmutableNodes.leafNode(FOO_QNAME, "bar"))
- .build())
- .build());
+ .withChild(ImmutableNodes.newUnkeyedListEntryBuilder()
+ .withNodeIdentifier(new NodeIdentifier(Unkeyed.QNAME))
+ .addChild(ImmutableNodes.leafNode(FOO_QNAME, "foo"))
+ .build())
+ .withChild(ImmutableNodes.newUnkeyedListEntryBuilder()
+ .withNodeIdentifier(new NodeIdentifier(Unkeyed.QNAME))
+ .addChild(ImmutableNodes.leafNode(FOO_QNAME, "bar"))
+ .build())
+ .build());
domTx.commit().get();
final var captor = ArgumentCaptor.forClass(Collection.class);
final DOMDataTreeWriteTransaction domTx = getDomBroker().newWriteOnlyTransaction();
domTx.put(CONFIGURATION, YangInstanceIdentifier.of(CHOICE_CONTAINER_NID).node(Foo.QNAME),
- Builders.choiceBuilder()
- .withNodeIdentifier(new NodeIdentifier(Foo.QNAME))
- .withChild(Builders.leafSetBuilder()
- .withNodeIdentifier(new NodeIdentifier(QName.create(Foo.QNAME, "unaddressable")))
- .withChildValue("foo")
- .build())
- .build());
+ ImmutableNodes.newChoiceBuilder()
+ .withNodeIdentifier(new NodeIdentifier(Foo.QNAME))
+ .withChild(ImmutableNodes.newSystemLeafSetBuilder()
+ .withNodeIdentifier(new NodeIdentifier(QName.create(Foo.QNAME, "unaddressable")))
+ .withChildValue("foo")
+ .build())
+ .build());
domTx.commit().get();
final var captor = ArgumentCaptor.forClass(Collection.class);
final DOMDataTreeWriteTransaction domTx = getDomBroker().newWriteOnlyTransaction();
domTx.put(CONFIGURATION, YangInstanceIdentifier.of(new NodeIdentifier(qname)),
- ImmutableNodes.containerNode(qname));
+ ImmutableNodes.newContainerBuilder().withNodeIdentifier(new NodeIdentifier(qname)).build());
domTx.commit().get();
final var captor = ArgumentCaptor.forClass(Collection.class);
getDataBroker().registerDataTreeChangeListener(CHOICE_CONTAINER_TID, listener);
final DOMDataTreeWriteTransaction domTx = getDomBroker().newWriteOnlyTransaction();
- domTx.put(CONFIGURATION, YangInstanceIdentifier.of(CHOICE_CONTAINER_NID),
- Builders.containerBuilder()
+ domTx.put(CONFIGURATION, YangInstanceIdentifier.of(CHOICE_CONTAINER_NID), ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(CHOICE_CONTAINER_NID)
- .withChild(Builders.choiceBuilder().withNodeIdentifier(CHOICE_NID).build())
+ .withChild(ImmutableNodes.newChoiceBuilder().withNodeIdentifier(CHOICE_NID).build())
.build());
domTx.commit().get();
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.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
@ExtendWith(MockitoExtension.class)
class Mdsal739Test {
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-data-impl</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-data-spi</artifactId>
+ </dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-model-api</artifactId>
requires org.opendaylight.yangtools.yang.binding;
requires org.opendaylight.yangtools.yang.common;
requires org.opendaylight.yangtools.yang.data.api;
+ requires org.opendaylight.yangtools.yang.data.spi;
requires org.opendaylight.yangtools.yang.data.impl;
requires org.opendaylight.yangtools.yang.data.util;
requires org.opendaylight.yangtools.yang.model.api;
}
@Override
+ @Deprecated(since = "13.0.0", forRemoval = true)
public final WithStatus getSchema() {
// FIXME: Bad cast, we should be returning an EffectiveStatement perhaps?
return (WithStatus) prototype().runtimeType().statement();
import org.opendaylight.yangtools.yang.binding.OpaqueData;
import org.opendaylight.yangtools.yang.binding.OpaqueObject;
import org.opendaylight.yangtools.yang.data.api.schema.AnydataNode;
-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.AnydataSchemaNode;
final class AnydataCodecContext<T extends OpaqueObject<T>> extends AbstractOpaqueCodecContext<T> {
}
private <M> @NonNull AnydataNode<M> buildAnydata(final OpaqueData<M> opaqueData) {
- return Builders.anydataBuilder(opaqueData.getObjectModel())
+ return ImmutableNodes.newAnydataBuilder(opaqueData.getObjectModel())
.withNodeIdentifier(getDomPathArgument())
.withValue(opaqueData.getData())
.build();
import org.opendaylight.yangtools.yang.data.api.schema.AnyxmlNode;
import org.opendaylight.yangtools.yang.data.api.schema.DOMSourceAnyxmlNode;
import org.opendaylight.yangtools.yang.data.api.schema.ForeignDataNode;
-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.AnyxmlSchemaNode;
final class AnyxmlCodecContext<T extends OpaqueObject<T>> extends AbstractOpaqueCodecContext<T> {
@Override
AnyxmlNode<?> serializedData(final OpaqueData<?> opaqueData) {
- final Class<?> model = opaqueData.getObjectModel();
+ final var model = opaqueData.getObjectModel();
verify(DOMSource.class.isAssignableFrom(model), "Cannot just yet support object model %s", model);
- return Builders.anyXmlBuilder()
+ return ImmutableNodes.newAnyxmlBuilder(DOMSource.class)
.withNodeIdentifier(getDomPathArgument())
.withValue((DOMSource) opaqueData.getData())
.build();
}
@Override
+ @Deprecated(since = "13.0.0", forRemoval = true)
public WithStatus getSchema() {
// FIXME: Bad cast, we should be returning an EffectiveStatement perhaps?
return (WithStatus) prototype().runtimeType().statement();
final DataContainerSerializer caseStreamer = registry.getSerializer(caseClass.asSubclass(DataObject.class));
if (caseStreamer != null) {
if (tryCache(writer, (DataObject) value)) {
- caseStreamer.serialize((DataObject) value, writer);
+ caseStreamer.serialize(value, writer);
}
} else {
LOG.warn("No serializer for case {} is available in registry {}", caseClass, registry);
import org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode;
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.Builders;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
import org.opendaylight.yangtools.yang.model.api.stmt.SchemaTreeEffectiveStatement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
}
}
- private final ImmutableMap<Class<?>, AugmentationCodecPrototype> augmentToPrototype;
+ private final ImmutableMap<Class<?>, AugmentationCodecPrototype<?>> augmentToPrototype;
private final ImmutableMap<NodeIdentifier, Class<?>> yangToAugmentClass;
private final @NonNull Class<? extends CodecDataObject<?>> generatedClass;
private final MethodHandle proxyConstructor;
return child;
}
- private @Nullable AugmentationCodecPrototype getAugmentationProtoByClass(final @NonNull Class<?> augmClass) {
+ private @Nullable AugmentationCodecPrototype<?> getAugmentationProtoByClass(final @NonNull Class<?> augmClass) {
final var childProto = augmentToPrototype.get(augmClass);
return childProto != null ? childProto : mismatchedAugmentationByClass(augmClass);
}
- private @Nullable AugmentationCodecPrototype mismatchedAugmentationByClass(final @NonNull Class<?> childClass) {
+ private @Nullable AugmentationCodecPrototype<?> mismatchedAugmentationByClass(final @NonNull Class<?> childClass) {
/*
* It is potentially mismatched valid augmentation - we look up equivalent augmentation using reflection
* and walk all stream child and compare augmentations classes if they are equivalent. When we find a match
* Due to augmentation fields are at same level as direct children the data of each augmentation needs to be
* aggregated into own container node, then only deserialized using associated prototype.
*/
- final var builders = new HashMap<Class<?>, DataContainerNodeBuilder>();
+ final var builders = new HashMap<Class<?>, DataContainerNodeBuilder<?, ?>>();
for (var childValue : data.body()) {
final var bindingClass = yangToAugmentClass.get(childValue.name());
if (bindingClass != null) {
builders.computeIfAbsent(bindingClass,
- key -> Builders.containerBuilder()
+ key -> ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(data.name().getNodeType())))
.addChild(childValue);
}
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodec;
-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.DataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
import org.opendaylight.mdsal.binding.runtime.api.ContainerRuntimeType;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.NodeStep;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
/**
* A {@link ContainerLikeCodecContext} specialized for {@code container}s which do not have a presence statement.
private @NonNull D loadEmptyObject() {
final var local = createBindingProxy(
- Builders.containerBuilder().withNodeIdentifier(getDomPathArgument()).build());
+ ImmutableNodes.newContainerBuilder().withNodeIdentifier(getDomPathArgument()).build());
final var witness = (D) EMPTY_OBJECT.compareAndExchangeRelease(this, null, local);
return witness != null ? witness : local;
}
abstract ValueCodec<Object, Object> getValueCodec();
@Override
+ @Deprecated(since = "13.0.0", forRemoval = true)
public final DataSchemaNode getSchema() {
return dataSchema;
}
import static org.junit.Assert.assertEquals;
import static org.opendaylight.yangtools.yang.common.YangConstants.operationInputQName;
import static org.opendaylight.yangtools.yang.common.YangConstants.operationOutputQName;
-import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.containerBuilder;
-import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.leafBuilder;
+import org.eclipse.jdt.annotation.NonNull;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.odl.actions.norev.cont.Foo;
import org.opendaylight.yang.gen.v1.urn.odl.actions.norev.cont.FooInput;
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.spi.node.ImmutableNodes;
public class ActionSerializeDeserializeTest extends AbstractBindingCodecTest {
private static final NodeIdentifier FOO_INPUT = NodeIdentifier.create(operationInputQName(Foo.QNAME.getModule()));
private static final NodeIdentifier FOO_OUTPUT = NodeIdentifier.create(operationOutputQName(Foo.QNAME.getModule()));
private static final NodeIdentifier FOO_XYZZY = NodeIdentifier.create(QName.create(Foo.QNAME, "xyzzy"));
- private static final ContainerNode DOM_FOO_INPUT = containerBuilder().withNodeIdentifier(FOO_INPUT)
- .withChild(leafBuilder().withNodeIdentifier(FOO_XYZZY).withValue("xyzzy").build())
- .build();
- private static final ContainerNode DOM_FOO_OUTPUT = containerBuilder().withNodeIdentifier(FOO_OUTPUT).build();
- private static final FooInput BINDING_FOO_INPUT = new FooInputBuilder().setXyzzy("xyzzy").build();
- private static final FooOutput BINDING_FOO_OUTPUT = new FooOutputBuilder().build();
+ private static final @NonNull ContainerNode DOM_FOO_INPUT = ImmutableNodes.newContainerBuilder()
+ .withNodeIdentifier(FOO_INPUT)
+ .withChild(ImmutableNodes.leafNode(FOO_XYZZY, "xyzzy"))
+ .build();
+ private static final @NonNull ContainerNode DOM_FOO_OUTPUT = ImmutableNodes.newContainerBuilder()
+ .withNodeIdentifier(FOO_OUTPUT)
+ .build();
+ private static final @NonNull FooInput BINDING_FOO_INPUT = new FooInputBuilder().setXyzzy("xyzzy").build();
+ private static final @NonNull FooOutput BINDING_FOO_OUTPUT = new FooOutputBuilder().build();
private static final NodeIdentifier BAR_INPUT = NodeIdentifier.create(operationInputQName(Foo.QNAME.getModule()));
private static final NodeIdentifier BAR_OUTPUT = NodeIdentifier.create(operationOutputQName(Foo.QNAME.getModule()));
private static final NodeIdentifier BAR_XYZZY = NodeIdentifier.create(QName.create(Bar.QNAME, "xyzzy"));
- private static final ContainerNode DOM_BAR_INPUT = containerBuilder().withNodeIdentifier(BAR_INPUT).build();
- private static final ContainerNode DOM_BAR_OUTPUT = containerBuilder().withNodeIdentifier(BAR_OUTPUT)
- .withChild(leafBuilder().withNodeIdentifier(BAR_XYZZY).withValue("xyzzy").build())
- .build();
- private static final BarInput BINDING_BAR_INPUT = new BarInputBuilder().build();
- private static final BarOutput BINDING_BAR_OUTPUT = new BarOutputBuilder().setXyzzy("xyzzy").build();
+ private static final ContainerNode DOM_BAR_INPUT = ImmutableNodes.newContainerBuilder()
+ .withNodeIdentifier(BAR_INPUT)
+ .build();
+ private static final ContainerNode DOM_BAR_OUTPUT = ImmutableNodes.newContainerBuilder()
+ .withNodeIdentifier(BAR_OUTPUT)
+ .withChild(ImmutableNodes.leafNode(BAR_XYZZY, "xyzzy"))
+ .build();
+ private static final @NonNull BarInput BINDING_BAR_INPUT = new BarInputBuilder().build();
+ private static final @NonNull BarOutput BINDING_BAR_OUTPUT = new BarOutputBuilder().setXyzzy("xyzzy").build();
private static final NodeIdentifier FOOIO_INPUT = NodeIdentifier.create(operationInputQName(Fooio.QNAME
.getModule()));
.getModule()));
private static final NodeIdentifier FOOIO_I = NodeIdentifier.create(QName.create(Fooio.QNAME, "fooi"));
private static final NodeIdentifier FOOIO_O = NodeIdentifier.create(QName.create(Fooio.QNAME, "fooo"));
- private static final ContainerNode DOM_FOOIO_INPUT = containerBuilder().withNodeIdentifier(FOOIO_INPUT).withChild(
- leafBuilder().withNodeIdentifier(FOOIO_I).withValue("ifoo").build()).build();
- private static final ContainerNode DOM_FOOIO_OUTPUT = containerBuilder().withNodeIdentifier(FOOIO_OUTPUT).withChild(
- leafBuilder().withNodeIdentifier(FOOIO_O).withValue("ofoo").build()).build();
- private static final FooioInput BINDING_FOOIO_INPUT = new FooioInputBuilder().setFooi("ifoo").build();
- private static final FooioOutput BINDING_FOOIO_OUTPUT = new FooioOutputBuilder().setFooo("ofoo").build();
+ private static final @NonNull ContainerNode DOM_FOOIO_INPUT = ImmutableNodes.newContainerBuilder()
+ .withNodeIdentifier(FOOIO_INPUT)
+ .withChild(ImmutableNodes.leafNode(FOOIO_I, "ifoo"))
+ .build();
+ private static final @NonNull ContainerNode DOM_FOOIO_OUTPUT = ImmutableNodes.newContainerBuilder()
+ .withNodeIdentifier(FOOIO_OUTPUT)
+ .withChild(ImmutableNodes.leafNode(FOOIO_O, "ofoo"))
+ .build();
+ private static final @NonNull FooioInput BINDING_FOOIO_INPUT = new FooioInputBuilder().setFooi("ifoo").build();
+ private static final @NonNull FooioOutput BINDING_FOOIO_OUTPUT = new FooioOutputBuilder().setFooo("ofoo").build();
@Test
public void testSerialization() {
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.data.spi.node.ImmutableNodes;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
final Element element = doc.createElement("foo");
domSource = new DOMSource(element);
- cont = Builders.containerBuilder()
- .withNodeIdentifier(CONT_NODE_ID)
- .withChild(Builders.anydataBuilder(DOMSource.class)
- .withNodeIdentifier(new NodeIdentifier(ContAny.QNAME))
- .withValue(domSource)
- .build())
- .build();
+ cont = ImmutableNodes.newContainerBuilder()
+ .withNodeIdentifier(CONT_NODE_ID)
+ .withChild(ImmutableNodes.newAnydataBuilder(DOMSource.class)
+ .withNodeIdentifier(new NodeIdentifier(ContAny.QNAME))
+ .withValue(domSource)
+ .build())
+ .build();
}
@Test
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.data.spi.node.ImmutableNodes;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
final Element element = doc.createElement("foo");
domSource = new DOMSource(element);
- cont = Builders.containerBuilder()
- .withNodeIdentifier(CONT_NODE_ID)
- .withChild(Builders.anyXmlBuilder()
- .withNodeIdentifier(new NodeIdentifier(ContAny.QNAME))
- .withValue(domSource)
- .build())
- .build();
+ cont = ImmutableNodes.newContainerBuilder()
+ .withNodeIdentifier(CONT_NODE_ID)
+ .withChild(ImmutableNodes.newAnyxmlBuilder(DOMSource.class)
+ .withNodeIdentifier(new NodeIdentifier(ContAny.QNAME))
+ .withValue(domSource)
+ .build())
+ .build();
}
@Test
import org.opendaylight.yang.gen.v1.mdsal552.norev.RefTestOutputBuilder;
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.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
public class Mdsal552Test extends AbstractBindingCodecTest {
@Test
public void testLeafrefEnumerationToNormalized() {
- assertEquals(Builders.containerBuilder()
+ assertEquals(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(RefTestOutput.QNAME))
.withChild(ImmutableNodes.leafNode(OUTPUTREF, OutputA.DownTest.getName()))
.build(),
@Test
public void testLeafrefEnumerationFromNormalized() {
assertEquals(new RefTestOutputBuilder().setOutputref(OutputA.DownTest).build(),
- codecContext.fromNormalizedNodeRpcData(OUTPUT_PATH, Builders.containerBuilder()
+ codecContext.fromNormalizedNodeRpcData(OUTPUT_PATH, ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(RefTestOutput.QNAME))
.withChild(ImmutableNodes.leafNode(OUTPUTREF, OutputA.DownTest.getName()))
.build()));
import org.opendaylight.yang.gen.v1.mdsal668.norev.bar.BarBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
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.spi.node.ImmutableNodes;
public class Mdsal668Test extends AbstractBindingCodecTest {
private static final NodeIdentifier FOO = new NodeIdentifier(Foo.QNAME);
@Test
public void testLeaflistLeafref() {
- assertEquals(Builders.containerBuilder()
+ assertEquals(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(FOO)
- .withChild(Builders.containerBuilder()
+ .withChild(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(Bar.QNAME))
- .withChild(Builders.leafSetBuilder()
+ .withChild(ImmutableNodes.newSystemLeafSetBuilder()
.withNodeIdentifier(new NodeIdentifier(Bar.QNAME))
- .withChild(Builders.leafSetEntryBuilder()
- // FIXME: MDSAL-670: these should get translated to YangInstanceIdentifier.of(FOO)
- .withNodeIdentifier(new NodeWithValue<>(Bar.QNAME, FOO_IID))
- .withValue(FOO_IID)
- .build())
+ // FIXME: MDSAL-670: these should get translated to YangInstanceIdentifier.of(FOO)
+ .withChild(ImmutableNodes.leafSetEntry(Bar.QNAME, FOO_IID))
.build())
.build())
.build(),
import static org.junit.Assert.assertThrows;
import static org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.top;
import static org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.topLevelList;
-import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.choiceBuilder;
-import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.containerBuilder;
-import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.leafSetBuilder;
-import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.leafSetEntryBuilder;
-import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.mapBuilder;
-import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.orderedLeafSetBuilder;
-import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.orderedMapBuilder;
-import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.leafNode;
-import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntry;
-import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntryBuilder;
-import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapNodeBuilder;
import java.util.List;
import java.util.Map;
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.api.YangInstanceIdentifier.NodeWithValue;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
public class NormalizedNodeSerializeDeserializeTest extends AbstractBindingCodecTest {
public static final String TOP_LEVEL_LIST_FOO_KEY_VALUE = "foo";
}
private static ContainerNode getEmptyTop() {
- return containerBuilder().withNodeIdentifier(new NodeIdentifier(TOP_QNAME)).build();
+ return ImmutableNodes.newContainerBuilder().withNodeIdentifier(new NodeIdentifier(TOP_QNAME)).build();
}
private static final QName AGUMENT_STRING_Q = QName.create(TOP_QNAME, "augmented-string");
@Test
public void equalsWithAugment() {
final ContainerNode topNormalizedWithAugments =
- getNormalizedTopWithChildren(leafNode(AGUMENT_STRING_Q, AUGMENT_STRING_VALUE));
+ getNormalizedTopWithChildren(ImmutableNodes.leafNode(AGUMENT_STRING_Q, AUGMENT_STRING_VALUE));
final ContainerNode topNormalized = getEmptyTop();
final var entry = codecContext.fromNormalizedNode(BI_TOP_PATH, topNormalized);
@Test
public void equalsWithMultipleAugments() {
final ContainerNode topNormalizedWithAugments = getNormalizedTopWithChildren(
- leafNode(AGUMENT_STRING_Q, AUGMENT_STRING_VALUE),
- leafNode(AUGMENT_INT_Q, AUGMENT_INT_VALUE));
+ ImmutableNodes.leafNode(AGUMENT_STRING_Q, AUGMENT_STRING_VALUE),
+ ImmutableNodes.leafNode(AUGMENT_INT_Q, AUGMENT_INT_VALUE));
final var entryWithAugments = codecContext.fromNormalizedNode(BI_TOP_PATH, topNormalizedWithAugments);
Top topWithAugments = topWithAugments(Map.of(
Top1.class, new Top1Builder().setAugmentedString(AUGMENT_STRING_VALUE).build(),
}
private static ContainerNode getNormalizedTopWithChildren(final DataContainerChild... children) {
- final var builder = containerBuilder();
- for (DataContainerChild child : children) {
+ final var builder = ImmutableNodes.newContainerBuilder().withNodeIdentifier(new NodeIdentifier(TOP_QNAME));
+ for (var child : children) {
builder.withChild(child);
}
- return builder.withNodeIdentifier(new NodeIdentifier(TOP_QNAME))
- .withChild(mapNodeBuilder(TOP_LEVEL_LIST_QNAME).build()).build();
+ return builder
+ .withChild(ImmutableNodes.newSystemMapBuilder()
+ .withNodeIdentifier(new NodeIdentifier(TOP_LEVEL_LIST_QNAME))
+ .build())
+ .build();
}
private static Top topWithAugments(
@Test
public void listWithKeysToNormalized() {
final var entry = codecContext.toNormalizedDataObject(BA_TOP_LEVEL_LIST, topLevelList(TOP_LEVEL_LIST_FOO_KEY));
- assertEquals(mapEntryBuilder()
+ assertEquals(ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(NodeIdentifierWithPredicates.of(TOP_LEVEL_LIST_QNAME, TOP_LEVEL_LIST_KEY_QNAME,
TOP_LEVEL_LIST_FOO_KEY_VALUE))
- .withChild(leafNode(TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
+ .withChild(ImmutableNodes.leafNode(TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
.build(),
entry.node());
}
@Test
public void listWithKeysFromNormalized() {
- final var entry = codecContext.fromNormalizedNode(BI_TOP_LEVEL_LIST_FOO_PATH, mapEntryBuilder()
- .withNodeIdentifier(NodeIdentifierWithPredicates.of(TOP_LEVEL_LIST_QNAME, TOP_LEVEL_LIST_KEY_QNAME,
- TOP_LEVEL_LIST_FOO_KEY_VALUE))
- .withChild(leafNode(TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
- .build());
+ final var entry = codecContext.fromNormalizedNode(BI_TOP_LEVEL_LIST_FOO_PATH,
+ ImmutableNodes.newMapEntryBuilder()
+ .withNodeIdentifier(NodeIdentifierWithPredicates.of(TOP_LEVEL_LIST_QNAME, TOP_LEVEL_LIST_KEY_QNAME,
+ TOP_LEVEL_LIST_FOO_KEY_VALUE))
+ .withChild(ImmutableNodes.leafNode(TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
+ .build());
assertEquals(topLevelList(TOP_LEVEL_LIST_FOO_KEY), entry.getValue());
}
final var entry = codecContext.toNormalizedDataObject(BA_TOP_LEVEL_LIST,
topLevelList(TOP_LEVEL_LIST_FOO_KEY,
new TreeLeafOnlyAugmentBuilder().setSimpleValue("simpleValue").build()));
- assertEquals(mapEntryBuilder()
+ assertEquals(ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(NodeIdentifierWithPredicates.of(TOP_LEVEL_LIST_QNAME, TOP_LEVEL_LIST_KEY_QNAME,
TOP_LEVEL_LIST_FOO_KEY_VALUE))
- .withChild(leafNode(TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
- .withChild(leafNode(SIMPLE_VALUE_QNAME, "simpleValue")) // augmentation child
+ .withChild(ImmutableNodes.leafNode(TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
+ .withChild(ImmutableNodes.leafNode(SIMPLE_VALUE_QNAME, "simpleValue")) // augmentation child
.build(),
entry.node());
}
@Test
public void leafOnlyAugmentationFromNormalized() {
- final var entry = codecContext.fromNormalizedNode(BI_TOP_LEVEL_LIST_FOO_PATH, mapEntryBuilder()
- .withNodeIdentifier(NodeIdentifierWithPredicates.of(TOP_LEVEL_LIST_QNAME, TOP_LEVEL_LIST_KEY_QNAME,
- TOP_LEVEL_LIST_FOO_KEY_VALUE))
- .withChild(leafNode(TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
- .withChild(leafNode(SIMPLE_VALUE_QNAME, "simpleValue")) // augmentation child
- .build());
+ final var entry = codecContext.fromNormalizedNode(BI_TOP_LEVEL_LIST_FOO_PATH,
+ ImmutableNodes.newMapEntryBuilder()
+ .withNodeIdentifier(NodeIdentifierWithPredicates.of(TOP_LEVEL_LIST_QNAME, TOP_LEVEL_LIST_KEY_QNAME,
+ TOP_LEVEL_LIST_FOO_KEY_VALUE))
+ .withChild(ImmutableNodes.leafNode(TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
+ .withChild(ImmutableNodes.leafNode(SIMPLE_VALUE_QNAME, "simpleValue")) // augmentation child
+ .build());
assertEquals(
topLevelList(TOP_LEVEL_LIST_FOO_KEY,
new TreeLeafOnlyAugmentBuilder().setSimpleValue("simpleValue").build()),
public void orderedleafListToNormalized() {
final var entry = codecContext.toNormalizedDataObject(InstanceIdentifier.create(Top.class),
new TopBuilder().setTopLevelOrderedLeafList(List.of("foo")).build());
- assertEquals(containerBuilder()
+ assertEquals(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(TOP_QNAME))
- .withChild(orderedLeafSetBuilder()
+ .withChild(ImmutableNodes.newUserLeafSetBuilder()
.withNodeIdentifier(new NodeIdentifier(TOP_LEVEL_ORDERED_LEAF_LIST_QNAME))
- .withChild(leafSetEntryBuilder()
- .withNodeIdentifier(new NodeWithValue<>(TOP_LEVEL_ORDERED_LEAF_LIST_QNAME, "foo"))
- .withValue("foo")
- .build())
+ .withChild(ImmutableNodes.leafSetEntry(TOP_LEVEL_ORDERED_LEAF_LIST_QNAME, "foo"))
.build())
.build(),
entry.node());
public void leafListToNormalized() {
final var entry = codecContext.toNormalizedDataObject(
InstanceIdentifier.create(Top.class), new TopBuilder().setTopLevelLeafList(Set.of("foo")).build());
- assertEquals(containerBuilder()
+ assertEquals(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(TOP_QNAME))
- .withChild(leafSetBuilder()
+ .withChild(ImmutableNodes.newSystemLeafSetBuilder()
.withNodeIdentifier(new NodeIdentifier(TOP_LEVEL_LEAF_LIST_QNAME))
- .withChild(leafSetEntryBuilder()
- .withNodeIdentifier(new NodeWithValue<>(TOP_LEVEL_LEAF_LIST_QNAME, "foo"))
- .withValue("foo")
- .build())
+ .withChild(ImmutableNodes.leafSetEntry(TOP_LEVEL_LEAF_LIST_QNAME, "foo"))
.build())
.build(),
entry.node());
@Test
public void leafListFromNormalized() {
- final var entry = codecContext.fromNormalizedNode(BI_TOP_PATH, containerBuilder()
+ final var entry = codecContext.fromNormalizedNode(BI_TOP_PATH, ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(TOP_QNAME))
- .withChild(leafSetBuilder()
+ .withChild(ImmutableNodes.newSystemLeafSetBuilder()
.withNodeIdentifier(new NodeIdentifier(TOP_LEVEL_LEAF_LIST_QNAME))
- .withChild(leafSetEntryBuilder()
- .withNodeIdentifier(new NodeWithValue<>(TOP_LEVEL_LEAF_LIST_QNAME, "foo"))
- .withValue("foo")
- .build())
+ .withChild(ImmutableNodes.leafSetEntry(TOP_LEVEL_LEAF_LIST_QNAME, "foo"))
.build())
.build());
assertEquals(new TopBuilder().setTopLevelLeafList(Set.of("foo")).build(), entry.getValue());
@Test
public void orderedLeafListFromNormalized() {
- final var entry = codecContext.fromNormalizedNode(BI_TOP_PATH, containerBuilder()
+ final var entry = codecContext.fromNormalizedNode(BI_TOP_PATH, ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(TOP_QNAME))
- .withChild(orderedLeafSetBuilder()
+ .withChild(ImmutableNodes.newUserLeafSetBuilder()
.withNodeIdentifier(new NodeIdentifier(TOP_LEVEL_ORDERED_LEAF_LIST_QNAME))
- .withChild(leafSetEntryBuilder()
- .withNodeIdentifier(new NodeWithValue<>(TOP_LEVEL_ORDERED_LEAF_LIST_QNAME, "foo"))
- .withValue("foo").build())
+ .withChild(ImmutableNodes.leafSetEntry(TOP_LEVEL_ORDERED_LEAF_LIST_QNAME, "foo"))
.build())
.build());
assertEquals(new TopBuilder().setTopLevelOrderedLeafList(List.of("foo")).build(), entry.getValue());
.setExtendedId(new ExtendedIdBuilder().setId("identifier_value").build())
.build())
.build());
- assertEquals(containerBuilder()
+ assertEquals(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(CHOICE_CONTAINER_QNAME))
- .withChild(choiceBuilder()
+ .withChild(ImmutableNodes.newChoiceBuilder()
.withNodeIdentifier(new NodeIdentifier(CHOICE_IDENTIFIER_QNAME))
- .withChild(containerBuilder()
+ .withChild(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(EXTENDED_ID_QNAME))
- .withChild(leafNode(CHOICE_IDENTIFIER_ID_QNAME, "identifier_value"))
+ .withChild(ImmutableNodes.leafNode(CHOICE_IDENTIFIER_ID_QNAME, "identifier_value"))
.build())
.build())
.build(),
final YangInstanceIdentifier yangInstanceIdentifierOuter = YangInstanceIdentifier.of(
containerIdentifierQname4798);
- final ContainerNode containerNodeOuter = containerBuilder()
+ final ContainerNode containerNodeOuter = ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(containerIdentifierQname4798))
- .withChild(containerBuilder()
+ .withChild(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(nestedContainerOuterQname))
- .withChild(leafNode(nestedContainerLeafOuterQname, "bar"))
+ .withChild(ImmutableNodes.leafNode(nestedContainerLeafOuterQname, "bar"))
.build())
.build();
final Entry<InstanceIdentifier<?>, DataObject> entryContainer = codecContext.fromNormalizedNode(
.node(nestedContainerValidQname)
.node(nestedListQname4798)
.node(nodeIdentifierWithPredicates4798);
- final ContainerNode containerNodeValid = containerBuilder()
+ final ContainerNode containerNodeValid = ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(containerIdentifierQname4798))
- .withChild(choiceBuilder()
+ .withChild(ImmutableNodes.newChoiceBuilder()
.withNodeIdentifier(new NodeIdentifier(choiceIdentifierQname4798))
- .withChild(containerBuilder()
+ .withChild(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(nestedContainerValidQname))
- .withChild(mapBuilder()
+ .withChild(ImmutableNodes.newSystemMapBuilder()
.withNodeIdentifier(new NodeIdentifier(nestedListQname4798))
- .withChild(mapEntry(nestedListQname4798, nestedListKeyQname4798, "foo"))
- .withChild(mapEntry(nestedListQname4798, nestedListKeyQname4798, "bar"))
+ .withChild(ImmutableNodes.newMapEntryBuilder()
+ .withNodeIdentifier(
+ NodeIdentifierWithPredicates.of(nestedListQname4798, nestedListKeyQname4798, "foo"))
+ .withChild(ImmutableNodes.leafNode(nestedListKeyQname4798, "foo"))
+ .build())
+ .withChild(ImmutableNodes.newMapEntryBuilder()
+ .withNodeIdentifier(
+ NodeIdentifierWithPredicates.of(nestedListQname4798, nestedListKeyQname4798, "bar"))
+ .withChild(ImmutableNodes.leafNode(nestedListKeyQname4798, "bar"))
+ .build())
.build())
.build())
.build())
.getMessage();
assertEquals("Expecting either a MapEntryNode or an UnkeyedListEntryNode, not ContainerNode", msg);
- final ContainerNode containerNode4798 = containerBuilder()
+ final ContainerNode containerNode4798 = ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(containerIdentifierQname4798))
- .withChild(choiceBuilder()
+ .withChild(ImmutableNodes.newChoiceBuilder()
.withNodeIdentifier(new NodeIdentifier(choiceIdentifierQname4798))
- .withChild(mapBuilder()
+ .withChild(ImmutableNodes.newSystemMapBuilder()
.withNodeIdentifier(new NodeIdentifier(nestedListQname4798))
- .withChild(mapEntry(nestedListQname4798, nestedListKeyQname4798, "foo"))
- .withChild(mapEntry(nestedListQname4798, nestedListKeyQname4798, "bar"))
+ .withChild(ImmutableNodes.newMapEntryBuilder()
+ .withNodeIdentifier(
+ NodeIdentifierWithPredicates.of(nestedListQname4798, nestedListKeyQname4798, "foo"))
+ .withChild(ImmutableNodes.leafNode(nestedListKeyQname4798, "foo"))
+ .build())
+ .withChild(ImmutableNodes.newMapEntryBuilder()
+ .withNodeIdentifier(
+ NodeIdentifierWithPredicates.of(nestedListQname4798, nestedListKeyQname4798, "bar"))
+ .withChild(ImmutableNodes.leafNode(nestedListKeyQname4798, "bar"))
+ .build())
.build())
.build())
.build();
@Test
public void choiceFromNormalized() {
- final ContainerNode choiceContainerBI = containerBuilder()
+ final ContainerNode choiceContainerBI = ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(CHOICE_CONTAINER_QNAME))
- .withChild(choiceBuilder()
+ .withChild(ImmutableNodes.newChoiceBuilder()
.withNodeIdentifier(new NodeIdentifier(CHOICE_IDENTIFIER_QNAME))
- .withChild(containerBuilder()
+ .withChild(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(EXTENDED_ID_QNAME))
- .withChild(leafNode(CHOICE_IDENTIFIER_ID_QNAME, "identifier_value"))
+ .withChild(ImmutableNodes.leafNode(CHOICE_IDENTIFIER_ID_QNAME, "identifier_value"))
.build())
.build())
.build();
new NestedListBuilder().withKey(new NestedListKey("foo")).build(),
new NestedListBuilder().withKey(new NestedListKey("bar")).build()))
.build());
- assertEquals(mapEntryBuilder()
+ assertEquals(ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(NodeIdentifierWithPredicates.of(TOP_LEVEL_LIST_QNAME,
TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
- .withChild(leafNode(TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
- .withChild(orderedMapBuilder()
+ .withChild(ImmutableNodes.leafNode(TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
+ .withChild(ImmutableNodes.newUserMapBuilder()
.withNodeIdentifier(new NodeIdentifier(NESTED_LIST_QNAME))
- .withChild(mapEntry(NESTED_LIST_QNAME, NESTED_LIST_KEY_QNAME, "foo"))
- .withChild(mapEntry(NESTED_LIST_QNAME, NESTED_LIST_KEY_QNAME, "bar"))
+ .withChild(ImmutableNodes.newMapEntryBuilder()
+ .withNodeIdentifier(
+ NodeIdentifierWithPredicates.of(NESTED_LIST_QNAME, NESTED_LIST_KEY_QNAME, "foo"))
+ .withChild(ImmutableNodes.leafNode(NESTED_LIST_KEY_QNAME, "foo"))
+ .build())
+ .withChild(ImmutableNodes.newMapEntryBuilder()
+ .withNodeIdentifier(
+ NodeIdentifierWithPredicates.of(NESTED_LIST_QNAME, NESTED_LIST_KEY_QNAME, "bar"))
+ .withChild(ImmutableNodes.leafNode(NESTED_LIST_KEY_QNAME, "bar"))
+ .build())
.build())
.build(),
entry.node());
@Test
public void orderedLisFromNormalized() {
- final var entry = codecContext.fromNormalizedNode(BI_TOP_LEVEL_LIST_FOO_PATH, mapEntryBuilder()
- .withNodeIdentifier(NodeIdentifierWithPredicates.of(
- TOP_LEVEL_LIST_QNAME, TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
- .withChild(leafNode(TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
- .withChild(orderedMapBuilder()
- .withNodeIdentifier(new NodeIdentifier(NESTED_LIST_QNAME))
- .withChild(mapEntry(NESTED_LIST_QNAME, NESTED_LIST_KEY_QNAME, "foo"))
- .withChild(mapEntry(NESTED_LIST_QNAME, NESTED_LIST_KEY_QNAME, "bar"))
- .build())
- .build());
+ final var entry = codecContext.fromNormalizedNode(BI_TOP_LEVEL_LIST_FOO_PATH,
+ ImmutableNodes.newMapEntryBuilder()
+ .withNodeIdentifier(NodeIdentifierWithPredicates.of(
+ TOP_LEVEL_LIST_QNAME, TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
+ .withChild(ImmutableNodes.leafNode(TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
+ .withChild(ImmutableNodes.newUserMapBuilder()
+ .withNodeIdentifier(new NodeIdentifier(NESTED_LIST_QNAME))
+ .withChild(ImmutableNodes.newMapEntryBuilder()
+ .withNodeIdentifier(
+ NodeIdentifierWithPredicates.of(NESTED_LIST_QNAME, NESTED_LIST_KEY_QNAME, "foo"))
+ .withChild(ImmutableNodes.leafNode(NESTED_LIST_KEY_QNAME, "foo"))
+ .build())
+ .withChild(ImmutableNodes.newMapEntryBuilder()
+ .withNodeIdentifier(
+ NodeIdentifierWithPredicates.of(NESTED_LIST_QNAME, NESTED_LIST_KEY_QNAME, "bar"))
+ .withChild(ImmutableNodes.leafNode(NESTED_LIST_KEY_QNAME, "bar"))
+ .build())
+ .build())
+ .build());
assertEquals(new TopLevelListBuilder()
.withKey(TOP_LEVEL_LIST_FOO_KEY)
.setNestedList(List.of(
final var biResult = codecContext.toNormalizedDataObject(InstanceIdentifier.create(Top.class), top);
- final var topNormalized = containerBuilder()
+ final var topNormalized = ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(TOP_QNAME))
- .withChild(choiceBuilder().withNodeIdentifier(augmentChoice1Id) // choice 1
- .withChild(choiceBuilder().withNodeIdentifier(augmentChoice2Id) // choice 2
- .withChild(containerBuilder().withNodeIdentifier(containerId)
- .withChild(leafNode(leafQName, "leaf-value")).build())
+ .withChild(ImmutableNodes.newChoiceBuilder()
+ .withNodeIdentifier(augmentChoice1Id)
+ .withChild(ImmutableNodes.newChoiceBuilder()
+ .withNodeIdentifier(augmentChoice2Id)
+ .withChild(ImmutableNodes.newContainerBuilder()
+ .withNodeIdentifier(containerId)
+ .withChild(ImmutableNodes.leafNode(leafQName, "leaf-value"))
+ .build())
.build())
.build())
.build();
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
-import com.google.common.collect.ImmutableMap;
import java.time.Instant;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.TwoLevelListChanged;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListKey;
import org.opendaylight.yangtools.yang.binding.EventInstantAware;
+import org.opendaylight.yangtools.yang.binding.util.BindingMap;
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.api.schema.ContainerNode;
-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;
public class NotificationProcessingTest extends AbstractBindingCodecTest {
private static final QName NAME = QName.create(TopLevelList.QNAME, "name");
private static TwoLevelListChanged createTestBindingData() {
- final TopLevelListKey key = new TopLevelListKey("test");
return new TwoLevelListChangedBuilder()
- .setTopLevelList(ImmutableMap.of(key, new TopLevelListBuilder().withKey(key).build()))
- .build();
+ .setTopLevelList(BindingMap.of(new TopLevelListBuilder().withKey(new TopLevelListKey("test")).build()))
+ .build();
}
private static ContainerNode createTestDomData() {
- return Builders.containerBuilder()
+ return ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(NodeIdentifier.create(TwoLevelListChanged.QNAME))
- .withChild(Builders.mapBuilder()
+ .withChild(ImmutableNodes.newSystemMapBuilder()
.withNodeIdentifier(NodeIdentifier.create(TopLevelList.QNAME))
- .withChild(Builders.mapEntryBuilder()
+ .withChild(ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(NodeIdentifierWithPredicates.of(TopLevelList.QNAME, NAME, "test"))
.build())
.build())
@Test
public void testNotificationToNormalized() {
- final ContainerNode dom = codecContext.toNormalizedNodeNotification(createTestBindingData());
+ final var dom = codecContext.toNormalizedNodeNotification(createTestBindingData());
assertEquals(createTestDomData(), dom);
}
@Test
public void testNormalizedToNotificationWithInstant() {
- final Instant instant = Instant.now();
+ final var instant = Instant.now();
final var bindingDeserialized = codecContext.fromNormalizedNodeNotification(
Absolute.of(TwoLevelListChanged.QNAME), createTestDomData(), instant);
assertTrue(bindingDeserialized instanceof TwoLevelListChanged);
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes;
-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 UnionTypeWithMultipleIdentityrefsTest extends AbstractBindingCodecTest {
}
private void verifyIdentityWasTranslatedToBindingCorrectly(final QName identityQname, final UnionType union) {
- final ContainerNode top = Builders.containerBuilder()
+ final ContainerNode top = ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(TOP_QNAME))
.withChild(ImmutableNodes.leafNode(NodeIdentifier.create(UNION_LEAF_QNAME), identityQname))
.build();
import com.google.common.collect.ImmutableMap;
import com.google.common.util.concurrent.ForwardingExecutorService;
-import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
import java.util.Collections;
import org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore;
import org.opendaylight.yangtools.util.concurrent.DeadlockDetectingListeningExecutorService;
import org.opendaylight.yangtools.util.concurrent.SpecialExecutors;
-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.DataContainerChild;
-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;
public class DOMBrokerTest extends AbstractDatastoreTest {
* Writes /test in writeTx.
*
*/
- writeTx.put(OPERATIONAL, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+ writeTx.put(OPERATIONAL, TestModel.TEST_PATH, ImmutableNodes.newContainerBuilder()
+ .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
+ .build());
/**
* Reads /test from readTx Read should return Absent.
*
*/
- final ListenableFuture<Optional<NormalizedNode>> readTxContainer = readTx.read(OPERATIONAL,
- TestModel.TEST_PATH);
- assertFalse(readTxContainer.get().isPresent());
+ final var readTxContainer = readTx.read(OPERATIONAL, TestModel.TEST_PATH);
+ assertEquals(Optional.empty(), readTxContainer.get());
}
@Test(timeout = 10000)
* Writes /test in writeTx
*
*/
- writeTx.put(OPERATIONAL, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+ writeTx.put(OPERATIONAL, TestModel.TEST_PATH, ImmutableNodes.newContainerBuilder()
+ .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
+ .build());
writeTx.commit().get();
- final Optional<NormalizedNode> afterCommitRead = domBroker.newReadOnlyTransaction()
- .read(OPERATIONAL, TestModel.TEST_PATH).get();
+ final var afterCommitRead = domBroker.newReadOnlyTransaction().read(OPERATIONAL, TestModel.TEST_PATH).get();
assertTrue(afterCommitRead.isPresent());
}
.awaitTermination(Mockito.anyLong(), Mockito.any(TimeUnit.class));
final DOMDataTreeWriteTransaction writeTx = domBroker.newWriteOnlyTransaction();
- writeTx.put(OPERATIONAL, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+ writeTx.put(OPERATIONAL, TestModel.TEST_PATH, ImmutableNodes.newContainerBuilder()
+ .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
+ .build());
try {
writeTx.commit().get(5, TimeUnit.SECONDS);
@Test(expected = ReadFailedException.class)
@SuppressWarnings({"checkstyle:IllegalThrows", "checkstyle:AvoidHidingCauseException"})
public void basicTests() throws Throwable {
- final DataContainerChild outerList = ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
- .withChild(ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1))
- .build();
- final NormalizedNode testContainer = Builders.containerBuilder()
- .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME))
+ final DataContainerChild outerList = ImmutableNodes.newSystemMapBuilder()
+ .withNodeIdentifier(new NodeIdentifier(TestModel.OUTER_LIST_QNAME))
+ .withChild(TestUtils.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1))
+ .build();
+ final ContainerNode testContainer = ImmutableNodes.newContainerBuilder()
+ .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
.withChild(outerList)
.build();
assertNotNull(readRx);
assertNotNull(((SerializedDOMDataBroker) domBroker).getCommitStatsTracker());
- writeTx.put(OPERATIONAL, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+ writeTx.put(OPERATIONAL, TestModel.TEST_PATH, ImmutableNodes.newContainerBuilder()
+ .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
+ .build());
writeTx.commit().get();
assertFalse(writeTx.cancel());
- assertEquals(false, domBroker.newReadOnlyTransaction().exists(CONFIGURATION, TestModel.TEST_PATH).get());
- assertEquals(true, domBroker.newReadOnlyTransaction().exists(OPERATIONAL, TestModel.TEST_PATH).get());
- assertEquals(false, domBroker.newReadOnlyTransaction().exists(OPERATIONAL, TestModel.TEST2_PATH).get());
+ assertFalse(domBroker.newReadOnlyTransaction().exists(CONFIGURATION, TestModel.TEST_PATH).get());
+ assertTrue(domBroker.newReadOnlyTransaction().exists(OPERATIONAL, TestModel.TEST_PATH).get());
+ assertFalse(domBroker.newReadOnlyTransaction().exists(OPERATIONAL, TestModel.TEST2_PATH).get());
writeTx = domBroker.newWriteOnlyTransaction();
- writeTx.put(OPERATIONAL, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+ writeTx.put(OPERATIONAL, TestModel.TEST_PATH, ImmutableNodes.newContainerBuilder()
+ .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
+ .build());
writeTx.delete(OPERATIONAL, TestModel.TEST_PATH);
writeTx.commit().get();
- assertEquals(false, domBroker.newReadOnlyTransaction().exists(OPERATIONAL, TestModel.TEST_PATH).get());
+ assertFalse(domBroker.newReadOnlyTransaction().exists(OPERATIONAL, TestModel.TEST_PATH).get());
assertTrue(domBroker.newWriteOnlyTransaction().cancel());
writeTx = domBroker.newWriteOnlyTransaction();
- writeTx.put(OPERATIONAL, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+ writeTx.put(OPERATIONAL, TestModel.TEST_PATH, ImmutableNodes.newContainerBuilder()
+ .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
+ .build());
writeTx.merge(OPERATIONAL, TestModel.TEST_PATH, testContainer);
writeTx.commit().get();
- assertEquals(Boolean.TRUE, domBroker.newReadOnlyTransaction().exists(OPERATIONAL, TestModel.TEST_PATH).get());
- assertEquals(Boolean.TRUE, domBroker.newReadOnlyTransaction().read(OPERATIONAL, TestModel.TEST_PATH).get()
+ assertTrue(domBroker.newReadOnlyTransaction().exists(OPERATIONAL, TestModel.TEST_PATH).get());
+ assertTrue(domBroker.newReadOnlyTransaction().read(OPERATIONAL, TestModel.TEST_PATH).get()
.orElseThrow().toString().contains(testContainer.toString()));
readRx.read(OPERATIONAL, TestModel.TEST_PATH).get(); // init backing tx before close
import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
import org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore;
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.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate;
public class DOMDataTreeChangeListenerTest extends AbstractDatastoreTest {
@Test
public void receiveOnDataInitialEventForNonExistingData() throws Exception {
final DOMDataTreeChangeListener listener = mock(DOMDataTreeChangeListener.class);
- final ArgumentCaptor<List> candidateCapture = ArgumentCaptor.forClass(List.class);
+ final var candidateCapture = ArgumentCaptor.forClass(List.class);
doNothing().when(listener).onInitialData();
doNothing().when(listener).onDataTreeChanged(any());
domStore.registerTreeChangeListener(TestModel.TEST_PATH, listener);
verify(listener, times(1)).onInitialData();
- final NormalizedNode testNode = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
+ final var testNode = ImmutableNodes.newContainerBuilder()
+ .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
+ .build();
DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
assertNotNull(writeTx);
writeTx.write(TestModel.TEST_PATH, testNode);
final ArgumentCaptor<List> candidateCapture = ArgumentCaptor.forClass(List.class);
doNothing().when(listener).onDataTreeChanged(any());
- final NormalizedNode testNode = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
+ final var testNode = ImmutableNodes.newContainerBuilder()
+ .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
+ .build();
DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
assertNotNull(writeTx);
final ArgumentCaptor<List> candidateCapture = ArgumentCaptor.forClass(List.class);
doNothing().when(listener).onDataTreeChanged(any());
- final ContainerNode testNode = Builders.containerBuilder()
- .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME))
- .addChild(ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
- .addChild(ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME,
- TestModel.ID_QNAME, 1)).build()).build();
+ final ContainerNode testNode = ImmutableNodes.newContainerBuilder()
+ .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
+ .addChild(ImmutableNodes.newSystemMapBuilder()
+ .withNodeIdentifier(new NodeIdentifier(TestModel.OUTER_LIST_QNAME))
+ .addChild(TestUtils.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1))
+ .build())
+ .build();
DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
assertNotNull(writeTx);
writeTx.write(TestModel.TEST_PATH, testNode);
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
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.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.tree.api.DataTreeCandidate;
import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode;
import org.opendaylight.yangtools.yang.data.tree.api.ModificationType;
private ExecutorService futureExecutor;
private CommitExecutorService commitExecutor;
- private static final MapNode OUTER_LIST = ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
- .withChild(ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1))
- .build();
+ private static final MapNode OUTER_LIST = ImmutableNodes.newSystemMapBuilder()
+ .withNodeIdentifier(new NodeIdentifier(TestModel.OUTER_LIST_QNAME))
+ .withChild(TestUtils.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1))
+ .build();
- private static final MapNode OUTER_LIST_2 = ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
- .withChild(ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 2))
- .build();
+ private static final MapNode OUTER_LIST_2 = ImmutableNodes.newSystemMapBuilder()
+ .withNodeIdentifier(new NodeIdentifier(TestModel.OUTER_LIST_QNAME))
+ .withChild(TestUtils.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 2))
+ .build();
- private static final NormalizedNode TEST_CONTAINER = Builders.containerBuilder()
+ private static final NormalizedNode TEST_CONTAINER = ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
.withChild(OUTER_LIST)
.build();
- private static final NormalizedNode TEST_CONTAINER_2 = Builders.containerBuilder()
+ private static final NormalizedNode TEST_CONTAINER_2 = ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
.withChild(OUTER_LIST_2)
.build();
final var outerListEntryId3 =
NodeIdentifierWithPredicates.of(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 3);
- final var outerListEntry1 = ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1);
- final var outerListEntry2 = ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 2);
- final var outerListEntry3 = ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 3);
+ final var outerListEntry1 = TestUtils.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1);
+ final var outerListEntry2 = TestUtils.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 2);
+ final var outerListEntry3 = TestUtils.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 3);
- final var listAfter = ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
- .withChild(outerListEntry2)
- .withChild(outerListEntry3)
- .build();
+ final var listAfter = ImmutableNodes.newSystemMapBuilder()
+ .withNodeIdentifier(new NodeIdentifier(TestModel.OUTER_LIST_QNAME))
+ .withChild(outerListEntry2)
+ .withChild(outerListEntry3)
+ .build();
writeTx = domBroker.newWriteOnlyTransaction();
writeTx.delete(LogicalDatastoreType.CONFIGURATION, TestModel.OUTER_LIST_PATH.node(outerListEntryId1));
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.spi.node.ImmutableNodes;
@RunWith(MockitoJUnitRunner.StrictStubs.class)
public class DOMRpcRouterTest {
private static final DOMActionImplementation IMPL =
(type, path, input) -> Futures.immediateFuture(new SimpleDOMActionResult(
- Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(Actions.OUTPUT)).build()));
+ ImmutableNodes.newContainerBuilder().withNodeIdentifier(new NodeIdentifier(Actions.OUTPUT)).build()));
@Test
public void registerRpcImplementation() {
final YangInstanceIdentifier path) {
return actionService.invokeAction(Actions.BAZ_TYPE,
DOMDataTreeIdentifier.of(LogicalDatastoreType.OPERATIONAL, path),
- Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(Actions.INPUT)).build());
+ ImmutableNodes.newContainerBuilder().withNodeIdentifier(new NodeIdentifier(Actions.INPUT)).build());
}
}
import org.opendaylight.mdsal.dom.api.DOMTransactionChain;
import org.opendaylight.mdsal.dom.spi.store.DOMStore;
import org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
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;
public class DOMTransactionChainTest extends AbstractDatastoreTest {
}
private static void writeTestContainer(final DOMDataTreeWriteTransaction tx) {
- tx.put(OPERATIONAL, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+ tx.put(OPERATIONAL, TestModel.TEST_PATH, ImmutableNodes.newContainerBuilder()
+ .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
+ .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.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;
@RunWith(MockitoJUnitRunner.StrictStubs.class)
public class RoutedDOMRpcRoutingTableEntryTest {
public static final YangInstanceIdentifier TWO_PATH = YangInstanceIdentifier.of(
new NodeIdentifier(Rpcs.BAZ), NodeIdentifierWithPredicates.of(Rpcs.BAZ, Rpcs.NAME, "two"));
- public static final ContainerNode ONE_INPUT = Builders.containerBuilder()
+ public static final ContainerNode ONE_INPUT = ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(Rpcs.INPUT))
.withChild(ImmutableNodes.leafNode(Rpcs.CTX, ONE_PATH))
.build();
- public static final ContainerNode TWO_INPUT = Builders.containerBuilder()
+ public static final ContainerNode TWO_INPUT = ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(Rpcs.INPUT))
.withChild(ImmutableNodes.leafNode(Rpcs.CTX, TWO_PATH))
.build();
- public static final ContainerNode GLOBAL_INPUT = Builders.containerBuilder()
+ public static final ContainerNode GLOBAL_INPUT = ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(Rpcs.INPUT))
// This not covered by schema
.withChild(ImmutableNodes.leafNode(Rpcs.NAME, "name"))
@Test
public void testWrongContext() {
- assertRpcUnavailable(Builders.containerBuilder()
+ assertRpcUnavailable(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(Rpcs.INPUT))
.withChild(ImmutableNodes.leafNode(Rpcs.CTX, "bad type"))
.build());
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.MapNode;
-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;
final class TestUtils {
- private static final MapNode OUTER_LIST = ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
- .withChild(ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1))
+ private static final MapNode OUTER_LIST = ImmutableNodes.newSystemMapBuilder()
+ .withNodeIdentifier(new NodeIdentifier(TestModel.OUTER_LIST_QNAME))
+ .withChild(ImmutableNodes.newMapEntryBuilder()
+ .withNodeIdentifier(NodeIdentifierWithPredicates.of(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1))
+ .withChild(ImmutableNodes.leafNode(TestModel.ID_QNAME, 1))
+ .build())
.build();
private static final String TOP_LEVEL_LIST_FOO_KEY_VALUE = "foo";
private static final QName TOP_LEVEL_LIST_QNAME = QName.create(TOP_QNAME, "top-level-list");
private static final QName TOP_LEVEL_LIST_KEY_QNAME = QName.create(TOP_QNAME, "name");
- private static final MapEntryNode TOP_LEVEL_LIST_NODE = Builders.mapEntryBuilder()
+ private static final MapEntryNode TOP_LEVEL_LIST_NODE = ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(NodeIdentifierWithPredicates.of(
TOP_LEVEL_LIST_QNAME, TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
.withChild(ImmutableNodes.leafNode(TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
.build();
- private static final MapNode CHILD_LIST = ImmutableNodes.mapNodeBuilder(TestModel.TEST_QNAME)
- .withNodeIdentifier(NodeIdentifier.create(TestModel.TEST_QNAME))
+ private static final MapNode CHILD_LIST = ImmutableNodes.newSystemMapBuilder()
+ .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
.withChild(TOP_LEVEL_LIST_NODE)
.build();
- static final ContainerNode TEST_CONTAINER = Builders.containerBuilder()
+ static final ContainerNode TEST_CONTAINER = ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
.withChild(OUTER_LIST)
.build();
- static final ContainerNode TEST_CHILD = Builders.containerBuilder()
+ static final ContainerNode TEST_CHILD = ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
.withChild(CHILD_LIST)
.build();
// Hidden on purpose
}
+ static MapEntryNode mapEntry(final QName listName, final QName keyName, final Object keyValue) {
+ return ImmutableNodes.newMapEntryBuilder()
+ .withNodeIdentifier(NodeIdentifierWithPredicates.of(listName, keyName, keyValue))
+ .withChild(ImmutableNodes.leafNode(keyName, keyValue))
+ .build();
+ }
+
static TestRpcImplementation getTestRpcImplementation() {
return new TestRpcImplementation();
}
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.DataContainerChild;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
+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.MapNode;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
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.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;
public abstract class AbstractInMemoryWriteTransactionBenchmark {
protected static final int WARMUP_ITERATIONS = 6;
protected static final int MEASUREMENT_ITERATIONS = 6;
- protected static final MapNode ONE_ITEM_INNER_LIST = initInnerListItems(1);
- protected static final MapNode TWO_ITEM_INNER_LIST = initInnerListItems(2);
- protected static final MapNode TEN_ITEM_INNER_LIST = initInnerListItems(10);
+ protected static final SystemMapNode ONE_ITEM_INNER_LIST = initInnerListItems(1);
+ protected static final SystemMapNode TWO_ITEM_INNER_LIST = initInnerListItems(2);
+ protected static final SystemMapNode TEN_ITEM_INNER_LIST = initInnerListItems(10);
- private static MapNode initInnerListItems(final int count) {
- final CollectionNodeBuilder<MapEntryNode, SystemMapNode> mapEntryBuilder = ImmutableNodes
- .mapNodeBuilder(BenchmarkModel.INNER_LIST_QNAME);
+ private static SystemMapNode initInnerListItems(final int count) {
+ final var mapBuilder = ImmutableNodes.newSystemMapBuilder()
+ .withNodeIdentifier(new NodeIdentifier(BenchmarkModel.INNER_LIST_QNAME));
for (int i = 1; i <= count; ++i) {
- mapEntryBuilder
- .withChild(ImmutableNodes.mapEntry(BenchmarkModel.INNER_LIST_QNAME, BenchmarkModel.NAME_QNAME, i));
+ Integer key = i;
+ mapBuilder.withChild(ImmutableNodes.newMapEntryBuilder()
+ .withNodeIdentifier(NodeIdentifierWithPredicates.of(BenchmarkModel.INNER_LIST_QNAME,
+ BenchmarkModel.NAME_QNAME, key))
+ .withChild(ImmutableNodes.leafNode(BenchmarkModel.NAME_QNAME, key))
+ .build());
}
- return mapEntryBuilder.build();
+ return mapBuilder.build();
}
- protected static final NormalizedNode[] OUTER_LIST_ONE_ITEM_INNER_LIST = initOuterListItems(OUTER_LIST_100K,
+ protected static final MapEntryNode[] OUTER_LIST_ONE_ITEM_INNER_LIST = initOuterListItems(OUTER_LIST_100K,
ONE_ITEM_INNER_LIST);
- protected static final NormalizedNode[] OUTER_LIST_TWO_ITEM_INNER_LIST = initOuterListItems(OUTER_LIST_50K,
+ protected static final MapEntryNode[] OUTER_LIST_TWO_ITEM_INNER_LIST = initOuterListItems(OUTER_LIST_50K,
TWO_ITEM_INNER_LIST);
- protected static final NormalizedNode[] OUTER_LIST_TEN_ITEM_INNER_LIST = initOuterListItems(OUTER_LIST_10K,
+ protected static final MapEntryNode[] OUTER_LIST_TEN_ITEM_INNER_LIST = initOuterListItems(OUTER_LIST_10K,
TEN_ITEM_INNER_LIST);
- private static NormalizedNode[] initOuterListItems(final int outerListItemsCount, final MapNode innerList) {
- final NormalizedNode[] outerListItems = new NormalizedNode[outerListItemsCount];
+ private static MapEntryNode[] initOuterListItems(final int outerListItemsCount, final SystemMapNode innerList) {
+ final var outerListItems = new MapEntryNode[outerListItemsCount];
for (int i = 0; i < outerListItemsCount; ++i) {
- int outerListKey = i;
- outerListItems[i] = ImmutableNodes
- .mapEntryBuilder(BenchmarkModel.OUTER_LIST_QNAME, BenchmarkModel.ID_QNAME, outerListKey)
- .withChild(innerList).build();
+ Integer key = i;
+ outerListItems[i] = ImmutableNodes.newMapEntryBuilder()
+ .withNodeIdentifier(
+ NodeIdentifierWithPredicates.of(BenchmarkModel.OUTER_LIST_QNAME, BenchmarkModel.ID_QNAME, key))
+ .withChild(ImmutableNodes.leafNode(BenchmarkModel.ID_QNAME, key))
+ .withChild(innerList)
+ .build();
}
return outerListItems;
}
public abstract void tearDown();
- protected static DataContainerChild provideOuterListNode() {
- return Builders.containerBuilder()
+ protected static ContainerNode provideOuterListNode() {
+ return ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(BenchmarkModel.TEST_QNAME))
- .withChild(ImmutableNodes.mapNodeBuilder(BenchmarkModel.OUTER_LIST_QNAME).build()).build();
+ .withChild(ImmutableNodes.newSystemMapBuilder()
+ .withNodeIdentifier(new NodeIdentifier(BenchmarkModel.OUTER_LIST_QNAME))
+ .build())
+ .build();
}
}
import org.opendaylight.mdsal.dom.api.DOMTransactionChain;
import org.opendaylight.mdsal.replicate.common.DataTreeCandidateUtils;
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.stream.ReusableStreamReceiver;
import org.opendaylight.yangtools.yang.data.codec.binfmt.DataTreeCandidateInputOutput;
import org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeDataInput;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
import org.opendaylight.yangtools.yang.data.impl.schema.ReusableImmutableNormalizedNodeStreamWriter;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.slf4j.Logger;
final class SinkRequestHandler extends SimpleChannelInboundHandler<ByteBuf> {
private static final Logger LOG = LoggerFactory.getLogger(SinkRequestHandler.class);
- private static final ContainerNode EMPTY_ROOT = ImmutableNodes.containerNode(SchemaContext.NAME);
+ private static final ContainerNode EMPTY_ROOT = ImmutableNodes.newContainerBuilder()
+ .withNodeIdentifier(NodeIdentifier.create(SchemaContext.NAME))
+ .build();
private final ReusableStreamReceiver receiver = ReusableImmutableNormalizedNodeStreamWriter.create();
private final List<ByteBuf> chunks = new ArrayList<>();
}
private void handleEmptyData() {
- final DOMDataTreeWriteTransaction tx = chain.newWriteOnlyTransaction();
+ final var tx = chain.newWriteOnlyTransaction();
- if (tree.getRootIdentifier().isEmpty()) {
- tx.put(tree.getDatastoreType(), YangInstanceIdentifier.of(), EMPTY_ROOT);
+ if (tree.path().isEmpty()) {
+ tx.put(tree.datastore(), YangInstanceIdentifier.of(), EMPTY_ROOT);
} else {
- tx.delete(tree.getDatastoreType(), tree.getRootIdentifier());
+ tx.delete(tree.datastore(), tree.path());
}
commit(tx);
}
}
final DOMDataTreeWriteTransaction tx = chain.newWriteOnlyTransaction();
- DataTreeCandidateUtils.applyToTransaction(tx, tree.getDatastoreType(), candidate);
+ DataTreeCandidateUtils.applyToTransaction(tx, tree.datastore(), candidate);
commit(tx);
}
private static final Logger LOG = LoggerFactory.getLogger(SinkSingletonService.class);
private static final ServiceGroupIdentifier SGID = new ServiceGroupIdentifier(SinkSingletonService.class.getName());
// TODO: allow different trees?
- private static final DOMDataTreeIdentifier TREE = new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION,
+ private static final DOMDataTreeIdentifier TREE = DOMDataTreeIdentifier.of(LogicalDatastoreType.CONFIGURATION,
YangInstanceIdentifier.of());
private static long CHANNEL_CLOSE_TIMEOUT_S = 10;
private static final ByteBuf TREE_REQUEST;
try (ByteBufOutputStream stream = new ByteBufOutputStream(ret)) {
stream.writeByte(Constants.MSG_SUBSCRIBE_REQ);
try (NormalizedNodeDataOutput output = NormalizedNodeStreamVersion.current().newDataOutput(stream)) {
- tree.getDatastoreType().writeTo(output);
- output.writeYangInstanceIdentifier(tree.getRootIdentifier());
+ tree.datastore().writeTo(output);
+ output.writeYangInstanceIdentifier(tree.path());
}
}
try (var input = new ByteBufInputStream(msg)) {
final var normalizedInput = NormalizedNodeDataInput.newDataInput(input);
- dataTree = new DOMDataTreeIdentifier(LogicalDatastoreType.readFrom(normalizedInput),
+ dataTree = DOMDataTreeIdentifier.of(LogicalDatastoreType.readFrom(normalizedInput),
normalizedInput.readYangInstanceIdentifier());
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.core.general.entity.rev150930.Entity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.core.general.entity.rev150930.EntityBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.core.general.entity.rev150930.EntityKey;
-import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
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.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
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.api.schema.SystemMapNode;
-import org.opendaylight.yangtools.yang.data.api.schema.builder.CollectionNodeBuilder;
-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.SchemaContext;
@RunWith(MockitoJUnitRunner.StrictStubs.class)
@Test
public void testSourceToSink() throws InterruptedException, ExecutionException {
// Make sure to start source...
- final Registration source = NettyReplicationSource.createSource(support, getDomBroker(), css, true, TEST_PORT,
- Duration.ZERO, 5);
- // ... and give it some time start up and open up the port
- Thread.sleep(1000);
-
- // Mocking for sink...
- final DOMTransactionChain sinkChain = mock(DOMTransactionChain.class);
- final DOMDataTreeWriteTransaction sinkTx = mock(DOMDataTreeWriteTransaction.class);
- doReturn(CommitInfo.emptyFluentFuture()).when(sinkTx).commit();
- doReturn(sinkTx).when(sinkChain).newWriteOnlyTransaction();
- final DOMDataBroker sinkBroker = mock(DOMDataBroker.class);
- doReturn(sinkChain).when(sinkBroker).createMergingTransactionChain();
-
- // Kick of the sink ...
- final Registration sink = NettyReplicationSink.createSink(support, sinkBroker, css, true,
- Inet4Address.getLoopbackAddress(), TEST_PORT, Duration.ZERO, Duration.ZERO, 3);
- // ... and sync on it starting up
-
- // verify the connection was established and MSG_EMPTY_DATA was transferred
- verify(sinkBroker, timeout(1000)).createMergingTransactionChain();
- verify(sinkTx, timeout(1000)).put(eq(LogicalDatastoreType.CONFIGURATION), eq(YangInstanceIdentifier.of()),
- any(ContainerNode.class));
-
- // generate some deltas
- final int deltaCount = 5;
- generateModification(getDataBroker(), deltaCount);
-
- // verify that all the deltas were transferred and committed + 1 invocation from receiving MSG_EMPTY_DATA
- verify(sinkChain, timeout(2000).times(deltaCount + 1)).newWriteOnlyTransaction();
- verify(sinkTx, timeout(2000).times(deltaCount + 1)).commit();
-
- sink.close();
- source.close();
+ try (var source = NettyReplicationSource.createSource(support, getDomBroker(), css, true, TEST_PORT,
+ Duration.ZERO, 5)) {
+ // ... and give it some time start up and open up the port
+ Thread.sleep(1000);
+
+ // Mocking for sink...
+ final DOMTransactionChain sinkChain = mock(DOMTransactionChain.class);
+ final DOMDataTreeWriteTransaction sinkTx = mock(DOMDataTreeWriteTransaction.class);
+ doReturn(CommitInfo.emptyFluentFuture()).when(sinkTx).commit();
+ doReturn(sinkTx).when(sinkChain).newWriteOnlyTransaction();
+ final DOMDataBroker sinkBroker = mock(DOMDataBroker.class);
+ doReturn(sinkChain).when(sinkBroker).createMergingTransactionChain();
+
+ // Kick of the sink ...
+ try (var sink = NettyReplicationSink.createSink(support, sinkBroker, css, true,
+ Inet4Address.getLoopbackAddress(), TEST_PORT, Duration.ZERO, Duration.ZERO, 3)) {
+ // ... and sync on it starting up
+
+ // verify the connection was established and MSG_EMPTY_DATA was transferred
+ verify(sinkBroker, timeout(1000)).createMergingTransactionChain();
+ verify(sinkTx, timeout(1000)).put(eq(LogicalDatastoreType.CONFIGURATION),
+ eq(YangInstanceIdentifier.of()), any(ContainerNode.class));
+
+ // generate some deltas
+ final int deltaCount = 5;
+ generateModification(getDataBroker(), deltaCount);
+
+ // verify that all the deltas were transferred and committed + 1 invocation from receiving
+ // MSG_EMPTY_DATA
+ verify(sinkChain, timeout(2000).times(deltaCount + 1)).newWriteOnlyTransaction();
+ verify(sinkTx, timeout(2000).times(deltaCount + 1)).commit();
+ }
+ }
}
/**
generateModification(getDataBroker(), deltaCount);
// Make sure to start source...
- final Registration source = NettyReplicationSource.createSource(support, getDomBroker(), css, true, TEST_PORT,
- Duration.ZERO, 5);
- // ... and give it some time start up and open up the port
- Thread.sleep(1000);
-
- // Mocking for sink...
- final DOMTransactionChain sinkChain = mock(DOMTransactionChain.class);
- final DOMDataTreeWriteTransaction sinkTx = mock(DOMDataTreeWriteTransaction.class);
- doReturn(CommitInfo.emptyFluentFuture()).when(sinkTx).commit();
- doReturn(sinkTx).when(sinkChain).newWriteOnlyTransaction();
- final DOMDataBroker sinkBroker = mock(DOMDataBroker.class);
- doReturn(sinkChain).when(sinkBroker).createMergingTransactionChain();
-
- // Kick of the sink ...
- final Registration sink = NettyReplicationSink.createSink(support, sinkBroker, css, true,
- Inet4Address.getLoopbackAddress(), TEST_PORT, Duration.ZERO, Duration.ZERO, 3);
- // ... and sync on it starting up
-
- // verify the connection was established and MSG_EMPTY_DATA was transferred
- verify(sinkBroker, timeout(1000)).createMergingTransactionChain();
- verify(sinkChain, timeout(2000).times(1)).newWriteOnlyTransaction();
-
- // verify that the initial data invoked onDataTreeChanged() and was transferred to sink
- ArgumentCaptor<NormalizedNode> dataCaptor = ArgumentCaptor.forClass(NormalizedNode.class);
- verify(sinkTx, timeout(2000).times(1)).put(any(), any(), dataCaptor.capture());
- // verify that the initial state contains everything
- NormalizedNode capturedInitialState = dataCaptor.getAllValues().iterator().next();
- NormalizedNode expectedEntityState = generateNormalizedNodeForEntities(deltaCount);
- assertEquals(expectedEntityState, capturedInitialState);
-
- verify(sinkTx, timeout(2000).times(1)).commit();
-
- sink.close();
- source.close();
+ try (var source = NettyReplicationSource.createSource(support, getDomBroker(), css, true, TEST_PORT,
+ Duration.ZERO, 5)) {
+ // ... and give it some time start up and open up the port
+ Thread.sleep(1000);
+
+ // Mocking for sink...
+ final DOMTransactionChain sinkChain = mock(DOMTransactionChain.class);
+ final DOMDataTreeWriteTransaction sinkTx = mock(DOMDataTreeWriteTransaction.class);
+ doReturn(CommitInfo.emptyFluentFuture()).when(sinkTx).commit();
+ doReturn(sinkTx).when(sinkChain).newWriteOnlyTransaction();
+ final DOMDataBroker sinkBroker = mock(DOMDataBroker.class);
+ doReturn(sinkChain).when(sinkBroker).createMergingTransactionChain();
+
+ // Kick of the sink ...
+ try (var sink = NettyReplicationSink.createSink(support, sinkBroker, css, true,
+ Inet4Address.getLoopbackAddress(), TEST_PORT, Duration.ZERO, Duration.ZERO, 3)) {
+ // ... and sync on it starting up
+
+ // verify the connection was established and MSG_EMPTY_DATA was transferred
+ verify(sinkBroker, timeout(1000)).createMergingTransactionChain();
+ verify(sinkChain, timeout(2000).times(1)).newWriteOnlyTransaction();
+
+ // verify that the initial data invoked onDataTreeChanged() and was transferred to sink
+ final var dataCaptor = ArgumentCaptor.forClass(NormalizedNode.class);
+ verify(sinkTx, timeout(2000).times(1)).put(any(), any(), dataCaptor.capture());
+ // verify that the initial state contains everything
+ NormalizedNode capturedInitialState = dataCaptor.getAllValues().iterator().next();
+ NormalizedNode expectedEntityState = generateNormalizedNodeForEntities(deltaCount);
+ assertEquals(expectedEntityState, capturedInitialState);
+
+ verify(sinkTx, timeout(2000).times(1)).commit();
+ }
+ }
}
private static ContainerNode generateNormalizedNodeForEntities(final int amount) {
- final CollectionNodeBuilder<MapEntryNode, SystemMapNode> builder = ImmutableNodes.mapNodeBuilder(ENTITY_QNAME);
+ final var builder = ImmutableNodes.newSystemMapBuilder().withNodeIdentifier(new NodeIdentifier(ENTITY_QNAME));
for (int i = 0; i < amount; i++) {
- builder.withChild(ImmutableNodes.mapEntry(ENTITY_QNAME, ENTITY_NAME_QNAME, "testEntity" + i));
+ final var name = "testEntity" + i;
+ builder.withChild(ImmutableNodes.newMapEntryBuilder()
+ .withNodeIdentifier(NodeIdentifierWithPredicates.of(ENTITY_QNAME, ENTITY_NAME_QNAME, name))
+ .build());
}
- return Builders.containerBuilder()
+ return ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(SchemaContext.NAME))
.withChild(builder.build())
.build();