import static java.util.Objects.requireNonNull;
-import com.google.common.util.concurrent.MoreExecutors;
import java.util.EnumMap;
import java.util.HashMap;
-import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
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.LeafSetNode;
-import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
-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;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
final QName location = QName.create(Schema.QNAME, "location");
final QName namespace = QName.create(Schema.QNAME, "namespace");
- CollectionNodeBuilder<MapEntryNode, SystemMapNode> schemaMapEntryNodeMapNodeCollectionNodeBuilder =
- Builders.mapBuilder().withNodeIdentifier(new NodeIdentifier(Schema.QNAME));
- LeafSetNode<String> locationLeafSet = Builders.<String>leafSetBuilder()
+ final var schemaMapEntryNodeMapNodeCollectionNodeBuilder = ImmutableNodes.newSystemMapBuilder()
+ .withNodeIdentifier(new NodeIdentifier(Schema.QNAME));
+ final var locationLeafSet = ImmutableNodes.<String>newSystemLeafSetBuilder()
.withNodeIdentifier(new NodeIdentifier(location))
- .withChild(Builders.<String>leafSetEntryBuilder()
- .withNodeIdentifier(new NodeWithValue<>(location, "NETCONF"))
- .withValue("NETCONF")
- .build())
+ .withChildValue("NETCONF")
.build();
- Map<QName, Object> keyValues = new HashMap<>();
+ final var keyValues = new HashMap<QName, Object>();
for (final Schema schema : monitor.getSchemas().nonnullSchema().values()) {
keyValues.put(identifier, schema.getIdentifier());
keyValues.put(version, schema.getVersion());
keyValues.put(format, Yang.QNAME);
- schemaMapEntryNodeMapNodeCollectionNodeBuilder.withChild(Builders.mapEntryBuilder()
+ schemaMapEntryNodeMapNodeCollectionNodeBuilder.withChild(ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(NodeIdentifierWithPredicates.of(Schema.QNAME, keyValues))
.withChild(ImmutableNodes.leafNode(identifier, schema.getIdentifier()))
.withChild(ImmutableNodes.leafNode(version, schema.getVersion()))
.build());
}
- return Builders.containerBuilder()
+ return ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(NetconfState.QNAME))
- .withChild(Builders.containerBuilder()
+ .withChild(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(Schemas.QNAME))
.withChild(schemaMapEntryNodeMapNodeCollectionNodeBuilder.build())
.build())
datastores.put(LogicalDatastoreType.CONFIGURATION, configStore);
datastores.put(LogicalDatastoreType.OPERATIONAL, operStore);
- return new SerializedDOMDataBroker(datastores, MoreExecutors.listeningDecorator(listenableFutureExecutor));
+ return new SerializedDOMDataBroker(datastores, listenableFutureExecutor);
}
private DOMSchemaService createSchemaService() {
import org.opendaylight.yangtools.yang.common.Uint16;
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.ChoiceNode;
-import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode;
import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter;
import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactory;
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.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.stmt.SchemaNodeIdentifier.Absolute;
import org.slf4j.Logger;
return normalizedNodeToString(createNormalizedNodePayload(devices, parameters));
}
- private static String normalizedNodeToString(final NormalizedNode node) {
+ private static String normalizedNodeToString(final SystemMapNode node) {
final StringWriter writer = new StringWriter();
final JsonWriter jsonWriter = JsonWriterFactory.createJsonWriter(writer, DEFAULT_REQUEST_PAYLOAD_INDENTATION);
final NormalizedNodeStreamWriter jsonStream = JSONNormalizedNodeStreamWriter.createExclusiveWriter(
return writer.toString();
}
- private static NormalizedNode createNormalizedNodePayload(final List<Integer> devices,
+ private static SystemMapNode createNormalizedNodePayload(final List<Integer> devices,
final TesttoolParameters parameters) {
- final var nodeBuilder = Builders.mapBuilder().withNodeIdentifier(NodeIdentifier.create(Node.QNAME));
+ final var nodeBuilder = ImmutableNodes.newSystemMapBuilder()
+ .withNodeIdentifier(NodeIdentifier.create(Node.QNAME));
for (final Integer device : devices) {
- nodeBuilder.withChild(Builders.mapEntryBuilder()
- .withNodeIdentifier(NodeIdentifierWithPredicates.of(Node.QNAME, NODE_ID_QNAME,
- createNodeID(device)))
- .withChild(leafPort(device))
- .withChild(leafHost(parameters.generateConfigsAddress))
- .withChild(containerCredentials(DEFAULT_NODE_USERNAME, DEFAULT_NODE_PASSWORD))
- .withChild(leafTcpOnly(!parameters.ssh))
- .withChild(leafKeepaliveDelay(DEFAULT_NODE_KEEPALIVE_DELAY))
- .withChild(leafSchemaless(DEFAULT_NODE_SCHEMALESS))
- .build());
- }
-
- return Builders.mapBuilder()
- .withNodeIdentifier(NodeIdentifier.create(Topology.QNAME))
- .withChild(Builders.mapEntryBuilder().withNodeIdentifier(NodeIdentifierWithPredicates
- .of(Topology.QNAME, TOPOLOGY_ID_QNAME, DEFAULT_TOPOLOGY_ID))
- .withChild(nodeBuilder.build())
+ nodeBuilder.withChild(ImmutableNodes.newMapEntryBuilder()
+ .withNodeIdentifier(NodeIdentifierWithPredicates.of(Node.QNAME, NODE_ID_QNAME, device + "-sim-device"))
+ .withChild(ImmutableNodes.leafNode(PORT_NODE_IDENTIFIER, Uint16.valueOf(device)))
+ .withChild(ImmutableNodes.leafNode(HOST_NODE_IDENTIFIER, parameters.generateConfigsAddress))
+ .withChild(ImmutableNodes.newChoiceBuilder()
+ .withNodeIdentifier(CREDENTIALS_NODE_IDENTIFIER)
+ .withChild(ImmutableNodes.newContainerBuilder()
+ .withNodeIdentifier(LOGIN_PASSWORD_UNENCRYPTED_NODE_IDENTIFIER)
+ .withChild(ImmutableNodes.leafNode(USERNAME_NODE_IDENTIFIER, DEFAULT_NODE_USERNAME))
+ .withChild(ImmutableNodes.leafNode(PASSWORD_NODE_IDENTIFIER, DEFAULT_NODE_PASSWORD))
.build())
- .build();
- }
-
- private static String createNodeID(final Integer port) {
- return String.format("%d-sim-device", port);
- }
-
- private static LeafNode<Uint16> leafPort(final int port) {
- return Builders.<Uint16>leafBuilder()
- .withNodeIdentifier(PORT_NODE_IDENTIFIER)
- .withValue(Uint16.valueOf(port))
- .build();
- }
-
- private static LeafNode<String> leafHost(final String host) {
- return Builders.<String>leafBuilder()
- .withNodeIdentifier(HOST_NODE_IDENTIFIER)
- .withValue(host)
- .build();
- }
-
- private static ChoiceNode containerCredentials(final String username, final String password) {
- return Builders.choiceBuilder().withNodeIdentifier(CREDENTIALS_NODE_IDENTIFIER)
- .withChild(Builders.containerBuilder().withNodeIdentifier(LOGIN_PASSWORD_UNENCRYPTED_NODE_IDENTIFIER)
- .withChild(Builders.<String>leafBuilder()
- .withNodeIdentifier(USERNAME_NODE_IDENTIFIER)
- .withValue(username)
- .build())
- .withChild(Builders.<String>leafBuilder()
- .withNodeIdentifier(PASSWORD_NODE_IDENTIFIER)
- .withValue(password)
- .build())
- .build())
- .build();
- }
-
- private static LeafNode<Boolean> leafTcpOnly(final Boolean tcpOnly) {
- return Builders.<Boolean>leafBuilder()
- .withNodeIdentifier(TCP_ONLY_NODE_IDENTIFIER)
- .withValue(tcpOnly)
- .build();
- }
-
- private static LeafNode<Integer> leafKeepaliveDelay(final Integer keepaliveDelay) {
- return Builders.<Integer>leafBuilder()
- .withNodeIdentifier(KEEPALIVE_DELAY_NODE_IDENTIFIER)
- .withValue(keepaliveDelay)
- .build();
- }
+ .build())
+ .withChild(ImmutableNodes.leafNode(TCP_ONLY_NODE_IDENTIFIER, !parameters.ssh))
+ .withChild(ImmutableNodes.leafNode(KEEPALIVE_DELAY_NODE_IDENTIFIER, DEFAULT_NODE_KEEPALIVE_DELAY))
+ .withChild(ImmutableNodes.leafNode(SCHEMALESS_NODE_IDENTIFIER, DEFAULT_NODE_SCHEMALESS))
+ .build());
+ }
- private static LeafNode<Boolean> leafSchemaless(final Boolean schemaless) {
- return Builders.<Boolean>leafBuilder()
- .withNodeIdentifier(SCHEMALESS_NODE_IDENTIFIER)
- .withValue(schemaless)
- .build();
+ return ImmutableNodes.newSystemMapBuilder()
+ .withNodeIdentifier(NodeIdentifier.create(Topology.QNAME))
+ .withChild(ImmutableNodes.newMapEntryBuilder()
+ .withNodeIdentifier(NodeIdentifierWithPredicates.of(Topology.QNAME,
+ TOPOLOGY_ID_QNAME, DEFAULT_TOPOLOGY_ID))
+ .withChild(nodeBuilder.build())
+ .build())
+ .build();
}
}