<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>feature-repo-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
- <artifactId>odl-message-bus-collector</artifactId>
- <version>1.11.0</version>
+ <artifactId>odl-controller-exp-messagebus</artifactId>
+ <version>2.0.0</version>
<type>xml</type>
<classifier>features</classifier>
</dependency>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>mdsal-artifacts</artifactId>
- <version>5.0.9</version>
+ <version>6.0.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-artifacts</artifactId>
- <version>1.11.0</version>
+ <artifactId>controller-artifacts</artifactId>
+ <version>2.0.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<groupId>org.opendaylight.netconf</groupId>
<artifactId>netconf-topology</artifactId>
</dependency>
- <dependency>
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>netconf-config</artifactId>
- </dependency>
<dependency>
<groupId>org.opendaylight.aaa</groupId>
<artifactId>odl-aaa-encryption-service</artifactId>
-->
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="odl-netconf-${project.version}">
<feature name="odl-netconf-connector" version="${project.version}">
- <feature version="[3,4)">odl-mdsal-model-draft-clemm-netmod-yang-network-topo-01-minimal</feature>
+ <feature version="[6,7)">odl-mdsal-model-draft-clemm-netmod-yang-network-topo-01-minimal</feature>
</feature>
</features>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>feature-repo-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-artifacts</artifactId>
- <version>4.0.6</version>
+ <version>5.0.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>mdsal-artifacts</artifactId>
- <version>5.0.9</version>
+ <version>6.0.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
-->
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="odl-netconf-${project.version}">
<feature name="odl-netconf-api" version="${project.version}">
- <feature version="[6,7)">odl-netty-4</feature>
- <feature version="[4,5)">odl-yangtools-parser-api</feature>
- <feature version="[3,4)">odl-mdsal-model-rfc7895</feature>
- <feature version="[3,4)">odl-mdsal-model-rfc8342</feature>
+ <feature version="[7,8)">odl-netty-4</feature>
+ <feature version="[5,6)">odl-yangtools-parser-api</feature>
+ <feature version="[6,7)">odl-mdsal-model-rfc7895</feature>
+ <feature version="[6,7)">odl-mdsal-model-rfc8342</feature>
</feature>
</features>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<packaging>feature</packaging>
<dependencies>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>odl-controller-exp-netty-config</artifactId>
+ <version>2.0.0</version>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>odl-netconf-netty-util</artifactId>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
-->
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="odl-netconf-${project.version}">
<feature name="odl-netconf-netty-util" version="${project.version}">
- <feature version="[6,7)">odl-apache-sshd</feature>
+ <feature version="[7,8)">odl-apache-sshd</feature>
</feature>
</features>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>mdsal-artifacts</artifactId>
- <version>5.0.9</version>
+ <version>6.0.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>odl-yangtools-codec</artifactId>
- <version>4.0.6</version>
+ <version>5.0.1</version>
<type>xml</type>
<classifier>features</classifier>
</dependency>
<configfile finalname="etc/netconf.cfg">
mvn:org.opendaylight.netconf/netconf-util/${project.version}/cfg/config
</configfile>
- <feature version="[4,5)">odl-yangtools-codec</feature>
+ <feature version="[5,6)">odl-yangtools-codec</feature>
</feature>
</features>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>feature-repo-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<dependencies>
<dependency>
<groupId>org.opendaylight.odlparent</groupId>
- <artifactId>odl-jackson-2.9</artifactId>
- <version>6.0.4</version>
+ <artifactId>odl-jackson-2.10</artifactId>
+ <version>7.0.1</version>
<type>xml</type>
<classifier>features</classifier>
</dependency>
-->
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="odl-netconf-${project.version}">
<feature name="odl-mdsal-apidocs" version="${project.version}">
- <feature version="[6,7)">odl-jackson-2.9</feature>
+ <feature version="[7,8)">odl-jackson-2.10</feature>
</feature>
</features>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-artifacts</artifactId>
- <version>4.0.6</version>
+ <version>5.0.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>mdsal-artifacts</artifactId>
- <version>5.0.9</version>
+ <version>6.0.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-artifacts</artifactId>
- <version>1.11.0</version>
+ <artifactId>controller-artifacts</artifactId>
+ <version>2.0.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
-->
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="odl-netconf-${project.version}">
<feature name="odl-restconf-common" version="${project.version}">
- <feature version="[6,7)">odl-karaf-feat-jetty</feature>
- <feature version="[4,5)">odl-yangtools-export</feature>
- <feature version="[3,4)">odl-mdsal-model-rfc7895</feature>
+ <feature version="[7,8)">odl-karaf-feat-jetty</feature>
+ <feature version="[5,6)">odl-yangtools-export</feature>
+ <feature version="[6,7)">odl-mdsal-model-rfc7895</feature>
</feature>
</features>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>mdsal-artifacts</artifactId>
- <version>5.0.9</version>
+ <version>6.0.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<dependencyManagement>
<dependencies>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>controller-artifacts</artifactId>
+ <version>2.0.0</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
<dependency>
<groupId>org.opendaylight.netconf</groupId>
<artifactId>netconf-artifacts</artifactId>
</dependencyManagement>
<dependencies>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>odl-controller-exp-netty-config</artifactId>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </dependency>
<dependency>
<groupId>org.opendaylight.netconf</groupId>
<artifactId>odl-restconf-common</artifactId>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>feature-repo-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
-->
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="odl-netconf-${project.version}">
<feature name="odl-yanglib" version="${project.version}">
- <feature version="[6,7)">odl-karaf-feat-jetty</feature>
+ <feature version="[7,8)">odl-karaf-feat-jetty</feature>
</feature>
</features>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>karaf4-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<groupId>org.opendaylight.netconf</groupId>
import org.opendaylight.netconf.client.NetconfClientSession;
import org.opendaylight.netconf.client.NetconfClientSessionListener;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Host;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPasswordBuilder;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
Node getConfigNode() {
return new NodeBuilder()
.setNodeId(getId())
- .addAugmentation(NetconfNode.class, new NetconfNodeBuilder()
+ .addAugmentation(new NetconfNodeBuilder()
.setHost(new Host(key.getIpAddress()))
.setPort(key.getPort())
.setTcpOnly(Boolean.FALSE)
import java.io.IOException;
import java.security.GeneralSecurityException;
import java.security.PublicKey;
-import java.util.ArrayList;
import java.util.Collection;
-import java.util.List;
+import java.util.Collections;
import java.util.Optional;
import java.util.concurrent.ExecutionException;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.netconf.callhome.protocol.AuthorizedKeysDecoder;
import org.opendaylight.netconf.callhome.protocol.StatusRecorder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.callhome.device.status.rev170112.Device1;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.callhome.device.status.rev170112.Device1.DeviceStatus;
import org.opendaylight.yang.gen.v1.urn.opendaylight.callhome.device.status.rev170112.Device1Builder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeConnectionStatus;
} catch (IOException e) {
LOG.warn("Unable to encode public key to ssh format.", e);
}
- Device1 d1 = new Device1Builder().setDeviceStatus(Device1.DeviceStatus.FAILEDNOTALLOWED).build();
- DeviceBuilder builder = new DeviceBuilder()
+ return new DeviceBuilder()
.setUniqueId(id)
.withKey(new DeviceKey(id))
.setSshHostKey(sshEncodedKey)
- .addAugmentation(Device1.class, d1);
-
- return builder.build();
+ .addAugmentation(new Device1Builder().setDeviceStatus(Device1.DeviceStatus.FAILEDNOTALLOWED).build())
+ .build();
}
private Device readAndGetDevice(final NodeId nodeId) {
}
private static Device withConnectedStatus(final Device opDev) {
- Device1 status = new Device1Builder().setDeviceStatus(Device1.DeviceStatus.CONNECTED).build();
- return new DeviceBuilder().addAugmentation(Device1.class, status).setUniqueId(opDev.getUniqueId())
- .setSshHostKey(opDev.getSshHostKey()).build();
+ return deviceWithStatus(opDev, Device1.DeviceStatus.CONNECTED);
}
private static Device withFailedStatus(final Device opDev) {
- Device1 status = new Device1Builder().setDeviceStatus(Device1.DeviceStatus.FAILED).build();
- return new DeviceBuilder().addAugmentation(Device1.class, status).setUniqueId(opDev.getUniqueId())
- .setSshHostKey(opDev.getSshHostKey()).build();
+ return deviceWithStatus(opDev, DeviceStatus.FAILED);
}
private static Device withDisconnectedStatus(final Device opDev) {
- Device1 status = new Device1Builder().setDeviceStatus(Device1.DeviceStatus.DISCONNECTED).build();
- return new DeviceBuilder().addAugmentation(Device1.class, status).setUniqueId(opDev.getUniqueId())
- .setSshHostKey(opDev.getSshHostKey()).build();
+ return deviceWithStatus(opDev, DeviceStatus.DISCONNECTED);
}
private static Device withFailedAuthStatus(final Device opDev) {
- Device1 status = new Device1Builder().setDeviceStatus(Device1.DeviceStatus.FAILEDAUTHFAILURE).build();
- return new DeviceBuilder().addAugmentation(Device1.class, status).setUniqueId(opDev.getUniqueId())
- .setSshHostKey(opDev.getSshHostKey()).build();
+ return deviceWithStatus(opDev, DeviceStatus.FAILEDAUTHFAILURE);
+ }
+
+ private static Device deviceWithStatus(final Device opDev, final DeviceStatus status) {
+ return new DeviceBuilder()
+ .setUniqueId(opDev.getUniqueId())
+ .setSshHostKey(opDev.getSshHostKey())
+ .addAugmentation(new Device1Builder().setDeviceStatus(status).build())
+ .build();
}
private void setDeviceStatus(final Device device) {
}
}
- private List<Device> getDevicesAsList() {
+ private Collection<Device> getDevicesAsList() {
AllowedDevices devices = getDevices();
- return devices == null ? new ArrayList<>() : devices.getDevice();
+ return devices == null ? Collections.emptyList() : devices.nonnullDevice().values();
}
@Override
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
-import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ExecutionException;
}, MoreExecutors.directExecutor());
}
- private static List<Device> getReadDevices(final ListenableFuture<Optional<AllowedDevices>> devicesFuture)
+ private static Collection<Device> getReadDevices(final ListenableFuture<Optional<AllowedDevices>> devicesFuture)
throws InterruptedException, ExecutionException {
- return devicesFuture.get().map(AllowedDevices::getDevice).orElse(Collections.emptyList());
+ return devicesFuture.get().map(AllowedDevices::nonnullDevice).orElse(Collections.emptyMap()).values();
}
private void readAndUpdateStatus(final Device cfgDevice) throws InterruptedException, ExecutionException {
}
tx.merge(LogicalDatastoreType.OPERATIONAL, deviceIID, new DeviceBuilder()
- .addAugmentation(Device1.class, devStatus).setSshHostKey(cfgDevice.getSshHostKey())
+ .addAugmentation(devStatus).setSshHostKey(cfgDevice.getSshHostKey())
.setUniqueId(cfgDevice.getUniqueId()).build());
tx.commit().addCallback(new FutureCallback<CommitInfo>() {
@Override
*/
package org.opendaylight.netconf.mdsal.connector;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkState;
+
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import org.opendaylight.netconf.api.capability.Capability;
import org.opendaylight.netconf.api.monitoring.CapabilityListener;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextListener;
import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider;
-public class CurrentSchemaContext implements SchemaContextListener, AutoCloseable {
- private final AtomicReference<SchemaContext> currentContext = new AtomicReference<>();
- private final ListenerRegistration<SchemaContextListener> schemaContextListenerListenerRegistration;
+public class CurrentSchemaContext implements EffectiveModelContextListener, AutoCloseable {
+ private final AtomicReference<EffectiveModelContext> currentContext = new AtomicReference<>();
+ private final ListenerRegistration<?> schemaContextListenerListenerRegistration;
private final Set<CapabilityListener> listeners1 = Collections.synchronizedSet(new HashSet<>());
private final SchemaSourceProvider<YangTextSchemaSource> rootSchemaSourceProvider;
- public SchemaContext getCurrentContext() {
- Preconditions.checkState(currentContext.get() != null, "Current context not received");
+ public EffectiveModelContext getCurrentContext() {
+ checkState(currentContext.get() != null, "Current context not received");
return currentContext.get();
}
}
@Override
- public void onGlobalContextUpdated(final SchemaContext schemaContext) {
+ public void onModelContextUpdated(final EffectiveModelContext schemaContext) {
currentContext.set(schemaContext);
// FIXME is notifying all the listeners from this callback wise ?
final Set<Capability> addedCaps = MdsalNetconfOperationServiceFactory.transformCapabilities(
// Added by netconf-impl by default
// capabilities.add(new BasicCapability("urn:ietf:params:netconf:capability:candidate:1.0"));
- final Set<Module> modules = currentContext.getModules();
- for (final Module module : modules) {
+ for (final Module module : currentContext.getModules()) {
Optional<YangModuleCapability> cap = moduleToCapability(module, rootSchemaSourceProviderDependency);
if (cap.isPresent()) {
capabilities.add(cap.get());
protected DataSchemaNode getSchemaNodeFromNamespace(final String namespace, final XmlElement element)
throws DocumentedException {
- final Iterator<Module> it;
+ final Iterator<? extends Module> it;
try {
// Returns module with newest revision since findModuleByNamespace returns a set of modules and we only
// need the newest one
@Override
protected HandlingPriority canHandle(final String netconfOperationName, final String namespace) {
final URI namespaceURI = createNsUri(namespace);
- final Optional<Module> module = getModule(namespaceURI);
+ final Optional<? extends Module> module = getModule(namespaceURI);
if (!module.isPresent()) {
LOG.debug("Cannot handle rpc: {}, {}", netconfOperationName, namespace);
}
//this returns module with the newest revision if more then 1 module with same namespace is found
- private Optional<Module> getModule(final URI namespaceURI) {
+ private Optional<? extends Module> getModule(final URI namespaceURI) {
return schemaContext.getCurrentContext().findModules(namespaceURI).stream().findFirst();
}
}
final URI namespaceURI = createNsUri(netconfOperationNamespace);
- final Optional<Module> moduleOptional = getModule(namespaceURI);
+ final Optional<? extends Module> moduleOptional = getModule(namespaceURI);
if (!moduleOptional.isPresent()) {
throw new DocumentedException("Unable to find module in Schema Context with namespace and name : "
final RpcDefinition rpcDefinition = rpcDefinitionOptional.get();
final SchemaPath schemaPath = SchemaPath.create(Collections.singletonList(rpcDefinition.getQName()), true);
- final NormalizedNode<?, ?> inputNode = rpcToNNode(operationElement, rpcDefinition.getInput());
+ final ContainerNode inputNode = rpcToNNode(operationElement, rpcDefinition.getInput());
final DOMRpcResult result;
try {
* @return parsed rpc into normalized node, or null if input schema is null
*/
@SuppressWarnings("checkstyle:IllegalCatch")
- private @Nullable NormalizedNode<?, ?> rpcToNNode(final XmlElement element,
+ private @Nullable ContainerNode rpcToNNode(final XmlElement element,
final @Nullable ContainerSchemaNode input) throws DocumentedException {
- if (input == null || input.getChildNodes().isEmpty()) {
- return null;
- }
-
final NormalizedNodeResult resultHolder = new NormalizedNodeResult();
final NormalizedNodeStreamWriter writer = ImmutableNormalizedNodeStreamWriter.from(resultHolder);
final XmlParserStream xmlParser = XmlParserStream.create(writer, schemaContext.getCurrentContext(), input);
ErrorTag.MALFORMED_MESSAGE, ErrorSeverity.ERROR);
}
- return resultHolder.getResult();
+ return (ContainerNode) resultHolder.getResult();
}
}
*/
private DataSchemaNode getRootDataSchemaNode(final Module module, final URI nameSpace, final String name)
throws DocumentedException {
- final Collection<DataSchemaNode> childNodes = module.getChildNodes();
- for (final DataSchemaNode childNode : childNodes) {
+ for (final DataSchemaNode childNode : module.getChildNodes()) {
final QName qName = childNode.getQName();
if (qName.getNamespace().equals(nameSpace) && qName.getLocalName().equals(name)) {
return childNode;
import org.opendaylight.netconf.util.test.NetconfXmlUnitRecursiveQualifier;
import org.opendaylight.netconf.util.test.XmlFileLoader;
import org.opendaylight.yangtools.util.concurrent.SpecialExecutors;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final String DATA_ELEMENT = "data";
protected static final Document RPC_REPLY_OK = getReplyOk();
- private static SchemaContext SCHEMA_CONTEXT;
+ private static EffectiveModelContext SCHEMA_CONTEXT;
private CurrentSchemaContext currentSchemaContext;
private TransactionProvider transactionProvider;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextListener;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
@Override
public FluentFuture<DOMRpcResult> invokeRpc(final SchemaPath type, final NormalizedNode<?, ?> input) {
final Collection<DataContainerChild<? extends PathArgument, ?>> children =
- (Collection<DataContainerChild<? extends PathArgument, ?>>) input.getValue();
+ ((ContainerNode) input).getValue();
final Module module = SCHEMA_CONTEXT.findModules(type.getLastComponent().getNamespace()).stream()
.findFirst().orElse(null);
final RpcDefinition rpcDefinition = getRpcDefinitionFromModule(
}
};
- private static SchemaContext SCHEMA_CONTEXT = null;
+ private static EffectiveModelContext SCHEMA_CONTEXT = null;
private CurrentSchemaContext currentSchemaContext = null;
@Mock
private DOMSchemaService schemaService;
@Mock
- private SchemaContextListener listener;
+ private EffectiveModelContextListener listener;
@Mock
private ListenerRegistration<?> registration;
@Mock
doReturn(null).when(schemaService).getGlobalContext();
doReturn(null).when(schemaService).getSessionContext();
doAnswer(invocationOnMock -> {
- ((SchemaContextListener) invocationOnMock.getArguments()[0]).onGlobalContextUpdated(SCHEMA_CONTEXT);
+ ((EffectiveModelContextListener) invocationOnMock.getArguments()[0]).onModelContextUpdated(SCHEMA_CONTEXT);
return registration;
- }).when(schemaService).registerSchemaContextListener(any(SchemaContextListener.class));
+ }).when(schemaService).registerSchemaContextListener(any(EffectiveModelContextListener.class));
XMLUnit.setIgnoreWhitespace(true);
XMLUnit.setIgnoreAttributeOrder(true);
*/
package org.opendaylight.netconf.mdsal.connector.ops;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.collect.ClassToInstanceMap;
import com.google.common.collect.ImmutableClassToInstanceMap;
import org.opendaylight.mdsal.dom.api.DOMSchemaService;
import org.opendaylight.mdsal.dom.api.DOMSchemaServiceExtension;
import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextListener;
final class SchemaServiceStub implements DOMSchemaService {
- private final SchemaContext schemaContext;
-
- SchemaServiceStub(SchemaContext schemaContext) {
- this.schemaContext = schemaContext;
- }
+ private final EffectiveModelContext schemaContext;
- @Override
- public SchemaContext getSessionContext() {
- return schemaContext;
+ SchemaServiceStub(final EffectiveModelContext schemaContext) {
+ this.schemaContext = requireNonNull(schemaContext);
}
@Override
- public SchemaContext getGlobalContext() {
+ public EffectiveModelContext getGlobalContext() {
return schemaContext;
}
@Override
- public ListenerRegistration<SchemaContextListener> registerSchemaContextListener(
- final SchemaContextListener listener) {
- listener.onGlobalContextUpdated(getGlobalContext());
- return new AbstractListenerRegistration<SchemaContextListener>(listener) {
+ public ListenerRegistration<EffectiveModelContextListener> registerSchemaContextListener(
+ final EffectiveModelContextListener listener) {
+ listener.onModelContextUpdated(schemaContext);
+ return new AbstractListenerRegistration<>(listener) {
@Override
protected void removeRegistration() {
// No-op
</dependency>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-binding-generator-impl</artifactId>
+ <artifactId>mdsal-binding-api</artifactId>
</dependency>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-binding-api</artifactId>
+ <artifactId>mdsal-binding-dom-codec-spi</artifactId>
</dependency>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-binding-dom-codec</artifactId>
+ <artifactId>mdsal-binding-runtime-spi</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<groupId>${project.groupId}</groupId>
<artifactId>netconf-util</artifactId>
</dependency>
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ <optional>true</optional>
+ </dependency>
+
<dependency>
<groupId>org.xmlunit</groupId>
<artifactId>xmlunit-legacy</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>mdsal-binding-generator-impl</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>mdsal-binding-dom-codec</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
import com.google.common.collect.HashMultimap;
import com.google.common.collect.HashMultiset;
-import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.google.common.collect.Multiset;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
+import javax.inject.Inject;
+import javax.inject.Singleton;
import org.checkerframework.checker.lock.qual.GuardedBy;
import org.opendaylight.netconf.mdsal.notification.impl.ops.NotificationsTransformUtil;
import org.opendaylight.netconf.notifications.BaseNotificationPublisherRegistration;
/**
* A thread-safe implementation NetconfNotificationRegistry.
*/
+@Singleton
public class NetconfNotificationManager implements NetconfNotificationCollector, NetconfNotificationRegistry,
NetconfNotificationListener, AutoCloseable {
public static final StreamNameType BASE_STREAM_NAME = new StreamNameType("NETCONF");
- public static final Stream BASE_NETCONF_STREAM;
-
- static {
- BASE_NETCONF_STREAM = new StreamBuilder()
+ public static final Stream BASE_NETCONF_STREAM = new StreamBuilder()
.setName(BASE_STREAM_NAME)
.withKey(new StreamKey(BASE_STREAM_NAME))
.setReplaySupport(false)
.setDescription("Default Event Stream")
.build();
- }
private static final Logger LOG = LoggerFactory.getLogger(NetconfNotificationManager.class);
@GuardedBy("this")
private final Set<GenericNotificationPublisherReg> notificationPublishers = new HashSet<>();
+ private final NotificationsTransformUtil transformUtil;
+
+ @Inject
+ public NetconfNotificationManager(final NotificationsTransformUtil transformUtil) {
+ this.transformUtil = requireNonNull(transformUtil);
+ }
@Override
public synchronized void onNotification(final StreamNameType stream, final NetconfNotification notification) {
@Override
public synchronized Streams getNotificationPublishers() {
- return new StreamsBuilder().setStream(Lists.newArrayList(streamMetadata.values())).build();
+ return new StreamsBuilder().setStream(Maps.uniqueIndex(streamMetadata.values(), Stream::key)).build();
}
@Override
public BaseNotificationPublisherRegistration registerBaseNotificationPublisher() {
final NotificationPublisherRegistration notificationPublisherRegistration =
registerNotificationPublisher(BASE_NETCONF_STREAM);
- return new BaseNotificationPublisherReg(notificationPublisherRegistration);
+ return new BaseNotificationPublisherReg(transformUtil, notificationPublisherRegistration);
}
@Override
public YangLibraryPublisherRegistration registerYangLibraryPublisher() {
final NotificationPublisherRegistration notificationPublisherRegistration =
registerNotificationPublisher(BASE_NETCONF_STREAM);
- return new YangLibraryPublisherReg(notificationPublisherRegistration);
+ return new YangLibraryPublisherReg(transformUtil, notificationPublisherRegistration);
}
private static class GenericNotificationPublisherReg implements NotificationPublisherRegistration {
static final SchemaPath SESSION_END_PATH = SchemaPath.create(true, NetconfSessionEnd.QNAME);
private final NotificationPublisherRegistration baseRegistration;
+ private final NotificationsTransformUtil transformUtil;
- BaseNotificationPublisherReg(final NotificationPublisherRegistration baseRegistration) {
+ BaseNotificationPublisherReg(final NotificationsTransformUtil transformUtil,
+ final NotificationPublisherRegistration baseRegistration) {
+ this.transformUtil = requireNonNull(transformUtil);
this.baseRegistration = baseRegistration;
}
baseRegistration.close();
}
- private static NetconfNotification serializeNotification(final Notification notification,
- final SchemaPath path) {
- return NotificationsTransformUtil.transform(notification, path);
+ private NetconfNotification serializeNotification(final Notification notification, final SchemaPath path) {
+ return transformUtil.transform(notification, path);
}
@Override
static final SchemaPath YANG_LIBRARY_CHANGE_PATH = SchemaPath.create(true, YangLibraryChange.QNAME);
private final NotificationPublisherRegistration baseRegistration;
+ private final NotificationsTransformUtil transformUtil;
- YangLibraryPublisherReg(final NotificationPublisherRegistration baseRegistration) {
+ YangLibraryPublisherReg(final NotificationsTransformUtil transformUtil,
+ final NotificationPublisherRegistration baseRegistration) {
+ this.transformUtil = requireNonNull(transformUtil);
this.baseRegistration = baseRegistration;
}
@Override
- public void onYangLibraryChange(YangLibraryChange yangLibraryChange) {
- baseRegistration.onNotification(BASE_STREAM_NAME, NotificationsTransformUtil
- .transform(yangLibraryChange, YANG_LIBRARY_CHANGE_PATH));
+ public void onYangLibraryChange(final YangLibraryChange yangLibraryChange) {
+ baseRegistration.onNotification(BASE_STREAM_NAME,
+ transformUtil.transform(yangLibraryChange, YANG_LIBRARY_CHANGE_PATH));
}
@Override
public void onStreamRegistered(final Stream stream) {
final WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
- final InstanceIdentifier<Stream> streamIdentifier = STREAMS.child(Stream.class, stream.key());
- tx.merge(LogicalDatastoreType.OPERATIONAL, streamIdentifier, stream, true);
+ tx.merge(LogicalDatastoreType.OPERATIONAL, STREAMS.child(Stream.class, stream.key()), stream);
try {
tx.commit().get();
*/
package org.opendaylight.netconf.mdsal.notification.impl.ops;
-import static com.google.common.base.Preconditions.checkState;
-import static java.util.Objects.requireNonNull;
+import static com.google.common.base.Verify.verify;
-import com.google.common.collect.Collections2;
-import com.google.common.collect.Iterables;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.IOException;
-import java.util.Collections;
import java.util.Date;
import java.util.Optional;
+import javax.inject.Singleton;
import javax.xml.stream.XMLStreamException;
import javax.xml.transform.dom.DOMResult;
-import org.opendaylight.mdsal.binding.dom.codec.impl.BindingNormalizedNodeCodecRegistry;
-import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext;
-import org.opendaylight.mdsal.binding.generator.util.BindingRuntimeContext;
+import org.opendaylight.binding.runtime.api.BindingRuntimeContext;
+import org.opendaylight.binding.runtime.api.BindingRuntimeGenerator;
+import org.opendaylight.binding.runtime.spi.BindingRuntimeHelpers;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
+import org.opendaylight.mdsal.binding.dom.codec.spi.BindingDOMCodecFactory;
import org.opendaylight.netconf.api.xml.XmlUtil;
import org.opendaylight.netconf.notifications.NetconfNotification;
import org.opendaylight.netconf.util.NetconfUtil;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.$YangModuleInfoImpl;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.Netconf;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfConfigChange;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.YangLibraryChange;
import org.opendaylight.yangtools.yang.binding.Notification;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.parser.api.YangParserFactory;
import org.w3c.dom.Document;
+@Singleton
public final class NotificationsTransformUtil {
- static final SchemaContext NOTIFICATIONS_SCHEMA_CTX;
- static final BindingNormalizedNodeCodecRegistry CODEC_REGISTRY;
- static final RpcDefinition CREATE_SUBSCRIPTION_RPC;
-
- static {
- final ModuleInfoBackedContext moduleInfoBackedContext = ModuleInfoBackedContext.create();
- moduleInfoBackedContext.addModuleInfos(Collections.singletonList($YangModuleInfoImpl.getInstance()));
- moduleInfoBackedContext.addModuleInfos(Collections.singletonList(org.opendaylight.yang.gen.v1.urn.ietf.params
- .xml.ns.yang.ietf.netconf.notifications.rev120206.$YangModuleInfoImpl.getInstance()));
- moduleInfoBackedContext.addModuleInfos(Collections.singletonList(org.opendaylight.yang.gen.v1.urn.ietf.params
- .xml.ns.yang.ietf.yang.library.rev160621.$YangModuleInfoImpl.getInstance()));
- final Optional<? extends SchemaContext> schemaContextOptional =
- moduleInfoBackedContext.tryToCreateSchemaContext();
- checkState(schemaContextOptional.isPresent());
- NOTIFICATIONS_SCHEMA_CTX = schemaContextOptional.get();
-
- CREATE_SUBSCRIPTION_RPC = requireNonNull(findCreateSubscriptionRpc());
-
- CODEC_REGISTRY = new BindingNormalizedNodeCodecRegistry(BindingRuntimeContext.create(moduleInfoBackedContext,
- NOTIFICATIONS_SCHEMA_CTX));
- }
-
- private NotificationsTransformUtil() {
+ private final SchemaContext schemaContext;
+ private final BindingNormalizedNodeSerializer serializer;
- }
-
- @SuppressFBWarnings(value = "NP_NONNULL_PARAM_VIOLATION", justification = "Unrecognised NullableDecl")
- private static RpcDefinition findCreateSubscriptionRpc() {
- return Iterables.getFirst(Collections2.filter(NOTIFICATIONS_SCHEMA_CTX.getOperations(),
- input -> input.getQName().getLocalName().equals(CreateSubscription.CREATE_SUBSCRIPTION)), null);
+ public NotificationsTransformUtil(final YangParserFactory parserFactory, final BindingRuntimeGenerator generator,
+ final BindingDOMCodecFactory codecFactory) {
+ final BindingRuntimeContext ctx = BindingRuntimeHelpers.createRuntimeContext(parserFactory, generator,
+ Netconf.class, NetconfConfigChange.class, YangLibraryChange.class);
+ schemaContext = ctx.getSchemaContext();
+ verify(schemaContext.getOperations().stream()
+ .filter(input -> input.getQName().getLocalName().equals(CreateSubscription.CREATE_SUBSCRIPTION))
+ .findFirst()
+ .isPresent());
+ serializer = codecFactory.createBindingDOMCodec(ctx);
}
/**
* Transform base notification for capabilities into NetconfNotification.
*/
- public static NetconfNotification transform(final Notification notification, final SchemaPath path) {
+ public NetconfNotification transform(final Notification notification, final SchemaPath path) {
return transform(notification, Optional.empty(), path);
}
- public static NetconfNotification transform(final Notification notification, final Date eventTime,
- final SchemaPath path) {
+ public NetconfNotification transform(final Notification notification, final Date eventTime, final SchemaPath path) {
return transform(notification, Optional.ofNullable(eventTime), path);
}
- private static NetconfNotification transform(final Notification notification, final Optional<Date> eventTime,
+ private NetconfNotification transform(final Notification notification, final Optional<Date> eventTime,
final SchemaPath path) {
- final ContainerNode containerNode = CODEC_REGISTRY.toNormalizedNodeNotification(notification);
+ final ContainerNode containerNode = serializer.toNormalizedNodeNotification(notification);
final DOMResult result = new DOMResult(XmlUtil.newDocument());
try {
- NetconfUtil.writeNormalizedNode(containerNode, result, path, NOTIFICATIONS_SCHEMA_CTX);
+ NetconfUtil.writeNormalizedNode(containerNode, result, path, schemaContext);
} catch (final XMLStreamException | IOException e) {
throw new IllegalStateException("Unable to serialize " + notification, e);
}
final Document node = (Document) result.getNode();
return eventTime.isPresent() ? new NetconfNotification(node, eventTime.get()) : new NetconfNotification(node);
}
-
}
<reference id="netconfOperationServiceFactoryListener"
interface="org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactoryListener"
odl:type="mapper-aggregator-registry"/>
+ <reference id="bindingGenerator"
+ interface="org.opendaylight.binding.runtime.api.BindingRuntimeGenerator"/>
+ <reference id="codecFactory"
+ interface="org.opendaylight.mdsal.binding.dom.codec.spi.BindingDOMCodecFactory"/>
+ <reference id="parserFactory"
+ interface="org.opendaylight.yangtools.yang.model.parser.api.YangParserFactory"/>
<!--This is the MD-SAL netconf server notification blueprint xml file-->
+ <bean id="transformUtil"
+ class="org.opendaylight.netconf.mdsal.notification.impl.ops.NotificationsTransformUtil">
+ <argument ref="parserFactory"/>
+ <argument ref="bindingGenerator"/>
+ <argument ref="codecFactory"/>
+ </bean>
<bean id="netconfNotificationManager"
class="org.opendaylight.netconf.mdsal.notification.impl.NetconfNotificationManager"
destroy-method="close">
+ <argument ref="transformUtil"/>
</bean>
<service ref="netconfNotificationManager"
interface="org.opendaylight.netconf.notifications.NetconfNotificationRegistry"
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.netconf.mdsal.notification.impl;
import static org.junit.Assert.assertEquals;
import java.util.Date;
import java.util.Iterator;
import org.junit.Assert;
-import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.opendaylight.mdsal.binding.dom.codec.impl.DefaultBindingDOMCodecFactory;
+import org.opendaylight.mdsal.binding.generator.impl.DefaultBindingRuntimeGenerator;
+import org.opendaylight.netconf.mdsal.notification.impl.ops.NotificationsTransformUtil;
import org.opendaylight.netconf.notifications.BaseNotificationPublisherRegistration;
import org.opendaylight.netconf.notifications.NetconfNotification;
import org.opendaylight.netconf.notifications.NetconfNotificationCollector;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.streams.Stream;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfCapabilityChange;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfCapabilityChangeBuilder;
+import org.opendaylight.yangtools.yang.parser.impl.YangParserFactoryImpl;
+@RunWith(MockitoJUnitRunner.class)
public class NetconfNotificationManagerTest {
public static final String RFC3339_DATE_FORMAT_WITH_MILLIS_BLUEPRINT = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX";
@Mock
private NetconfNotificationRegistry notificationRegistry;
- @Before
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
- }
-
@Test
public void testEventTime() throws Exception {
//Testing values with SimpleDateFormat
@Test
public void testNotificationListeners() throws Exception {
- final NetconfNotificationManager netconfNotificationManager = new NetconfNotificationManager();
+ final NetconfNotificationManager netconfNotificationManager = createManager();
final BaseNotificationPublisherRegistration baseNotificationPublisherRegistration =
netconfNotificationManager.registerBaseNotificationPublisher();
@Test
public void testClose() throws Exception {
- final NetconfNotificationManager netconfNotificationManager = new NetconfNotificationManager();
+ final NetconfNotificationManager netconfNotificationManager = createManager();
final BaseNotificationPublisherRegistration baseNotificationPublisherRegistration =
netconfNotificationManager.registerBaseNotificationPublisher();
final NetconfNotificationListener listener = mock(NetconfNotificationListener.class);
- doNothing().when(listener).onNotification(any(StreamNameType.class), any(NetconfNotification.class));
netconfNotificationManager
.registerNotificationListener(NetconfNotificationManager.BASE_NETCONF_STREAM.getName(), listener);
@Test
public void testStreamListeners() throws Exception {
- final NetconfNotificationManager netconfNotificationManager = new NetconfNotificationManager();
+ final NetconfNotificationManager netconfNotificationManager = createManager();
final NetconfNotificationCollector.NetconfNotificationStreamListener streamListener =
mock(NetconfNotificationCollector.NetconfNotificationStreamListener.class);
verify(streamListener).onStreamUnregistered(NetconfNotificationManager.BASE_STREAM_NAME);
}
+
+ private static NetconfNotificationManager createManager() {
+ return new NetconfNotificationManager(new NotificationsTransformUtil(new YangParserFactoryImpl(),
+ new DefaultBindingRuntimeGenerator(), new DefaultBindingDOMCodecFactory()));
+ }
}
\ No newline at end of file
package org.opendaylight.netconf.mdsal.notification.impl;
import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
WriteTransaction tx = mock(WriteTransaction.class);
doNothing().when(tx).merge(any(LogicalDatastoreType.class), any(InstanceIdentifier.class),
- any(DataObject.class), anyBoolean());
+ any(DataObject.class));
doNothing().when(tx).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
doReturn(emptyFluentFuture()).when(tx).commit();
doReturn(tx).when(dataBroker).newWriteOnlyTransaction();
writer.onStreamRegistered(testStream);
verify(dataBroker.newWriteOnlyTransaction()).merge(LogicalDatastoreType.OPERATIONAL, streamIdentifier,
- testStream, true);
+ testStream);
writer.onStreamUnregistered(testStreamName);
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.netconf.mdsal.notification.impl.ops;
import static org.junit.Assert.assertTrue;
import org.custommonkey.xmlunit.Diff;
import org.custommonkey.xmlunit.XMLUnit;
import org.custommonkey.xmlunit.examples.RecursiveElementNameAndTextQualifier;
+import org.junit.BeforeClass;
import org.junit.Test;
+import org.opendaylight.mdsal.binding.dom.codec.impl.DefaultBindingDOMCodecFactory;
+import org.opendaylight.mdsal.binding.generator.impl.DefaultBindingRuntimeGenerator;
import org.opendaylight.netconf.api.xml.XmlUtil;
import org.opendaylight.netconf.notifications.NetconfNotification;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfCapabilityChange;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfCapabilityChangeBuilder;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.parser.impl.YangParserFactoryImpl;
import org.xml.sax.SAXException;
public class NotificationsTransformUtilTest {
-
private static final Date DATE = new Date();
private static final String INNER_NOTIFICATION =
"<netconf-capability-change xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-notifications\">"
+ "</eventTime>"
+ "</notification>";
+ private static NotificationsTransformUtil UTIL;
+
+ @BeforeClass
+ public static void beforeClass() {
+ UTIL = new NotificationsTransformUtil(new YangParserFactoryImpl(), new DefaultBindingRuntimeGenerator(),
+ new DefaultBindingDOMCodecFactory());
+ }
+
@Test
public void testTransform() throws Exception {
final NetconfCapabilityChangeBuilder netconfCapabilityChangeBuilder = new NetconfCapabilityChangeBuilder();
netconfCapabilityChangeBuilder.setDeletedCapability(Lists.newArrayList(new Uri("uri4"), new Uri("uri3")));
final NetconfCapabilityChange capabilityChange = netconfCapabilityChangeBuilder.build();
- final NetconfNotification transform = NotificationsTransformUtil.transform(capabilityChange, DATE,
+ final NetconfNotification transform = UTIL.transform(capabilityChange, DATE,
SchemaPath.create(true, NetconfCapabilityChange.QNAME));
final String serialized = XmlUtil.toString(transform.getDocument());
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.MoreExecutors;
-import java.util.List;
-import java.util.Set;
+import java.util.Collection;
+import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
+import java.util.function.Function;
import java.util.stream.Collectors;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.WriteTransaction;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.module.list.ModuleBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.module.list.module.Submodule;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.module.list.module.SubmoduleBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.module.list.module.SubmoduleKey;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.YangIdentifier;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextListener;
import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* Listens for updates on global schema context, transforms context to ietf-yang-library:modules-state and
* writes this state to operational data store.
*/
-public class SchemaServiceToMdsalWriter implements SchemaContextListener, AutoCloseable {
-
+public class SchemaServiceToMdsalWriter implements EffectiveModelContextListener, AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(SchemaServiceToMdsalWriter.class);
-
private static final InstanceIdentifier<ModulesState> MODULES_STATE_INSTANCE_IDENTIFIER =
InstanceIdentifier.create(ModulesState.class);
@Override
- public void onGlobalContextUpdated(final SchemaContext context) {
+ public void onModelContextUpdated(final EffectiveModelContext context) {
final ModulesState newModuleState = createModuleStateFromModules(context.getModules());
final WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
tx.put(LogicalDatastoreType.OPERATIONAL,
}, MoreExecutors.directExecutor());
}
- private ModulesState createModuleStateFromModules(final Set<Module> modules) {
+ private ModulesState createModuleStateFromModules(final Collection<? extends Module> modules) {
return new ModulesStateBuilder()
- .setModule(modules.stream().map(this::createModuleEntryFromModule).collect(Collectors.toList()))
+ .setModule(modules.stream()
+ .map(this::createModuleEntryFromModule)
+ .collect(Collectors.toMap(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library
+ .rev160621.module.list.Module::key, Function.identity())))
.setModuleSetId(String.valueOf(moduleSetId.getAndIncrement()))
.build();
}
.build();
}
- private static List<Submodule> createSubmodulesForModule(final Module module) {
- return module.getSubmodules().stream().map(subModule -> new SubmoduleBuilder()
- .setName(new YangIdentifier(subModule.getName()))
- .setRevision(RevisionUtils.fromYangCommon(subModule.getQNameModule().getRevision()))
- .build()).collect(Collectors.toList());
+ private static Map<SubmoduleKey, Submodule> createSubmodulesForModule(final Module module) {
+ return module.getSubmodules().stream()
+ .map(subModule -> new SubmoduleBuilder()
+ .setName(new YangIdentifier(subModule.getName()))
+ .setRevision(RevisionUtils.fromYangCommon(subModule.getQNameModule().getRevision()))
+ .build())
+ .collect(Collectors.toMap(Submodule::key, Function.identity()));
}
}
import static org.mockito.Mockito.when;
import static org.opendaylight.mdsal.common.api.CommitInfo.emptyFluentFuture;
-import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.YangIdentifier;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextListener;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
public class SchemaServiceToMdsalWriterTest {
doNothing().when(writeTransaction).put(eq(LogicalDatastoreType.OPERATIONAL), any(), any());
doReturn(emptyFluentFuture()).when(writeTransaction).commit();
when(schemaService.registerSchemaContextListener(any())).thenReturn(
- new ListenerRegistration<SchemaContextListener>() {
+ new ListenerRegistration<EffectiveModelContextListener>() {
@Override
public void close() {
}
@Override
- public SchemaContextListener getInstance() {
+ public EffectiveModelContextListener getInstance() {
return null;
}
});
public void testOnGlobalContextUpdated() throws Exception {
schemaServiceToMdsalWriter.start();
- schemaServiceToMdsalWriter.onGlobalContextUpdated(getSchema());
+ schemaServiceToMdsalWriter.onModelContextUpdated(getSchema());
verify(writeTransaction).put(eq(LogicalDatastoreType.OPERATIONAL),
eq(MODULES_STATE_INSTANCE_IDENTIFIER), eq(createTestModuleState()));
}
- private static SchemaContext getSchema() {
+ private static EffectiveModelContext getSchema() {
return YangParserTestUtils.parseYangResources(SchemaServiceToMdsalWriterTest.class, "/test-module.yang",
"/test-submodule.yang");
}
private static ModulesState createTestModuleState() {
- Submodule sub = new SubmoduleBuilder().setName(new YangIdentifier("test-submodule"))
+ Submodule sub = new SubmoduleBuilder()
+ .setName(new YangIdentifier("test-submodule"))
.setRevision(RevisionUtils.emptyRevision())
.build();
Module module = new ModuleBuilder().setName(new YangIdentifier("test-module"))
.setNamespace(new Uri("test:namespace"))
.setRevision(new Revision(new RevisionIdentifier("2013-07-22")))
- .setSubmodule(ImmutableList.of(sub))
+ .setSubmodule(ImmutableMap.of(sub.key(), sub))
.setConformanceType(Module.ConformanceType.Implement)
.build();
- return new ModulesStateBuilder().setModuleSetId("0")
- .setModule(ImmutableList.of(module)).build();
+ return new ModulesStateBuilder()
+ .setModuleSetId("0")
+ .setModule(ImmutableMap.of(module.key(), module))
+ .build();
}
}
</dependency>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-binding-dom-codec</artifactId>
+ <artifactId>mdsal-binding-dom-codec-api</artifactId>
</dependency>
<!-- Testing Dependencies -->
<dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>hamcrest-core</artifactId>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>mdsal-binding-dom-codec</artifactId>
+ <scope>test</scope>
</dependency>
</dependencies>
</project>
import static java.util.Objects.requireNonNull;
import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.google.common.collect.Multimaps;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
-import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.regex.Pattern;
import javax.xml.stream.XMLStreamException;
}
private Map<String, Stream> getAvailableStreams() {
- Map<String, Stream> streamMap = new HashMap<>();
- final List<Stream> availableStreams;
+ final Collection<Stream> availableStreams;
try {
availableStreams = mount.getAvailableStreams();
- streamMap = Maps.uniqueIndex(availableStreams, input -> input.getName().getValue());
} catch (InterruptedException | ExecutionException e) {
LOG.warn("Can not read streams for node {}", mount.getNodeId(), e);
+ return ImmutableMap.of();
}
- return streamMap;
+
+ return Maps.uniqueIndex(availableStreams, input -> input.getName().getValue());
}
@Override
// add Event Source Connection status notification
availNotifList.add(ConnectionNotificationTopicRegistration.EVENT_SOURCE_STATUS_PATH);
- final Set<NotificationDefinition> availableNotifications = mount.getSchemaContext()
- .getNotifications();
// add all known notifications from netconf device
- for (final NotificationDefinition nd : availableNotifications) {
+ for (final NotificationDefinition nd : mount.getSchemaContext().getNotifications()) {
availNotifList.add(nd.getPath());
}
return availNotifList;
import org.opendaylight.mdsal.binding.api.DataTreeChangeListener;
import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
import org.opendaylight.mdsal.binding.api.DataTreeModification;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.mdsal.dom.api.DOMMountPointService;
import org.opendaylight.mdsal.dom.api.DOMNotificationPublishService;
private ListenerRegistration<NetconfEventSourceManager> listenerRegistration;
private final EventSourceRegistry eventSourceRegistry;
private final DataBroker dataBroker;
+ private final BindingNormalizedNodeSerializer serializer;
public NetconfEventSourceManager(final DataBroker dataBroker,
+ final BindingNormalizedNodeSerializer serializer,
final DOMNotificationPublishService domPublish,
final DOMMountPointService domMount,
final EventSourceRegistry eventSourceRegistry) {
this.dataBroker = requireNonNull(dataBroker);
+ this.serializer = requireNonNull(serializer);
this.domMounts = requireNonNull(domMount);
this.publishService = requireNonNull(domPublish);
this.eventSourceRegistry = requireNonNull(eventSourceRegistry);
return;
}
LOG.info("Netconf event source [{}] is creating...", key);
- NetconfEventSourceRegistration nesr = NetconfEventSourceRegistration.create(requireNonNull(key), node, this);
+ NetconfEventSourceRegistration nesr = NetconfEventSourceRegistration.create(serializer, requireNonNull(key),
+ node, this);
if (nesr != null) {
NetconfEventSourceRegistration nesrOld = registrationMap.put(key, nesr);
if (nesrOld != null) {
*/
package org.opendaylight.netconf.messagebus.eventsources.netconf;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.ListenableFuture;
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
+import java.util.Collection;
import java.util.Collections;
-import java.util.List;
import java.util.Optional;
import java.util.concurrent.ExecutionException;
-import org.opendaylight.mdsal.binding.dom.codec.impl.BindingNormalizedNodeCodecRegistry;
-import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext;
-import org.opendaylight.mdsal.binding.generator.util.BindingRuntimeContext;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.mdsal.dom.api.DOMDataBroker;
import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction;
* Facade of mounted netconf device.
*/
class NetconfEventSourceMount {
-
- private static final BindingNormalizedNodeCodecRegistry CODEC_REGISTRY;
private static final YangInstanceIdentifier STREAMS_PATH = YangInstanceIdentifier.builder().node(Netconf.QNAME)
.node(Streams.QNAME).build();
private static final SchemaPath CREATE_SUBSCRIPTION = SchemaPath
.create(true, QName.create(CreateSubscriptionInput.QNAME, "create-subscription"));
- static {
- final ModuleInfoBackedContext moduleInfoBackedContext = ModuleInfoBackedContext.create();
- moduleInfoBackedContext.addModuleInfos(Collections.singletonList(org.opendaylight.yang.gen.v1.urn.ietf.params
- .xml.ns.netmod.notification.rev080714.$YangModuleInfoImpl.getInstance()));
- SchemaContext notificationsSchemaCtx = moduleInfoBackedContext.tryToCreateSchemaContext().get();
-
- CODEC_REGISTRY = new BindingNormalizedNodeCodecRegistry(BindingRuntimeContext.create(moduleInfoBackedContext,
- notificationsSchemaCtx));
- }
-
private final DOMMountPoint mountPoint;
private final DOMRpcService rpcService;
private final DOMNotificationService notificationService;
private final DOMDataBroker dataBroker;
private final Node node;
private final String nodeId;
+ private final BindingNormalizedNodeSerializer serializer;
- NetconfEventSourceMount(final Node node, final DOMMountPoint mountPoint) {
+ NetconfEventSourceMount(final BindingNormalizedNodeSerializer serializer, final Node node,
+ final DOMMountPoint mountPoint) {
+ this.serializer = requireNonNull(serializer);
this.mountPoint = mountPoint;
this.node = node;
this.nodeId = node.getNodeId().getValue();
* @param lastEventTime last event time
* @return rpc result
*/
- ListenableFuture<DOMRpcResult> invokeCreateSubscription(final Stream stream,
+ ListenableFuture<? extends DOMRpcResult> invokeCreateSubscription(final Stream stream,
final Optional<Instant> lastEventTime) {
final CreateSubscriptionInputBuilder inputBuilder = new CreateSubscriptionInputBuilder()
.setStream(stream.getName());
inputBuilder.setStartTime(new DateAndTime(formattedDate));
}
final CreateSubscriptionInput input = inputBuilder.build();
- final ContainerNode nnInput = CODEC_REGISTRY.toNormalizedNodeRpcData(input);
+ final ContainerNode nnInput = serializer.toNormalizedNodeRpcData(input);
return rpcService.invokeRpc(CREATE_SUBSCRIPTION, nnInput);
}
* @param stream stream
* @return rpc result
*/
- ListenableFuture<DOMRpcResult> invokeCreateSubscription(final Stream stream) {
+ ListenableFuture<? extends DOMRpcResult> invokeCreateSubscription(final Stream stream) {
return invokeCreateSubscription(stream, Optional.empty());
}
* @throws ExecutionException if data read fails
* @throws InterruptedException if data read fails
*/
- List<Stream> getAvailableStreams() throws InterruptedException, ExecutionException {
+ Collection<Stream> getAvailableStreams() throws InterruptedException, ExecutionException {
final Optional<NormalizedNode<?, ?>> streams;
try (DOMDataTreeReadTransaction tx = dataBroker.newReadOnlyTransaction()) {
streams = tx.read(LogicalDatastoreType.OPERATIONAL, STREAMS_PATH).get();
}
if (streams.isPresent()) {
- Streams streams1 = (Streams) CODEC_REGISTRY.fromNormalizedNode(STREAMS_PATH, streams.get()).getValue();
- return streams1.getStream();
+ Streams streams1 = (Streams) serializer.fromNormalizedNode(STREAMS_PATH, streams.get()).getValue();
+ return streams1.nonnullStream().values();
}
return Collections.emptyList();
}
import java.util.List;
import java.util.Optional;
import org.opendaylight.controller.messagebus.spi.EventSourceRegistration;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.mdsal.dom.api.DOMMountPoint;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeConnectionStatus.ConnectionStatus;
/**
* Helper class to keep connection status of netconf node and event source registration object.
*/
-public final class NetconfEventSourceRegistration implements AutoCloseable {
+final class NetconfEventSourceRegistration implements AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(NetconfEventSourceRegistration.class);
private static final YangInstanceIdentifier NETCONF_DEVICE_DOM_PATH = YangInstanceIdentifier.builder()
private final Node node;
private final NetconfEventSourceManager netconfEventSourceManager;
+ private final BindingNormalizedNodeSerializer serializer;
+
private ConnectionStatus currentNetconfConnStatus;
private EventSourceRegistration<NetconfEventSource> eventSourceRegistration;
- public static NetconfEventSourceRegistration create(final InstanceIdentifier<?> instanceIdent, final Node node,
- final NetconfEventSourceManager netconfEventSourceManager) {
+ private NetconfEventSourceRegistration(final BindingNormalizedNodeSerializer serializer, final Node node,
+ final NetconfEventSourceManager netconfEventSourceManager) {
+ this.serializer = requireNonNull(serializer);
+ this.node = node;
+ this.netconfEventSourceManager = netconfEventSourceManager;
+ this.eventSourceRegistration = null;
+ this.currentNetconfConnStatus = ConnectionStatus.Connecting;
+ }
+
+ static NetconfEventSourceRegistration create(final BindingNormalizedNodeSerializer serializer,
+ final InstanceIdentifier<?> instanceIdent, final Node node,
+ final NetconfEventSourceManager netconfEventSourceManager) {
requireNonNull(instanceIdent);
- requireNonNull(node);
requireNonNull(netconfEventSourceManager);
if (!isEventSource(node)) {
return null;
}
- NetconfEventSourceRegistration nesr = new NetconfEventSourceRegistration(node, netconfEventSourceManager);
+ NetconfEventSourceRegistration nesr = new NetconfEventSourceRegistration(serializer, node,
+ netconfEventSourceManager);
nesr.updateStatus();
LOG.debug("NetconfEventSourceRegistration for node {} has been initialized...", node.getNodeId().getValue());
return nesr;
return false;
}
- private NetconfEventSourceRegistration(final Node node, final NetconfEventSourceManager netconfEventSourceManager) {
- this.node = node;
- this.netconfEventSourceManager = netconfEventSourceManager;
- this.eventSourceRegistration = null;
- this.currentNetconfConnStatus = ConnectionStatus.Connecting;
- }
-
Optional<EventSourceRegistration<NetconfEventSource>> getEventSourceRegistration() {
return Optional.ofNullable(eventSourceRegistration);
}
.getMountPoint(domMountPath(node.getNodeId()));
EventSourceRegistration<NetconfEventSource> registration = null;
if (domMountPoint.isPresent()/* && mountPoint.isPresent()*/) {
- NetconfEventSourceMount mount = new NetconfEventSourceMount(node, domMountPoint.get());
+ NetconfEventSourceMount mount = new NetconfEventSourceMount(serializer, node, domMountPoint.get());
final NetconfEventSource netconfEventSource = new NetconfEventSource(
netconfEventSourceManager.getStreamMap(),
mount,
void activateNotificationSource() {
if (!isActive()) {
LOG.info("Stream {} is not active on node {}. Will subscribe.", this.getStreamName(), this.nodeId);
- final ListenableFuture<DOMRpcResult> result = mountPoint.invokeCreateSubscription(stream);
+ final ListenableFuture<? extends DOMRpcResult> result = mountPoint.invokeCreateSubscription(stream);
try {
result.get();
setActive(true);
void reActivateNotificationSource() {
if (isActive()) {
LOG.info("Stream {} is reactivating on node {}.", this.getStreamName(), this.nodeId);
- final ListenableFuture<DOMRpcResult> result = mountPoint.invokeCreateSubscription(stream,
+ final ListenableFuture<? extends DOMRpcResult> result = mountPoint.invokeCreateSubscription(stream,
getLastEventTime());
try {
result.get();
<reference id="dataBroker"
interface="org.opendaylight.mdsal.binding.api.DataBroker"
odl:type="default"/>
+ <reference id="domCodec"
+ interface="org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer" />
<reference id="domMountPointService"
interface="org.opendaylight.mdsal.dom.api.DOMMountPointService" />
<reference id="domNotificationPublishService"
init-method="initialize"
destroy-method="close">
<argument ref="dataBroker" />
+ <argument ref="domCodec" />
<argument ref="domNotificationPublishService" />
<argument ref="domMountPointService" />
<argument ref="eventSourceRegistry" />
--- /dev/null
+/*
+ * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.netconf.messagebus.eventsources.netconf;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.opendaylight.binding.runtime.spi.BindingRuntimeHelpers;
+import org.opendaylight.mdsal.binding.dom.codec.impl.BindingCodecContext;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.Netconf;
+
+public abstract class AbstractCodecTest {
+ static BindingCodecContext SERIALIZER;
+
+ @BeforeClass
+ public static void beforeClass() {
+ SERIALIZER = new BindingCodecContext(BindingRuntimeHelpers.createRuntimeContext(Netconf.class));
+ }
+
+ @AfterClass
+ public static void afterClass() {
+ SERIALIZER = null;
+ }
+}
import java.util.HashMap;
import java.util.Optional;
import org.junit.Before;
-import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.controller.messagebus.spi.EventSource;
import org.opendaylight.controller.messagebus.spi.EventSourceRegistry;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-public class NetconfEventSourceManagerTest {
+public class NetconfEventSourceManagerTest extends AbstractCodecTest {
NetconfEventSourceManager netconfEventSourceManager;
- ListenerRegistration listenerRegistrationMock;
+ ListenerRegistration<?> listenerRegistrationMock;
DOMMountPointService domMountPointServiceMock;
MountPointService mountPointServiceMock;
EventSourceRegistry eventSourceTopologyMock;
RpcProviderService rpcProviderRegistryMock;
EventSourceRegistry eventSourceRegistry;
- @BeforeClass
- public static void initTestClass() throws IllegalAccessException, InstantiationException {
- }
@SuppressWarnings("unchecked")
@Before
.build();
doReturn(readStreamFuture).when(rtx).read(LogicalDatastoreType.OPERATIONAL, pathStream);
- netconfEventSourceManager = new NetconfEventSourceManager(dataBrokerMock,
+ netconfEventSourceManager = new NetconfEventSourceManager(dataBrokerMock, SERIALIZER,
domNotificationPublishServiceMock, domMountPointServiceMock, eventSourceRegistry);
netconfEventSourceManager.setStreamMap(new HashMap<>());
}
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
-import com.google.common.collect.Lists;
+import com.google.common.collect.Collections2;
import java.time.Instant;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
-import java.util.List;
+import java.util.Collection;
import java.util.Optional;
import org.junit.Assert;
import org.junit.Before;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-public class NetconfEventSourceMountTest {
-
+public class NetconfEventSourceMountTest extends AbstractCodecTest {
public static final String STREAM_1 = "stream-1";
public static final String STREAM_2 = "stream-2";
+
@Mock
private DOMMountPoint domMountPoint;
@Mock
final NormalizedNode<?, ?> streamsNode = NetconfTestUtils.getStreamsNode(STREAM_1, STREAM_2);
doReturn(FluentFutures.immediateFluentFuture(Optional.of(streamsNode)))
.when(tx).read(LogicalDatastoreType.OPERATIONAL, path);
- mount = new NetconfEventSourceMount(NetconfTestUtils.getNode("node-1"), domMountPoint);
+ mount = new NetconfEventSourceMount(SERIALIZER, NetconfTestUtils.getNode("node-1"), domMountPoint);
}
@Test
@Test
public void testGetAvailableStreams() throws Exception {
- final List<Stream> availableStreams = mount.getAvailableStreams();
+ final Collection<Stream> availableStreams = mount.getAvailableStreams();
Assert.assertEquals(2, availableStreams.size());
- final List<String> streamNames = Lists.transform(availableStreams, input -> input.getName().getValue());
+ final Collection<String> streamNames = Collections2.transform(availableStreams,
+ input -> input.getName().getValue());
streamNames.contains(STREAM_1);
streamNames.contains(STREAM_2);
}
*/
package org.opendaylight.netconf.messagebus.eventsources.netconf;
+import com.google.common.collect.ImmutableMap;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.streams.StreamBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.DomainName;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Host;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeConnectionStatus.ConnectionStatus;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.AvailableCapabilitiesBuilder;
return new NodeBuilder()
.withKey(new NodeKey(new NodeId(nodeIdent)))
- .addAugmentation(NetconfNode.class, new NetconfNodeBuilder()
+ .addAugmentation(new NetconfNodeBuilder()
.setConnectionStatus(cs)
.setHost(new Host(new DomainName(hostName)))
.setAvailableCapabilities(new AvailableCapabilitiesBuilder()
public static Optional<Streams> getAvailableStream(final String name, final boolean replaySupport) {
Stream stream = new StreamBuilder().setName(new StreamNameType(name)).setReplaySupport(replaySupport).build();
- List<Stream> streamList = new ArrayList<>();
- streamList.add(stream);
- Streams streams = new StreamsBuilder().setStream(streamList).build();
- return Optional.of(streams);
+ return Optional.of(new StreamsBuilder().setStream(ImmutableMap.of(stream.key(), stream)).build());
}
public static NormalizedNode<?, ?> getStreamsNode(final String... streamName) {
import static org.hamcrest.CoreMatchers.hasItems;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.opendaylight.yangtools.util.concurrent.FluentFutures.immediateNullFluentFuture;
when(mount.registerNotificationListener(source, ConnectionNotificationTopicRegistration
.EVENT_SOURCE_STATUS_PATH))
.thenReturn(listenerRegistration);
- when(mount.invokeCreateSubscription(any(), any())).thenReturn(immediateNullFluentFuture());
- when(mount.invokeCreateSubscription(any())).thenReturn(immediateNullFluentFuture());
+ doReturn(immediateNullFluentFuture()).when(mount).invokeCreateSubscription(any(), any());
+ doReturn(immediateNullFluentFuture()).when(mount).invokeCreateSubscription(any());
when(source.getMount()).thenReturn(mount);
stream = new StreamBuilder().setName(StreamNameType.getDefaultInstance(STREAM_NAME)).setReplaySupport(true)
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>bundle-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
return new HashMap<>();
}
final Map<String, Map<String, String>> netconfNodes = new HashMap<>();
- for (final Node node : topology.getNode()) {
+ for (final Node node : topology.nonnullNode().values()) {
final NetconfNode netconfNode = node.augmentation(NetconfNode.class);
final Map<String, String> attributes = new HashMap<>();
attributes.put(NetconfConsoleConstants.NETCONF_ID, node.getNodeId().getValue());
*/
package org.opendaylight.netconf.console.utils;
+import com.google.common.collect.ImmutableList;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.ExecutionException;
public static List<Node> getNetconfNodeFromIp(final String deviceIp, final DataBroker db) {
final Topology topology = read(LogicalDatastoreType.OPERATIONAL, NetconfIidFactory.NETCONF_TOPOLOGY_IID, db);
List<Node> nodes = new ArrayList<>();
- if (isNetconfNodesPresent(topology)) {
- for (Node node : topology.getNode()) {
- final NetconfNode netconfNode = node.augmentation(NetconfNode.class);
- if (netconfNode != null
- && netconfNode.getHost().getIpAddress().getIpv4Address().getValue().equals(deviceIp)) {
- nodes.add(node);
- }
+ for (Node node : netconfNodes(topology)) {
+ final NetconfNode netconfNode = node.augmentation(NetconfNode.class);
+ if (netconfNode != null
+ && netconfNode.getHost().getIpAddress().getIpv4Address().getValue().equals(deviceIp)) {
+ nodes.add(node);
}
}
return nodes.isEmpty() ? null : nodes;
public static Node getNetconfNodeFromIpAndPort(final String deviceIp, final String devicePort,
final DataBroker db) {
final Topology topology = read(LogicalDatastoreType.OPERATIONAL, NetconfIidFactory.NETCONF_TOPOLOGY_IID, db);
- if (isNetconfNodesPresent(topology)) {
- for (Node node : topology.getNode()) {
- final NetconfNode netconfNode = node.augmentation(NetconfNode.class);
- if (netconfNode != null
- && netconfNode.getHost().getIpAddress().getIpv4Address().getValue().equals(deviceIp)
- && devicePort.equals(netconfNode.getPort().getValue().toString())) {
- return node;
- }
+ for (Node node : netconfNodes(topology)) {
+ final NetconfNode netconfNode = node.augmentation(NetconfNode.class);
+ if (netconfNode != null && netconfNode.getHost().getIpAddress().getIpv4Address().getValue().equals(deviceIp)
+ && devicePort.equals(netconfNode.getPort().getValue().toString())) {
+ return node;
}
}
return null;
* @param topology :NETCONF topology instance
* @return :<code>true</code> if not empty, else, <code>false</code>
*/
- private static boolean isNetconfNodesPresent(final Topology topology) {
- return topology != null && topology.getNode() != null && !topology.getNode().isEmpty();
+ private static Collection<Node> netconfNodes(final Topology topology) {
+ return topology == null ? ImmutableList.of() : topology.nonnullNode().values();
}
/**
import static org.junit.Assert.assertNotNull;
import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
import org.opendaylight.yangtools.yang.common.Uint16;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
public class NetconfCommandsImplTest {
NetconfNodeConnectionStatus.ConnectionStatus.Connected;
private static final String CAP_PREFIX = "prefix";
- private static SchemaContext SCHEMA_CONTEXT;
+ private static EffectiveModelContext SCHEMA_CONTEXT;
private DataBroker dataBroker;
private NetconfCommandsImpl netconfCommands;
Awaitility.await().atMost(5, TimeUnit.SECONDS).until(() -> {
final Topology topology = NetconfConsoleUtils.read(LogicalDatastoreType.CONFIGURATION,
NetconfIidFactory.NETCONF_TOPOLOGY_IID, dataBroker);
- final List<Node> nodes = topology.getNode();
+ final Collection<Node> nodes = topology.nonnullNode().values();
if (nodes.size() != 2) {
return false;
}
Awaitility.await().atMost(5, TimeUnit.SECONDS).until(() -> {
final Topology topologyDeleted = NetconfConsoleUtils.read(LogicalDatastoreType.CONFIGURATION,
NetconfIidFactory.NETCONF_TOPOLOGY_IID, dataBroker);
- final List<Node> nodesDeleted = topologyDeleted.getNode();
+ final Collection<Node> nodesDeleted = topologyDeleted.nonnullNode().values();
if (nodesDeleted.size() != 1) {
return false;
}
Awaitility.await().atMost(5, TimeUnit.SECONDS).until(() -> {
final Topology topology = NetconfConsoleUtils.read(LogicalDatastoreType.CONFIGURATION,
NetconfIidFactory.NETCONF_TOPOLOGY_IID, dataBroker);
- final List<Node> nodes = topology.getNode();
+ final Collection<Node> nodes = topology.nonnullNode().values();
if (nodes.size() != 1) {
return false;
}
private void createTopology(final LogicalDatastoreType dataStoreType)
throws TimeoutException, InterruptedException, ExecutionException {
- final List<Node> nodes = new ArrayList<>();
final Node node = getNetconfNode(NODE_ID, IP, PORT, CONN_STATUS, CAP_PREFIX);
- nodes.add(node);
final Topology topology = new TopologyBuilder()
.withKey(new TopologyKey(new TopologyId(TopologyNetconf.QNAME.getLocalName())))
- .setTopologyId(new TopologyId(TopologyNetconf.QNAME.getLocalName())).setNode(nodes).build();
+ .setTopologyId(new TopologyId(TopologyNetconf.QNAME.getLocalName()))
+ .setNode(ImmutableMap.of(node.key(), node)).build();
final WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
writeTransaction.put(dataStoreType, NetconfIidFactory.NETCONF_TOPOLOGY_IID, topology);
<name>${project.artifactId}</name>
<packaging>bundle</packaging>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>config-artifacts</artifactId>
- <version>0.12.0</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
package org.opendaylight.netconf.impl;
import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.base.Verify.verify;
import com.google.common.net.InetAddresses;
import io.netty.channel.Channel;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
-import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.opendaylight.netconf.api.NetconfMessage;
import org.opendaylight.netconf.api.messages.NetconfHelloMessageAdditionalHeader;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.extension.rev131210.NetconfTcp;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.extension.rev131210.Session1;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.extension.rev131210.Session1Builder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.NetconfSsh;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.Transport;
private static final Logger LOG = LoggerFactory.getLogger(NetconfServerSession.class);
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
- private static final String DATE_TIME_PATTERN_STRING = DateAndTime.PATTERN_CONSTANTS.get(0);
+
+ private static final String DATE_TIME_PATTERN_STRING;
+
+ static {
+ verify(DateAndTime.PATTERN_CONSTANTS.size() == 1);
+ DATE_TIME_PATTERN_STRING = DateAndTime.PATTERN_CONSTANTS.get(0);
+ }
+
private static final Pattern DATE_TIME_PATTERN = Pattern.compile(DATE_TIME_PATTERN_STRING);
private final NetconfHelloMessageAdditionalHeader header;
@Override
public Session toManagementSession() {
- SessionBuilder builder = new SessionBuilder();
-
- builder.setSessionId(Uint32.valueOf(getSessionId()));
- IpAddress address;
- InetAddress address1 = InetAddresses.forString(header.getAddress());
+ final SessionBuilder builder = new SessionBuilder()
+ .withKey(new SessionKey(Uint32.valueOf(getSessionId())));
+ final InetAddress address1 = InetAddresses.forString(header.getAddress());
+ final IpAddress address;
if (address1 instanceof Inet4Address) {
address = new IpAddress(new Ipv4Address(header.getAddress()));
} else {
}
builder.setSourceHost(new Host(address));
- checkState(DateAndTime.PATTERN_CONSTANTS.size() == 1);
- String formattedDateTime = DATE_FORMATTER.format(loginTime);
-
- Matcher matcher = DATE_TIME_PATTERN.matcher(formattedDateTime);
- checkState(matcher.matches(), "Formatted datetime %s does not match pattern %s",
- formattedDateTime, DATE_TIME_PATTERN);
- builder.setLoginTime(new DateAndTime(formattedDateTime));
-
- builder.setInBadRpcs(new ZeroBasedCounter32(Uint32.valueOf(inRpcFail)));
- builder.setInRpcs(new ZeroBasedCounter32(Uint32.valueOf(inRpcSuccess)));
- builder.setOutRpcErrors(new ZeroBasedCounter32(Uint32.valueOf(outRpcError)));
-
- builder.setUsername(header.getUserName());
- builder.setTransport(getTransportForString(header.getTransport()));
-
- builder.setOutNotifications(new ZeroBasedCounter32(Uint32.valueOf(outNotification)));
-
- builder.withKey(new SessionKey(Uint32.valueOf(getSessionId())));
-
- Session1Builder builder1 = new Session1Builder();
- builder1.setSessionIdentifier(header.getSessionIdentifier());
- builder.addAugmentation(Session1.class, builder1.build());
-
- return builder.build();
+ final String formattedDateTime = DATE_FORMATTER.format(loginTime);
+ checkState(DATE_TIME_PATTERN.matcher(formattedDateTime).matches(),
+ "Formatted datetime %s does not match pattern %s", formattedDateTime, DATE_TIME_PATTERN);
+
+ return builder
+ .setLoginTime(new DateAndTime(formattedDateTime))
+ .setInBadRpcs(new ZeroBasedCounter32(Uint32.valueOf(inRpcFail)))
+ .setInRpcs(new ZeroBasedCounter32(Uint32.valueOf(inRpcSuccess)))
+ .setOutRpcErrors(new ZeroBasedCounter32(Uint32.valueOf(outRpcError)))
+ .setUsername(header.getUserName())
+ .setTransport(getTransportForString(header.getTransport()))
+ .setOutNotifications(new ZeroBasedCounter32(Uint32.valueOf(outNotification)))
+ .addAugmentation(new Session1Builder().setSessionIdentifier(header.getSessionIdentifier()).build())
+ .build();
}
private static Class<? extends Transport> getTransportForString(final String transport) {
import com.google.common.collect.ImmutableList.Builder;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
}
private static Schemas transformSchemas(final Set<Capability> caps) {
- final List<Schema> schemas = new ArrayList<>(caps.size());
+ final Map<SchemaKey, Schema> schemas = Maps.newHashMapWithExpectedSize(caps.size());
for (final Capability cap : caps) {
if (cap.getCapabilitySchema().isPresent()) {
- final SchemaBuilder builder = new SchemaBuilder();
-
Preconditions.checkState(isValidModuleCapability(cap));
- builder.setNamespace(new Uri(cap.getModuleNamespace().get()));
-
- final String version = cap.getRevision().get();
- builder.setVersion(version);
-
- final String identifier = cap.getModuleName().get();
- builder.setIdentifier(identifier);
-
- builder.setFormat(Yang.class);
-
- builder.setLocation(transformLocations(cap.getLocation()));
-
- builder.withKey(new SchemaKey(Yang.class, identifier, version));
-
- schemas.add(builder.build());
+ final SchemaKey key = new SchemaKey(Yang.class, cap.getModuleName().get(), cap.getRevision().get());
+ schemas.put(key, new SchemaBuilder()
+ .withKey(key)
+ .setNamespace(new Uri(cap.getModuleNamespace().get()))
+ .setLocation(transformLocations(cap.getLocation()))
+ .build());
}
}
import com.google.common.base.Preconditions;
import com.google.common.collect.Collections2;
import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Maps;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
/**
* This class implements {@link SessionListener} to receive updates about Netconf sessions. Instance notifies its
- * listeners
- * about session start and end. It also publishes on regular interval list of sessions,
+ * listeners about session start and end. It also publishes on regular interval list of sessions,
* where events like rpc or notification happened.
*/
class NetconfSessionMonitoringService implements SessionListener, AutoCloseable {
-
private static final Logger LOG = LoggerFactory.getLogger(NetconfSessionMonitoringService.class);
private final Set<NetconfManagementSession> sessions = new HashSet<>();
* scheduled.
* @param updateInterval update interval. If is less than 0, updates won't be scheduled
*/
- NetconfSessionMonitoringService(Optional<ScheduledThreadPool> schedulingThreadPool, long updateInterval) {
+ NetconfSessionMonitoringService(final Optional<ScheduledThreadPool> schedulingThreadPool,
+ final long updateInterval) {
this.updateInterval = updateInterval;
if (schedulingThreadPool.isPresent() && updateInterval > 0) {
this.executor = schedulingThreadPool.get().getExecutor();
synchronized Sessions getSessions() {
final Collection<Session> managementSessions = Collections2.transform(sessions,
NetconfManagementSession::toManagementSession);
- return new SessionsBuilder().setSession(ImmutableList.copyOf(managementSessions)).build();
+ return new SessionsBuilder()
+ .setSession(Maps.uniqueIndex(managementSessions, Session::key))
+ .build();
}
@Override
}
@Override
- public synchronized void onSessionEvent(SessionEvent event) {
+ public synchronized void onSessionEvent(final SessionEvent event) {
changedSessions.add(event.getSession());
}
changedSessions.clear();
}
- private void notifySessionUp(NetconfManagementSession managementSession) {
+ private void notifySessionUp(final NetconfManagementSession managementSession) {
Session session = managementSession.toManagementSession();
for (NetconfMonitoringService.SessionsListener listener : listeners) {
listener.onSessionStarted(session);
}
}
- private void notifySessionDown(NetconfManagementSession managementSession) {
+ private void notifySessionDown(final NetconfManagementSession managementSession) {
Session session = managementSession.toManagementSession();
for (NetconfMonitoringService.SessionsListener listener : listeners) {
listener.onSessionEnded(session);
*/
package org.opendaylight.netconf.impl.osgi;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import java.util.List;
import java.util.Optional;
import java.util.Set;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
@Test
public void testGetSchemas() throws Exception {
Schemas schemas = monitoringService.getSchemas();
- Schema schema = schemas.getSchema().get(0);
- Assert.assertEquals(TEST_MODULE_NAMESPACE, schema.getNamespace());
- Assert.assertEquals(TEST_MODULE_NAME, schema.getIdentifier());
- Assert.assertEquals(TEST_MODULE_REV, schema.getVersion());
+ Schema schema = schemas.getSchema().values().iterator().next();
+ assertEquals(TEST_MODULE_NAMESPACE, schema.getNamespace());
+ assertEquals(TEST_MODULE_NAME, schema.getIdentifier());
+ assertEquals(TEST_MODULE_REV, schema.getVersion());
}
@Test
monitoringService.onCapabilitiesChanged(Collections.singleton(moduleCapability2), Collections.emptySet());
final String schema =
monitoringService.getSchemaForModuleRevision(TEST_MODULE_NAME, Optional.of(TEST_MODULE_REV));
- Assert.assertEquals(TEST_MODULE_CONTENT, schema);
+ assertEquals(TEST_MODULE_CONTENT, schema);
final String schema2 =
monitoringService.getSchemaForModuleRevision(TEST_MODULE_NAME, Optional.of(TEST_MODULE_REV2));
- Assert.assertEquals(TEST_MODULE_CONTENT2, schema2);
+ assertEquals(TEST_MODULE_CONTENT2, schema2);
//remove one revision
monitoringService.onCapabilitiesChanged(Collections.emptySet(), Collections.singleton(moduleCapability1));
//only one revision present
final String schema3 = monitoringService.getSchemaForModuleRevision(TEST_MODULE_NAME, Optional.empty());
- Assert.assertEquals(TEST_MODULE_CONTENT2, schema3);
+ assertEquals(TEST_MODULE_CONTENT2, schema3);
}
@Test
exp.add(new Uri(URN_IETF_PARAMS_NETCONF_CAPABILITY_URL_1_0));
Capabilities expected = new CapabilitiesBuilder().setCapability(exp).build();
Capabilities actual = monitoringService.getCapabilities();
- Assert.assertEquals(new HashSet<>(expected.getCapability()), new HashSet<>(actual.getCapability()));
+ assertEquals(new HashSet<>(expected.getCapability()), new HashSet<>(actual.getCapability()));
}
@Test
public void testClose() throws Exception {
- Assert.assertFalse(monitoringService.getCapabilities().getCapability().isEmpty());
+ assertFalse(monitoringService.getCapabilities().getCapability().isEmpty());
monitoringService.close();
- Assert.assertTrue(monitoringService.getCapabilities().getCapability().isEmpty());
+ assertTrue(monitoringService.getCapabilities().getCapability().isEmpty());
}
@Test
final List<Uri> afterAddState = listenerValues.get(1).getCapability();
final List<Uri> afterRemoveState = listenerValues.get(2).getCapability();
- Assert.assertEquals(capabilitiesSize, afterRegisterState.size());
- Assert.assertEquals(capabilitiesSize + 1, afterAddState.size());
- Assert.assertEquals(capabilitiesSize, afterRemoveState.size());
- Assert.assertFalse(afterRegisterState.contains(uri));
- Assert.assertTrue(afterAddState.contains(uri));
- Assert.assertFalse(afterRemoveState.contains(uri));
+ assertEquals(capabilitiesSize, afterRegisterState.size());
+ assertEquals(capabilitiesSize + 1, afterAddState.size());
+ assertEquals(capabilitiesSize, afterRemoveState.size());
+ assertFalse(afterRegisterState.contains(uri));
+ assertTrue(afterAddState.contains(uri));
+ assertFalse(afterRemoveState.contains(uri));
//verify notification publication
final List<NetconfCapabilityChange> publisherValues = capabilityChangeCaptor.getAllValues();
final NetconfCapabilityChange afterAdd = publisherValues.get(0);
final NetconfCapabilityChange afterRemove = publisherValues.get(1);
- Assert.assertEquals(Collections.singleton(uri), new HashSet<>(afterAdd.getAddedCapability()));
- Assert.assertEquals(Collections.emptySet(), new HashSet<>(afterAdd.getDeletedCapability()));
- Assert.assertEquals(Collections.singleton(uri), new HashSet<>(afterRemove.getDeletedCapability()));
- Assert.assertEquals(Collections.emptySet(), new HashSet<>(afterRemove.getAddedCapability()));
+ assertEquals(Collections.singleton(uri), new HashSet<>(afterAdd.getAddedCapability()));
+ assertEquals(Collections.emptySet(), new HashSet<>(afterAdd.getDeletedCapability()));
+ assertEquals(Collections.singleton(uri), new HashSet<>(afterRemove.getDeletedCapability()));
+ assertEquals(Collections.emptySet(), new HashSet<>(afterRemove.getAddedCapability()));
}
-
}
*/
package org.opendaylight.netconf.impl.osgi;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import java.util.Optional;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.controller.config.threadpool.ScheduledThreadPool;
import org.opendaylight.netconf.api.capability.BasicCapability;
import org.opendaylight.netconf.api.capability.Capability;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.sessions.SessionBuilder;
import org.opendaylight.yangtools.yang.common.Uint32;
+@RunWith(MockitoJUnitRunner.StrictStubs.class)
public class NetconfSessionMonitoringServiceTest {
private static final Session SESSION_1 = new SessionBuilder()
private NetconfSessionMonitoringService monitoringService;
@Before
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
-
+ public void setUp() {
doReturn(SESSION_1).when(sessionMock1).toManagementSession();
doReturn(SESSION_2).when(sessionMock2).toManagementSession();
doNothing().when(listener).onSessionStarted(any());
doNothing().when(listener).onSessionEnded(any());
- doNothing().when(notificationPublisher).onCapabilityChanged(any());
- doNothing().when(notificationPublisher).onSessionStarted(any());
- doNothing().when(notificationPublisher).onSessionEnded(any());
-
monitoringService = new NetconfSessionMonitoringService(Optional.empty(), 0);
monitoringService.registerListener(listener);
}
@Test
- public void testListeners() throws Exception {
+ public void testListeners() {
monitoringService.onSessionUp(sessionMock1);
HashSet<Capability> added = new HashSet<>();
added.add(new BasicCapability("toAdd"));
verify(listener).onSessionEnded(any());
}
-
@Test
- public void testClose() throws Exception {
+ public void testClose() {
monitoringService.onSessionUp(sessionMock1);
- Assert.assertFalse(monitoringService.getSessions().getSession().isEmpty());
+ assertEquals(1, monitoringService.getSessions().getSession().size());
monitoringService.close();
- Assert.assertTrue(monitoringService.getSessions().getSession().isEmpty());
+ assertNull(monitoringService.getSessions().getSession());
}
-
@Test
- public void testOnSessionUpAndDown() throws Exception {
+ public void testOnSessionUpAndDown() {
monitoringService.onSessionUp(sessionMock1);
ArgumentCaptor<Session> sessionUpCaptor = ArgumentCaptor.forClass(Session.class);
verify(listener).onSessionStarted(sessionUpCaptor.capture());
final Session sesionUp = sessionUpCaptor.getValue();
- Assert.assertEquals(SESSION_1.getSessionId(), sesionUp.getSessionId());
- Assert.assertEquals(SESSION_1.getSourceHost(), sesionUp.getSourceHost());
- Assert.assertEquals(SESSION_1.getUsername(), sesionUp.getUsername());
+ assertEquals(SESSION_1.getSessionId(), sesionUp.getSessionId());
+ assertEquals(SESSION_1.getSourceHost(), sesionUp.getSourceHost());
+ assertEquals(SESSION_1.getUsername(), sesionUp.getUsername());
monitoringService.onSessionDown(sessionMock1);
ArgumentCaptor<Session> sessionDownCaptor = ArgumentCaptor.forClass(Session.class);
verify(listener).onSessionEnded(sessionDownCaptor.capture());
final Session sessionDown = sessionDownCaptor.getValue();
- Assert.assertEquals(SESSION_1.getSessionId(), sessionDown.getSessionId());
- Assert.assertEquals(SESSION_1.getSourceHost(), sessionDown.getSourceHost());
- Assert.assertEquals(SESSION_1.getUsername(), sessionDown.getUsername());
+ assertEquals(SESSION_1.getSessionId(), sessionDown.getSessionId());
+ assertEquals(SESSION_1.getSourceHost(), sessionDown.getSourceHost());
+ assertEquals(SESSION_1.getUsername(), sessionDown.getUsername());
}
@Test
@SuppressWarnings("unchecked")
- public void testListenerUpdateSession() throws Exception {
+ public void testListenerUpdateSession() {
ScheduledThreadPool threadPool = mock(ScheduledThreadPool.class);
ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
doReturn(executor).when(threadPool).getExecutor();
ArgumentCaptor.forClass(Collection.class);
verify(listener, timeout(2000)).onSessionsUpdated(captor.capture());
final Collection<Session> value = captor.getValue();
- Assert.assertTrue(value.contains(SESSION_1));
- Assert.assertFalse(value.contains(SESSION_2));
+ assertTrue(value.contains(SESSION_1));
+ assertFalse(value.contains(SESSION_2));
monitoringService.close();
}
}
import org.opendaylight.mdsal.common.api.CommitInfo;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.netconf.topology.api.NetconfConnectorFactory;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Host;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.HostBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.Credentials;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPwBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.login.pw.LoginPasswordBuilder;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
final Boolean tcpOnly,
final Boolean reconnectOnSchemaChange) {
- final NodeId nodeId = new NodeId(instanceName);
- final NodeKey nodeKey = new NodeKey(nodeId);
- final Credentials credentials = new LoginPwBuilder()
- .setLoginPassword(
- new LoginPasswordBuilder()
- .setUsername(username)
- .setPassword(password)
- .build())
- .build();
- final Host host = HostBuilder.getDefaultInstance(address);
- final PortNumber portNumber = new PortNumber(Uint16.valueOf(port));
- final NetconfNode netconfNode = new NetconfNodeBuilder()
- .setHost(host)
- .setPort(portNumber)
- .setCredentials(credentials)
- .setTcpOnly(tcpOnly)
- .setReconnectOnChangedSchema(reconnectOnSchemaChange)
- .build();
+ final NodeKey nodeKey = new NodeKey(new NodeId(instanceName));
final Node node = new NodeBuilder()
- .setNodeId(nodeId)
.withKey(nodeKey)
- .addAugmentation(NetconfNode.class, netconfNode)
+ .addAugmentation(new NetconfNodeBuilder()
+ .setHost(HostBuilder.getDefaultInstance(address))
+ .setPort(new PortNumber(Uint16.valueOf(port)))
+ .setCredentials(new LoginPwBuilder()
+ .setLoginPassword(new LoginPasswordBuilder()
+ .setUsername(username)
+ .setPassword(password)
+ .build())
+ .build())
+ .setTcpOnly(tcpOnly)
+ .setReconnectOnChangedSchema(reconnectOnSchemaChange)
+ .build())
.build();
final InstanceIdentifier<Node> nodePath = TOPOLOGY_PATH.child(Node.class, nodeKey);
<reference id="dataBroker"
interface="org.opendaylight.mdsal.binding.api.DataBroker"/>
<reference id="mountPointService"
- interface="org.opendaylight.mdsal.dom.api.DOMMountPointService"
- odl:type="default"/>
+ interface="org.opendaylight.mdsal.dom.api.DOMMountPointService"/>
<reference id="encryptionService"
interface="org.opendaylight.aaa.encrypt.AAAEncryptionService" />
<reference id="deviceActionFactory"
*/
package org.opendaylight.netconf.topology.impl;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import io.netty.util.concurrent.EventExecutor;
import java.util.Collection;
import java.util.HashSet;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
PathArgument pa = IdentifiableItem.of(Node.class, new NodeKey(NODE_ID));
when(newNode.getIdentifier()).thenReturn(pa);
-
- final NetconfNode testingNode = new NetconfNodeBuilder()
- .setHost(new Host(new IpAddress(new Ipv4Address("127.0.0.1"))))
- .setPort(new PortNumber(Uint16.valueOf(9999)))
- .setReconnectOnChangedSchema(true)
- .setDefaultRequestTimeoutMillis(Uint32.valueOf(1000))
- .setBetweenAttemptsTimeoutMillis(Uint16.valueOf(100))
- .setKeepaliveDelay(Uint32.valueOf(1000))
- .setTcpOnly(true)
- .setCredentials(new LoginPasswordBuilder()
- .setUsername("testuser").setPassword("testpassword").build())
- .build();
-
- final NodeBuilder nn = new NodeBuilder().addAugmentation(NetconfNode.class, testingNode);
+ final NodeBuilder nn = new NodeBuilder()
+ .addAugmentation(new NetconfNodeBuilder()
+ .setHost(new Host(new IpAddress(new Ipv4Address("127.0.0.1"))))
+ .setPort(new PortNumber(Uint16.valueOf(9999)))
+ .setReconnectOnChangedSchema(true)
+ .setDefaultRequestTimeoutMillis(Uint32.valueOf(1000))
+ .setBetweenAttemptsTimeoutMillis(Uint16.valueOf(100))
+ .setKeepaliveDelay(Uint32.valueOf(1000))
+ .setTcpOnly(true)
+ .setCredentials(new LoginPasswordBuilder()
+ .setUsername("testuser")
+ .setPassword("testpassword")
+ .build())
+ .build());
when(newNode.getDataAfter()).thenReturn(nn.build());
.build();
final NetconfReconnectingClientConfiguration configuration =
spyTopology.getClientConfig(sessionListener, testingNode);
- Assert.assertEquals(NetconfClientConfiguration.NetconfClientProtocol.TCP, configuration.getProtocol());
- Assert.assertNotNull(configuration.getAuthHandler());
- Assert.assertNull(configuration.getSslHandlerFactory());
+ assertEquals(NetconfClientConfiguration.NetconfClientProtocol.TCP, configuration.getProtocol());
+ assertNotNull(configuration.getAuthHandler());
+ assertNull(configuration.getSslHandlerFactory());
final NetconfNode testingNode2 = new NetconfNodeBuilder()
.build();
final NetconfReconnectingClientConfiguration configuration2 =
spyTopology.getClientConfig(sessionListener, testingNode2);
- Assert.assertEquals(NetconfClientConfiguration.NetconfClientProtocol.SSH, configuration2.getProtocol());
- Assert.assertNotNull(configuration2.getAuthHandler());
- Assert.assertNull(configuration2.getSslHandlerFactory());
+ assertEquals(NetconfClientConfiguration.NetconfClientProtocol.SSH, configuration2.getProtocol());
+ assertNotNull(configuration2.getAuthHandler());
+ assertNull(configuration2.getSslHandlerFactory());
final NetconfNode testingNode3 = new NetconfNodeBuilder()
.build();
final NetconfReconnectingClientConfiguration configuration3 =
spyTopology.getClientConfig(sessionListener, testingNode3);
- Assert.assertEquals(NetconfClientConfiguration.NetconfClientProtocol.SSH, configuration3.getProtocol());
- Assert.assertNotNull(configuration3.getAuthHandler());
- Assert.assertNull(configuration3.getSslHandlerFactory());
+ assertEquals(NetconfClientConfiguration.NetconfClientProtocol.SSH, configuration3.getProtocol());
+ assertNotNull(configuration3.getAuthHandler());
+ assertNull(configuration3.getSslHandlerFactory());
final NetconfNode testingNode4 = new NetconfNodeBuilder()
.build();
final NetconfReconnectingClientConfiguration configuration4 =
spyTopology.getClientConfig(sessionListener, testingNode4);
- Assert.assertEquals(NetconfClientConfiguration.NetconfClientProtocol.TLS, configuration4.getProtocol());
- Assert.assertNull(configuration4.getAuthHandler());
- Assert.assertNotNull(configuration4.getSslHandlerFactory());
+ assertEquals(NetconfClientConfiguration.NetconfClientProtocol.TLS, configuration4.getProtocol());
+ assertNull(configuration4.getAuthHandler());
+ assertNotNull(configuration4.getSslHandlerFactory());
}
public static class TestingNetconfTopologyImpl extends NetconfTopologyImpl {
public void hideCredentialsTest() {
final String userName = "admin";
final String password = "pa$$word";
- final NetconfNode netconfNode = new NetconfNodeBuilder()
- .setHost(new Host(new IpAddress(new Ipv4Address("127.0.0.1"))))
- .setPort(new PortNumber(Uint16.valueOf(9999)))
- .setReconnectOnChangedSchema(true)
- .setDefaultRequestTimeoutMillis(Uint32.valueOf(1000))
- .setBetweenAttemptsTimeoutMillis(Uint16.valueOf(100))
- .setKeepaliveDelay(Uint32.valueOf(1000))
- .setTcpOnly(false)
- .setProtocol(new ProtocolBuilder().setName(Name.TLS).build())
- .setCredentials(new LoginPasswordBuilder()
- .setUsername(userName).setPassword(password).build())
- .build();
final Node node = new NodeBuilder()
- .addAugmentation(NetconfNode.class, netconfNode)
+ .addAugmentation(new NetconfNodeBuilder()
+ .setHost(new Host(new IpAddress(new Ipv4Address("127.0.0.1"))))
+ .setPort(new PortNumber(Uint16.valueOf(9999)))
+ .setReconnectOnChangedSchema(true)
+ .setDefaultRequestTimeoutMillis(Uint32.valueOf(1000))
+ .setBetweenAttemptsTimeoutMillis(Uint16.valueOf(100))
+ .setKeepaliveDelay(Uint32.valueOf(1000))
+ .setTcpOnly(false)
+ .setProtocol(new ProtocolBuilder().setName(Name.TLS).build())
+ .setCredentials(new LoginPasswordBuilder()
+ .setUsername(userName)
+ .setPassword(password)
+ .build())
+ .build())
.setNodeId(NodeId.getDefaultInstance("junos"))
.build();
final String transformedNetconfNode = AbstractNetconfTopology.hideCredentials(node);
- Assert.assertTrue(transformedNetconfNode.contains("credentials=***"));
- Assert.assertFalse(transformedNetconfNode.contains(userName));
- Assert.assertFalse(transformedNetconfNode.contains(password));
+ assertTrue(transformedNetconfNode.contains("credentials=***"));
+ assertFalse(transformedNetconfNode.contains(userName));
+ assertFalse(transformedNetconfNode.contains(password));
}
}
<name>${project.artifactId}</name>
<packaging>bundle</packaging>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>config-artifacts</artifactId>
- <version>0.12.0</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
<dependencies>
<dependency>
<groupId>com.typesafe.akka</groupId>
- <artifactId>akka-actor_2.12</artifactId>
+ <artifactId>akka-actor_2.13</artifactId>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
- <artifactId>akka-cluster_2.12</artifactId>
+ <artifactId>akka-cluster_2.13</artifactId>
</dependency>
<dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
- <artifactId>akka-testkit_2.12</artifactId>
+ <artifactId>akka-testkit_2.13</artifactId>
</dependency>
</dependencies>
</project>
// on leader node would be same as on follower node
final ProxyDOMDataBroker proxyDataBroker = new ProxyDOMDataBroker(id, masterActorRef, actorSystem.dispatcher(),
actorResponseWaitTime);
- salProvider.getMountInstance().onTopologyDeviceConnected(currentMountContext.getSchemaContext(),
+ salProvider.getMountInstance().onTopologyDeviceConnected(currentMountContext.getEffectiveModelContext(),
proxyDataBroker, deviceRpc, notificationService, deviceAction);
}
}
private Future<Object> sendInitialDataToActor() {
- final List<SourceIdentifier> sourceIdentifiers =
- SchemaContextUtil.getConstituentModuleIdentifiers(currentMountContext.getSchemaContext()).stream()
+ final List<SourceIdentifier> sourceIdentifiers = SchemaContextUtil.getConstituentModuleIdentifiers(
+ currentMountContext.getEffectiveModelContext()).stream()
.map(mi -> RevisionSourceIdentifier.create(mi.getName(), mi.getRevision()))
.collect(Collectors.toList());
import org.opendaylight.netconf.sal.connect.netconf.sal.NetconfDeviceNotificationService;
import org.opendaylight.netconf.sal.connect.netconf.sal.NetconfDeviceSalProvider;
import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
this.actorResponseWaitTime = actorResponseWaitTime;
}
- public void registerSlaveMountPoint(final SchemaContext remoteSchemaContext, final DOMRpcService deviceRpc,
+ public void registerSlaveMountPoint(final EffectiveModelContext remoteSchemaContext, final DOMRpcService deviceRpc,
final DOMActionService deviceAction, final ActorRef masterActorRef) {
if (!registered.compareAndSet(false, true)) {
return;
import org.opendaylight.netconf.topology.singleton.messages.transactions.NewWriteTransactionRequest;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.repo.api.EffectiveModelContextFactory;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository;
LOG.debug("{}: invokeSlaveRpc for {}, input: {} on rpc service {}", id, schemaPath, normalizedNodeMessage,
deviceRpc);
- final ListenableFuture<DOMRpcResult> rpcResult = deviceRpc.invokeRpc(schemaPath,
+ final ListenableFuture<? extends DOMRpcResult> rpcResult = deviceRpc.invokeRpc(schemaPath,
normalizedNodeMessage != null ? normalizedNodeMessage.getNode() : null);
Futures.addCallback(rpcResult, new FutureCallback<DOMRpcResult>() {
final SlaveSalFacade localSlaveSalManager, final ActorRef masterReference, final int tries) {
final ListenableFuture<EffectiveModelContext> schemaContextFuture =
schemaContextFactory.createEffectiveModelContext(sourceIdentifiers);
- Futures.addCallback(schemaContextFuture, new FutureCallback<SchemaContext>() {
+ Futures.addCallback(schemaContextFuture, new FutureCallback<EffectiveModelContext>() {
@Override
- public void onSuccess(final SchemaContext result) {
+ public void onSuccess(final EffectiveModelContext result) {
executeInSelf(() -> {
// Make sure the slaveSalManager instance hasn't changed since we initiated the schema context
// resolution.
interface="org.opendaylight.netconf.client.NetconfClientDispatcher"
odl:type="netconf-client-dispatcher"/>
<reference id="mountPointService"
- interface="org.opendaylight.mdsal.dom.api.DOMMountPointService"
- odl:type="default"/>
+ interface="org.opendaylight.mdsal.dom.api.DOMMountPointService"/>
<reference id="deviceActionFactory"
interface="org.opendaylight.netconf.sal.connect.api.DeviceActionFactory"/>
<reference id="schemaManager"
import akka.testkit.javadsl.TestKit;
import akka.util.Timeout;
import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.Futures;
import io.netty.util.concurrent.SucceededFuture;
import java.io.File;
import java.util.AbstractMap.SimpleEntry;
-import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
+import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.Set;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.aaa.encrypt.AAAEncryptionService;
+import org.opendaylight.binding.runtime.spi.BindingRuntimeHelpers;
import org.opendaylight.controller.cluster.ActorSystemProvider;
import org.opendaylight.controller.config.threadpool.ScheduledThreadPool;
import org.opendaylight.controller.config.threadpool.ThreadPool;
import org.opendaylight.mdsal.binding.api.WriteTransaction;
import org.opendaylight.mdsal.binding.dom.adapter.test.AbstractConcurrentDataBrokerTest;
import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
-import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext;
import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.mdsal.dom.api.DOMActionProviderService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.network.topology.topology.topology.types.TopologyNetconf;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.topology.singleton.config.rev170419.Config;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.topology.singleton.config.rev170419.ConfigBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.GetTopInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.GetTopOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.PutTopInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
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.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
import org.opendaylight.yangtools.yang.model.repo.spi.PotentialSchemaSource;
+import org.opendaylight.yangtools.yang.parser.impl.YangParserFactoryImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private final EventExecutor eventExecutor = GlobalEventExecutor.INSTANCE;
private final Config config = new ConfigBuilder().setWriteTransactionIdleTimeout(Uint16.ZERO).build();
- private SchemaContext deviceSchemaContext;
+ private EffectiveModelContext deviceSchemaContext;
private YangModuleInfo topModuleInfo;
private SchemaPath putTopRpcSchemaPath;
private SchemaPath getTopRpcSchemaPath;
private BindingNormalizedNodeSerializer bindingToNormalized;
private YangInstanceIdentifier yangNodeInstanceId;
private final TopDOMRpcImplementation topRpcImplementation = new TopDOMRpcImplementation();
+ private final ContainerNode getTopInput = ImmutableNodes.containerNode(GetTopInput.QNAME);
private SchemaResourceManager resourceManager;
public void setUp() throws Exception {
deleteCacheDir();
- resourceManager = new DefaultSchemaResourceManager(TEST_ROOT_DIRECTORY, TEST_DEFAULT_SUBDIR);
+ resourceManager = new DefaultSchemaResourceManager(new YangParserFactoryImpl(), TEST_ROOT_DIRECTORY,
+ TEST_DEFAULT_SUBDIR);
topModuleInfo = BindingReflections.getModuleInfo(Top.class);
- final ModuleInfoBackedContext moduleContext = ModuleInfoBackedContext.create();
- moduleContext.addModuleInfos(Arrays.asList(topModuleInfo));
- deviceSchemaContext = moduleContext.tryToCreateSchemaContext().get();
+ deviceSchemaContext = BindingRuntimeHelpers.createEffectiveModel(Top.class);
- deviceRpcService.onGlobalContextUpdated(deviceSchemaContext);
+ deviceRpcService.onModelContextUpdated(deviceSchemaContext);
putTopRpcSchemaPath = findRpcDefinition("put-top").getPath();
getTopRpcSchemaPath = findRpcDefinition("get-top").getPath();
AbstractConcurrentDataBrokerTest dataBrokerTest = newDataBrokerTest();
masterDataBroker = dataBrokerTest.getDataBroker();
deviceDOMDataBroker = dataBrokerTest.getDomBroker();
- bindingToNormalized = dataBrokerTest.getDataBrokerTestCustomizer().getBindingToNormalized();
+ bindingToNormalized = dataBrokerTest.getDataBrokerTestCustomizer().getAdapterContext().currentSerializer();
masterSystem = ActorSystem.create(ACTOR_SYSTEM_NAME, ConfigFactory.load().getConfig("Master"));
RpcResultBuilder.newError(ErrorType.APPLICATION, "tag2", "error2"))));
testGetTopRpc(domRpcService, new DefaultDOMRpcResult(bindingToNormalized.toNormalizedNodeRpcData(
- new GetTopOutputBuilder().setTopLevelList(Arrays.asList(new TopLevelListBuilder().setName("one")
- .build())).build())));
+ new GetTopOutputBuilder().setTopLevelList(oneTopLevelList()).build())));
- testFailedRpc(domRpcService, getTopRpcSchemaPath, null);
+ testFailedRpc(domRpcService, getTopRpcSchemaPath, getTopInput);
}
private void testPutTopRpc(final DOMRpcService domRpcService, final DOMRpcResult result)
throws InterruptedException, ExecutionException, TimeoutException {
ContainerNode putTopInput = bindingToNormalized.toNormalizedNodeRpcData(
- new PutTopInputBuilder().setTopLevelList(Arrays.asList(new TopLevelListBuilder().setName("one")
- .build())).build());
+ new PutTopInputBuilder().setTopLevelList(oneTopLevelList()).build());
testRpc(domRpcService, putTopRpcSchemaPath, putTopInput, result);
}
+ private static Map<TopLevelListKey, TopLevelList> oneTopLevelList() {
+ final TopLevelListKey key = new TopLevelListKey("one");
+ return ImmutableMap.of(key, new TopLevelListBuilder().withKey(key).build());
+ }
+
private void testGetTopRpc(final DOMRpcService domRpcService, final DOMRpcResult result)
throws InterruptedException, ExecutionException, TimeoutException {
- testRpc(domRpcService, getTopRpcSchemaPath, null, result);
+ testRpc(domRpcService, getTopRpcSchemaPath, getTopInput, result);
}
private void testRpc(final DOMRpcService domRpcService, final SchemaPath schemaPath,
final NormalizedNode<?, ?> input, final FluentFuture<DOMRpcResult> returnFuture)
throws InterruptedException, ExecutionException, TimeoutException {
topRpcImplementation.init(returnFuture);
- final ListenableFuture<DOMRpcResult> resultFuture = domRpcService.invokeRpc(schemaPath, input);
+ final ListenableFuture<? extends DOMRpcResult> resultFuture = domRpcService.invokeRpc(schemaPath, input);
topRpcImplementation.verify(DOMRpcIdentifier.create(schemaPath), input);
private static void writeNetconfNode(final String cacheDir, final DataBroker databroker)
throws InterruptedException, ExecutionException, TimeoutException {
- final NetconfNode netconfNode = new NetconfNodeBuilder()
- .setHost(new Host(new IpAddress(new Ipv4Address("127.0.0.1"))))
- .setPort(new PortNumber(Uint16.valueOf(1234)))
- .setActorResponseWaitTime(Uint16.valueOf(10))
- .setTcpOnly(Boolean.TRUE)
- .setSchemaless(Boolean.FALSE)
- .setKeepaliveDelay(Uint32.ZERO)
- .setConnectionTimeoutMillis(Uint32.valueOf(5000))
- .setDefaultRequestTimeoutMillis(Uint32.valueOf(5000))
- .setMaxConnectionAttempts(Uint32.ONE)
- .setCredentials(new LoginPwUnencryptedBuilder().setLoginPasswordUnencrypted(
- new LoginPasswordUnencryptedBuilder().setUsername("user").setPassword("pass").build()).build())
- .setSchemaCacheDirectory(cacheDir)
+ final Node node = new NodeBuilder()
+ .setNodeId(NODE_ID)
+ .addAugmentation(new NetconfNodeBuilder()
+ .setHost(new Host(new IpAddress(new Ipv4Address("127.0.0.1"))))
+ .setPort(new PortNumber(Uint16.valueOf(1234)))
+ .setActorResponseWaitTime(Uint16.valueOf(10))
+ .setTcpOnly(Boolean.TRUE)
+ .setSchemaless(Boolean.FALSE)
+ .setKeepaliveDelay(Uint32.ZERO)
+ .setConnectionTimeoutMillis(Uint32.valueOf(5000))
+ .setDefaultRequestTimeoutMillis(Uint32.valueOf(5000))
+ .setMaxConnectionAttempts(Uint32.ONE)
+ .setCredentials(new LoginPwUnencryptedBuilder()
+ .setLoginPasswordUnencrypted(new LoginPasswordUnencryptedBuilder()
+ .setUsername("user")
+ .setPassword("pass")
+ .build())
+ .build())
+ .setSchemaCacheDirectory(cacheDir)
+ .build())
.build();
- final Node node = new NodeBuilder().setNodeId(NODE_ID).addAugmentation(NetconfNode.class, netconfNode).build();
final WriteTransaction writeTx = databroker.newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, NODE_INSTANCE_ID, node);
import org.opendaylight.yangtools.concepts.ObjectRegistration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.Uint16;
+import org.opendaylight.yangtools.yang.model.repo.api.EffectiveModelContextFactory;
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaContextFactory;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
import org.opendaylight.yangtools.yang.model.repo.spi.PotentialSchemaSource;
private NetconfDeviceSchemasResolver mockSchemasResolver;
@Mock
- private SchemaContextFactory mockSchemaContextFactory;
+ private EffectiveModelContextFactory mockSchemaContextFactory;
private ActorSystem slaveSystem;
private ActorSystem masterSystem;
// Connected. Expect the slave mount point created and registered.
final NetconfNode netconfNode = newNetconfNode();
- final Node node = new NodeBuilder().setNodeId(nodeId).addAugmentation(NetconfNode.class, netconfNode).build();
+ final Node node = new NodeBuilder().setNodeId(nodeId).addAugmentation(netconfNode).build();
DataObjectModification<Node> mockDataObjModification = mock(DataObjectModification.class);
doReturn(Iterables.getLast(nodeListPath.getPathArguments())).when(mockDataObjModification).getIdentifier();
setupMountPointMocks();
final Node updatedNode = new NodeBuilder().setNodeId(nodeId)
- .addAugmentation(NetconfNode.class, new NetconfNodeBuilder(netconfNode)
- .setConnectionStatus(NetconfNodeConnectionStatus.ConnectionStatus.UnableToConnect)
- .build()).build();
+ .addAugmentation(new NetconfNodeBuilder(netconfNode)
+ .setConnectionStatus(NetconfNodeConnectionStatus.ConnectionStatus.UnableToConnect)
+ .build())
+ .build();
doReturn(SUBTREE_MODIFIED).when(mockDataObjModification).getModificationType();
doReturn(node).when(mockDataObjModification).getDataBefore();
nodeKey, topologyId);
final NetconfNode netconfNode = newNetconfNode();
- final Node node = new NodeBuilder().setNodeId(nodeId).addAugmentation(NetconfNode.class, netconfNode).build();
+ final Node node = new NodeBuilder().setNodeId(nodeId).addAugmentation(netconfNode).build();
DataObjectModification<Node> mockDataObjModification = mock(DataObjectModification.class);
doReturn(Iterables.getLast(nodeListPath.getPathArguments())).when(mockDataObjModification).getIdentifier();
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
import org.opendaylight.yangtools.yang.common.Uint16;
+import org.opendaylight.yangtools.yang.parser.impl.YangParserFactoryImpl;
public class NetconfTopologyManagerTest {
private static final Uint16 ACTOR_RESPONSE_WAIT_TIME = Uint16.valueOf(10);
netconfTopologyManager = new NetconfTopologyManager(dataBroker, rpcProviderRegistry, actionProviderRegistry,
clusterSingletonServiceProvider, keepaliveExecutor, processingThreadPool,
actorSystemProvider, eventExecutor, clientDispatcher, TOPOLOGY_ID, config,
- mountPointService, encryptionService, deviceActionFactory, new DefaultSchemaResourceManager()) {
+ mountPointService, encryptionService, deviceActionFactory,
+ new DefaultSchemaResourceManager(new YangParserFactoryImpl())) {
@Override
protected NetconfTopologyContext newNetconfTopologyContext(final NetconfTopologySetup setup,
final ServiceGroupIdentifier serviceGroupIdent, final Timeout actorResponseWaitTime,
.setPort(new PortNumber(Uint16.valueOf(1111)))
.setActorResponseWaitTime(ACTOR_RESPONSE_WAIT_TIME)
.build();
- final Node node1 = new NodeBuilder().setNodeId(nodeId1).addAugmentation(NetconfNode.class,
- netconfNode1).build();
+ final Node node1 = new NodeBuilder().setNodeId(nodeId1).addAugmentation(netconfNode1).build();
final DataObjectModification<Node> dataObjectModification1 = mock(DataObjectModification.class);
doReturn(WRITE).when(dataObjectModification1).getModificationType();
.setPort(new PortNumber(Uint16.valueOf(2222)))
.setActorResponseWaitTime(ACTOR_RESPONSE_WAIT_TIME)
.build();
- final Node node2 = new NodeBuilder().setNodeId(nodeId2).addAugmentation(NetconfNode.class,
- netconfNode2).build();
+ final Node node2 = new NodeBuilder().setNodeId(nodeId2).addAugmentation(netconfNode2).build();
final DataObjectModification<Node> dataObjectModification2 = mock(DataObjectModification.class);
doReturn(WRITE).when(dataObjectModification2).getModificationType();
final NetconfNode updatedNetconfNode1 = new NetconfNodeBuilder(netconfNode1)
.setPort(new PortNumber(Uint16.valueOf(33333))).build();
- final Node updatedNode1 = new NodeBuilder().setNodeId(nodeId1).addAugmentation(NetconfNode.class,
- updatedNetconfNode1).build();
+ final Node updatedNode1 = new NodeBuilder().setNodeId(nodeId1).addAugmentation(updatedNetconfNode1).build();
doReturn(WRITE).when(dataObjectModification1).getModificationType();
doReturn(node1).when(dataObjectModification1).getDataBefore();
final InstanceIdentifier<Node> nodeInstanceId = NetconfTopologyUtils.createTopologyNodeListPath(
new NodeKey(nodeId), TOPOLOGY_ID);
- final NetconfNode netconfNode = new NetconfNodeBuilder()
- .setHost(new Host(new IpAddress(new Ipv4Address("127.0.0.1"))))
- .setPort(new PortNumber(Uint16.valueOf(10)))
- .setActorResponseWaitTime(ACTOR_RESPONSE_WAIT_TIME).build();
- final Node node = new NodeBuilder().setNodeId(nodeId).addAugmentation(NetconfNode.class,
- netconfNode).build();
+ final Node node = new NodeBuilder()
+ .setNodeId(nodeId)
+ .addAugmentation(new NetconfNodeBuilder()
+ .setHost(new Host(new IpAddress(new Ipv4Address("127.0.0.1"))))
+ .setPort(new PortNumber(Uint16.valueOf(10)))
+ .setActorResponseWaitTime(ACTOR_RESPONSE_WAIT_TIME)
+ .build())
+ .build();
final DataObjectModification<Node> dataObjectModification = mock(DataObjectModification.class);
doReturn(WRITE).when(dataObjectModification).getModificationType();
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder;
import org.opendaylight.yangtools.yang.common.Uint16;
import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.parser.impl.YangParserFactoryImpl;
import scala.concurrent.duration.Duration;
public class RemoteDeviceConnectorImplTest {
@SuppressWarnings("unchecked")
@Test
public void testStopRemoteDeviceConnection() {
- final Credentials credentials = new LoginPasswordBuilder()
- .setPassword("admin").setUsername("admin").build();
- final NetconfNode netconfNode = new NetconfNodeBuilder()
+ builder.setNode(new NodeBuilder().setNodeId(NODE_ID)
+ .addAugmentation(new NetconfNodeBuilder()
.setHost(new Host(new IpAddress(new Ipv4Address("127.0.0.1"))))
.setPort(new PortNumber(Uint16.valueOf(9999)))
.setReconnectOnChangedSchema(true)
.setBetweenAttemptsTimeoutMillis(Uint16.valueOf(100))
.setSchemaless(false)
.setTcpOnly(false)
- .setCredentials(credentials)
- .build();
- final Node node = new NodeBuilder().setNodeId(NODE_ID).addAugmentation(NetconfNode.class, netconfNode).build();
-
- builder.setNode(node);
-
+ .setCredentials(new LoginPasswordBuilder()
+ .setPassword("admin").setUsername("admin")
+ .build())
+ .build())
+ .build());
final NetconfDeviceCommunicator communicator = mock(NetconfDeviceCommunicator.class);
final RemoteDeviceHandler<NetconfSessionPreferences> salFacade = mock(RemoteDeviceHandler.class);
verify(communicator, times(1)).close();
verify(salFacade, times(1)).close();
-
}
@SuppressWarnings("unchecked")
.setKeepaliveDelay(Uint32.ONE)
.build();
- final Node node = new NodeBuilder().setNodeId(NODE_ID).addAugmentation(NetconfNode.class, netconfNode).build();
+ final Node node = new NodeBuilder().setNodeId(NODE_ID).addAugmentation(netconfNode).build();
- builder.setSchemaResourceDTO(new DefaultSchemaResourceManager().getSchemaResources(netconfNode, "foo"));
+ builder.setSchemaResourceDTO(new DefaultSchemaResourceManager(new YangParserFactoryImpl())
+ .getSchemaResources(netconfNode, "foo"));
final RemoteDeviceConnectorImpl remoteDeviceConnection =
new RemoteDeviceConnectorImpl(builder.build(), remoteDeviceId, deviceActionFactory);
<description>NETCONF topology APIs</description>
<packaging>bundle</packaging>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>config-artifacts</artifactId>
- <version>0.12.0</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
<dependencies>
<dependency>
<groupId>org.opendaylight.aaa</groupId>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
- <dependency>
- <groupId>org.xmlunit</groupId>
- <artifactId>xmlunit-legacy</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-binding-generator-impl</artifactId>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>mockito-configuration</artifactId>
<groupId>org.osgi</groupId>
<artifactId>osgi.cmpn</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>org.xmlunit</groupId>
+ <artifactId>xmlunit-legacy</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>mdsal-binding-generator-impl</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>mdsal-binding-runtime-spi</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeStreamWriter;
import org.opendaylight.yangtools.yang.data.impl.schema.NormalizedNodeResult;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.slf4j.Logger;
// FIXME: document this interface contract. Does it support RFC8528/RFC8542? How?
- public static NormalizedNodeResult transformDOMSourceToNormalizedNode(final SchemaContext schemaContext,
+ public static NormalizedNodeResult transformDOMSourceToNormalizedNode(final EffectiveModelContext schemaContext,
final DOMSource value) throws XMLStreamException, URISyntaxException, IOException, SAXException {
return transformDOMSourceToNormalizedNode(new EmptyMountPointContext(schemaContext), value);
}
import static java.util.Objects.requireNonNull;
import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
import java.util.Collection;
import java.util.Collections;
-import java.util.List;
import java.util.Map;
import java.util.Optional;
-import java.util.Set;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.ActionDefinition;
import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.Status;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
import org.opendaylight.yangtools.yang.model.api.UsesNode;
/**
*/
public final class NodeContainerProxy implements ContainerSchemaNode {
- private final Map<QName, DataSchemaNode> childNodes;
+ private final Map<QName, ? extends DataSchemaNode> childNodes;
private final QName qualifiedName;
- private final Set<AugmentationSchemaNode> availableAugmentations;
+ private final Collection<? extends AugmentationSchemaNode> availableAugmentations;
- public NodeContainerProxy(final QName qualifiedName, final Map<QName, DataSchemaNode> childNodes,
- final Set<AugmentationSchemaNode> availableAugmentations) {
+ public NodeContainerProxy(final QName qualifiedName, final Map<QName, ? extends DataSchemaNode> childNodes,
+ final Collection<? extends AugmentationSchemaNode> availableAugmentations) {
this.availableAugmentations = availableAugmentations;
this.childNodes = requireNonNull(childNodes, "childNodes");
this.qualifiedName = qualifiedName;
}
- public NodeContainerProxy(final QName qualifiedName, final Collection<DataSchemaNode> childNodes) {
+ public NodeContainerProxy(final QName qualifiedName, final Collection<? extends DataSchemaNode> childNodes) {
this(qualifiedName, asMap(childNodes), Collections.emptySet());
}
- public NodeContainerProxy(final QName qualifiedName, final Collection<DataSchemaNode> childNodes,
- final Set<AugmentationSchemaNode> availableAugmentations) {
+ public NodeContainerProxy(final QName qualifiedName, final Collection<? extends DataSchemaNode> childNodes,
+ final Collection<? extends AugmentationSchemaNode> availableAugmentations) {
this(qualifiedName, asMap(childNodes), availableAugmentations);
}
- private static Map<QName, DataSchemaNode> asMap(final Collection<DataSchemaNode> childNodes) {
+ private static Map<QName, ? extends DataSchemaNode> asMap(final Collection<? extends DataSchemaNode> childNodes) {
return Maps.uniqueIndex(childNodes, DataSchemaNode::getQName);
}
@Override
- public Set<TypeDefinition<?>> getTypeDefinitions() {
+ public Collection<? extends TypeDefinition<?>> getTypeDefinitions() {
return Collections.emptySet();
}
@Override
- public Set<DataSchemaNode> getChildNodes() {
- return Sets.newHashSet(childNodes.values());
+ public Collection<? extends DataSchemaNode> getChildNodes() {
+ return childNodes.values();
}
@Override
- public Set<GroupingDefinition> getGroupings() {
+ public Collection<? extends GroupingDefinition> getGroupings() {
return Collections.emptySet();
}
}
@Override
- public Set<UsesNode> getUses() {
+ public Collection<? extends UsesNode> getUses() {
return Collections.emptySet();
}
}
@Override
- public Set<AugmentationSchemaNode> getAvailableAugmentations() {
+ public Collection<? extends AugmentationSchemaNode> getAvailableAugmentations() {
return availableAugmentations;
}
}
@Override
- public List<UnknownSchemaNode> getUnknownSchemaNodes() {
- return Collections.emptyList();
- }
-
- @Override
- public Set<NotificationDefinition> getNotifications() {
+ public Collection<? extends NotificationDefinition> getNotifications() {
return Collections.emptySet();
}
@Override
- public Set<ActionDefinition> getActions() {
+ public Collection<? extends ActionDefinition> getActions() {
return Collections.emptySet();
}
}
@Override
- public Collection<MustDefinition> getMustConstraints() {
+ public Collection<? extends MustDefinition> getMustConstraints() {
return Collections.emptySet();
}
}
private static ChoiceSchemaNode findChoice(final Iterable<ChoiceSchemaNode> choices, final QName child) {
for (final ChoiceSchemaNode choice : choices) {
- for (final CaseSchemaNode caze : choice.getCases().values()) {
+ for (final CaseSchemaNode caze : choice.getCases()) {
if (findChildSchemaNode(caze, child).isPresent()) {
return choice;
}
super(NodeIdentifier.create(schema.getQName()));
final ImmutableMap.Builder<PathArgument, StreamingContext<?>> byArgBuilder = ImmutableMap.builder();
- for (final CaseSchemaNode caze : schema.getCases().values()) {
+ for (final CaseSchemaNode caze : schema.getCases()) {
for (final DataSchemaNode cazeChild : caze.getChildNodes()) {
final StreamingContext<?> childOp = fromDataSchemaNode(cazeChild);
byArgBuilder.put(childOp.getIdentifier(), childOp);
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext;
+import org.opendaylight.binding.runtime.spi.BindingRuntimeHelpers;
import org.opendaylight.netconf.api.xml.XmlUtil;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.$YangModuleInfoImpl;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.NetconfState;
@Test
public void testWriteNormalizedNode() throws Exception {
- final ModuleInfoBackedContext moduleInfoBackedContext = ModuleInfoBackedContext.create();
- moduleInfoBackedContext.addModuleInfos(Collections.singletonList($YangModuleInfoImpl.getInstance()));
- final SchemaContext context = moduleInfoBackedContext.getSchemaContext();
+ final SchemaContext context = BindingRuntimeHelpers.createEffectiveModel(
+ Collections.singletonList($YangModuleInfoImpl.getInstance()));
final LeafNode<?> username = Builders.leafBuilder()
.withNodeIdentifier(new NodeIdentifier(QName.create(Session.QNAME, "username")))
.withValue("admin")
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>mdsal-binding-generator-impl</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>mdsal-binding-runtime-spi</artifactId>
+ </dependency>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>mdsal-dom-spi</artifactId>
import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences;
import org.opendaylight.netconf.sal.connect.netconf.sal.NetconfDeviceRpc;
import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
/**
* Factory for netconf device schemas.
public interface NetconfDeviceSchemasResolver {
NetconfDeviceSchemas resolve(
NetconfDeviceRpc deviceRpc, NetconfSessionPreferences remoteSessionCapabilities, RemoteDeviceId id,
- SchemaContext schemaContext);
+ EffectiveModelContext schemaContext);
}
import org.opendaylight.netconf.sal.connect.netconf.NetconfDevice.SchemaResourcesDTO;
import org.opendaylight.netconf.sal.connect.netconf.NetconfStateSchemasResolverImpl;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
+import org.opendaylight.yangtools.yang.model.parser.api.YangParserFactory;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaContextFactoryConfiguration;
import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
import org.opendaylight.yangtools.yang.model.repo.util.FilesystemSchemaSourceCache;
@GuardedBy("this")
private final Map<String, SchemaResourcesDTO> resources = new HashMap<>();
private final @NonNull SchemaResourcesDTO defaultResources;
+ private final YangParserFactory parserFactory;
private final String defaultSubdirectory;
private final String rootDirectory;
@Inject
- public DefaultSchemaResourceManager() {
- this("cache", "schema");
+ public DefaultSchemaResourceManager(final YangParserFactory parserFactory) {
+ this(parserFactory, "cache", "schema");
}
- public DefaultSchemaResourceManager(final String rootDirectory, final String defaultSubdirectory) {
+ public DefaultSchemaResourceManager(final YangParserFactory parserFactory, final String rootDirectory,
+ final String defaultSubdirectory) {
+ this.parserFactory = requireNonNull(parserFactory);
this.rootDirectory = requireNonNull(rootDirectory);
this.defaultSubdirectory = requireNonNull(defaultSubdirectory);
this.defaultResources = createResources(defaultSubdirectory);
private @NonNull SchemaResourcesDTO createResources(final String subdir) {
// Setup the baseline empty registry
- // FIXME: add YangParserFactory argument
- final SharedSchemaRepository repository = new SharedSchemaRepository(subdir);
+ final SharedSchemaRepository repository = new SharedSchemaRepository(subdir, parserFactory);
// Teach the registry how to transform YANG text to ASTSchemaSource internally
repository.registerSchemaSourceListener(TextToASTTransformer.create(repository, repository));
import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.util.AbstractSchemaContextProvider;
+import org.opendaylight.yangtools.yang.model.util.AbstractEffectiveModelContextProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
// TODO: this should really come from rfc8528-data-util
-final class DeviceMountPointContext extends AbstractSchemaContextProvider implements Immutable, MountPointContext {
+final class DeviceMountPointContext extends AbstractEffectiveModelContextProvider implements Immutable,
+ MountPointContext {
private static final Logger LOG = LoggerFactory.getLogger(DeviceMountPointContext.class);
private static final NodeIdentifier MOUNT_POINT = NodeIdentifier.create(
QName.create(SchemaMountConstants.RFC8528_MODULE, "mount-point").intern());
private final ImmutableMap<MountPointIdentifier, NetconfMountPointContextFactory> mountPoints;
- private DeviceMountPointContext(final SchemaContext schemaContext,
+ private DeviceMountPointContext(final EffectiveModelContext schemaContext,
final Map<MountPointIdentifier, NetconfMountPointContextFactory> mountPoints) {
super(schemaContext);
this.mountPoints = ImmutableMap.copyOf(mountPoints);
return emptyContext;
}
- final SchemaContext schemaContext = emptyContext.getSchemaContext();
+ final EffectiveModelContext schemaContext = emptyContext.getEffectiveModelContext();
final DataContainerChild<?, ?> mountPoint = optMountPoint.get();
checkArgument(mountPoint instanceof MapNode, "mount-point list %s is not a MapNode", mountPoint);
checkArgument(value instanceof String, "Unexpected module leaf value %s", value);
return (String) value;
}).orElseThrow(() -> new IllegalArgumentException("Mount module missing in " + entry));
- final Iterator<Module> it = schemaContext.findModules(moduleName).iterator();
+ final Iterator<? extends Module> it = schemaContext.findModules(moduleName).iterator();
checkArgument(it.hasNext(), "Failed to find a module named %s", moduleName);
final QNameModule module = it.next().getQNameModule();
@Override
public DeviceSources call() {
final NetconfDeviceSchemas availableSchemas = stateSchemasResolver.resolve(deviceRpc, remoteSessionCapabilities,
- id, baseSchema.getSchemaContext());
+ id, baseSchema.getEffectiveModelContext());
LOG.debug("{}: Schemas exposed by ietf-netconf-monitoring: {}", id,
availableSchemas.getAvailableYangSchemasQNames());
import javax.xml.stream.XMLStreamException;
import javax.xml.transform.dom.DOMSource;
import org.eclipse.jdt.annotation.Nullable;
-import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext;
+import org.opendaylight.binding.runtime.spi.BindingRuntimeHelpers;
import org.opendaylight.mdsal.dom.api.DOMRpcResult;
import org.opendaylight.netconf.sal.connect.api.NetconfDeviceSchemas;
import org.opendaylight.netconf.sal.connect.netconf.sal.NetconfDeviceRpc;
import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeStreamWriter;
import org.opendaylight.yangtools.yang.data.impl.schema.NormalizedNodeResult;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
import org.slf4j.Logger;
private static final Logger LOG = LoggerFactory.getLogger(LibraryModulesSchemas.class);
private static final Pattern DATE_PATTERN = Pattern.compile("(\\d{4}-\\d{2}-\\d{2})");
- private static final SchemaContext LIBRARY_CONTEXT;
-
- static {
- final ModuleInfoBackedContext moduleInfoBackedContext = ModuleInfoBackedContext.create();
- moduleInfoBackedContext.registerModuleInfo(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang
- .library.rev160621.$YangModuleInfoImpl.getInstance());
- LIBRARY_CONTEXT = moduleInfoBackedContext.tryToCreateSchemaContext().get();
- }
+ private static final EffectiveModelContext LIBRARY_CONTEXT = BindingRuntimeHelpers.createEffectiveModel(
+ ModulesState.class);
private static final NodeIdentifier MODULES_STATE_NID = NodeIdentifier.create(ModulesState.QNAME);
private static final NodeIdentifier MODULE_NID = NodeIdentifier.create(Module.QNAME);
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.model.repo.api.EffectiveModelContextFactory;
import org.opendaylight.yangtools.yang.model.repo.api.MissingSchemaSourceException;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaContextFactory;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaResolutionException;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
NodeIdentifier.create(RFC8528_SCHEMA_MOUNTS_QNAME));
protected final RemoteDeviceId id;
- protected final SchemaContextFactory schemaContextFactory;
+ protected final EffectiveModelContextFactory schemaContextFactory;
protected final SchemaSourceRegistry schemaRegistry;
protected final SchemaRepository schemaRepository;
}
// Set up the SchemaContext for the device
- final ListenableFuture<SchemaContext> futureSchema = Futures.transformAsync(sourceResolverFuture,
+ final ListenableFuture<EffectiveModelContext> futureSchema = Futures.transformAsync(sourceResolverFuture,
deviceSources -> assembleSchemaContext(deviceSources, remoteSessionCapabilities), processingExecutor);
// Potentially acquire mount point list and interpret it
@SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
justification = "https://github.com/spotbugs/spotbugs/issues/811")
- private ListenableFuture<SchemaContext> assembleSchemaContext(final DeviceSources deviceSources,
+ private ListenableFuture<EffectiveModelContext> assembleSchemaContext(final DeviceSources deviceSources,
final NetconfSessionPreferences remoteSessionCapabilities) {
LOG.debug("{}: Resolved device sources to {}", id, deviceSources);
final SchemaSourceProvider<YangTextSchemaSource> yangProvider = deviceSources.getSourceProvider();
return new SchemaSetup(deviceSources, remoteSessionCapabilities).startResolution();
}
- private ListenableFuture<MountPointContext> createMountPointContext(final SchemaContext schemaContext,
+ private ListenableFuture<MountPointContext> createMountPointContext(final EffectiveModelContext schemaContext,
final BaseSchema baseSchema, final NetconfDeviceCommunicator listener) {
final MountPointContext emptyContext = new EmptyMountPointContext(schemaContext);
if (!schemaContext.findModule(SchemaMountConstants.RFC8528_MODULE).isPresent()) {
public static class SchemaResourcesDTO {
private final SchemaSourceRegistry schemaRegistry;
private final SchemaRepository schemaRepository;
- private final SchemaContextFactory schemaContextFactory;
+ private final EffectiveModelContextFactory schemaContextFactory;
private final NetconfDeviceSchemasResolver stateSchemasResolver;
public SchemaResourcesDTO(final SchemaSourceRegistry schemaRegistry,
final SchemaRepository schemaRepository,
- final SchemaContextFactory schemaContextFactory,
+ final EffectiveModelContextFactory schemaContextFactory,
final NetconfDeviceSchemasResolver deviceSchemasResolver) {
this.schemaRegistry = requireNonNull(schemaRegistry);
this.schemaRepository = requireNonNull(schemaRepository);
return schemaRepository;
}
- public SchemaContextFactory getSchemaContextFactory() {
+ public EffectiveModelContextFactory getSchemaContextFactory() {
return schemaContextFactory;
}
/**
* Schema builder that tries to build schema context from provided sources or biggest subset of it.
*/
- private final class SchemaSetup implements FutureCallback<SchemaContext> {
- private final SettableFuture<SchemaContext> resultFuture = SettableFuture.create();
+ private final class SchemaSetup implements FutureCallback<EffectiveModelContext> {
+ private final SettableFuture<EffectiveModelContext> resultFuture = SettableFuture.create();
private final DeviceSources deviceSources;
private final NetconfSessionPreferences remoteSessionCapabilities;
requiredSources.removeAll(missingSources);
}
- ListenableFuture<SchemaContext> startResolution() {
+ ListenableFuture<EffectiveModelContext> startResolution() {
trySetupSchema();
return resultFuture;
}
@Override
- public void onSuccess(final SchemaContext result) {
+ public void onSuccess(final EffectiveModelContext result) {
LOG.debug("{}: Schema context built successfully from {}", id, requiredSources);
final Collection<QName> filteredQNames = Sets.difference(deviceSources.getRequiredSourcesQName(),
if (!requiredSources.isEmpty()) {
// Initiate async resolution, drive it back based on the result
LOG.trace("{}: Trying to build schema context from {}", id, requiredSources);
- Futures.addCallback(schemaContextFactory.createSchemaContext(requiredSources), this,
+ Futures.addCallback(schemaContextFactory.createEffectiveModelContext(requiredSources), this,
MoreExecutors.directExecutor());
} else {
LOG.debug("{}: no more sources for schema context", id);
import org.opendaylight.yangtools.rfc8528.data.api.MountPointContext;
import org.opendaylight.yangtools.rfc8528.data.api.MountPointContextFactory;
import org.opendaylight.yangtools.rfc8528.data.api.YangLibraryConstants.ContainerName;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.parser.api.YangParserException;
// TODO: this should really come from mdsal-yanglib-rfc8525
final class NetconfMountPointContextFactory implements MountPointContextFactory {
private final MountPointContext mountPoint;
- NetconfMountPointContextFactory(final SchemaContext schemaContext) {
+ NetconfMountPointContextFactory(final EffectiveModelContext schemaContext) {
mountPoint = new EmptyMountPointContext(schemaContext);
}
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.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xml.sax.SAXException;
*/
static NetconfStateSchemas create(final DOMRpcService deviceRpc,
final NetconfSessionPreferences remoteSessionCapabilities, final RemoteDeviceId id,
- final SchemaContext schemaContext) {
+ final EffectiveModelContext schemaContext) {
if (!remoteSessionCapabilities.isMonitoringSupported()) {
// TODO - need to search for get-schema support, not just ietf-netconf-monitoring support
// issue might be a deviation to ietf-netconf-monitoring where get-schema is unsupported...
}
private static Optional<? extends NormalizedNode<?, ?>> findSchemasNode(final NormalizedNode<?, ?> result,
- final SchemaContext schemaContext) {
+ final EffectiveModelContext schemaContext) {
if (result == null) {
return Optional.empty();
}
import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.ModulesState;
import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
/**
* Default implementation resolving schemas QNames from netconf-state or from modules-state.
@Override
public NetconfDeviceSchemas resolve(final NetconfDeviceRpc deviceRpc,
final NetconfSessionPreferences remoteSessionCapabilities,
- final RemoteDeviceId id, final SchemaContext schemaContext) {
+ final RemoteDeviceId id, final EffectiveModelContext schemaContext) {
if (remoteSessionCapabilities.isMonitoringSupported()) {
return NetconfStateSchemas.create(deviceRpc, remoteSessionCapabilities, id, schemaContext);
}
private static final class ResponseWaiting implements Runnable {
- private final ListenableFuture<DOMRpcResult> rpcResultFuture;
+ private final ListenableFuture<? extends DOMRpcResult> rpcResultFuture;
private final ResponseWaitingScheduler responseWaitingScheduler;
ResponseWaiting(final ResponseWaitingScheduler responseWaitingScheduler,
- final ListenableFuture<DOMRpcResult> rpcResultFuture) {
+ final ListenableFuture<? extends DOMRpcResult> rpcResultFuture) {
this.responseWaitingScheduler = responseWaitingScheduler;
this.rpcResultFuture = rpcResultFuture;
}
* it.
*/
private static final class RequestTimeoutTask implements Runnable {
- private final ListenableFuture<DOMRpcResult> rpcResultFuture;
+ private final ListenableFuture<? extends DOMRpcResult> rpcResultFuture;
private final ResponseWaiting responseWaiting;
- RequestTimeoutTask(final ListenableFuture<DOMRpcResult> rpcResultFuture,
- final ResponseWaiting responseWaiting) {
+ RequestTimeoutTask(final ListenableFuture<? extends DOMRpcResult> rpcResultFuture,
+ final ResponseWaiting responseWaiting) {
this.rpcResultFuture = rpcResultFuture;
this.responseWaiting = responseWaiting;
}
* request-timeout-task to each RPC invocation.
*/
public static final class KeepaliveDOMRpcService implements DOMRpcService {
-
private final DOMRpcService deviceRpc;
private final ResetKeepalive resetKeepaliveTask;
private final long defaultRequestTimeoutMillis;
}
@Override
- public ListenableFuture<DOMRpcResult> invokeRpc(final SchemaPath type, final NormalizedNode<?, ?> input) {
- final ListenableFuture<DOMRpcResult> rpcResultFuture = deviceRpc.invokeRpc(type, input);
+ public ListenableFuture<? extends DOMRpcResult> invokeRpc(final SchemaPath type,
+ final NormalizedNode<?, ?> input) {
+ final ListenableFuture<? extends DOMRpcResult> rpcResultFuture = deviceRpc.invokeRpc(type, input);
final ResponseWaiting responseWaiting = new ResponseWaiting(responseWaitingScheduler, rpcResultFuture);
responseWaiting.start();
Futures.addCallback(rpcResultFuture, resetKeepaliveTask, MoreExecutors.directExecutor());
* Invokes RPC by sending netconf message via listener. Also transforms result from NetconfMessage to CompositeNode.
*/
public final class NetconfDeviceRpc implements DOMRpcService {
-
private final RemoteDeviceCommunicator<NetconfMessage> communicator;
private final MessageTransformer<NetconfMessage> transformer;
private final SchemaContext schemaContext;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.rfc8528.data.api.MountPointContext;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public synchronized void onDeviceConnected(final MountPointContext mountContext,
final NetconfSessionPreferences netconfSessionPreferences,
final DOMRpcService deviceRpc, final DOMActionService deviceAction) {
- final SchemaContext schemaContext = mountContext.getSchemaContext();
+ final EffectiveModelContext schemaContext = mountContext.getEffectiveModelContext();
final NetconfDeviceDataBroker netconfDeviceDataBroker =
new NetconfDeviceDataBroker(id, mountContext, deviceRpc, netconfSessionPreferences);
registerLockListener(netconfDeviceDataBroker);
import org.opendaylight.mdsal.dom.api.DOMRpcService;
import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
import org.opendaylight.yangtools.concepts.ObjectRegistration;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
this.id = requireNonNull(id);
}
- public void onTopologyDeviceConnected(final SchemaContext initialCtx,
+ public void onTopologyDeviceConnected(final EffectiveModelContext initialCtx,
final DOMDataBroker broker, final DOMRpcService rpc,
final NetconfDeviceNotificationService newNotificationService) {
onTopologyDeviceConnected(initialCtx, broker, rpc, newNotificationService, null);
}
- public synchronized void onTopologyDeviceConnected(final SchemaContext initialCtx,
+ public synchronized void onTopologyDeviceConnected(final EffectiveModelContext initialCtx,
final DOMDataBroker broker, final DOMRpcService rpc,
final NetconfDeviceNotificationService newNotificationService, final DOMActionService deviceAction) {
requireNonNull(mountService, "Closed");
createNetworkTopologyIfNotPresent(writeTx);
- final InstanceIdentifier<Node> path = id.getTopologyBindingPath();
- final NodeBuilder nodeBuilder = getNodeIdBuilder(id);
- NetconfNodeBuilder netconfNodeBuilder = new NetconfNodeBuilder();
- netconfNodeBuilder.setConnectionStatus(ConnectionStatus.Connecting);
- netconfNodeBuilder.setHost(id.getHost());
- netconfNodeBuilder.setPort(new PortNumber(Uint16.valueOf(id.getAddress().getPort())));
- nodeBuilder.addAugmentation(NetconfNode.class, netconfNodeBuilder.build());
- Node node = nodeBuilder.build();
+ final Node node = getNodeIdBuilder(id)
+ .addAugmentation(new NetconfNodeBuilder()
+ .setConnectionStatus(ConnectionStatus.Connecting)
+ .setHost(id.getHost())
+ .setPort(new PortNumber(Uint16.valueOf(id.getAddress().getPort()))).build())
+ .build();
LOG.trace("{}: Init device state transaction {} putting if absent operational data started.",
id, writeTx.getIdentifier());
- writeTx.put(LogicalDatastoreType.OPERATIONAL, path, node);
+ writeTx.put(LogicalDatastoreType.OPERATIONAL, id.getTopologyBindingPath(), node);
LOG.trace("{}: Init device state transaction {} putting operational data ended.", id, writeTx.getIdentifier());
LOG.trace("{}: Init device state transaction {} putting if absent config data started.",
id, writeTx.getIdentifier());
final WriteTransaction writeTx = txChain.newWriteOnlyTransaction();
LOG.trace("{}: Update device state transaction {} merging operational data started.",
id, writeTx.getIdentifier());
- writeTx.put(dsType, id.getTopologyBindingPath().augmentation(NetconfNode.class), data, true);
+ writeTx.mergeParentStructurePut(dsType, id.getTopologyBindingPath().augmentation(NetconfNode.class), data);
LOG.trace("{}: Update device state transaction {} merging operational data ended.",
id, writeTx.getIdentifier());
final WriteTransaction writeTx = txChain.newWriteOnlyTransaction();
LOG.trace("{}: Update device state transaction {} merging operational data started.",
id, writeTx.getIdentifier());
- writeTx.put(LogicalDatastoreType.OPERATIONAL,
- id.getTopologyBindingPath().augmentation(NetconfNode.class), data, true);
+ writeTx.mergeParentStructurePut(LogicalDatastoreType.OPERATIONAL,
+ id.getTopologyBindingPath().augmentation(NetconfNode.class), data);
LOG.trace("{}: Update device state transaction {} merging operational data ended.",
id, writeTx.getIdentifier());
LOG.trace(
"{}: Setting device state as failed {} putting operational data started.",
id, writeTx.getIdentifier());
- writeTx.put(LogicalDatastoreType.OPERATIONAL,
- id.getTopologyBindingPath().augmentation(NetconfNode.class), data, true);
+ writeTx.mergeParentStructurePut(LogicalDatastoreType.OPERATIONAL,
+ id.getTopologyBindingPath().augmentation(NetconfNode.class), data);
LOG.trace(
"{}: Setting device state as failed {} putting operational data ended.",
id, writeTx.getIdentifier());
pairs.clear();
if (dataAfter != null) {
- dataAfter.getKeyCredential().forEach(pair -> pairs.put(pair.key().getKeyId(), pair));
+ dataAfter.nonnullKeyCredential().values()
+ .forEach(pair -> pairs.put(pair.key().getKeyId(), pair));
}
} else if (changedChild.getDataType().equals(PrivateKey.class)) {
protected final RemoteDeviceId id;
protected final NetconfBaseOps netOps;
protected final boolean rollbackSupport;
- protected final List<ListenableFuture<DOMRpcResult>> resultsFutures = new ArrayList<>();
+ protected final List<ListenableFuture<? extends DOMRpcResult>> resultsFutures = new ArrayList<>();
private final List<TxListener> listeners = new CopyOnWriteArrayList<>();
// Allow commit to be called only once
protected volatile boolean finished = false;
this.defaultOperation = defaultOperation;
}
- ListenableFuture<DOMRpcResult> execute(final RemoteDeviceId id, final NetconfBaseOps netOps,
- final boolean rollbackSupport) {
+ ListenableFuture<? extends DOMRpcResult> execute(final RemoteDeviceId id, final NetconfBaseOps netOps,
+ final boolean rollbackSupport) {
final NetconfRpcFutureCallback editConfigCallback = new NetconfRpcFutureCallback("Edit running", id);
if (defaultOperation.isPresent()) {
return netOps.editConfigRunning(editConfigCallback, editStructure, defaultOperation.get(),
final String moduleName = sourceIdentifier.getName();
final Optional<String> revision = sourceIdentifier.getRevision().map(Revision::toString);
- final NormalizedNode<?, ?> getSchemaRequest = createGetSchemaRequest(moduleName, revision);
+ final ContainerNode getSchemaRequest = createGetSchemaRequest(moduleName, revision);
LOG.trace("{}: Loading YANG schema source for {}:{}", id, moduleName, revision);
return Futures.transform(
rpc.invokeRpc(SchemaPath.create(true, NetconfMessageTransformUtil.GET_SCHEMA_QNAME), getSchemaRequest),
*/
public class BaseRpcSchemalessTransformer implements MessageTransformer<NetconfMessage> {
- private static final Map<QName, RpcDefinition> MAPPED_RPCS = BaseSchema.BASE_NETCONF_CTX.getMappedRpcs();
+ private static final Map<QName, ? extends RpcDefinition> MAPPED_RPCS = BaseSchema.BASE_NETCONF_CTX.getMappedRpcs();
private static final SchemaContext SCHEMA_CONTEXT = BaseSchema.BASE_NETCONF_CTX.getSchemaContext();
private final MessageCounter counter;
import com.google.common.collect.Maps;
import java.util.Arrays;
import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext;
+import org.opendaylight.binding.runtime.spi.BindingRuntimeHelpers;
import org.opendaylight.yangtools.rcf8528.data.util.EmptyMountPointContext;
import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextProvider;
import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
-public enum BaseSchema implements SchemaContextProvider {
+public enum BaseSchema implements EffectiveModelContextProvider {
BASE_NETCONF_CTX(
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601
.$YangModuleInfoImpl.getInstance(),
.$YangModuleInfoImpl.getInstance()
);
- private final @NonNull ImmutableMap<QName, RpcDefinition> mappedRpcs;
+ private final @NonNull ImmutableMap<QName, ? extends RpcDefinition> mappedRpcs;
private final @NonNull EmptyMountPointContext mountContext;
BaseSchema(final YangModuleInfo... modules) {
- final ModuleInfoBackedContext moduleInfoBackedContext = ModuleInfoBackedContext.create();
- moduleInfoBackedContext.addModuleInfos(Arrays.asList(modules));
- mountContext = new EmptyMountPointContext(moduleInfoBackedContext.tryToCreateSchemaContext().get());
+ mountContext = new EmptyMountPointContext(BindingRuntimeHelpers.createEffectiveModel(Arrays.asList(modules)));
mappedRpcs = Maps.uniqueIndex(getSchemaContext().getOperations(), RpcDefinition::getQName);
}
- @NonNull ImmutableMap<QName, RpcDefinition> getMappedRpcs() {
+ @NonNull ImmutableMap<QName, ? extends RpcDefinition> getMappedRpcs() {
return mappedRpcs;
}
}
@Override
- public @NonNull SchemaContext getSchemaContext() {
- return mountContext.getSchemaContext();
+ public @NonNull EffectiveModelContext getEffectiveModelContext() {
+ return mountContext.getEffectiveModelContext();
}
}
import org.xml.sax.SAXException;
public class NetconfMessageTransformer implements MessageTransformer<NetconfMessage> {
-
private static final Logger LOG = LoggerFactory.getLogger(NetconfMessageTransformer.class);
private static final ImmutableSet<URI> BASE_OR_NOTIFICATION_NS = ImmutableSet.of(
private final DataSchemaContextTree contextTree;
private final BaseSchema baseSchema;
private final MessageCounter counter;
- private final ImmutableMap<QName, RpcDefinition> mappedRpcs;
- private final Multimap<QName, NotificationDefinition> mappedNotifications;
+ private final ImmutableMap<QName, ? extends RpcDefinition> mappedRpcs;
+ private final Multimap<QName, ? extends NotificationDefinition> mappedNotifications;
private final boolean strictParsing;
private final ImmutableMap<SchemaPath, ActionDefinition> actions;
findAction(innerDataSchemaNode, builder);
}
} else if (dataSchemaNode instanceof ChoiceSchemaNode) {
- for (CaseSchemaNode caze : ((ChoiceSchemaNode) dataSchemaNode).getCases().values()) {
+ for (CaseSchemaNode caze : ((ChoiceSchemaNode) dataSchemaNode).getCases()) {
findAction(caze, builder);
}
}
throw new IllegalArgumentException(
"Unable to parse notification " + message + ", cannot find namespace", e);
}
- final Collection<NotificationDefinition> notificationDefinitions = mappedNotifications.get(notificationNoRev);
+ final Collection<? extends NotificationDefinition> notificationDefinitions =
+ mappedNotifications.get(notificationNoRev);
Preconditions.checkArgument(notificationDefinitions.size() > 0,
"Unable to parse notification %s, unknown notification. Available notifications: %s",
notificationDefinitions, mappedNotifications.keySet());
}
private static NotificationDefinition getMostRecentNotification(
- final Collection<NotificationDefinition> notificationDefinitions) {
+ final Collection<? extends NotificationDefinition> notificationDefinitions) {
return Collections.max(notificationDefinitions, (o1, o2) ->
Revision.compare(o1.getQName().getRevision(), o2.getQName().getRevision()));
}
// and also check if the device exposed model for base netconf.
// If no, use pre built base netconf operations model
final boolean needToUseBaseCtx = mappedRpcs.get(rpcQName) == null && isBaseOrNotificationRpc(rpcQName);
- final ImmutableMap<QName, RpcDefinition> currentMappedRpcs;
+ final ImmutableMap<QName, ? extends RpcDefinition> currentMappedRpcs;
if (needToUseBaseCtx) {
currentMappedRpcs = baseSchema.getMappedRpcs();
} else {
// Determine whether a base netconf operation is being invoked
// and also check if the device exposed model for base netconf.
// If no, use pre built base netconf operations model
- final ImmutableMap<QName, RpcDefinition> currentMappedRpcs;
+ final ImmutableMap<QName, ? extends RpcDefinition> currentMappedRpcs;
if (mappedRpcs.get(rpcQName) == null && isBaseOrNotificationRpc(rpcQName)) {
currentMappedRpcs = baseSchema.getMappedRpcs();
} else {
import static com.google.common.base.Preconditions.checkArgument;
import static java.util.Objects.requireNonNull;
+import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.COMMIT_RPC_CONTENT;
import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.EDIT_CONTENT_NODEID;
import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_CANDIDATE_QNAME;
+import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_COMMIT_PATH;
import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_COPY_CONFIG_NODEID;
import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_COPY_CONFIG_PATH;
import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_DEFAULT_OPERATION_NODEID;
import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_UNLOCK_NODEID;
import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_UNLOCK_PATH;
import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_VALIDATE_NODEID;
+import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_VALIDATE_PATH;
import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.ROLLBACK_ON_ERROR_OPTION;
import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.toFilterStructure;
import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.toId;
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.schema.ChoiceNode;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.data.api.schema.DOMSourceAnyxmlNode;
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.impl.schema.builder.api.DataContainerNodeBuilder;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
/**
* Provides base operations for netconf e.g. get, get-config, edit-config, (un)lock, commit etc.
private final RpcStructureTransformer transformer;
@Deprecated
- public NetconfBaseOps(final DOMRpcService rpc, final SchemaContext schemaContext) {
+ public NetconfBaseOps(final DOMRpcService rpc, final EffectiveModelContext schemaContext) {
this(rpc, new EmptyMountPointContext(schemaContext));
}
}
}
- public ListenableFuture<DOMRpcResult> lock(final FutureCallback<DOMRpcResult> callback, final QName datastore) {
+ public ListenableFuture<? extends DOMRpcResult> lock(final FutureCallback<DOMRpcResult> callback,
+ final QName datastore) {
requireNonNull(callback);
requireNonNull(datastore);
- final ListenableFuture<DOMRpcResult> future = rpc.invokeRpc(NETCONF_LOCK_PATH, getLockContent(datastore));
+ final ListenableFuture<? extends DOMRpcResult> future = rpc.invokeRpc(NETCONF_LOCK_PATH,
+ getLockContent(datastore));
Futures.addCallback(future, callback, MoreExecutors.directExecutor());
return future;
}
- public ListenableFuture<DOMRpcResult> lockCandidate(final FutureCallback<DOMRpcResult> callback) {
- final ListenableFuture<DOMRpcResult> future = rpc.invokeRpc(NETCONF_LOCK_PATH,
+ public ListenableFuture<? extends DOMRpcResult> lockCandidate(final FutureCallback<DOMRpcResult> callback) {
+ final ListenableFuture<? extends DOMRpcResult> future = rpc.invokeRpc(NETCONF_LOCK_PATH,
getLockContent(NETCONF_CANDIDATE_QNAME));
Futures.addCallback(future, callback, MoreExecutors.directExecutor());
return future;
}
- public ListenableFuture<DOMRpcResult> lockRunning(final FutureCallback<DOMRpcResult> callback) {
- final ListenableFuture<DOMRpcResult> future = rpc.invokeRpc(NETCONF_LOCK_PATH,
+ public ListenableFuture<? extends DOMRpcResult> lockRunning(final FutureCallback<DOMRpcResult> callback) {
+ final ListenableFuture<? extends DOMRpcResult> future = rpc.invokeRpc(NETCONF_LOCK_PATH,
getLockContent(NETCONF_RUNNING_QNAME));
Futures.addCallback(future, callback, MoreExecutors.directExecutor());
return future;
}
- public ListenableFuture<DOMRpcResult> unlock(final FutureCallback<DOMRpcResult> callback, final QName datastore) {
+ public ListenableFuture<? extends DOMRpcResult> unlock(final FutureCallback<DOMRpcResult> callback,
+ final QName datastore) {
requireNonNull(callback);
requireNonNull(datastore);
- final ListenableFuture<DOMRpcResult> future = rpc.invokeRpc(NETCONF_UNLOCK_PATH, getUnLockContent(datastore));
+ final ListenableFuture<? extends DOMRpcResult> future = rpc.invokeRpc(NETCONF_UNLOCK_PATH,
+ getUnLockContent(datastore));
Futures.addCallback(future, callback, MoreExecutors.directExecutor());
return future;
}
- public ListenableFuture<DOMRpcResult> unlockRunning(final FutureCallback<DOMRpcResult> callback) {
- final ListenableFuture<DOMRpcResult> future = rpc.invokeRpc(NETCONF_UNLOCK_PATH,
+ public ListenableFuture<? extends DOMRpcResult> unlockRunning(final FutureCallback<DOMRpcResult> callback) {
+ final ListenableFuture<? extends DOMRpcResult> future = rpc.invokeRpc(NETCONF_UNLOCK_PATH,
getUnLockContent(NETCONF_RUNNING_QNAME));
Futures.addCallback(future, callback, MoreExecutors.directExecutor());
return future;
}
- public ListenableFuture<DOMRpcResult> unlockCandidate(final FutureCallback<DOMRpcResult> callback) {
- final ListenableFuture<DOMRpcResult> future = rpc.invokeRpc(NETCONF_UNLOCK_PATH,
+ public ListenableFuture<? extends DOMRpcResult> unlockCandidate(final FutureCallback<DOMRpcResult> callback) {
+ final ListenableFuture<? extends DOMRpcResult> future = rpc.invokeRpc(NETCONF_UNLOCK_PATH,
getUnLockContent(NETCONF_CANDIDATE_QNAME));
Futures.addCallback(future, callback, MoreExecutors.directExecutor());
return future;
}
- public ListenableFuture<DOMRpcResult> discardChanges(final FutureCallback<DOMRpcResult> callback) {
+ public ListenableFuture<? extends DOMRpcResult> discardChanges(final FutureCallback<DOMRpcResult> callback) {
requireNonNull(callback);
- final ListenableFuture<DOMRpcResult> future = rpc.invokeRpc(NETCONF_DISCARD_CHANGES_PATH, null);
+ final ListenableFuture<? extends DOMRpcResult> future = rpc.invokeRpc(NETCONF_DISCARD_CHANGES_PATH, null);
Futures.addCallback(future, callback, MoreExecutors.directExecutor());
return future;
}
- public ListenableFuture<DOMRpcResult> commit(final FutureCallback<DOMRpcResult> callback) {
+ public ListenableFuture<? extends DOMRpcResult> commit(final FutureCallback<DOMRpcResult> callback) {
requireNonNull(callback);
- final ListenableFuture<DOMRpcResult> future = rpc.invokeRpc(NetconfMessageTransformUtil.NETCONF_COMMIT_PATH,
- NetconfMessageTransformUtil.COMMIT_RPC_CONTENT);
+ final ListenableFuture<? extends DOMRpcResult> future = rpc.invokeRpc(NETCONF_COMMIT_PATH, COMMIT_RPC_CONTENT);
Futures.addCallback(future, callback, MoreExecutors.directExecutor());
return future;
}
- public ListenableFuture<DOMRpcResult> validate(final FutureCallback<DOMRpcResult> callback, final QName datastore) {
+ public ListenableFuture<? extends DOMRpcResult> validate(final FutureCallback<DOMRpcResult> callback,
+ final QName datastore) {
requireNonNull(callback);
- final ListenableFuture<DOMRpcResult> future = rpc.invokeRpc(NetconfMessageTransformUtil.NETCONF_VALIDATE_PATH,
+ final ListenableFuture<? extends DOMRpcResult> future = rpc.invokeRpc(NETCONF_VALIDATE_PATH,
getValidateContent(requireNonNull(datastore)));
Futures.addCallback(future, callback, MoreExecutors.directExecutor());
return future;
}
- public ListenableFuture<DOMRpcResult> validateCandidate(final FutureCallback<DOMRpcResult> callback) {
+ public ListenableFuture<? extends DOMRpcResult> validateCandidate(final FutureCallback<DOMRpcResult> callback) {
return validate(callback, NETCONF_CANDIDATE_QNAME);
}
- public ListenableFuture<DOMRpcResult> validateRunning(final FutureCallback<DOMRpcResult> callback) {
+ public ListenableFuture<? extends DOMRpcResult> validateRunning(final FutureCallback<DOMRpcResult> callback) {
return validate(callback, NETCONF_RUNNING_QNAME);
}
- public ListenableFuture<DOMRpcResult> copyConfig(final FutureCallback<DOMRpcResult> callback,
- final QName source, final QName target) {
+ public ListenableFuture<? extends DOMRpcResult> copyConfig(final FutureCallback<DOMRpcResult> callback,
+ final QName source, final QName target) {
requireNonNull(callback);
- final ListenableFuture<DOMRpcResult> future = rpc.invokeRpc(NETCONF_COPY_CONFIG_PATH,
+ final ListenableFuture<? extends DOMRpcResult> future = rpc.invokeRpc(NETCONF_COPY_CONFIG_PATH,
getCopyConfigContent(requireNonNull(source), requireNonNull(target)));
Futures.addCallback(future, callback, MoreExecutors.directExecutor());
return future;
}
- public ListenableFuture<DOMRpcResult> copyRunningToCandidate(final FutureCallback<DOMRpcResult> callback) {
+ public ListenableFuture<? extends DOMRpcResult> copyRunningToCandidate(
+ final FutureCallback<DOMRpcResult> callback) {
return copyConfig(callback, NETCONF_RUNNING_QNAME, NETCONF_CANDIDATE_QNAME);
}
- public ListenableFuture<DOMRpcResult> getConfig(final FutureCallback<DOMRpcResult> callback, final QName datastore,
- final Optional<YangInstanceIdentifier> filterPath) {
+ public ListenableFuture<? extends DOMRpcResult> getConfig(final FutureCallback<DOMRpcResult> callback,
+ final QName datastore,
+ final Optional<YangInstanceIdentifier> filterPath) {
requireNonNull(callback);
requireNonNull(datastore);
- final ListenableFuture<DOMRpcResult> future;
+ final ListenableFuture<? extends DOMRpcResult> future;
if (isFilterPresent(filterPath)) {
final DataContainerChild<?, ?> node = transformer.toFilterStructure(filterPath.get());
future = rpc.invokeRpc(NETCONF_GET_CONFIG_PATH,
public ListenableFuture<Optional<NormalizedNode<?, ?>>> getConfigRunningData(
final FutureCallback<DOMRpcResult> callback, final Optional<YangInstanceIdentifier> filterPath) {
- final ListenableFuture<DOMRpcResult> configRunning = getConfigRunning(callback, filterPath);
- return extractData(filterPath, configRunning);
+ return extractData(filterPath, getConfigRunning(callback, filterPath));
}
public ListenableFuture<Optional<NormalizedNode<?, ?>>> getData(final FutureCallback<DOMRpcResult> callback,
final Optional<YangInstanceIdentifier> filterPath) {
- final ListenableFuture<DOMRpcResult> configRunning = get(callback, filterPath);
- return extractData(filterPath, configRunning);
+ return extractData(filterPath, get(callback, filterPath));
}
private ListenableFuture<Optional<NormalizedNode<?, ?>>> extractData(
- final Optional<YangInstanceIdentifier> path, final ListenableFuture<DOMRpcResult> configRunning) {
+ final Optional<YangInstanceIdentifier> path, final ListenableFuture<? extends DOMRpcResult> configRunning) {
return Futures.transform(configRunning, result -> {
checkArgument(result.getErrors().isEmpty(), "Unable to read data: %s, errors: %s", path,
result.getErrors());
- final DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?> dataNode =
- ((ContainerNode) result.getResult()).getChild(NetconfMessageTransformUtil.NETCONF_DATA_NODEID)
- .get();
+ final DataContainerChild<?, ?> dataNode = ((ContainerNode) result.getResult())
+ .getChild(NetconfMessageTransformUtil.NETCONF_DATA_NODEID).get();
return transformer.selectFromDataStructure(dataNode, path.get());
}, MoreExecutors.directExecutor());
}
- public ListenableFuture<DOMRpcResult> getConfigRunning(final FutureCallback<DOMRpcResult> callback,
- final Optional<YangInstanceIdentifier> filterPath) {
+ public ListenableFuture<? extends DOMRpcResult> getConfigRunning(final FutureCallback<DOMRpcResult> callback,
+ final Optional<YangInstanceIdentifier> filterPath) {
return getConfig(callback, NETCONF_RUNNING_QNAME, filterPath);
}
- public ListenableFuture<DOMRpcResult> getConfigCandidate(final FutureCallback<DOMRpcResult> callback,
- final Optional<YangInstanceIdentifier> filterPath) {
+ public ListenableFuture<? extends DOMRpcResult> getConfigCandidate(final FutureCallback<DOMRpcResult> callback,
+ final Optional<YangInstanceIdentifier> filterPath) {
return getConfig(callback, NETCONF_CANDIDATE_QNAME, filterPath);
}
- public ListenableFuture<DOMRpcResult> get(final FutureCallback<DOMRpcResult> callback,
- final Optional<YangInstanceIdentifier> filterPath) {
+ public ListenableFuture<? extends DOMRpcResult> get(final FutureCallback<DOMRpcResult> callback,
+ final Optional<YangInstanceIdentifier> filterPath) {
requireNonNull(callback);
- final ListenableFuture<DOMRpcResult> future = rpc.invokeRpc(NETCONF_GET_PATH, isFilterPresent(filterPath)
- ? NetconfMessageTransformUtil.wrap(NETCONF_GET_NODEID,
- toFilterStructure(filterPath.get(), mountContext.getSchemaContext()))
+ final ListenableFuture<? extends DOMRpcResult> future = rpc.invokeRpc(NETCONF_GET_PATH,
+ isFilterPresent(filterPath)
+ ? NetconfMessageTransformUtil.wrap(NETCONF_GET_NODEID,
+ toFilterStructure(filterPath.get(), mountContext.getSchemaContext()))
: NetconfMessageTransformUtil.GET_RPC_CONTENT);
Futures.addCallback(future, callback, MoreExecutors.directExecutor());
return future;
return filterPath.isPresent() && !filterPath.get().isEmpty();
}
- public ListenableFuture<DOMRpcResult> editConfigCandidate(final FutureCallback<? super DOMRpcResult> callback,
- final DataContainerChild<?, ?> editStructure,
- final ModifyAction modifyAction, final boolean rollback) {
+ public ListenableFuture<? extends DOMRpcResult> editConfigCandidate(
+ final FutureCallback<? super DOMRpcResult> callback, final DataContainerChild<?, ?> editStructure,
+ final ModifyAction modifyAction, final boolean rollback) {
return editConfig(callback, NETCONF_CANDIDATE_QNAME, editStructure, Optional.of(modifyAction), rollback);
}
- public ListenableFuture<DOMRpcResult> editConfigCandidate(final FutureCallback<? super DOMRpcResult> callback,
- final DataContainerChild<?, ?> editStructure,
- final boolean rollback) {
+ public ListenableFuture<? extends DOMRpcResult> editConfigCandidate(
+ final FutureCallback<? super DOMRpcResult> callback, final DataContainerChild<?, ?> editStructure,
+ final boolean rollback) {
return editConfig(callback, NETCONF_CANDIDATE_QNAME, editStructure, Optional.empty(), rollback);
}
- public ListenableFuture<DOMRpcResult> editConfigRunning(final FutureCallback<? super DOMRpcResult> callback,
- final DataContainerChild<?, ?> editStructure,
- final ModifyAction modifyAction, final boolean rollback) {
+ public ListenableFuture<? extends DOMRpcResult> editConfigRunning(
+ final FutureCallback<? super DOMRpcResult> callback, final DataContainerChild<?, ?> editStructure,
+ final ModifyAction modifyAction, final boolean rollback) {
return editConfig(callback, NETCONF_RUNNING_QNAME, editStructure, Optional.of(modifyAction), rollback);
}
- public ListenableFuture<DOMRpcResult> editConfigRunning(final FutureCallback<? super DOMRpcResult> callback,
- final DataContainerChild<?, ?> editStructure,
- final boolean rollback) {
+ public ListenableFuture<? extends DOMRpcResult> editConfigRunning(
+ final FutureCallback<? super DOMRpcResult> callback, final DataContainerChild<?, ?> editStructure,
+ final boolean rollback) {
return editConfig(callback, NETCONF_RUNNING_QNAME, editStructure, Optional.empty(), rollback);
}
- public ListenableFuture<DOMRpcResult> editConfig(
+ public ListenableFuture<? extends DOMRpcResult> editConfig(
final FutureCallback<? super DOMRpcResult> callback, final QName datastore,
final DataContainerChild<?, ?> editStructure, final Optional<ModifyAction> modifyAction,
final boolean rollback) {
requireNonNull(callback);
- final ListenableFuture<DOMRpcResult> future = rpc.invokeRpc(NETCONF_EDIT_CONFIG_PATH,
+ final ListenableFuture<? extends DOMRpcResult> future = rpc.invokeRpc(NETCONF_EDIT_CONFIG_PATH,
getEditConfigContent(requireNonNull(datastore), requireNonNull(editStructure), modifyAction, rollback));
Futures.addCallback(future, callback, MoreExecutors.directExecutor());
return future;
}
- public DataContainerChild<?, ?> createEditConfigStrcture(final Optional<NormalizedNode<?, ?>> lastChild,
- final Optional<ModifyAction> operation,
- final YangInstanceIdentifier dataPath) {
- final DOMSourceAnyxmlNode configContent = transformer.createEditConfigStructure(lastChild, dataPath, operation);
- return Builders.choiceBuilder().withNodeIdentifier(EDIT_CONTENT_NODEID).withChild(configContent).build();
+ public ChoiceNode createEditConfigStrcture(final Optional<NormalizedNode<?, ?>> lastChild,
+ final Optional<ModifyAction> operation,
+ final YangInstanceIdentifier dataPath) {
+ return Builders.choiceBuilder()
+ .withNodeIdentifier(EDIT_CONTENT_NODEID)
+ .withChild(transformer.createEditConfigStructure(lastChild, dataPath, operation))
+ .build();
}
private static ContainerNode getEditConfigContent(
return editBuilder.build();
}
- public static DataContainerChild<?, ?> getSourceNode(final QName datastore) {
- return Builders.containerBuilder().withNodeIdentifier(NETCONF_SOURCE_NODEID)
- .withChild(Builders.choiceBuilder().withNodeIdentifier(CONFIG_SOURCE_NODEID).withChild(
- Builders.leafBuilder().withNodeIdentifier(toId(datastore)).withValue(Empty.getInstance()).build())
- .build()).build();
+ public static ContainerNode getSourceNode(final QName datastore) {
+ return Builders.containerBuilder()
+ .withNodeIdentifier(NETCONF_SOURCE_NODEID)
+ .withChild(Builders.choiceBuilder()
+ .withNodeIdentifier(CONFIG_SOURCE_NODEID)
+ .withChild(ImmutableNodes.leafNode(datastore, Empty.getInstance()))
+ .build())
+ .build();
}
public static ContainerNode getLockContent(final QName datastore) {
.withChild(getTargetNode(datastore)).build();
}
- public static DataContainerChild<?, ?> getTargetNode(final QName datastore) {
+ public static ContainerNode getTargetNode(final QName datastore) {
return Builders.containerBuilder().withNodeIdentifier(NETCONF_TARGET_NODEID)
.withChild(Builders.choiceBuilder().withNodeIdentifier(CONFIG_TARGET_NODEID).withChild(
Builders.leafBuilder().withNodeIdentifier(toId(datastore)).withValue(Empty.getInstance()).build())
.build()).build();
}
- public static NormalizedNode<?, ?> getCopyConfigContent(final QName source, final QName target) {
+ public static ContainerNode getCopyConfigContent(final QName source, final QName target) {
return Builders.containerBuilder().withNodeIdentifier(NETCONF_COPY_CONFIG_NODEID)
.withChild(getTargetNode(target)).withChild(getSourceNode(source)).build();
}
- public static NormalizedNode<?, ?> getValidateContent(final QName source) {
+ public static ContainerNode getValidateContent(final QName source) {
return Builders.containerBuilder().withNodeIdentifier(NETCONF_VALIDATE_NODEID)
.withChild(getSourceNode(source)).build();
}
- public static NormalizedNode<?, ?> getUnLockContent(final QName datastore) {
+ public static ContainerNode getUnLockContent(final QName datastore) {
return Builders.containerBuilder().withNodeIdentifier(NETCONF_UNLOCK_NODEID)
.withChild(getTargetNode(datastore)).build();
}
LOG.debug("Adding keypairs: {}", input);
final WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
- final List<KeyCredential> keypairs = input.getKeyCredential().stream().map(keypair ->
- new KeyCredentialBuilder(keypair)
+ final List<KeyCredential> keypairs = input.nonnullKeyCredential().values().stream()
+ .map(keypair -> new KeyCredentialBuilder(keypair)
.setPrivateKey(encryptionService.encrypt(keypair.getPrivateKey()))
.setPassphrase(encryptionService.encrypt(keypair.getPassphrase()))
- .build()).collect(Collectors.toList());
+ .build())
+ .collect(Collectors.toList());
for (KeyCredential keypair : keypairs) {
writeTransaction.merge(LogicalDatastoreType.CONFIGURATION,
final AddTrustedCertificateInput input) {
final WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
- for (TrustedCertificate certificate : input.getTrustedCertificate()) {
+ for (TrustedCertificate certificate : input.nonnullTrustedCertificate().values()) {
writeTransaction.merge(LogicalDatastoreType.CONFIGURATION,
keystoreIid.child(TrustedCertificate.class, certificate.key()), certificate);
}
public ListenableFuture<RpcResult<AddPrivateKeyOutput>> addPrivateKey(final AddPrivateKeyInput input) {
final WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
- for (PrivateKey key: input.getPrivateKey()) {
+ for (PrivateKey key: input.nonnullPrivateKey().values()) {
writeTransaction.merge(LogicalDatastoreType.CONFIGURATION,
keystoreIid.child(PrivateKey.class, key.key()), key);
}
final WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
final InstanceIdentifier<NetconfNode> niid = topologyPath.child(Node.class,
new NodeKey(nodeId)).augmentation(NetconfNode.class);
- writeTransaction.merge(LogicalDatastoreType.CONFIGURATION, niid, node, true);
+ writeTransaction.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, niid, node);
writeTransaction.commit().addCallback(new FutureCallback<CommitInfo>() {
@Override
xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
odl:use-default-for-reference-types="true">
+ <reference id="parserFactory"
+ interface="org.opendaylight.yangtools.yang.model.parser.api.YangParserFactory"/>
+
<bean id="deviceActionFactory"
class="org.opendaylight.netconf.sal.connect.netconf.DeviceActionFactoryImpl">
</bean>
<bean id="schemaResourceManager"
class="org.opendaylight.netconf.sal.connect.impl.DefaultSchemaResourceManager">
+ <argument ref="parserFactory"/>
</bean>
<service ref="schemaResourceManager"
interface="org.opendaylight.netconf.sal.connect.api.SchemaResourceManager"/>
-</blueprint>
\ No newline at end of file
+</blueprint>
import org.junit.AfterClass;
import org.junit.BeforeClass;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
public abstract class AbstractTestModelTest {
- protected static SchemaContext SCHEMA_CONTEXT;
+ protected static EffectiveModelContext SCHEMA_CONTEXT;
@BeforeClass
public static void beforeClass() {
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.repo.api.EffectiveModelContextFactory;
import org.opendaylight.yangtools.yang.model.repo.api.MissingSchemaSourceException;
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaContextFactory;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaResolutionException;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
final RemoteDeviceHandler<NetconfSessionPreferences> facade = getFacade();
final NetconfDeviceCommunicator listener = getListener();
- final SchemaContextFactory schemaFactory = getSchemaFactory();
+ final EffectiveModelContextFactory schemaFactory = getSchemaFactory();
final SchemaRepository schemaRepository = getSchemaRepository();
final SchemaResolutionException schemaResolutionException =
} else {
return Futures.immediateFuture(SCHEMA_CONTEXT);
}
- }).when(schemaFactory).createSchemaContext(anyCollectionOf(SourceIdentifier.class));
+ }).when(schemaFactory).createEffectiveModelContext(anyCollectionOf(SourceIdentifier.class));
final NetconfDeviceSchemasResolver stateSchemasResolver = (deviceRpc, remoteSessionCapabilities, id,
schemaContext) -> {
Mockito.verify(facade, Mockito.timeout(5000)).onDeviceConnected(any(MountPointContext.class),
any(NetconfSessionPreferences.class), any(NetconfDeviceRpc.class), isNull());
- Mockito.verify(schemaFactory, times(2)).createSchemaContext(anyCollectionOf(SourceIdentifier.class));
+ Mockito.verify(schemaFactory, times(2)).createEffectiveModelContext(anyCollectionOf(SourceIdentifier.class));
}
@Test
final RemoteDeviceHandler<NetconfSessionPreferences> facade = getFacade();
final NetconfDeviceCommunicator listener = getListener();
- final SchemaContextFactory schemaFactory = getSchemaFactory();
+ final EffectiveModelContextFactory schemaFactory = getSchemaFactory();
final SchemaRepository schemaRepository = getSchemaRepository();
// Make fallback attempt to fail due to empty resolved sources
= new SchemaResolutionException("fail first",
Collections.emptyList(), HashMultimap.create());
doReturn(Futures.immediateFailedFuture(schemaResolutionException))
- .when(schemaFactory).createSchemaContext(anyCollectionOf(SourceIdentifier.class));
+ .when(schemaFactory).createEffectiveModelContext(anyCollectionOf(SourceIdentifier.class));
final NetconfDevice.SchemaResourcesDTO schemaResourcesDTO = new NetconfDevice
.SchemaResourcesDTO(getSchemaRegistry(), schemaRepository, schemaFactory, STATE_SCHEMAS_RESOLVER);
Mockito.verify(facade, Mockito.timeout(5000)).onDeviceDisconnected();
Mockito.verify(listener, Mockito.timeout(5000)).close();
- Mockito.verify(schemaFactory, times(1)).createSchemaContext(anyCollectionOf(SourceIdentifier.class));
+ Mockito.verify(schemaFactory, times(1)).createEffectiveModelContext(anyCollectionOf(SourceIdentifier.class));
}
@Test
final RemoteDeviceHandler<NetconfSessionPreferences> facade = getFacade();
final NetconfDeviceCommunicator listener = getListener();
- final SchemaContextFactory schemaFactory = getSchemaFactory();
+ final EffectiveModelContextFactory schemaFactory = getSchemaFactory();
final SchemaRepository schemaRepository = getSchemaRepository();
// Make fallback attempt to fail due to empty resolved sources
} else {
return Futures.immediateFuture(SCHEMA_CONTEXT);
}
- }).when(schemaFactory).createSchemaContext(anyCollectionOf(SourceIdentifier.class));
+ }).when(schemaFactory).createEffectiveModelContext(anyCollectionOf(SourceIdentifier.class));
final NetconfDeviceSchemasResolver stateSchemasResolver = (deviceRpc, remoteSessionCapabilities, id,
schemaContext) -> {
Mockito.verify(facade, Mockito.timeout(5000)).onDeviceConnected(any(MountPointContext.class),
any(NetconfSessionPreferences.class), any(NetconfDeviceRpc.class), isNull());
- Mockito.verify(schemaFactory, times(1)).createSchemaContext(anyCollectionOf(SourceIdentifier.class));
+ Mockito.verify(schemaFactory, times(1)).createEffectiveModelContext(anyCollectionOf(SourceIdentifier.class));
}
private static SchemaSourceRegistry getSchemaRegistry() {
public void testNotificationBeforeSchema() throws Exception {
final RemoteDeviceHandler<NetconfSessionPreferences> facade = getFacade();
final NetconfDeviceCommunicator listener = getListener();
- final SchemaContextFactory schemaContextProviderFactory = mock(SchemaContextFactory.class);
+ final EffectiveModelContextFactory schemaContextProviderFactory = mock(EffectiveModelContextFactory.class);
final SettableFuture<SchemaContext> schemaFuture = SettableFuture.create();
- doReturn(schemaFuture).when(schemaContextProviderFactory).createSchemaContext(any(Collection.class));
+ doReturn(schemaFuture).when(schemaContextProviderFactory).createEffectiveModelContext(any(Collection.class));
final NetconfDevice.SchemaResourcesDTO schemaResourcesDTO =
new NetconfDevice.SchemaResourcesDTO(getSchemaRegistry(), getSchemaRepository(),
schemaContextProviderFactory, STATE_SCHEMAS_RESOLVER);
final RemoteDeviceHandler<NetconfSessionPreferences> facade = getFacade();
final NetconfDeviceCommunicator listener = getListener();
- final SchemaContextFactory schemaContextProviderFactory = getSchemaFactory();
+ final EffectiveModelContextFactory schemaContextProviderFactory = getSchemaFactory();
final NetconfDevice.SchemaResourcesDTO schemaResourcesDTO = new NetconfDevice.SchemaResourcesDTO(
getSchemaRegistry(), getSchemaRepository(), schemaContextProviderFactory, STATE_SCHEMAS_RESOLVER);
Lists.newArrayList(TEST_NAMESPACE + "?module=" + TEST_MODULE + "&revision=" + TEST_REVISION));
device.onRemoteSessionUp(sessionCaps, listener);
- verify(schemaContextProviderFactory, timeout(5000)).createSchemaContext(any(Collection.class));
+ verify(schemaContextProviderFactory, timeout(5000)).createEffectiveModelContext(any(Collection.class));
verify(facade, timeout(5000)).onDeviceConnected(
any(MountPointContext.class), any(NetconfSessionPreferences.class), any(DOMRpcService.class),
isNull());
device.onRemoteSessionUp(sessionCaps, listener);
- verify(schemaContextProviderFactory, timeout(5000).times(2)).createSchemaContext(any(Collection.class));
+ verify(schemaContextProviderFactory, timeout(5000).times(2)).createEffectiveModelContext(any(Collection.class));
verify(facade, timeout(5000).times(2)).onDeviceConnected(
any(MountPointContext.class), any(NetconfSessionPreferences.class), any(DOMRpcService.class),
isNull());
public void testNetconfDeviceDisconnectListenerCallCancellation() throws Exception {
final RemoteDeviceHandler<NetconfSessionPreferences> facade = getFacade();
final NetconfDeviceCommunicator listener = getListener();
- final SchemaContextFactory schemaContextProviderFactory = mock(SchemaContextFactory.class);
+ final EffectiveModelContextFactory schemaContextProviderFactory = mock(EffectiveModelContextFactory.class);
final SettableFuture<SchemaContext> schemaFuture = SettableFuture.create();
- doReturn(schemaFuture).when(schemaContextProviderFactory).createSchemaContext(any(Collection.class));
+ doReturn(schemaFuture).when(schemaContextProviderFactory).createEffectiveModelContext(any(Collection.class));
final NetconfDevice.SchemaResourcesDTO schemaResourcesDTO
= new NetconfDevice.SchemaResourcesDTO(getSchemaRegistry(), getSchemaRepository(),
schemaContextProviderFactory, STATE_SCHEMAS_RESOLVER);
final RemoteDeviceHandler<NetconfSessionPreferences> facade = getFacade();
final NetconfDeviceCommunicator listener = getListener();
- final SchemaContextFactory schemaContextProviderFactory = getSchemaFactory();
+ final EffectiveModelContextFactory schemaContextProviderFactory = getSchemaFactory();
final NetconfDevice.SchemaResourcesDTO schemaResourcesDTO = new NetconfDevice.SchemaResourcesDTO(
getSchemaRegistry(), getSchemaRepository(), schemaContextProviderFactory, STATE_SCHEMAS_RESOLVER);
QName.create(entry.getCapability())).getName(), entry.getCapabilityOrigin().getName()));
}
- private static SchemaContextFactory getSchemaFactory() throws Exception {
- final SchemaContextFactory schemaFactory = mockClass(SchemaContextFactory.class);
+ private static EffectiveModelContextFactory getSchemaFactory() throws Exception {
+ final EffectiveModelContextFactory schemaFactory = mockClass(EffectiveModelContextFactory.class);
doReturn(Futures.immediateFuture(SCHEMA_CONTEXT))
- .when(schemaFactory).createSchemaContext(any(Collection.class));
+ .when(schemaFactory).createEffectiveModelContext(any(Collection.class));
return schemaFactory;
}
package org.opendaylight.netconf.sal.connect.netconf;
import static org.hamcrest.CoreMatchers.hasItem;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_GET_QNAME;
import org.opendaylight.yangtools.yang.data.impl.schema.NormalizedNodeResult;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Mock
private DOMRpcService rpc;
- private SchemaContext schemaContext;
+ private EffectiveModelContext schemaContext;
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
- schemaContext = BaseSchema.BASE_NETCONF_CTX_WITH_NOTIFICATIONS.getSchemaContext();
+ schemaContext = BaseSchema.BASE_NETCONF_CTX_WITH_NOTIFICATIONS.getEffectiveModelContext();
final DataSchemaNode schemasNode =
((ContainerSchemaNode) schemaContext
.getDataChildByName(NetconfState.QNAME)).getDataChildByName(Schemas.QNAME);
.NodeIdentifier(NetconfMessageTransformUtil.NETCONF_RPC_REPLY_QNAME))
.withChild(data)
.build();
- when(rpc.invokeRpc(eq(toPath(NETCONF_GET_QNAME)), any()))
- .thenReturn(immediateFluentFuture(new DefaultDOMRpcResult(rpcReply)));
+ doReturn(immediateFluentFuture(new DefaultDOMRpcResult(rpcReply))).when(rpc)
+ .invokeRpc(eq(toPath(NETCONF_GET_QNAME)), any());
final NetconfStateSchemas stateSchemas = NetconfStateSchemas.create(rpc, CAPS, deviceId, schemaContext);
final Set<QName> availableYangSchemasQNames = stateSchemas.getAvailableYangSchemasQNames();
assertEquals(numberOfLegalSchemas, availableYangSchemasQNames.size());
@Test
public void testCreateRpcError() throws Exception {
final RpcError rpcError = RpcResultBuilder.newError(RpcError.ErrorType.RPC, "fail", "fail");
- when(rpc.invokeRpc(eq(toPath(NETCONF_GET_QNAME)), any()))
- .thenReturn(immediateFluentFuture(new DefaultDOMRpcResult(rpcError)));
+ doReturn(immediateFluentFuture(new DefaultDOMRpcResult(rpcError))).when(rpc)
+ .invokeRpc(eq(toPath(NETCONF_GET_QNAME)), any());
final NetconfStateSchemas stateSchemas = NetconfStateSchemas.create(rpc, CAPS, deviceId, schemaContext);
final Set<QName> availableYangSchemasQNames = stateSchemas.getAvailableYangSchemasQNames();
Assert.assertTrue(availableYangSchemasQNames.isEmpty());
final ListenableFuture<DOMRpcResult> interruptedFuture = mock(ListenableFuture.class);
try {
when(interruptedFuture.get()).thenThrow(new InterruptedException("interrupted"));
- when(rpc.invokeRpc(eq(toPath(NETCONF_GET_QNAME)), any())).thenReturn(
- FluentFuture.from(interruptedFuture));
+ doReturn(FluentFuture.from(interruptedFuture)).when(rpc)
+ .invokeRpc(eq(toPath(NETCONF_GET_QNAME)), any());
NetconfStateSchemas.create(rpc, CAPS, deviceId, schemaContext);
} catch (final InterruptedException | ExecutionException e) {
LOG.info("Operation failed.", e);
import com.google.common.collect.Iterables;
import java.io.InputStream;
-import java.util.Set;
+import java.util.Collection;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.mdsal.dom.api.DOMEvent;
import org.opendaylight.netconf.sal.connect.netconf.schema.mapping.NetconfMessageTransformer;
import org.opendaylight.yangtools.rcf8528.data.util.EmptyMountPointContext;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
import org.w3c.dom.Document;
userNotification = new NetconfMessage(doc);
}
- static SchemaContext getNotificationSchemaContext(final Class<?> loadClass, final boolean getExceptionTest) {
- final SchemaContext context;
+ static EffectiveModelContext getNotificationSchemaContext(final Class<?> loadClass,
+ final boolean getExceptionTest) {
+ final EffectiveModelContext context;
if (getExceptionTest) {
context = YangParserTestUtils.parseYangResources(loadClass, "/schemas/user-notification4.yang",
"/schemas/user-notification3.yang");
"/schemas/user-notification2.yang");
}
- final Set<Module> modules = context.getModules();
+ final Collection<? extends Module> modules = context.getModules();
assertTrue(!modules.isEmpty());
assertNotNull(context);
return context;
@Test(expected = IllegalArgumentException.class)
public void testMostRecentWrongYangModel() throws Exception {
- final SchemaContext schemaContext = getNotificationSchemaContext(getClass(), true);
+ final EffectiveModelContext schemaContext = getNotificationSchemaContext(getClass(), true);
messageTransformer = new NetconfMessageTransformer(new EmptyMountPointContext(schemaContext), true);
messageTransformer.toNotification(userNotification);
}
@Test
public void testToNotificationFunction() throws Exception {
- final SchemaContext schemaContext = getNotificationSchemaContext(getClass(), false);
+ final EffectiveModelContext schemaContext = getNotificationSchemaContext(getClass(), false);
messageTransformer = new NetconfMessageTransformer(new EmptyMountPointContext(schemaContext), true);
final DOMNotification domNotification = messageTransformer.toNotification(userNotification);
final ContainerNode root = domNotification.getBody();
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.netconf.sal.connect.netconf;
import static org.junit.Assert.assertEquals;
import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.toId;
import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.toPath;
-import java.util.Set;
+import java.util.Collection;
import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.netconf.api.NetconfMessage;
import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
import org.w3c.dom.Document;
private static final QName GET_CONFIG_QNAME =
QName.create(CONFIG_TEST_NAMESPACE, CONFIG_TEST_REVISION, "get-config");
- static SchemaContext cfgCtx;
+ static EffectiveModelContext cfgCtx;
static NetconfMessageTransformer messageTransformer;
@BeforeClass
public static void setup() {
- final Set<Module> notifModules = YangParserTestUtils.parseYangResource(
+ final Collection<? extends Module> notifModules = YangParserTestUtils.parseYangResource(
"/schemas/rpc-notification-subscription.yang").getModules();
assertTrue(!notifModules.isEmpty());
import static org.mockito.Mockito.after;
import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfBaseOps.getSourceNode;
import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_GET_CONFIG_NODEID;
import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_GET_CONFIG_PATH;
//This settable future object will be never set to any value. The test wants to simulate waiting for the result
//of the future object.
final SettableFuture<DOMRpcResult> settableFuture = SettableFuture.create();
- when(deviceRpc.invokeRpc(null, null)).thenReturn(settableFuture);
+ doReturn(settableFuture).when(deviceRpc).invokeRpc(null, null);
//This settable future will be used to check the invokation of keepalive RPC. Should be never invoked.
final SettableFuture<DOMRpcResult> keepaliveSettableFuture = SettableFuture.create();
- when(deviceRpc.invokeRpc(NETCONF_GET_CONFIG_PATH, KEEPALIVE_PAYLOAD)).thenReturn(keepaliveSettableFuture);
+ doReturn(keepaliveSettableFuture).when(deviceRpc).invokeRpc(NETCONF_GET_CONFIG_PATH, KEEPALIVE_PAYLOAD);
final DOMRpcResult keepaliveResult = new DefaultDOMRpcResult(Builders.containerBuilder().withNodeIdentifier(
new YangInstanceIdentifier.NodeIdentifier(NetconfMessageTransformUtil.NETCONF_RUNNING_QNAME)).build());
keepaliveSettableFuture.set(keepaliveResult);
import org.opendaylight.yangtools.util.concurrent.FluentFutures;
import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
.when(deviceRpc).invokeRpc(any(SchemaPath.class), isNull());
doReturn(FluentFutures.immediateFluentFuture(result))
- .when(deviceRpc).invokeRpc(any(SchemaPath.class), any(NormalizedNode.class));
+ .when(deviceRpc).invokeRpc(any(SchemaPath.class), any(ContainerNode.class));
keepaliveSalFacade.onDeviceConnected(null, null, deviceRpc);
verify(underlyingSalFacade).onDeviceConnected(
isNull(), isNull(), any(DOMRpcService.class), isNull());
- verify(deviceRpc, timeout(15000).times(5)).invokeRpc(any(SchemaPath.class), any(NormalizedNode.class));
+ verify(deviceRpc, timeout(15000).times(5)).invokeRpc(any(SchemaPath.class), any(ContainerNode.class));
}
@Test
public void testKeepaliveRpcFailure() {
doReturn(FluentFutures.immediateFailedFluentFuture(new IllegalStateException("illegal-state")))
- .when(deviceRpc).invokeRpc(any(SchemaPath.class), any(NormalizedNode.class));
+ .when(deviceRpc).invokeRpc(any(SchemaPath.class), any(ContainerNode.class));
keepaliveSalFacade.onDeviceConnected(null, null, deviceRpc);
// Should disconnect the session
verify(listener, timeout(15000).times(1)).disconnect();
- verify(deviceRpc, times(1)).invokeRpc(any(SchemaPath.class), any(NormalizedNode.class));
+ verify(deviceRpc, times(1)).invokeRpc(any(SchemaPath.class), any(ContainerNode.class));
}
@Test
final DOMRpcResult rpcSuccessWithError = new DefaultDOMRpcResult(mock(RpcError.class));
doReturn(FluentFutures.immediateFluentFuture(rpcSuccessWithError))
- .when(deviceRpc).invokeRpc(any(SchemaPath.class), any(NormalizedNode.class));
+ .when(deviceRpc).invokeRpc(any(SchemaPath.class), any(ContainerNode.class));
keepaliveSalFacade.onDeviceConnected(null, null, deviceRpc);
// Shouldn't disconnect the session
verify(listener, times(0)).disconnect();
- verify(deviceRpc, timeout(15000).times(1)).invokeRpc(any(SchemaPath.class), any(NormalizedNode.class));
+ verify(deviceRpc, timeout(15000).times(1)).invokeRpc(any(SchemaPath.class), any(ContainerNode.class));
}
@Test
}).when(underlyingSalFacade).onDeviceConnected(isNull(), isNull(), any(DOMRpcService.class), isNull());
doReturn(FluentFutures.immediateFailedFluentFuture(new IllegalStateException("illegal-state")))
- .when(deviceRpc).invokeRpc(any(SchemaPath.class), any(NormalizedNode.class));
+ .when(deviceRpc).invokeRpc(any(SchemaPath.class), any(ContainerNode.class));
keepaliveSalFacade =
new KeepaliveSalFacade(REMOTE_DEVICE_ID, underlyingSalFacade, executorServiceSpy, 100L, 1L);
keepaliveSalFacade.onDeviceConnected(null, null, deviceRpc);
- proxyRpc.invokeRpc(mock(SchemaPath.class), mock(NormalizedNode.class));
+ proxyRpc.invokeRpc(mock(SchemaPath.class), mock(ContainerNode.class));
verify(listener, times(1)).disconnect();
}
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import com.google.common.collect.Lists;
import java.net.InetSocketAddress;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext;
+import org.opendaylight.binding.runtime.spi.BindingRuntimeHelpers;
import org.opendaylight.mdsal.dom.api.DOMDataBroker;
import org.opendaylight.mdsal.dom.api.DOMMountPoint;
import org.opendaylight.mdsal.dom.api.DOMMountPointService;
import org.opendaylight.mdsal.dom.api.DOMNotificationService;
import org.opendaylight.mdsal.dom.api.DOMRpcService;
import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.IetfNetconfService;
import org.opendaylight.yangtools.concepts.ObjectRegistration;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class MountInstanceTest {
-
private static final Logger LOG = LoggerFactory.getLogger(MountInstanceTest.class);
- private static SchemaContext SCHEMA_CONTEXT;
+ private static EffectiveModelContext SCHEMA_CONTEXT;
@Mock
private DOMMountPointService service;
@BeforeClass
public static void suiteSetUp() throws Exception {
- final ModuleInfoBackedContext moduleInfoBackedContext = ModuleInfoBackedContext.create();
- moduleInfoBackedContext.addModuleInfos(Lists.newArrayList(org.opendaylight.yang.gen
- .v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.$YangModuleInfoImpl.getInstance()));
- SCHEMA_CONTEXT = moduleInfoBackedContext.tryToCreateSchemaContext().get();
-
+ SCHEMA_CONTEXT = BindingRuntimeHelpers.createEffectiveModel(IetfNetconfService.class);
}
@Before
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_GET_QNAME;
import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.toPath;
-import com.google.common.collect.Lists;
import java.net.InetSocketAddress;
import java.util.Arrays;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.opendaylight.binding.runtime.spi.BindingRuntimeHelpers;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction;
import org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction;
-import org.opendaylight.mdsal.dom.api.DOMRpcResult;
import org.opendaylight.mdsal.dom.api.DOMRpcService;
import org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult;
import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences;
import org.opendaylight.netconf.sal.connect.netconf.sal.tx.WriteRunningTx;
import org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil;
import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.extension.rev131210.$YangModuleInfoImpl;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.IetfNetconfService;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.extension.rev131210.NetconfTcp;
import org.opendaylight.yangtools.rcf8528.data.util.EmptyMountPointContext;
import org.opendaylight.yangtools.util.concurrent.FluentFutures;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+@RunWith(MockitoJUnitRunner.class)
public class NetconfDeviceDataBrokerTest {
- private static SchemaContext SCHEMA_CONTEXT;
+ private static EffectiveModelContext SCHEMA_CONTEXT;
@Mock
private DOMRpcService rpcService;
@BeforeClass
public static void beforeClass() {
- final ModuleInfoBackedContext moduleInfoBackedContext = ModuleInfoBackedContext.create();
- moduleInfoBackedContext.addModuleInfos(
- Lists.newArrayList($YangModuleInfoImpl.getInstance(),
- org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns
- .netconf.base._1._0.rev110601.$YangModuleInfoImpl.getInstance()));
- SCHEMA_CONTEXT = moduleInfoBackedContext.tryToCreateSchemaContext().get();
+ SCHEMA_CONTEXT = BindingRuntimeHelpers.createEffectiveModel(IetfNetconfService.class, NetconfTcp.class);
}
@AfterClass
@Before
public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
-
- DOMRpcResult result = new DefaultDOMRpcResult();
- when(rpcService.invokeRpc(any(SchemaPath.class), any(NormalizedNode.class)))
- .thenReturn(FluentFutures.immediateFluentFuture(result));
-
+ doReturn(FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult())).when(rpcService)
+ .invokeRpc(any(SchemaPath.class), any(ContainerNode.class));
dataBroker = getDataBroker(NetconfMessageTransformUtil.NETCONF_CANDIDATE_URI.toString());
}
*/
package org.opendaylight.netconf.sal.connect.netconf.sal;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.verify;
import com.google.common.util.concurrent.Futures;
import java.util.Collection;
-import java.util.Collections;
-import java.util.Set;
import org.junit.AfterClass;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext;
+import org.opendaylight.binding.runtime.spi.BindingRuntimeHelpers;
import org.opendaylight.mdsal.dom.api.DOMRpcAvailabilityListener;
import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier;
import org.opendaylight.mdsal.dom.api.DOMRpcResult;
import org.opendaylight.netconf.sal.connect.api.RemoteDeviceCommunicator;
import org.opendaylight.netconf.sal.connect.netconf.schema.mapping.NetconfMessageTransformer;
import org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.$YangModuleInfoImpl;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.IetfNetconfService;
import org.opendaylight.yangtools.rcf8528.data.util.EmptyMountPointContext;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.DOMSourceAnyxmlNode;
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.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.w3c.dom.Node;
public class NetconfDeviceRpcTest {
- private static SchemaContext SCHEMA_CONTEXT;
+ private static EffectiveModelContext SCHEMA_CONTEXT;
@Mock
private DOMRpcAvailabilityListener listener;
@BeforeClass
public static void beforeClass() {
- final ModuleInfoBackedContext moduleInfoBackedContext = ModuleInfoBackedContext.create();
- moduleInfoBackedContext.addModuleInfos(Collections.singleton($YangModuleInfoImpl.getInstance()));
- SCHEMA_CONTEXT = moduleInfoBackedContext.tryToCreateSchemaContext().get();
+ SCHEMA_CONTEXT = BindingRuntimeHelpers.createEffectiveModel(IetfNetconfService.class);
}
@AfterClass
@Test
public void testInvokeRpc() throws Exception {
- NormalizedNode<?, ?> input = createNode("urn:ietf:params:xml:ns:netconf:base:1.0", "2011-06-01", "filter");
+ ContainerNode input = createNode("urn:ietf:params:xml:ns:netconf:base:1.0", "2011-06-01", "filter");
final DOMRpcResult result = rpc.invokeRpc(path, input).get();
- Assert.assertEquals(expectedReply.getResult().getIdentifier(), result.getResult().getIdentifier());
- Assert.assertEquals(resolveNode(expectedReply), resolveNode(result));
+ assertEquals(expectedReply.getResult().getIdentifier(), result.getResult().getIdentifier());
+ assertEquals(resolveNode(expectedReply), resolveNode(result));
}
private static Node resolveNode(final DOMRpcResult result) {
verify(listener).onRpcAvailable(argument.capture());
final Collection<DOMRpcIdentifier> argValue = argument.getValue();
- final Set<RpcDefinition> operations = SCHEMA_CONTEXT.getOperations();
- Assert.assertEquals(argValue.size(), operations.size());
+ final Collection<? extends RpcDefinition> operations = SCHEMA_CONTEXT.getOperations();
+ assertEquals(argValue.size(), operations.size());
for (RpcDefinition operation : operations) {
final DOMRpcIdentifier domRpcIdentifier = DOMRpcIdentifier.create(operation.getPath());
- Assert.assertTrue(argValue.contains(domRpcIdentifier));
+ assertTrue(argValue.contains(domRpcIdentifier));
}
}
private static ContainerNode createNode(final String namespace, final String date, final String localName) {
return Builders.containerBuilder().withNodeIdentifier(
- new YangInstanceIdentifier.NodeIdentifier(QName.create(namespace, date, localName))).build();
+ new NodeIdentifier(QName.create(namespace, date, localName))).build();
}
}
import org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil;
import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
import org.opendaylight.yangtools.rcf8528.data.util.EmptyMountPointContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
public class NetconfDeviceSalFacadeTest {
@Test
public void testOnDeviceConnected() {
- final SchemaContext schemaContext = mock(SchemaContext.class);
+ final EffectiveModelContext schemaContext = mock(EffectiveModelContext.class);
final NetconfSessionPreferences netconfSessionPreferences =
NetconfSessionPreferences.fromStrings(getCapabilities());
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
public class NetconfDeviceTopologyAdapterTest {
- private static SchemaContext SCHEMA_CONTEXT;
+ private static EffectiveModelContext SCHEMA_CONTEXT;
private final RemoteDeviceId id = new RemoteDeviceId("test", new InetSocketAddress("localhost", 22));
import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
public class NetconfDeviceWriteOnlyTxTest {
doReturn(successFuture)
.doReturn(FluentFutures.immediateFailedFluentFuture(new IllegalStateException("Failed tx")))
.doReturn(successFuture)
- .when(rpc).invokeRpc(any(SchemaPath.class), any(NormalizedNode.class));
+ .when(rpc).invokeRpc(any(SchemaPath.class), any(ContainerNode.class));
yangIId = YangInstanceIdentifier.builder().node(NetconfState.QNAME).build();
}
@Test
public void testIgnoreNonVisibleData() {
- final WriteCandidateTx tx = new WriteCandidateTx(id, new NetconfBaseOps(rpc, mock(SchemaContext.class)),
+ final WriteCandidateTx tx = new WriteCandidateTx(id, new NetconfBaseOps(rpc, mock(EffectiveModelContext.class)),
false);
final MapNode emptyList = ImmutableNodes.mapNodeBuilder(NETCONF_FILTER_QNAME).build();
tx.merge(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier
tx.put(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier
.create(new YangInstanceIdentifier.NodeIdentifier(NETCONF_FILTER_QNAME)), emptyList);
- verify(rpc, atMost(1)).invokeRpc(any(SchemaPath.class), any(NormalizedNode.class));
+ verify(rpc, atMost(1)).invokeRpc(any(SchemaPath.class), any(ContainerNode.class));
}
@Test
doReturn(FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult((NormalizedNode<?, ?>) null)))
.when(rpc).invokeRpc(any(SchemaPath.class), isNull());
- final WriteCandidateTx tx = new WriteCandidateTx(id, new NetconfBaseOps(rpc, mock(SchemaContext.class)),
+ final WriteCandidateTx tx = new WriteCandidateTx(id, new NetconfBaseOps(rpc, mock(EffectiveModelContext.class)),
false);
try {
tx.commit().get();
new DefaultDOMRpcResult(RpcResultBuilder.newError(RpcError.ErrorType.APPLICATION, "a", "m")));
doReturn(FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult((NormalizedNode<?, ?>) null)))
- .doReturn(rpcErrorFuture).when(rpc).invokeRpc(any(SchemaPath.class), any(NormalizedNode.class));
+ .doReturn(rpcErrorFuture).when(rpc).invokeRpc(any(SchemaPath.class), any(ContainerNode.class));
- final WriteCandidateTx tx = new WriteCandidateTx(id, new NetconfBaseOps(rpc, mock(SchemaContext.class)),
+ final WriteCandidateTx tx = new WriteCandidateTx(id, new NetconfBaseOps(rpc, mock(EffectiveModelContext.class)),
false);
try {
public void testDiscardChangesNotSentWithoutCandidate() {
doReturn(FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult((NormalizedNode<?, ?>) null)))
.doReturn(FluentFutures.immediateFailedFluentFuture(new IllegalStateException("Failed tx")))
- .when(rpc).invokeRpc(any(SchemaPath.class), any(NormalizedNode.class));
+ .when(rpc).invokeRpc(any(SchemaPath.class), any(ContainerNode.class));
- final WriteRunningTx tx = new WriteRunningTx(
- id, new NetconfBaseOps(rpc, BaseSchema.BASE_NETCONF_CTX_WITH_NOTIFICATIONS.getSchemaContext()), false);
+ final WriteRunningTx tx = new WriteRunningTx(id,
+ new NetconfBaseOps(rpc, BaseSchema.BASE_NETCONF_CTX_WITH_NOTIFICATIONS.getEffectiveModelContext()), false);
tx.delete(LogicalDatastoreType.CONFIGURATION, yangIId);
tx.commit();
inOrder.verify(rpc).invokeRpc(toPath(NetconfMessageTransformUtil.NETCONF_LOCK_QNAME),
NetconfBaseOps.getLockContent(NETCONF_RUNNING_QNAME));
inOrder.verify(rpc).invokeRpc(eq(toPath(NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME)),
- any(NormalizedNode.class));
+ any(ContainerNode.class));
inOrder.verify(rpc).invokeRpc(toPath(NetconfMessageTransformUtil.NETCONF_UNLOCK_QNAME),
NetconfBaseOps.getUnLockContent(NETCONF_RUNNING_QNAME));
}
@Test
public void testListenerSuccess() throws Exception {
doReturn(FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult((NormalizedNode<?, ?>) null)))
- .when(rpc).invokeRpc(any(SchemaPath.class), any(NormalizedNode.class));
+ .when(rpc).invokeRpc(any(SchemaPath.class), any(ContainerNode.class));
final WriteCandidateTx tx = new WriteCandidateTx(
- id, new NetconfBaseOps(rpc, BaseSchema.BASE_NETCONF_CTX.getSchemaContext()), false);
+ id, new NetconfBaseOps(rpc, BaseSchema.BASE_NETCONF_CTX.getEffectiveModelContext()), false);
final TxListener listener = mock(TxListener.class);
tx.addListener(listener);
tx.delete(LogicalDatastoreType.CONFIGURATION, yangIId);
doReturn(FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult((NormalizedNode<?, ?>) null)))
.when(rpc).invokeRpc(any(SchemaPath.class), isNull());
final WriteCandidateTx tx = new WriteCandidateTx(
- id, new NetconfBaseOps(rpc, BaseSchema.BASE_NETCONF_CTX.getSchemaContext()), false);
+ id, new NetconfBaseOps(rpc, BaseSchema.BASE_NETCONF_CTX.getEffectiveModelContext()), false);
final TxListener listener = mock(TxListener.class);
tx.addListener(listener);
tx.delete(LogicalDatastoreType.CONFIGURATION, yangIId);
public void testListenerFailure() throws Exception {
final IllegalStateException cause = new IllegalStateException("Failed tx");
doReturn(FluentFutures.immediateFailedFluentFuture(cause))
- .when(rpc).invokeRpc(any(SchemaPath.class), any(NormalizedNode.class));
+ .when(rpc).invokeRpc(any(SchemaPath.class), any(ContainerNode.class));
final WriteCandidateTx tx = new WriteCandidateTx(
- id, new NetconfBaseOps(rpc, BaseSchema.BASE_NETCONF_CTX.getSchemaContext()), false);
+ id, new NetconfBaseOps(rpc, BaseSchema.BASE_NETCONF_CTX.getEffectiveModelContext()), false);
final TxListener listener = mock(TxListener.class);
tx.addListener(listener);
tx.delete(LogicalDatastoreType.CONFIGURATION, yangIId);
import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
import org.opendaylight.yangtools.util.concurrent.FluentFutures;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
public class ReadOnlyTxTest {
public void setUp() {
MockitoAnnotations.initMocks(this);
doReturn(FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult(mockedNode))).when(rpc)
- .invokeRpc(any(SchemaPath.class), any(NormalizedNode.class));
+ .invokeRpc(any(SchemaPath.class), any(ContainerNode.class));
doReturn("node").when(mockedNode).toString();
}
@Test
public void testRead() throws Exception {
- final NetconfBaseOps netconfOps = new NetconfBaseOps(rpc, mock(SchemaContext.class));
+ final NetconfBaseOps netconfOps = new NetconfBaseOps(rpc, mock(EffectiveModelContext.class));
final ReadOnlyTx readOnlyTx =
new ReadOnlyTx(netconfOps, new RemoteDeviceId("a", new InetSocketAddress("localhost", 196)));
readOnlyTx.read(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.create());
verify(rpc).invokeRpc(Mockito.eq(NetconfMessageTransformUtil.toPath(
- NetconfMessageTransformUtil.NETCONF_GET_CONFIG_QNAME)), any(NormalizedNode.class));
+ NetconfMessageTransformUtil.NETCONF_GET_CONFIG_QNAME)), any(ContainerNode.class));
readOnlyTx.read(LogicalDatastoreType.OPERATIONAL, PATH);
verify(rpc).invokeRpc(Mockito.eq(NetconfMessageTransformUtil.toPath(
- NetconfMessageTransformUtil.NETCONF_GET_QNAME)), any(NormalizedNode.class));
+ NetconfMessageTransformUtil.NETCONF_GET_QNAME)), any(ContainerNode.class));
}
@Test
public void testExists() throws Exception {
- final NetconfBaseOps netconfOps = new NetconfBaseOps(rpc, mock(SchemaContext.class));
+ final NetconfBaseOps netconfOps = new NetconfBaseOps(rpc, mock(EffectiveModelContext.class));
final ReadOnlyTx readOnlyTx =
new ReadOnlyTx(netconfOps, new RemoteDeviceId("a", new InetSocketAddress("localhost", 196)));
readOnlyTx.exists(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.create());
verify(rpc).invokeRpc(Mockito.eq(NetconfMessageTransformUtil.toPath(
- NetconfMessageTransformUtil.NETCONF_GET_CONFIG_QNAME)), any(NormalizedNode.class));
+ NetconfMessageTransformUtil.NETCONF_GET_CONFIG_QNAME)), any(ContainerNode.class));
readOnlyTx.exists(LogicalDatastoreType.OPERATIONAL, PATH);
verify(rpc).invokeRpc(Mockito.eq(NetconfMessageTransformUtil.toPath(
- NetconfMessageTransformUtil.NETCONF_GET_QNAME)), any(NormalizedNode.class));
+ NetconfMessageTransformUtil.NETCONF_GET_QNAME)), any(ContainerNode.class));
}
@Test
public void testIdentifier() throws Exception {
- final NetconfBaseOps netconfOps = new NetconfBaseOps(rpc, mock(SchemaContext.class));
+ final NetconfBaseOps netconfOps = new NetconfBaseOps(rpc, mock(EffectiveModelContext.class));
final ReadOnlyTx tx1 =
new ReadOnlyTx(netconfOps, new RemoteDeviceId("a", new InetSocketAddress("localhost", 196)));
final ReadOnlyTx tx2 =
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.Revision;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+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.builder.impl.ImmutableAnyXmlNodeBuilder;
final DOMRpcResult value = new DefaultDOMRpcResult(getNode(), Collections.emptySet());
final FluentFuture<DOMRpcResult> response = FluentFutures.immediateFluentFuture(value);
- doReturn(response).when(service).invokeRpc(any(SchemaPath.class), any(NormalizedNode.class));
+ doReturn(response).when(service).invokeRpc(any(SchemaPath.class), any(ContainerNode.class));
provider = new NetconfRemoteSchemaYangSourceProvider(
new RemoteDeviceId("device1", InetSocketAddress.createUnresolved("localhost", 17830)), service);
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext;
+import org.opendaylight.binding.runtime.spi.BindingRuntimeHelpers;
import org.opendaylight.mdsal.dom.api.DOMActionResult;
import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
import org.opendaylight.mdsal.dom.api.DOMRpcResult;
import org.opendaylight.netconf.sal.connect.netconf.util.NetconfBaseOps;
import org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil;
import org.opendaylight.netconf.util.NetconfUtil;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.$YangModuleInfoImpl;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.IetfNetconfService;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.NetconfState;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.Capabilities;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.Schemas;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder;
import org.opendaylight.yangtools.yang.model.api.ActionDefinition;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
import org.w3c.dom.Node;
private static final SchemaPath CHOICE_ACTION_PATH =
SchemaPath.create(true, CONFLICT_CHOICE_QNAME, CHOICE_CONT_QNAME, CHOICE_CONT_QNAME, CHOICE_ACTION_QNAME);
- private static SchemaContext PARTIAL_SCHEMA;
- private static SchemaContext SCHEMA;
- private static SchemaContext ACTION_SCHEMA;
+ private static EffectiveModelContext PARTIAL_SCHEMA;
+ private static EffectiveModelContext SCHEMA;
+ private static EffectiveModelContext ACTION_SCHEMA;
private NetconfMessageTransformer actionNetconfMessageTransformer;
private NetconfMessageTransformer netconfMessageTransformer;
@BeforeClass
public static void beforeClass() {
- final ModuleInfoBackedContext context = ModuleInfoBackedContext.create();
- context.addModuleInfos(Collections.singleton(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf
- .netconf.monitoring.rev101004.$YangModuleInfoImpl.getInstance()));
- PARTIAL_SCHEMA = context.tryToCreateSchemaContext().get();
-
- context.addModuleInfos(Collections.singleton($YangModuleInfoImpl.getInstance()));
- SCHEMA = context.tryToCreateSchemaContext().get();
-
+ PARTIAL_SCHEMA = BindingRuntimeHelpers.createEffectiveModel(NetconfState.class);
+ SCHEMA = BindingRuntimeHelpers.createEffectiveModel(IetfNetconfService.class, NetconfState.class);
ACTION_SCHEMA = YangParserTestUtils.parseYangResources(NetconfMessageTransformerTest.class,
"/schemas/example-server-farm.yang","/schemas/example-server-farm-2.yang",
"/schemas/conflicting-actions.yang", "/schemas/augmented-action.yang",
+ "</rpc>");
}
- private static NetconfMessageTransformer getTransformer(final SchemaContext schema) {
+ private static NetconfMessageTransformer getTransformer(final EffectiveModelContext schema) {
return new NetconfMessageTransformer(new EmptyMountPointContext(schema), true);
}
import static org.opendaylight.mdsal.common.api.CommitInfo.emptyFluentFuture;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
}
private AddPrivateKeyInput getPrivateKeyInput() throws Exception {
- final List<PrivateKey> privateKeys = new ArrayList<>();
+ final Map<PrivateKeyKey, PrivateKey> privateKeys = new HashMap<>();
final Document document = readKeystoreXML();
final NodeList nodeList = document.getElementsByTagName(XML_ELEMENT_PRIVATE_KEY);
for (int i = 0; i < nodeList.getLength(); i++) {
certChain.add(certNode.getTextContent());
}
- final PrivateKey privateKey = new PrivateKeyBuilder()
- .withKey(new PrivateKeyKey(keyName))
- .setName(keyName)
- .setData(keyData)
- .setCertificateChain(certChain)
- .build();
- privateKeys.add(privateKey);
+ final PrivateKeyKey key = new PrivateKeyKey(keyName);
+ privateKeys.put(key, new PrivateKeyBuilder()
+ .withKey(key)
+ .setData(keyData)
+ .setCertificateChain(certChain)
+ .build());
}
return new AddPrivateKeyInputBuilder().setPrivateKey(privateKeys).build();
}
private AddTrustedCertificateInput getTrustedCertificateInput() throws Exception {
- final List<TrustedCertificate> trustedCertificates = new ArrayList<>();
+ final Map<TrustedCertificateKey, TrustedCertificate> trustedCertificates = new HashMap<>();
final Document document = readKeystoreXML();
final NodeList nodeList = document.getElementsByTagName(XML_ELEMENT_TRUSTED_CERT);
for (int i = 0; i < nodeList.getLength(); i++) {
final String certName = element.getElementsByTagName(XML_ELEMENT_NAME).item(0).getTextContent();
final String certData = element.getElementsByTagName(XML_ELEMENT_CERT).item(0).getTextContent();
- final TrustedCertificate certificate = new TrustedCertificateBuilder()
- .withKey(new TrustedCertificateKey(certName))
- .setName(certName)
- .setCertificate(certData)
- .build();
- trustedCertificates.add(certificate);
+ final TrustedCertificateKey key = new TrustedCertificateKey(certName);
+ trustedCertificates.put(key, new TrustedCertificateBuilder()
+ .withKey(key)
+ .setName(certName)
+ .setCertificate(certData)
+ .build());
}
return new AddTrustedCertificateInputBuilder().setTrustedCertificate(trustedCertificates).build();
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.netconf.sal.connect.netconf.util;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
@Test
public void testGetQName() throws Exception {
- Assert.assertEquals(QNAME, proxy.getQName());
+ assertEquals(QNAME, proxy.getQName());
}
@Test
public void testGetChildNodes() throws Exception {
- Assert.assertEquals(2, proxy.getChildNodes().size());
+ assertEquals(2, proxy.getChildNodes().size());
}
@Test
public void testGetAvailableAugmentations() throws Exception {
- final Set<AugmentationSchemaNode> augmentations = proxy.getAvailableAugmentations();
- Assert.assertEquals(2, augmentations.size());
- Assert.assertTrue(augmentations.contains(augSchema1));
- Assert.assertTrue(augmentations.contains(augSchema2));
+ final Collection<? extends AugmentationSchemaNode> augmentations = proxy.getAvailableAugmentations();
+ assertEquals(2, augmentations.size());
+ assertTrue(augmentations.contains(augSchema1));
+ assertTrue(augmentations.contains(augSchema2));
}
@Test
public void testGetDataChildByName() throws Exception {
final DataSchemaNode schemaNode = proxy.getDataChildByName(NODE_1_QNAME);
- Assert.assertEquals(schemaNode1, schemaNode);
+ assertEquals(schemaNode1, schemaNode);
}
@Test
public void testGetTypeDefinitions() throws Exception {
- Assert.assertTrue(proxy.getTypeDefinitions().isEmpty());
+ assertTrue(proxy.getTypeDefinitions().isEmpty());
}
@Test
public void testGetGroupings() throws Exception {
- Assert.assertTrue(proxy.getGroupings().isEmpty());
+ assertTrue(proxy.getGroupings().isEmpty());
}
@Test
public void testGetUses() throws Exception {
- Assert.assertTrue(proxy.getUses().isEmpty());
+ assertTrue(proxy.getUses().isEmpty());
}
@Test
public void testGetUnknownSchemaNodes() throws Exception {
- Assert.assertTrue(proxy.getUnknownSchemaNodes().isEmpty());
+ assertTrue(proxy.getUnknownSchemaNodes().isEmpty());
}
@Test(expected = UnsupportedOperationException.class)
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>bundle-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
import com.google.common.base.Function;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Collections2;
+import com.google.common.collect.Maps;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
public class DummyMonitoringService implements NetconfMonitoringService {
- private static final Sessions EMPTY_SESSIONS = new SessionsBuilder().setSession(Collections.emptyList()).build();
+ private static final Sessions EMPTY_SESSIONS = new SessionsBuilder().build();
private static final Function<Capability, Uri> CAPABILITY_URI_FUNCTION =
capability -> new Uri(capability.getCapabilityUri());
}
}
- this.schemas = new SchemasBuilder().setSchema(
- new ArrayList<>(Collections2.transform(moduleCapabilities, CAPABILITY_SCHEMA_FUNCTION))).build();
+ this.schemas = new SchemasBuilder()
+ .setSchema(Maps.uniqueIndex(Collections2.transform(moduleCapabilities, CAPABILITY_SCHEMA_FUNCTION),
+ Schema::key))
+ .build();
}
@Override
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.builder.api.CollectionNodeBuilder;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextListener;
import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider;
import org.slf4j.Logger;
.getLogger(MdsalOperationProvider.class);
private final Set<Capability> caps;
- private final SchemaContext schemaContext;
+ private final EffectiveModelContext schemaContext;
private final SchemaSourceProvider<YangTextSchemaSource> sourceProvider;
MdsalOperationProvider(final SessionIdProvider idProvider,
final Set<Capability> caps,
- final SchemaContext schemaContext,
+ final EffectiveModelContext schemaContext,
final SchemaSourceProvider<YangTextSchemaSource> sourceProvider) {
this.caps = caps;
this.schemaContext = schemaContext;
static class MdsalOperationService implements NetconfOperationService {
private final long currentSessionId;
- private final SchemaContext schemaContext;
+ private final EffectiveModelContext schemaContext;
private final Set<Capability> caps;
private final DOMSchemaService schemaService;
private final DOMDataBroker dataBroker;
private final SchemaSourceProvider<YangTextSchemaSource> sourceProvider;
MdsalOperationService(final long currentSessionId,
- final SchemaContext schemaContext,
+ final EffectiveModelContext schemaContext,
final Set<Capability> caps,
final SchemaSourceProvider<YangTextSchemaSource> sourceProvider) {
this.currentSessionId = currentSessionId;
new NodeWithValue<>(location, "NETCONF")).withValue("NETCONF").build();
Map<QName, Object> keyValues = new HashMap<>();
- for (final Schema schema : monitor.getSchemas().getSchema()) {
+ for (final Schema schema : monitor.getSchemas().getSchema().values()) {
keyValues.put(identifier, schema.getIdentifier());
keyValues.put(version, schema.getVersion());
keyValues.put(format, Yang.QNAME);
return new DOMSchemaService() {
@Override
- public SchemaContext getSessionContext() {
+ public EffectiveModelContext getSessionContext() {
return schemaContext;
}
@Override
- public SchemaContext getGlobalContext() {
+ public EffectiveModelContext getGlobalContext() {
return schemaContext;
}
@Override
- public ListenerRegistration<SchemaContextListener> registerSchemaContextListener(
- final SchemaContextListener listener) {
- listener.onGlobalContextUpdated(getGlobalContext());
- return new AbstractListenerRegistration<SchemaContextListener>(listener) {
+ public ListenerRegistration<EffectiveModelContextListener> registerSchemaContextListener(
+ final EffectiveModelContextListener listener) {
+ listener.onModelContextUpdated(getGlobalContext());
+ return new AbstractListenerRegistration<>(listener) {
@Override
protected void removeRegistration() {
import org.opendaylight.netconf.test.tool.rpchandler.SettableOperationRpcProvider;
import org.opendaylight.netconf.test.tool.schemacache.SchemaSourceCache;
import org.opendaylight.yangtools.yang.common.Revision;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
private final ScheduledExecutorService minaTimerExecutor;
private final ExecutorService nioExecutor;
private final Configuration configuration;
- private SchemaContext schemaContext;
+ private EffectiveModelContext schemaContext;
private boolean sendFakeSchema = false;
@XmlElementWrapper(name = "schemas")
@XmlElement(name = "schema")
public Collection<MonitoringSchema> getSchemas() {
- return Collections2.transform(schemas.getSchema(), MonitoringSchema::new);
+ return Collections2.transform(schemas.nonnullSchema().values(), MonitoringSchema::new);
}
@XmlElementWrapper(name = "sessions")
@XmlElement(name = "session")
public Collection<MonitoringSession> getSessions() {
- return Collections2.transform(sessions.getSession(), MonitoringSession::new);
+ return Collections2.transform(sessions.nonnullSession().values(), MonitoringSession::new);
}
}
package org.opendaylight.netconf.test.tool;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.xmlunit.assertj.XmlAssert.assertThat;
+ "</rpc>";
Document docResponse = invokeRpc(TCP_SIMULATOR_CONFIG, getSchema);
Set<YangResource> expectedYangResources = Configuration.DEFAULT_YANG_RESOURCES;
- assert expectedYangResources.size() > 0;
+ assertEquals(4, expectedYangResources.size());
assertThat(docResponse)
.withNamespaceContext(PREFIX_2_URI)
.valueByXPath("count(//base10:rpc-reply/base10:data/ncmon:netconf-state/ncmon:schemas/ncmon:schema)")
.isEqualTo(expectedYangResources.size());
}
- private Document invokeRpc(Configuration simulatorConfig, String xmlRequest)
+ private Document invokeRpc(final Configuration simulatorConfig, final String xmlRequest)
throws Exception {
// GIVEN
int localPort = launchSimulator(simulatorConfig);
* @param configuration The simulator configuration.
* @return The TCP port number to access the launched simulator.
*/
- private int launchSimulator(Configuration configuration) {
+ private int launchSimulator(final Configuration configuration) {
return CACHED_SIMULATORS.computeIfAbsent(configuration, cfg -> {
NetconfDeviceSimulator simulator = new NetconfDeviceSimulator(cfg);
simulator.start();
}
@SuppressWarnings("deprecation")
- private static Configuration getSimulatorConfig(NetconfClientProtocol protocol, User user) {
+ private static Configuration getSimulatorConfig(final NetconfClientProtocol protocol, final User user) {
return new ConfigurationBuilder()
.setStartingPort(RANDOM_PORT)
.setRpcConfigFile(CUSTOM_RPC_CONFIG)
}
@SuppressWarnings("deprecation")
- private static NetconfClientConfiguration getClientConfig(String host, int port,
- Configuration simulatorConfig,
- NetconfClientSessionListener sessionListener) {
+ private static NetconfClientConfiguration getClientConfig(final String host, final int port,
+ final Configuration simulatorConfig,
+ final NetconfClientSessionListener sessionListener) {
User user = ((InMemoryAuthenticationProvider) simulatorConfig.getAuthProvider()).user;
return NetconfClientConfigurationBuilder.create()
.withAddress(new InetSocketAddress(host, port))
private final String username;
private final String password;
- private User(String username, String password) {
+ private User(final String username, final String password) {
this.username = username;
this.password = password;
}
private final User user;
- private InMemoryAuthenticationProvider(User user) {
+ private InMemoryAuthenticationProvider(final User user) {
this.user = user;
}
@Override
- public boolean authenticated(String username, String password) {
+ public boolean authenticated(final String username, final String password) {
return user.username.equals(username) && user.password.equals(password);
}
}
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
import com.google.common.base.Predicate;
import com.google.common.base.Strings;
import com.google.common.collect.Iterables;
+import com.google.common.io.ByteStreams;
import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.WriteTransaction;
import org.opendaylight.mdsal.common.api.CommitInfo;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.module.list.ModuleKey;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.YangIdentifier;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.yanglib.impl.rev141210.YanglibConfig;
+import org.opendaylight.yanglib.api.YangLibService;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.Revision;
+import org.opendaylight.yangtools.yang.model.parser.api.YangParserFactory;
+import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
* along with source identifier to
* ietf-netconf-yang-library/modules-state/module list.
*/
-public class YangLibProvider implements AutoCloseable, SchemaSourceListener {
+public class YangLibProvider implements AutoCloseable, SchemaSourceListener, YangLibService {
private static final Logger LOG = LoggerFactory.getLogger(YangLibProvider.class);
private static final Predicate<PotentialSchemaSource<?>> YANG_SCHEMA_SOURCE =
private SchemaListenerRegistration schemaListenerRegistration;
public YangLibProvider(final YanglibConfig yanglibConfig, final DataBroker dataBroker,
- final SharedSchemaRepository schemaRepository) {
+ final YangParserFactory parserFactory) {
this.yanglibConfig = requireNonNull(yanglibConfig);
this.dataBroker = requireNonNull(dataBroker);
- this.schemaRepository = requireNonNull(schemaRepository);
+ this.schemaRepository = new SharedSchemaRepository("yang-library", parserFactory);
}
@Override
@Override
public void schemaSourceRegistered(final Iterable<PotentialSchemaSource<?>> sources) {
- final List<Module> newModules = new ArrayList<>();
+ final Map<ModuleKey, Module> newModules = new HashMap<>();
for (PotentialSchemaSource<?> potentialYangSource : Iterables.filter(sources, YANG_SCHEMA_SOURCE)) {
final YangIdentifier moduleName = new YangIdentifier(potentialYangSource.getSourceIdentifier().getName());
.setSchema(getUrlForModule(potentialYangSource.getSourceIdentifier()))
.build();
- newModules.add(newModule);
+ newModules.put(newModule.key(), newModule);
}
if (newModules.isEmpty()) {
}
WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
- tx.delete(LogicalDatastoreType.OPERATIONAL,
- InstanceIdentifier.create(ModulesState.class)
- .child(Module.class,
- new ModuleKey(
- new YangIdentifier(source.getSourceIdentifier().getName()),
- RevisionUtils.fromYangCommon(source.getSourceIdentifier().getRevision()))));
+ tx.delete(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(ModulesState.class)
+ .child(Module.class, new ModuleKey(new YangIdentifier(source.getSourceIdentifier().getName()),
+ RevisionUtils.fromYangCommon(source.getSourceIdentifier().getRevision()))));
tx.commit().addCallback(new FutureCallback<CommitInfo>() {
@Override
}, MoreExecutors.directExecutor());
}
-
+ @Override
+ public String getSchema(final String name, final String revision) {
+ LOG.debug("Attempting load for schema source {}:{}", name, revision);
+ final SourceIdentifier sourceId = RevisionSourceIdentifier.create(name,
+ revision.isEmpty() ? null : Revision.of(revision));
+
+ final ListenableFuture<YangTextSchemaSource> sourceFuture = schemaRepository.getSchemaSource(sourceId,
+ YangTextSchemaSource.class);
+
+ try {
+ final YangTextSchemaSource source = sourceFuture.get();
+ return new String(ByteStreams.toByteArray(source.openStream()), Charset.defaultCharset());
+ } catch (InterruptedException | ExecutionException | IOException e) {
+ throw new IllegalStateException("Unable to get schema " + sourceId, e);
+ }
+ }
private Uri getUrlForModule(final SourceIdentifier sourceIdentifier) {
return new Uri("http://" + yanglibConfig.getBindingAddr() + ':' + yanglibConfig.getBindingPort()
+++ /dev/null
-/*
- * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.yanglib.impl;
-
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.io.ByteStreams;
-import com.google.common.util.concurrent.ListenableFuture;
-import java.io.IOException;
-import java.nio.charset.Charset;
-import java.util.concurrent.ExecutionException;
-import org.opendaylight.yanglib.api.YangLibService;
-import org.opendaylight.yangtools.yang.common.Revision;
-import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Provides schema sources from yang library.
- */
-public class YangLibServiceImpl implements YangLibService {
- private static final Logger LOG = LoggerFactory.getLogger(YangLibServiceImpl.class);
-
- private final SchemaRepository schemaRepository;
-
- public YangLibServiceImpl(final SchemaRepository schemaRepository) {
- this.schemaRepository = requireNonNull(schemaRepository);
- }
-
- @Override
- public String getSchema(final String name, final String revision) {
- LOG.debug("Attempting load for schema source {}:{}", name, revision);
- final SourceIdentifier sourceId = RevisionSourceIdentifier.create(name,
- revision.isEmpty() ? null : Revision.of(revision));
-
- final ListenableFuture<YangTextSchemaSource> sourceFuture = schemaRepository.getSchemaSource(sourceId,
- YangTextSchemaSource.class);
-
- try {
- final YangTextSchemaSource source = sourceFuture.get();
- return new String(ByteStreams.toByteArray(source.openStream()), Charset.defaultCharset());
- } catch (InterruptedException | ExecutionException | IOException e) {
- throw new IllegalStateException("Unable to get schema " + sourceId, e);
- }
- }
-}
<reference id="webServer" interface="org.opendaylight.aaa.web.WebServer"/>
<reference id="webContextSecurer" interface="org.opendaylight.aaa.web.WebContextSecurer"/>
<reference id="servletSupport" interface="org.opendaylight.aaa.web.servlet.ServletSupport" />
-
- <bean id="schemaRepository" class="org.opendaylight.yangtools.yang.parser.repo.SharedSchemaRepository">
- <argument value="yang-library"/>
- </bean>
-
- <bean id="yangLibService" class="org.opendaylight.yanglib.impl.YangLibServiceImpl">
- <argument ref="schemaRepository"/>
- </bean>
-
- <bean id="yangLibRestApp" class="org.opendaylight.yanglib.impl.YangLibRestApp">
- <argument ref="yangLibService"/>
- </bean>
+ <reference id="parserFactory" interface="org.opendaylight.yangtools.yang.model.parser.api.YangParserFactory" />
<bean id="yangLibProvider" class="org.opendaylight.yanglib.impl.YangLibProvider"
init-method="init" destroy-method="close">
<argument ref="yanglibConfig"/>
<argument ref="dataBroker"/>
- <argument ref="schemaRepository"/>
+ <argument ref="parserFactory"/>
+ </bean>
+
+ <bean id="yangLibRestApp" class="org.opendaylight.yanglib.impl.YangLibRestApp">
+ <argument ref="yangLibProvider"/>
</bean>
<bean id="webInitializer" class="org.opendaylight.yanglib.impl.WebInitializer"
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.apache.commons.io.FileUtils;
import org.junit.AfterClass;
import org.junit.Before;
import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
import org.opendaylight.yangtools.yang.model.repo.api.YinSchemaSourceRepresentation;
import org.opendaylight.yangtools.yang.model.repo.spi.PotentialSchemaSource;
-import org.opendaylight.yangtools.yang.parser.repo.SharedSchemaRepository;
+import org.opendaylight.yangtools.yang.parser.impl.YangParserFactoryImpl;
import org.opendaylight.yangtools.yang.parser.rfc7950.repo.ASTSchemaSource;
public class YangLibProviderTest {
final YanglibConfig yanglibConfig = new YanglibConfigBuilder().setBindingAddr("www.fake.com")
.setBindingPort(Uint32.valueOf(300)).setCacheFolder(CACHE_DIR.getAbsolutePath()).build();
- yangLibProvider = new YangLibProvider(yanglibConfig, dataBroker, new SharedSchemaRepository("yang-library"));
+ yangLibProvider = new YangLibProvider(yanglibConfig, dataBroker, new YangParserFactoryImpl());
}
@Test
doReturn(emptyFluentFuture()).when(writeTransaction).commit();
yangLibProvider.schemaSourceRegistered(list);
- List<Module> newModulesList = new ArrayList<>();
+ Map<ModuleKey, Module> newModulesList = new HashMap<>();
Module newModule = new ModuleBuilder()
.setName(new YangIdentifier("no-revision"))
.setSchema(new Uri("http://www.fake.com:300/yanglib/schemas/no-revision/"))
.build();
- newModulesList.add(newModule);
+ newModulesList.put(newModule.key(), newModule);
newModule = new ModuleBuilder()
.setName(new YangIdentifier("with-revision"))
.setSchema(new Uri("http://www.fake.com:300/yanglib/schemas/with-revision/2016-04-28"))
.build();
- newModulesList.add(newModule);
+ newModulesList.put(newModule.key(), newModule);
verify(dataBroker).newWriteOnlyTransaction();
verify(writeTransaction).merge(eq(LogicalDatastoreType.OPERATIONAL),
+++ /dev/null
-/*
- * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.yanglib.impl;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-
-import com.google.common.base.MoreObjects.ToStringHelper;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import org.junit.Test;
-import org.opendaylight.yangtools.yang.common.Revision;
-import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
-
-public class YangLibServiceImplTest {
-
- private static final String TEST_OUTPUT_STRING = "hello world";
-
- @Test
- public void testSchema() throws SchemaSourceException {
-
- final SchemaRepository schemaRepository = mock(SchemaRepository.class);
- final YangLibServiceImpl yangLibService = new YangLibServiceImpl(schemaRepository);
-
- final SourceIdentifier sourceIdentifier = RevisionSourceIdentifier.create("name", Revision.of("2016-01-01"));
-
- final YangTextSchemaSource yangTextSchemaSource = new YangTextSchemaSource(sourceIdentifier) {
- @Override
- protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
- return null;
- }
-
- @Override
- public InputStream openStream() throws IOException {
- return new ByteArrayInputStream(TEST_OUTPUT_STRING.getBytes());
- }
- };
-
- final ListenableFuture<YangTextSchemaSource> sourceFuture = Futures.immediateFuture(yangTextSchemaSource);
- doReturn(sourceFuture).when(schemaRepository).getSchemaSource(any(SourceIdentifier.class),
- eq(YangTextSchemaSource.class));
-
- final String outputStream = yangLibService.getSchema("name", "2016-01-01");
- assertEquals(TEST_OUTPUT_STRING, outputStream);
- }
-
-}
<parent>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>binding-parent</artifactId>
- <version>5.0.9</version>
+ <version>6.0.0</version>
<relativePath/>
</parent>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
- <artifactId>config-artifacts</artifactId>
- <version>0.12.0</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-artifacts</artifactId>
- <version>1.11.0</version>
+ <artifactId>controller-artifacts</artifactId>
+ <version>2.0.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
import org.opendaylight.mdsal.dom.api.DOMMountPoint;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
public class InstanceIdentifierContext<T extends SchemaNode> {
private final YangInstanceIdentifier instanceIdentifier;
private final T schemaNode;
private final DOMMountPoint mountPoint;
- private final SchemaContext schemaContext;
+ private final EffectiveModelContext schemaContext;
public InstanceIdentifierContext(final YangInstanceIdentifier instanceIdentifier, final T schemaNode,
- final DOMMountPoint mountPoint,final SchemaContext context) {
+ final DOMMountPoint mountPoint, final EffectiveModelContext context) {
this.instanceIdentifier = instanceIdentifier;
this.schemaNode = schemaNode;
this.mountPoint = mountPoint;
return mountPoint;
}
- public SchemaContext getSchemaContext() {
+ public EffectiveModelContext getSchemaContext() {
return schemaContext;
}
}
import java.util.Collections;
import java.util.List;
+import java.util.Map;
import java.util.Optional;
import java.util.Set;
import org.opendaylight.yangtools.concepts.SemVer;
+import org.opendaylight.yangtools.yang.common.QNameModule;
import org.opendaylight.yangtools.yang.common.YangVersion;
import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
import org.opendaylight.yangtools.yang.model.api.Deviation;
import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
import org.opendaylight.yangtools.yang.model.api.UsesNode;
+import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
+import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
+import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
+import org.opendaylight.yangtools.yang.model.api.meta.StatementSource;
+import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ModuleStatement;
+
+abstract class AbstractOperationsModule implements Module, ModuleEffectiveStatement {
+ @Override
+ public final ModuleStatement getDeclared() {
+ return null;
+ }
+
+ @Override
+ public final StatementDefinition statementDefinition() {
+ return YangStmtMapping.MODULE;
+ }
+
+ @Override
+ public final StatementSource getStatementSource() {
+ return StatementSource.CONTEXT;
+ }
+
+ @Override
+ public final <K, V, N extends IdentifierNamespace<K, V>> Optional<? extends V> get(final Class<N> namespace,
+ final K identifier) {
+ return Optional.empty();
+ }
+
+ @Override
+ public final <K, V, N extends IdentifierNamespace<K, V>> Map<K, V> getAll(final Class<N> namespace) {
+ return Map.of();
+ }
+
+ @Override
+ public final String argument() {
+ return getName();
+ }
+
+ @Override
+ public final QNameModule localQNameModule() {
+ return getQNameModule();
+ }
-abstract class AbstractOperationsModule implements Module {
@Override
public final Set<ModuleImport> getImports() {
// Yeah, not accurate, but this should not be needed
--- /dev/null
+/*
+ * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.restconf.common.util;
+
+import static com.google.common.base.Verify.verify;
+
+import com.google.common.collect.ImmutableMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.function.Function;
+import org.opendaylight.yangtools.yang.common.QNameModule;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement;
+import org.opendaylight.yangtools.yang.model.util.SimpleSchemaContext;
+
+final class OperationsEffectiveModuleContext extends SimpleSchemaContext implements EffectiveModelContext {
+ private final Map<QNameModule, ModuleEffectiveStatement> modules;
+
+ OperationsEffectiveModuleContext(final Set<Module> modules) {
+ super(modules);
+ this.modules = modules.stream()
+ .map(module -> {
+ verify(module instanceof ModuleEffectiveStatement, "Module %s is not an effective statement");
+ return (ModuleEffectiveStatement) module;
+ })
+ .collect(ImmutableMap.toImmutableMap(ModuleEffectiveStatement::localQNameModule, Function.identity()));
+ }
+
+ @Override
+ public Map<QNameModule, ModuleEffectiveStatement> getModuleStatements() {
+ return modules;
+ }
+}
import java.util.Collection;
import java.util.Collections;
+import java.util.List;
import java.util.Optional;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
final class OperationsImportedModule extends AbstractOperationsModule {
private final Module original;
public Optional<DataSchemaNode> findDataChildByName(final QName name) {
return Optional.empty();
}
+
+ @Override
+ public Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements() {
+ return List.of();
+ }
}
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.util.SimpleSchemaContext;
public final class OperationsResourceUtils {
}
return new NormalizedNodeContext(new InstanceIdentifierContext<>(null, operatationsSchema, mountPoint,
- SimpleSchemaContext.forModules(ImmutableSet.copyOf(modules))), operationsBuilder.build());
+ new OperationsEffectiveModuleContext(ImmutableSet.copyOf(modules))), operationsBuilder.build());
}
}
import java.net.URI;
import java.util.Collection;
import java.util.Collections;
+import java.util.List;
import java.util.Optional;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
final class OperationsRestconfModule extends AbstractOperationsModule {
// There is no need to intern this nor add a revision, as we are providing the corresponding context anyway
- static final QNameModule NAMESPACE = QNameModule.create(URI.create("urn:ietf:params:xml:ns:yang:ietf-restconf"));
+ static final @NonNull QNameModule NAMESPACE =
+ QNameModule.create(URI.create("urn:ietf:params:xml:ns:yang:ietf-restconf"));
private final OperationsContainerSchemaNode operations;
return NAMESPACE;
}
+ @Override
+ public String getPrefix() {
+ return "rc";
+ }
+
@Override
public Collection<DataSchemaNode> getChildNodes() {
return Collections.singleton(operations);
}
@Override
- public String getPrefix() {
- return "rc";
+ public Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements() {
+ // This is not accurate, but works for now
+ return List.of();
}
}
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
</dependency>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-binding-dom-adapter</artifactId>
+ <artifactId>mdsal-binding-test-utils</artifactId>
<scope>test</scope>
</dependency>
<dependency>
import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
import org.opendaylight.yangtools.yang.data.codec.xml.XMLStreamNormalizedNodeStreamWriter;
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
final InstanceIdentifierContext<?> pathContext, NormalizedNode<?, ?> data, final Optional<Integer> depth)
throws IOException {
final RestconfNormalizedNodeWriter nnWriter;
- final SchemaContext schemaCtx = pathContext.getSchemaContext();
+ final EffectiveModelContext schemaCtx = pathContext.getSchemaContext();
if (SchemaPath.ROOT.equals(schemaPath)) {
nnWriter = createNormalizedNodeWriter(xmlWriter, schemaCtx, schemaPath, depth);
if (data instanceof DOMSourceAnyxmlNode) {
import java.net.URISyntaxException;
import java.util.ArrayDeque;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Deque;
import java.util.List;
import java.util.Optional;
final String namespace) {
final Deque<Object> result = new ArrayDeque<>();
final ArrayList<ChoiceSchemaNode> choiceSchemaNodes = new ArrayList<>();
- final Collection<DataSchemaNode> children = ((DataNodeContainer) schemaNode).getChildNodes();
- for (final DataSchemaNode child : children) {
+ for (final DataSchemaNode child : ((DataNodeContainer) schemaNode).getChildNodes()) {
if (child instanceof ChoiceSchemaNode) {
choiceSchemaNodes.add((ChoiceSchemaNode) child);
} else if (child.getQName().getLocalName().equalsIgnoreCase(elementName)
}
for (final ChoiceSchemaNode choiceNode : choiceSchemaNodes) {
- for (final CaseSchemaNode caseNode : choiceNode.getCases().values()) {
+ for (final CaseSchemaNode caseNode : choiceNode.getCases()) {
final Deque<Object> resultFromRecursion = findPathToSchemaNodeByName(caseNode, elementName, namespace);
if (!resultFromRecursion.isEmpty()) {
resultFromRecursion.push(choiceNode);
}
// RPC
- public ListenableFuture<DOMRpcResult> invokeRpc(final SchemaPath type, final NormalizedNode<?, ?> input) {
+ public ListenableFuture<? extends DOMRpcResult> invokeRpc(final SchemaPath type, final NormalizedNode<?, ?> input) {
if (this.rpcService == null) {
throw new RestconfDocumentedException(Status.SERVICE_UNAVAILABLE);
}
import java.util.List;
import java.util.Map;
import java.util.Optional;
-import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextListener;
import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition;
import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition;
import org.slf4j.LoggerFactory;
@Singleton
-public final class ControllerContext implements SchemaContextListener, Closeable {
+public final class ControllerContext implements EffectiveModelContextListener, Closeable {
// FIXME: this should be in md-sal somewhere
public static final String MOUNT = "yang-ext:mount";
private final DOMMountPointService mountService;
private final DOMYangTextSourceProvider yangTextSourceProvider;
- private final ListenerRegistration<SchemaContextListener> listenerRegistration;
- private volatile SchemaContext globalSchema;
+ private final ListenerRegistration<?> listenerRegistration;
+ private volatile EffectiveModelContext globalSchema;
private volatile DataNormalizer dataNormalizer;
@Inject
this.mountService = mountService;
this.yangTextSourceProvider = domSchemaService.getExtensions().getInstance(DOMYangTextSourceProvider.class);
- onGlobalContextUpdated(schemaService.getGlobalContext());
+ onModelContextUpdated(schemaService.getGlobalContext());
listenerRegistration = schemaService.registerSchemaContextListener(this);
}
return new ControllerContext(schemaService, mountService, domSchemaService);
}
- private void setGlobalSchema(final SchemaContext globalSchema) {
+ private void setGlobalSchema(final EffectiveModelContext globalSchema) {
this.globalSchema = globalSchema;
this.dataNormalizer = new DataNormalizer(globalSchema);
}
listenerRegistration.close();
}
- public void setSchemas(final SchemaContext schemas) {
- onGlobalContextUpdated(schemas);
+ public void setSchemas(final EffectiveModelContext schemas) {
+ onModelContextUpdated(schemas);
}
public InstanceIdentifierContext<?> toInstanceIdentifier(final String restconfInstance) {
return toIdentifier(restconfInstance, false);
}
- public SchemaContext getGlobalSchema() {
+ public EffectiveModelContext getGlobalSchema() {
return this.globalSchema;
}
}
final InstanceIdentifierBuilder builder = YangInstanceIdentifier.builder();
- final Set<Module> latestModule = this.globalSchema.findModules(startModule);
+ final Collection<? extends Module> latestModule = this.globalSchema.findModules(startModule);
if (latestModule.isEmpty()) {
throw new RestconfDocumentedException("The module named '" + startModule + "' does not exist.",
return module == null ? null : module.getNamespace();
}
- public Set<Module> getAllModules(final DOMMountPoint mountPoint) {
+ public Collection<? extends Module> getAllModules(final DOMMountPoint mountPoint) {
checkPreconditions();
final SchemaContext schemaContext = mountPoint == null ? null : mountPoint.getSchemaContext();
return schemaContext == null ? null : schemaContext.getModules();
}
- public Set<Module> getAllModules() {
+ public Collection<? extends Module> getAllModules() {
checkPreconditions();
return this.globalSchema.getModules();
}
return null;
}
- final Set<GroupingDefinition> groupings = restconfModule.getGroupings();
+ final Collection<? extends GroupingDefinition> groupings = restconfModule.getGroupings();
- final Iterable<GroupingDefinition> filteredGroups = Iterables.filter(groupings,
+ final Iterable<? extends GroupingDefinition> filteredGroups = Iterables.filter(groupings,
g -> RestConfModule.ERRORS_GROUPING_SCHEMA_NODE.equals(g.getQName().getLocalName()));
final GroupingDefinition restconfGrouping = Iterables.getFirst(filteredGroups, null);
return null;
}
- final Set<GroupingDefinition> groupings = restconfModule.getGroupings();
- final Iterable<GroupingDefinition> filteredGroups = Iterables.filter(groupings,
+ final Collection<? extends GroupingDefinition> groupings = restconfModule.getGroupings();
+ final Iterable<? extends GroupingDefinition> filteredGroups = Iterables.filter(groupings,
g -> RestConfModule.RESTCONF_GROUPING_SCHEMA_NODE.equals(g.getQName().getLocalName()));
final GroupingDefinition restconfGrouping = Iterables.getFirst(filteredGroups, null);
}
private static DataSchemaNode childByQName(final ChoiceSchemaNode container, final QName name) {
- for (final CaseSchemaNode caze : container.getCases().values()) {
+ for (final CaseSchemaNode caze : container.getCases()) {
final DataSchemaNode ret = childByQName(caze, name);
if (ret != null) {
return ret;
if (strings.isEmpty()) {
return createContext(builder.build(), (DataSchemaNode) parentNode,
- mountPoint,mountPoint != null ? mountPoint.getSchemaContext() : this.globalSchema);
+ mountPoint,mountPoint != null ? mountPoint.getEffectiveModelContext() : this.globalSchema);
}
final String head = strings.iterator().next();
}
final DOMMountPoint mount = mountOpt.get();
- final SchemaContext mountPointSchema = mount.getSchemaContext();
+ final EffectiveModelContext mountPointSchema = mount.getEffectiveModelContext();
if (mountPointSchema == null) {
throw new RestconfDocumentedException("Mount point does not contain any schema with modules.",
ErrorType.APPLICATION, ErrorTag.UNKNOWN_ELEMENT);
if (returnJustMountPoint || strings.size() == 1) {
final YangInstanceIdentifier instance = YangInstanceIdentifier.builder().build();
- return new InstanceIdentifierContext<>(instance, mountPointSchema, mount,mountPointSchema);
+ return new InstanceIdentifierContext<>(instance, mountPointSchema, mount, mountPointSchema);
}
final String moduleNameBehindMountPoint = toModuleName(strings.get(1));
ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE);
}
- final Iterator<Module> it = mountPointSchema.findModules(moduleNameBehindMountPoint).iterator();
+ final Iterator<? extends Module> it = mountPointSchema.findModules(moduleNameBehindMountPoint)
+ .iterator();
if (!it.hasNext()) {
throw new RestconfDocumentedException("\"" + moduleNameBehindMountPoint
+ "\" module does not exist in mount point.", ErrorType.PROTOCOL, ErrorTag.UNKNOWN_ELEMENT);
ErrorType.PROTOCOL, ErrorTag.UNKNOWN_ELEMENT);
}
} else {
- final SchemaContext schemaContext = mountPoint.getSchemaContext();
+ final EffectiveModelContext schemaContext = mountPoint.getEffectiveModelContext();
if (schemaContext != null) {
module = schemaContext.findModules(moduleName).stream().findFirst().orElse(null);
} else {
}
if (rpc != null) {
return new InstanceIdentifierContext<>(builder.build(), rpc, mountPoint,
- mountPoint != null ? mountPoint.getSchemaContext() : this.globalSchema);
+ mountPoint != null ? mountPoint.getEffectiveModelContext() : this.globalSchema);
}
}
}
return createContext(builder.build(), targetNode, mountPoint,
- mountPoint != null ? mountPoint.getSchemaContext() : this.globalSchema);
+ mountPoint != null ? mountPoint.getEffectiveModelContext() : this.globalSchema);
}
private static InstanceIdentifierContext<?> createContext(final YangInstanceIdentifier instance,
- final DataSchemaNode dataSchemaNode, final DOMMountPoint mountPoint, final SchemaContext schemaContext) {
+ final DataSchemaNode dataSchemaNode, final DOMMountPoint mountPoint,
+ final EffectiveModelContext schemaContext) {
final YangInstanceIdentifier instanceIdentifier = new DataNormalizer(schemaContext).toNormalized(instance);
return new InstanceIdentifierContext<>(instanceIdentifier, dataSchemaNode, mountPoint, schemaContext);
}
private static void collectInstanceDataNodeContainers(final List<DataSchemaNode> potentialSchemaNodes,
final DataNodeContainer container, final String name) {
- final Iterable<DataSchemaNode> nodes = Iterables.filter(container.getChildNodes(),
+ final Iterable<? extends DataSchemaNode> nodes = Iterables.filter(container.getChildNodes(),
node -> name.equals(node.getQName().getLocalName()));
// Can't combine this loop with the filter above because the filter is
final Iterable<ChoiceSchemaNode> choiceNodes = Iterables.filter(container.getChildNodes(),
ChoiceSchemaNode.class);
- final Iterable<Collection<CaseSchemaNode>> map = Iterables.transform(choiceNodes,
- choice -> choice.getCases().values());
+ final Iterable<Collection<? extends CaseSchemaNode>> map = Iterables.transform(choiceNodes,
+ ChoiceSchemaNode::getCases);
for (final CaseSchemaNode caze : Iterables.concat(map)) {
collectInstanceDataNodeContainers(potentialSchemaNodes, caze, name);
}
checkPreconditions();
final String module = toModuleName(name);
final String node = toNodeName(name);
- final Set<Module> modules = schemaContext.findModules(module);
+ final Collection<? extends Module> modules = schemaContext.findModules(module);
return modules.isEmpty() ? null : QName.create(modules.iterator().next().getQNameModule(), node);
}
}
@Override
- public void onGlobalContextUpdated(final SchemaContext context) {
+ public void onModelContextUpdated(final EffectiveModelContext context) {
if (context != null) {
- final Collection<RpcDefinition> defs = context.getOperations();
+ final Collection<? extends RpcDefinition> defs = context.getOperations();
final Map<QName, RpcDefinition> newMap = new HashMap<>(defs.size());
for (final RpcDefinition operation : defs) {
final ImmutableMap.Builder<PathArgument, DataNormalizationOperation<?>> byArgBuilder =
ImmutableMap.builder();
- for (final CaseSchemaNode caze : schema.getCases().values()) {
+ for (final CaseSchemaNode caze : schema.getCases()) {
for (final DataSchemaNode cazeChild : caze.getChildNodes()) {
final DataNormalizationOperation<?> childOp = fromDataSchemaNode(cazeChild);
byArgBuilder.put(childOp.getIdentifier(), childOp);
private static @Nullable ChoiceSchemaNode findChoice(final DataNodeContainer parent, final QName child) {
for (final ChoiceSchemaNode choice : Iterables.filter(parent.getChildNodes(), ChoiceSchemaNode.class)) {
- for (final CaseSchemaNode caze : choice.getCases().values()) {
+ for (final CaseSchemaNode caze : choice.getCases()) {
if (findChildSchemaNode(caze, child) != null) {
return choice;
}
import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.net.URI;
import java.time.Instant;
import java.time.format.DateTimeFormatter;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.FeatureDefinition;
import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
@Override
public NormalizedNodeContext getModules(final UriInfo uriInfo) {
- final Set<Module> allModules = this.controllerContext.getAllModules();
- final MapNode allModuleMap = makeModuleMapNode(allModules);
+ final MapNode allModuleMap = makeModuleMapNode(controllerContext.getAllModules());
- final SchemaContext schemaContext = this.controllerContext.getGlobalSchema();
+ final EffectiveModelContext schemaContext = this.controllerContext.getGlobalSchema();
final Module restconfModule = getRestconfModule();
final DataSchemaNode modulesSchemaNode = this.controllerContext.getRestconfModuleRestConfSchemaNode(
final InstanceIdentifierContext<?> mountPointIdentifier =
this.controllerContext.toMountPointIdentifier(identifier);
final DOMMountPoint mountPoint = mountPointIdentifier.getMountPoint();
- final Set<Module> modules = this.controllerContext.getAllModules(mountPoint);
- final MapNode mountPointModulesMap = makeModuleMapNode(modules);
+ final MapNode mountPointModulesMap = makeModuleMapNode(controllerContext.getAllModules(mountPoint));
final Module restconfModule = getRestconfModule();
final DataSchemaNode modulesSchemaNode = this.controllerContext.getRestconfModuleRestConfSchemaNode(
final Entry<String, Revision> nameRev = getModuleNameAndRevision(identifier);
Module module = null;
DOMMountPoint mountPoint = null;
- final SchemaContext schemaContext;
+ final EffectiveModelContext schemaContext;
if (identifier.contains(ControllerContext.MOUNT)) {
final InstanceIdentifierContext<?> mountPointIdentifier =
this.controllerContext.toMountPointIdentifier(identifier);
mountPoint = mountPointIdentifier.getMountPoint();
module = this.controllerContext.findModuleByNameAndRevision(mountPoint, nameRev.getKey(),
nameRev.getValue());
- schemaContext = mountPoint.getSchemaContext();
+ schemaContext = mountPoint.getEffectiveModelContext();
} else {
module = this.controllerContext.findModuleByNameAndRevision(nameRev.getKey(), nameRev.getValue());
schemaContext = this.controllerContext.getGlobalSchema();
@Override
public NormalizedNodeContext getAvailableStreams(final UriInfo uriInfo) {
- final SchemaContext schemaContext = this.controllerContext.getGlobalSchema();
+ final EffectiveModelContext schemaContext = this.controllerContext.getGlobalSchema();
final Set<String> availableStreams = Notificator.getStreamNames();
final Module restconfModule = getRestconfModule();
final DataSchemaNode streamSchemaNode = this.controllerContext
final SchemaPath type = payload.getInstanceIdentifierContext().getSchemaNode().getPath();
final URI namespace = payload.getInstanceIdentifierContext().getSchemaNode().getQName().getNamespace();
- final ListenableFuture<DOMRpcResult> response;
+ final ListenableFuture<? extends DOMRpcResult> response;
final DOMMountPoint mountPoint = payload.getInstanceIdentifierContext().getMountPoint();
- final SchemaContext schemaContext;
+ final EffectiveModelContext schemaContext;
if (mountPoint != null) {
final Optional<DOMRpcService> mountRpcServices = mountPoint.getService(DOMRpcService.class);
LOG.debug("Error: Rpc service is missing.");
throw new RestconfDocumentedException("Rpc service is missing.");
}
- schemaContext = mountPoint.getSchemaContext();
+ schemaContext = mountPoint.getEffectiveModelContext();
response = mountRpcServices.get().invokeRpc(type, payload.getData());
} else {
if (namespace.toString().equals(SAL_REMOTE_NAMESPACE)) {
}
}
+ @SuppressFBWarnings(value = "NP_LOAD_OF_KNOWN_NULL_VALUE",
+ justification = "Looks like a false positive, see below FIXME")
private NormalizedNodeContext invokeRpc(final String identifier, final UriInfo uriInfo) {
-
- DOMMountPoint mountPoint = null;
+ final DOMMountPoint mountPoint;
final String identifierEncoded;
- final SchemaContext schemaContext;
+ final EffectiveModelContext schemaContext;
if (identifier.contains(ControllerContext.MOUNT)) {
// mounted RPC call - look up mount instance.
final InstanceIdentifierContext<?> mountPointId = this.controllerContext.toMountPointIdentifier(identifier);
mountPoint = mountPointId.getMountPoint();
- schemaContext = mountPoint.getSchemaContext();
+ schemaContext = mountPoint.getEffectiveModelContext();
final int startOfRemoteRpcName =
identifier.lastIndexOf(ControllerContext.MOUNT) + ControllerContext.MOUNT.length() + 1;
final String remoteRpcName = identifier.substring(startOfRemoteRpcName);
identifierEncoded = remoteRpcName;
- } else if (identifier.indexOf('/') != CHAR_NOT_FOUND) {
+ } else if (identifier.indexOf('/') == CHAR_NOT_FOUND) {
+ identifierEncoded = identifier;
+ mountPoint = null;
+ schemaContext = this.controllerContext.getGlobalSchema();
+ } else {
LOG.debug("Identifier {} cannot contain slash character (/).", identifier);
throw new RestconfDocumentedException(String.format("Identifier %n%s%ncan\'t contain slash character (/).%n"
+ "If slash is part of identifier name then use %%2F placeholder.", identifier), ErrorType.PROTOCOL,
ErrorTag.INVALID_VALUE);
- } else {
- identifierEncoded = identifier;
- schemaContext = this.controllerContext.getGlobalSchema();
}
final String identifierDecoded = ControllerContext.urlPathArgDecode(identifierEncoded);
-
- RpcDefinition rpc;
+ final RpcDefinition rpc;
if (mountPoint == null) {
rpc = this.controllerContext.getRpcDefinition(identifierDecoded);
} else {
+ " with an input section defined", ErrorType.RPC, ErrorTag.MISSING_ELEMENT);
}
- final ListenableFuture<DOMRpcResult> response;
+ final ListenableFuture<? extends DOMRpcResult> response;
if (mountPoint != null) {
final Optional<DOMRpcService> mountRpcServices = mountPoint.getService(DOMRpcService.class);
if (!mountRpcServices.isPresent()) {
response = this.broker.invokeRpc(rpc.getPath(), null);
}
- final DOMRpcResult result = checkRpcResponse(response);
-
- if (result.getResult() != null && ((ContainerNode) result.getResult()).getValue().isEmpty()) {
+ final NormalizedNode<?, ?> result = checkRpcResponse(response).getResult();
+ if (result != null && ((ContainerNode) result).getValue().isEmpty()) {
throw new WebApplicationException(Response.Status.NO_CONTENT);
- } else {
- return new NormalizedNodeContext(new InstanceIdentifierContext<>(null, rpc, mountPoint, schemaContext),
- result.getResult(), QueryParametersParser.parseWriterParameters(uriInfo));
}
+
+ // FIXME: in reference to the above @SupressFBWarnings: "mountPoint" reference here trips up SpotBugs, as it
+ // thinks it can only ever be null. Except it can very much be non-null. The core problem is the horrible
+ // structure of this code where we have a sh*tload of checks for mountpoint above and all over the
+ // codebase where all that difference should have been properly encapsulated.
+ //
+ // This is legacy code, so if anybody cares to do that refactor, feel free to contribute, but I am not
+ // doing that work.
+ return new NormalizedNodeContext(new InstanceIdentifierContext<>(null, rpc, mountPoint, schemaContext), result,
+ QueryParametersParser.parseWriterParameters(uriInfo));
}
@SuppressWarnings("checkstyle:avoidHidingCauseException")
- private static DOMRpcResult checkRpcResponse(final ListenableFuture<DOMRpcResult> response) {
+ private static DOMRpcResult checkRpcResponse(final ListenableFuture<? extends DOMRpcResult> response) {
if (response == null) {
return null;
}
} catch (final ExecutionException e) {
LOG.debug("Execution RpcError: ", e);
Throwable cause = e.getCause();
- if (cause != null) {
- while (cause.getCause() != null) {
- cause = cause.getCause();
- }
-
- if (cause instanceof IllegalArgumentException) {
- throw new RestconfDocumentedException(cause.getMessage(), ErrorType.PROTOCOL,
- ErrorTag.INVALID_VALUE);
- } else if (cause instanceof DOMRpcImplementationNotAvailableException) {
- throw new RestconfDocumentedException(cause.getMessage(), ErrorType.APPLICATION,
- ErrorTag.OPERATION_NOT_SUPPORTED);
- }
+ if (cause == null) {
throw new RestconfDocumentedException("The operation encountered an unexpected error while executing.",
- cause);
- } else {
- throw new RestconfDocumentedException("The operation encountered an unexpected error while executing.",
- e);
+ e);
+ }
+ while (cause.getCause() != null) {
+ cause = cause.getCause();
+ }
+
+ if (cause instanceof IllegalArgumentException) {
+ throw new RestconfDocumentedException(cause.getMessage(), ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE);
+ } else if (cause instanceof DOMRpcImplementationNotAvailableException) {
+ throw new RestconfDocumentedException(cause.getMessage(), ErrorType.APPLICATION,
+ ErrorTag.OPERATION_NOT_SUPPORTED);
}
+ throw new RestconfDocumentedException("The operation encountered an unexpected error while executing.",
+ cause);
} catch (final CancellationException e) {
final String errMsg = "The operation was cancelled while executing.";
LOG.debug("Cancel RpcExecution: {}", errMsg, e);
*/
private InstanceIdentifierContext<?> prepareIIDSubsStreamOutput() {
final QName qnameBase = QName.create("subscribe:to:notification", "2016-10-28", "notifi");
- final SchemaContext schemaCtx = controllerContext.getGlobalSchema();
+ final EffectiveModelContext schemaCtx = controllerContext.getGlobalSchema();
final DataSchemaNode location = ((ContainerSchemaNode) schemaCtx
.findModule(qnameBase.getModule()).orElse(null)
.getDataChildByName(qnameBase)).getDataChildByName(QName.create(qnameBase, "location"));
return result;
}
- private MapNode makeModuleMapNode(final Set<Module> modules) {
+ private MapNode makeModuleMapNode(final Collection<? extends Module> modules) {
Preconditions.checkNotNull(modules);
final Module restconfModule = getRestconfModule();
final DataSchemaNode moduleSchemaNode = this.controllerContext
<reference id="dOMDataBroker" interface="org.opendaylight.mdsal.dom.api.DOMDataBroker"
ext:filter="(type=@{databroker-service-type})"/>
- <bean id="webSocketPort" class="org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber">
+ <bean id="webSocketPort" class="org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber" factory-method="getDefaultInstance">
<argument value="${websocket-port}"/>
</bean>
package org.opendaylight.controller.md.sal.rest.common;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doCallRealMethod;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
import org.slf4j.Logger;
throw new UnsupportedOperationException("Test utility class");
}
- public static ControllerContext newControllerContext(final SchemaContext schemaContext) {
+ public static ControllerContext newControllerContext(final EffectiveModelContext schemaContext) {
return newControllerContext(schemaContext, null);
}
- public static ControllerContext newControllerContext(final SchemaContext schemaContext,
+ public static ControllerContext newControllerContext(final EffectiveModelContext schemaContext,
final DOMMountPoint mountInstance) {
final DOMMountPointService mockMountService = mock(DOMMountPointService.class);
if (mountInstance != null) {
- doReturn(schemaContext).when(mountInstance).getSchemaContext();
+ doReturn(schemaContext).when(mountInstance).getEffectiveModelContext();
+ doCallRealMethod().when(mountInstance).getSchemaContext();
doReturn(Optional.ofNullable(mountInstance)).when(mockMountService).getMountPoint(
any(YangInstanceIdentifier.class));
}
}
@SuppressWarnings("checkstyle:IllegalCatch")
- public static SchemaContext loadSchemaContext(final String yangPath, final SchemaContext schemaContext) {
+ public static EffectiveModelContext loadSchemaContext(final String yangPath,
+ final EffectiveModelContext schemaContext) {
try {
Preconditions.checkArgument(yangPath != null, "Path can not be null.");
Preconditions.checkArgument(!yangPath.isEmpty(), "Path can not be empty.");
final String schemaNodeName = iiContext.getSchemaNode().getQName().getLocalName();
if (!schemaNodeName.equalsIgnoreCase(docRootElm)) {
- final Collection<DataSchemaNode> children = ((DataNodeContainer) schemaNode).getChildNodes();
- for (final DataSchemaNode child : children) {
+ for (final DataSchemaNode child : ((DataNodeContainer) schemaNode).getChildNodes()) {
if (child.getQName().getLocalName().equalsIgnoreCase(docRootElm)) {
schemaNode = child;
break;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
public class InstanceIdentifierTypeLeafTest {
@Test
public void stringToInstanceIdentifierTest() throws Exception {
- final SchemaContext schemaContext =
+ final EffectiveModelContext schemaContext =
YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/instanceidentifier"));
ControllerContext controllerContext = TestRestconfUtils.newControllerContext(schemaContext);
final InstanceIdentifierContext<?> instanceIdentifier =
import org.opendaylight.netconf.sal.restconf.impl.ControllerContext;
import org.opendaylight.restconf.common.context.NormalizedNodeContext;
import org.opendaylight.restconf.common.patch.PatchContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
public abstract class AbstractBodyReaderTest {
private static Field uriField;
protected final ControllerContext controllerContext;
protected final MediaType mediaType;
- protected AbstractBodyReaderTest(final SchemaContext schemaContext, final DOMMountPoint mountInstance) {
+ protected AbstractBodyReaderTest(final EffectiveModelContext schemaContext, final DOMMountPoint mountInstance) {
this.mediaType = getMediaType();
controllerContext = TestRestconfUtils.newControllerContext(schemaContext, mountInstance);
protected abstract MediaType getMediaType();
- protected static SchemaContext schemaContextLoader(final String yangPath,
- final SchemaContext schemaContext) {
+ protected static EffectiveModelContext schemaContextLoader(final String yangPath,
+ final EffectiveModelContext schemaContext) {
return TestRestconfUtils.loadSchemaContext(yangPath, schemaContext);
}
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes;
import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
public class TestJsonBodyReader extends AbstractBodyReaderTest {
private final JsonNormalizedNodeBodyReader jsonBodyReader;
- private static SchemaContext schemaContext;
+ private static EffectiveModelContext schemaContext;
private static final QNameModule INSTANCE_IDENTIFIER_MODULE_QNAME = QNameModule.create(
URI.create("instance:identifier:module"), Revision.of("2014-01-17"));
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes;
import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
public class TestJsonBodyReaderMountPoint extends AbstractBodyReaderTest {
private final JsonNormalizedNodeBodyReader jsonBodyReader;
- private static SchemaContext schemaContext;
+ private static EffectiveModelContext schemaContext;
private static final QNameModule INSTANCE_IDENTIFIER_MODULE_QNAME = QNameModule.create(
URI.create("instance:identifier:module"), Revision.of("2014-01-17"));
.getChild(yangCont.getLastPathArgument());
assertTrue(contDataNode.isPresent());
assertTrue(contDataNode.get() instanceof ContainerNode);
- final YangInstanceIdentifier yangleaf = YangInstanceIdentifier.of(QName
- .create(inputNode.getNodeType(), "lf"));
+ final YangInstanceIdentifier yangleaf = YangInstanceIdentifier.of(QName.create(inputNode.getNodeType(), "lf"));
final Optional<DataContainerChild<? extends PathArgument, ?>> leafDataNode =
((ContainerNode) contDataNode.get()).getChild(yangleaf.getLastPathArgument());
assertTrue(leafDataNode.isPresent());
- assertTrue("lf-test".equalsIgnoreCase(leafDataNode.get().getValue()
- .toString()));
+ assertTrue("lf-test".equalsIgnoreCase(leafDataNode.get().getValue().toString()));
}
private void checkExpectValueNormalizeNodeContext(
.of(dataSchemaNode.getQName());
final DOMMountPoint mountPoint = nnContext
.getInstanceIdentifierContext().getMountPoint();
- final DataSchemaNode mountDataSchemaNode = mountPoint
- .getSchemaContext().getDataChildByName(
+ final DataSchemaNode mountDataSchemaNode = mountPoint.getSchemaContext().getDataChildByName(
dataSchemaNode.getQName());
assertNotNull(mountDataSchemaNode);
if (qualifiedName != null && dataSchemaNode instanceof DataNodeContainer) {
- final DataSchemaNode child = ((DataNodeContainer) dataSchemaNode)
- .getDataChildByName(qualifiedName);
- dataNodeIdent = YangInstanceIdentifier.builder(dataNodeIdent)
- .node(child.getQName()).build();
- assertTrue(nnContext.getInstanceIdentifierContext().getSchemaNode()
- .equals(child));
+ final DataSchemaNode child = ((DataNodeContainer) dataSchemaNode).getDataChildByName(qualifiedName);
+ dataNodeIdent = YangInstanceIdentifier.builder(dataNodeIdent).node(child.getQName()).build();
+ assertTrue(nnContext.getInstanceIdentifierContext().getSchemaNode().equals(child));
} else {
assertTrue(mountDataSchemaNode.equals(dataSchemaNode));
}
import org.opendaylight.netconf.sal.rest.impl.JsonNormalizedNodeBodyReader;
import org.opendaylight.netconf.sal.rest.impl.NormalizedNodeJsonBodyWriter;
import org.opendaylight.restconf.common.context.NormalizedNodeContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
public class TestJsonBodyWriter extends AbstractBodyReaderTest {
private final JsonNormalizedNodeBodyReader jsonBodyReader;
private final NormalizedNodeJsonBodyWriter jsonBodyWriter;
- private static SchemaContext schemaContext;
+ private static EffectiveModelContext schemaContext;
public TestJsonBodyWriter() {
super(schemaContext, null);
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.controller.sal.rest.impl.test.providers;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import org.opendaylight.netconf.sal.rest.impl.JsonToPatchBodyReader;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.restconf.common.patch.PatchContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
public class TestJsonPatchBodyReader extends AbstractBodyReaderTest {
private final JsonToPatchBodyReader jsonToPatchBodyReader;
- private static SchemaContext schemaContext;
+ private static EffectiveModelContext schemaContext;
public TestJsonPatchBodyReader() {
super(schemaContext, null);
import org.opendaylight.netconf.sal.rest.impl.JsonToPatchBodyReader;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.restconf.common.patch.PatchContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
public class TestJsonPatchBodyReaderMountPoint extends AbstractBodyReaderTest {
-
private final JsonToPatchBodyReader jsonToPatchBodyReader;
- private static SchemaContext schemaContext;
+ private static EffectiveModelContext schemaContext;
private static final String MOUNT_POINT = "instance-identifier-module:cont/yang-ext:mount";
public TestJsonPatchBodyReaderMountPoint() {
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes;
import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
public class TestXmlBodyReader extends AbstractBodyReaderTest {
private final XmlNormalizedNodeBodyReader xmlBodyReader;
- private static SchemaContext schemaContext;
+ private static EffectiveModelContext schemaContext;
private static final QNameModule INSTANCE_IDENTIFIER_MODULE_QNAME = QNameModule.create(
URI.create("instance:identifier:module"), Revision.of("2014-01-17"));
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes;
import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
public class TestXmlBodyReaderMountPoint extends AbstractBodyReaderTest {
private final XmlNormalizedNodeBodyReader xmlBodyReader;
- private static SchemaContext schemaContext;
+ private static EffectiveModelContext schemaContext;
private static final QNameModule INSTANCE_IDENTIFIER_MODULE_QNAME = QNameModule.create(
URI.create("instance:identifier:module"), Revision.of("2014-01-17"));
import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils;
import org.opendaylight.netconf.sal.rest.impl.NormalizedNodeXmlBodyWriter;
import org.opendaylight.restconf.common.context.NormalizedNodeContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
public class TestXmlBodyWriter extends AbstractBodyReaderTest {
private final NormalizedNodeXmlBodyWriter xmlBodyWriter;
- private static SchemaContext schemaContext;
+ private static EffectiveModelContext schemaContext;
public TestXmlBodyWriter() {
super(schemaContext, null);
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.controller.sal.rest.impl.test.providers;
import static org.junit.Assert.assertEquals;
import org.opendaylight.netconf.sal.rest.impl.XmlToPatchBodyReader;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.restconf.common.patch.PatchContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
public class TestXmlPatchBodyReader extends AbstractBodyReaderTest {
private final XmlToPatchBodyReader xmlToPatchBodyReader;
- private static SchemaContext schemaContext;
+ private static EffectiveModelContext schemaContext;
public TestXmlPatchBodyReader() {
super(schemaContext, null);
import org.opendaylight.netconf.sal.rest.impl.XmlToPatchBodyReader;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.restconf.common.patch.PatchContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
public class TestXmlPatchBodyReaderMountPoint extends AbstractBodyReaderTest {
private final XmlToPatchBodyReader xmlToPatchBodyReader;
- private static SchemaContext schemaContext;
+ private static EffectiveModelContext schemaContext;
private static final String MOUNT_POINT = "instance-identifier-module:cont/yang-ext:mount";
public TestXmlPatchBodyReaderMountPoint() {
import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.valid.DataValidationException;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
public class RestPutListDataTest {
- private static SchemaContext schemaContextTestModule;
+ private static EffectiveModelContext schemaContextTestModule;
private static BrokerFacade brokerFacade;
private static RestconfImpl restconfImpl;
import org.opendaylight.netconf.sal.rest.impl.JsonNormalizedNodeBodyReader;
import org.opendaylight.restconf.common.context.NormalizedNodeContext;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
public class JsonIdentityrefToNnTest extends AbstractBodyReaderTest {
private final JsonNormalizedNodeBodyReader jsonBodyReader;
- private static SchemaContext schemaContext;
+ private static EffectiveModelContext schemaContext;
public JsonIdentityrefToNnTest() {
super(schemaContext, null);
import org.opendaylight.netconf.sal.rest.impl.JsonNormalizedNodeBodyReader;
import org.opendaylight.restconf.common.context.NormalizedNodeContext;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
public class JsonLeafrefToNnTest extends AbstractBodyReaderTest {
private final JsonNormalizedNodeBodyReader jsonBodyReader;
- private static SchemaContext schemaContext;
+ private static EffectiveModelContext schemaContext;
public JsonLeafrefToNnTest() {
super(schemaContext, null);
import org.opendaylight.restconf.common.context.NormalizedNodeContext;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final Logger LOG = LoggerFactory.getLogger(AbstractBodyReaderTest.class);
private final JsonNormalizedNodeBodyReader jsonBodyReader;
- private static SchemaContext schemaContext;
+ private static EffectiveModelContext schemaContext;
public JsonToNnTest() {
super(schemaContext, null);
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.controller.sal.restconf.impl.nn.to.json.test;
import static org.junit.Assert.assertTrue;
import org.opendaylight.controller.sal.rest.impl.test.providers.AbstractBodyReaderTest;
import org.opendaylight.netconf.sal.rest.impl.NormalizedNodeJsonBodyWriter;
import org.opendaylight.restconf.common.context.NormalizedNodeContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
public class NnJsonChoiceCaseTest extends AbstractBodyReaderTest {
- private static SchemaContext schemaContext;
+ private static EffectiveModelContext schemaContext;
private final NormalizedNodeJsonBodyWriter jsonBodyWriter;
public NnJsonChoiceCaseTest() {
import org.opendaylight.controller.sal.rest.impl.test.providers.AbstractBodyReaderTest;
import org.opendaylight.netconf.sal.rest.impl.NormalizedNodeJsonBodyWriter;
import org.opendaylight.restconf.common.context.NormalizedNodeContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
public class NnToJsonLeafrefType extends AbstractBodyReaderTest {
- private static SchemaContext schemaContext;
+ private static EffectiveModelContext schemaContext;
private final NormalizedNodeJsonBodyWriter jsonBodyWriter;
public NnToJsonLeafrefType() {
import org.opendaylight.controller.sal.rest.impl.test.providers.AbstractBodyReaderTest;
import org.opendaylight.netconf.sal.rest.impl.NormalizedNodeJsonBodyWriter;
import org.opendaylight.restconf.common.context.NormalizedNodeContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
@Deprecated
public class NnToJsonWithAugmentTest extends AbstractBodyReaderTest {
- private static SchemaContext schemaContext;
+ private static EffectiveModelContext schemaContext;
private final NormalizedNodeJsonBodyWriter xmlBodyWriter;
public NnToJsonWithAugmentTest() {
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
public class NnInstanceIdentifierToXmlTest extends AbstractBodyReaderTest {
- private static SchemaContext schemaContext;
+ private static EffectiveModelContext schemaContext;
NormalizedNodeXmlBodyWriter xmlBodyWriter;
public NnInstanceIdentifierToXmlTest() {
import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
import org.opendaylight.restconf.common.context.NormalizedNodeContext;
import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.Uint32;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodec;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition;
import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition;
public ExpectedException thrown = ExpectedException.none();
private final NormalizedNodeXmlBodyWriter xmlBodyWriter;
- private static SchemaContext schemaContext;
+ private static EffectiveModelContext schemaContext;
public NnToXmlTest() {
super(schemaContext, null);
public void nnAsYangBitsToXmlTest() throws Exception {
final BitsTypeDefinition.Bit mockBit1 = Mockito.mock(BitsTypeDefinition.Bit.class);
Mockito.when(mockBit1.getName()).thenReturn("one");
- Mockito.when(mockBit1.getPosition()).thenReturn(1L);
+ Mockito.when(mockBit1.getPosition()).thenReturn(Uint32.ONE);
final BitsTypeDefinition.Bit mockBit2 = Mockito.mock(BitsTypeDefinition.Bit.class);
Mockito.when(mockBit2.getName()).thenReturn("two");
- Mockito.when(mockBit2.getPosition()).thenReturn(2L);
+ Mockito.when(mockBit2.getPosition()).thenReturn(Uint32.TWO);
final BitsTypeBuilder bitsTypeBuilder = BaseTypes.bitsTypeBuilder(Mockito.mock(SchemaPath.class));
bitsTypeBuilder.addBit(mockBit1);
bitsTypeBuilder.addBit(mockBit2);
public void nnAsYangUnionToXmlTest() throws Exception {
final BitsTypeDefinition.Bit mockBit1 = Mockito.mock(BitsTypeDefinition.Bit.class);
Mockito.when(mockBit1.getName()).thenReturn("first");
- Mockito.when(mockBit1.getPosition()).thenReturn(1L);
+ Mockito.when(mockBit1.getPosition()).thenReturn(Uint32.ONE);
final BitsTypeDefinition.Bit mockBit2 = Mockito.mock(BitsTypeDefinition.Bit.class);
Mockito.when(mockBit2.getName()).thenReturn("second");
- Mockito.when(mockBit2.getPosition()).thenReturn(2L);
+ Mockito.when(mockBit2.getPosition()).thenReturn(Uint32.TWO);
final BitsTypeBuilder bitsTypeBuilder = BaseTypes.bitsTypeBuilder(Mockito.mock(SchemaPath.class));
bitsTypeBuilder.addBit(mockBit1);
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
public class NnToXmlWithChoiceTest extends AbstractBodyReaderTest {
private final NormalizedNodeXmlBodyWriter xmlBodyWriter;
- private static SchemaContext schemaContext;
+ private static EffectiveModelContext schemaContext;
public NnToXmlWithChoiceTest() {
super(schemaContext, null);
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
public class NnToXmlWithDataFromSeveralModulesTest extends
AbstractBodyReaderTest {
private final NormalizedNodeXmlBodyWriter xmlBodyWriter;
- private static SchemaContext schemaContext;
+ private static EffectiveModelContext schemaContext;
public NnToXmlWithDataFromSeveralModulesTest() {
super(schemaContext, null);
final DOMRpcResult expResult = mock(DOMRpcResult.class);
doReturn(immediateFluentFuture(expResult)).when(this.mockRpcService).invokeRpc(this.type, this.dummyNode);
- final ListenableFuture<DOMRpcResult> actualFuture = this.brokerFacade.invokeRpc(this.type, this.dummyNode);
+ final ListenableFuture<? extends DOMRpcResult> actualFuture = this.brokerFacade.invokeRpc(this.type,
+ this.dummyNode);
assertNotNull("Future is null", actualFuture);
final DOMRpcResult actualResult = actualFuture.get();
assertSame("invokeRpc", expResult, actualResult);
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
public class Bug3595Test {
private static final QName CONT_QNAME = QName.create("leafref:module", "2014-04-17", "cont");
private static final QName LST_WITH_LFREF_KEY_QNAME = QName.create(CONT_QNAME, "lst-with-lfref-key");
private static final QName LFREF_KEY_QNAME = QName.create(CONT_QNAME, "lfref-key");
- private static SchemaContext schemaContext;
+ private static EffectiveModelContext schemaContext;
private final ControllerContext controllerContext = TestRestconfUtils.newControllerContext(schemaContext);
package org.opendaylight.controller.sal.restconf.impl.test;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import java.io.FileNotFoundException;
import java.util.HashMap;
import java.util.Map;
-import java.util.Set;
import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
private static final QName TYPE_QNAME = QName.create("test:module", "2014-01-09", "type");
private static final QName MODULE_TYPE_QNAME = QName.create("test:module", "2014-01-09", "module-type");
- private static SchemaContext schemaContext;
+ private static EffectiveModelContext schemaContext;
private final ControllerContext controllerContext;
final SchemaContext mountPointContext = TestUtils.loadSchemaContext("/full-versions/test-module");
final DOMMountPoint mountInstance = mock(DOMMountPoint.class);
controllerContext = TestRestconfUtils.newControllerContext(schemaContext, mountInstance);
- doReturn(mountPointContext).when(mountInstance).getSchemaContext();
+ doReturn(mountPointContext).when(mountInstance).getEffectiveModelContext();
}
@BeforeClass
public static void init() throws FileNotFoundException, ReactorException {
schemaContext = TestUtils.loadSchemaContext("/full-versions/yangs");
assertEquals(0, schemaContext.findModules(EXTERNAL_MODULE_NAME).size());
- final Set<Module> allModules = schemaContext.getModules();
- assertNotNull(allModules);
}
@Test
import org.opendaylight.netconf.sal.restconf.impl.BrokerFacade;
import org.opendaylight.netconf.sal.restconf.impl.ControllerContext;
import org.opendaylight.netconf.sal.restconf.impl.RestconfImpl;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
public class CodecsExceptionsCatchingTest extends JerseyTest {
@Before
public void init() throws FileNotFoundException, ReactorException {
restConf = RestconfImpl.newInstance(mock(BrokerFacade.class), controllerContext);
- final SchemaContext schemaContext = TestUtils.loadSchemaContext("/decoding-exception/yang");
- controllerContext = TestRestconfUtils.newControllerContext(schemaContext);
+ controllerContext = TestRestconfUtils.newControllerContext(TestUtils.loadSchemaContext(
+ "/decoding-exception/yang"));
}
@Override
import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.ListNodeBuilder;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static NormalizedNode<?, ?> depth1Cont;
private static NormalizedNode<?, ?> depth2Cont1;
private NormalizedNode<?, ?> globalPayload;
- private static SchemaContext schemaContextModules;
+ private static EffectiveModelContext schemaContextModules;
private final ControllerContext controllerContext =
TestRestconfUtils.newControllerContext(schemaContextModules, null);
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Collections;
import java.util.List;
-import java.util.Set;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MultivaluedHashMap;
import javax.ws.rs.core.MultivaluedMap;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeBuilder;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
public class InvokeRpcMethodTest {
private static UriInfo uriInfo;
- private static SchemaContext schemaContext;
+ private static EffectiveModelContext schemaContext;
private final RestconfImpl restconfImpl;
private final ControllerContext controllerContext;
@BeforeClass
public static void init() throws FileNotFoundException, ReactorException {
schemaContext = TestUtils.loadSchemaContext("/full-versions/yangs", "/invoke-rpc");
- final Set<Module> allModules = schemaContext.getModules();
+ final Collection<? extends Module> allModules = schemaContext.getModules();
assertNotNull(allModules);
final Module module = TestUtils.resolveModule("invoke-rpc-module", allModules);
assertNotNull(module);
}
private NormalizedNodeContext prepareDomPayload() {
- final SchemaContext schema = controllerContext.getGlobalSchema();
+ final EffectiveModelContext schema = controllerContext.getGlobalSchema();
final Module rpcModule = schema.findModules("invoke-rpc-module").iterator().next();
assertNotNull(rpcModule);
final QName rpcQName = QName.create(rpcModule.getQNameModule(), "rpc-test");
final QName rpcInputQName = QName.create(rpcModule.getQNameModule(),"input");
- final Set<RpcDefinition> setRpcs = rpcModule.getRpcs();
ContainerSchemaNode rpcInputSchemaNode = null;
- for (final RpcDefinition rpc : setRpcs) {
+ for (final RpcDefinition rpc : rpcModule.getRpcs()) {
if (rpcQName.isEqualWithoutRevision(rpc.getQName())) {
rpcInputSchemaNode = SchemaNodeUtils.getRpcDataSchema(rpc, rpcInputQName);
break;
final QName rpcQName = QName.create(rpcModule.getQNameModule(), "make-toast");
final QName rpcInputQName = QName.create(rpcModule.getQNameModule(),"input");
- final Set<RpcDefinition> setRpcs = rpcModule.getRpcs();
RpcDefinition rpcDef = null;
ContainerSchemaNode rpcInputSchemaNode = null;
-
- for (final RpcDefinition rpc : setRpcs) {
+ for (final RpcDefinition rpc : rpcModule.getRpcs()) {
if (rpcQName.isEqualWithoutRevision(rpc.getQName())) {
rpcInputSchemaNode = SchemaNodeUtils.getRpcDataSchema(rpc, rpcInputQName);
rpcDef = rpc;
final QName rpcQName = QName.create(rpcModule.getQNameModule(), "testOutput");
final QName rpcOutputQName = QName.create(rpcModule.getQNameModule(),"output");
- final Set<RpcDefinition> setRpcs = rpcModule.getRpcs();
RpcDefinition rpcDef = null;
ContainerSchemaNode rpcOutputSchemaNode = null;
- for (final RpcDefinition rpc : setRpcs) {
+ for (final RpcDefinition rpc : rpcModule.getRpcs()) {
if (rpcQName.isEqualWithoutRevision(rpc.getQName())) {
rpcOutputSchemaNode = SchemaNodeUtils.getRpcDataSchema(rpc, rpcOutputQName);
rpcDef = rpc;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.ArgumentMatchers.notNull;
import static org.mockito.ArgumentMatchers.same;
+import static org.mockito.Mockito.doCallRealMethod;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
static final QName TEST_OUTPUT_QNAME = QName.create(TOASTER_MODULE_NS, TOASTER_MODULE_VERSION, "testOutput");
static final QName TEXT_OUT_QNAME = QName.create(TOASTER_MODULE_NS, TOASTER_MODULE_VERSION, "textOut");
- private static SchemaContext schemaContext;
+ private static EffectiveModelContext schemaContext;
private final BrokerFacade brokerFacade = mock(BrokerFacade.class);
private final DOMMountPoint mockMountPoint = mock(DOMMountPoint.class);
final SchemaContext mountPointSchemaContext = TestUtils.loadSchemaContext("/full-versions/test-module");
final ControllerContext controllerContext =
TestRestconfUtils.newControllerContext(schemaContext, mockMountPoint);
- doReturn(mountPointSchemaContext).when(mockMountPoint).getSchemaContext();
+ doCallRealMethod().when(mockMountPoint).getSchemaContext();
+ doReturn(mountPointSchemaContext).when(mockMountPoint).getEffectiveModelContext();
service = new JSONRestconfServiceImpl(controllerContext,
RestconfImpl.newInstance(brokerFacade, controllerContext));
package org.opendaylight.controller.sal.restconf.impl.test;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import java.io.FileNotFoundException;
import java.io.UnsupportedEncodingException;
-import java.util.Set;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.glassfish.jersey.test.JerseyTest;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils;
import org.opendaylight.mdsal.common.api.CommitInfo;
+import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
import org.opendaylight.netconf.sal.rest.impl.JsonNormalizedNodeBodyReader;
import org.opendaylight.netconf.sal.rest.impl.NormalizedNodeJsonBodyWriter;
import org.opendaylight.netconf.sal.rest.impl.NormalizedNodeXmlBodyWriter;
import org.opendaylight.netconf.sal.restconf.impl.RestconfImpl;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
public class RestDeleteOperationTest extends JerseyTest {
- private static SchemaContext schemaContext;
+ private static EffectiveModelContext schemaContext;
private ControllerContext controllerContext;
private BrokerFacade brokerFacade;
@BeforeClass
public static void init() throws FileNotFoundException, ReactorException {
schemaContext = TestUtils.loadSchemaContext("/test-config-data/yang1");
- final Set<Module> allModules = schemaContext.getModules();
- assertNotNull(allModules);
}
@Override
import org.opendaylight.netconf.sal.restconf.impl.ControllerContext;
import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
public class RestGetAugmentedElementWhenEqualNamesTest {
- private static SchemaContext schemaContext;
+ private static EffectiveModelContext schemaContext;
private final ControllerContext controllerContext = TestRestconfUtils.newControllerContext(schemaContext);
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapEntryNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapNodeBuilder;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
}
}
- private static SchemaContext schemaContextYangsIetf;
- private static SchemaContext schemaContextTestModule;
- private static SchemaContext schemaContextModules;
- private static SchemaContext schemaContextBehindMountPoint;
+ private static EffectiveModelContext schemaContextYangsIetf;
+ private static EffectiveModelContext schemaContextTestModule;
+ private static EffectiveModelContext schemaContextModules;
+ private static EffectiveModelContext schemaContextBehindMountPoint;
@SuppressWarnings("rawtypes")
private static NormalizedNode answerFromGet;
return resourceConfig;
}
- private void setControllerContext(final SchemaContext schemaContext) {
+ private void setControllerContext(final EffectiveModelContext schemaContext) {
controllerContext.setSchemas(schemaContext);
}
import org.opendaylight.netconf.sal.restconf.impl.RestconfImpl;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
public class RestPostOperationTest extends JerseyTest {
private static String xmlData3;
private static String xmlData4;
- private static SchemaContext schemaContextYangsIetf;
- private static SchemaContext schemaContextTestModule;
- private static SchemaContext schemaContext;
+ private static EffectiveModelContext schemaContextYangsIetf;
+ private static EffectiveModelContext schemaContextTestModule;
+ private static EffectiveModelContext schemaContext;
private BrokerFacade brokerFacade;
private RestconfImpl restconfImpl;
private DOMMountPoint mountInstance;
@BeforeClass
- public static void init() throws URISyntaxException, IOException, ReactorException {
+ public static void init() throws URISyntaxException, IOException {
schemaContextYangsIetf = TestUtils.loadSchemaContext("/full-versions/yangs");
schemaContextTestModule = TestUtils.loadSchemaContext("/full-versions/test-module");
schemaContext = TestUtils.loadSchemaContext("/test-config-data/yang1");
return resourceConfig;
}
- private void setSchemaControllerContext(final SchemaContext schema) {
+ private void setSchemaControllerContext(final EffectiveModelContext schema) {
controllerContext.setSchemas(schema);
}
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
@RunWith(MockitoJUnitRunner.class)
public class RestPutConfigTest {
- private static SchemaContext schemaContext;
+ private static EffectiveModelContext schemaContext;
private RestconfImpl restconfService;
private ControllerContext controllerCx;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
private static String xmlData2;
private static String xmlData3;
- private static SchemaContext schemaContextYangsIetf;
- private static SchemaContext schemaContextTestModule;
+ private static EffectiveModelContext schemaContextYangsIetf;
+ private static EffectiveModelContext schemaContextTestModule;
private BrokerFacade brokerFacade;
private RestconfImpl restconfImpl;
import org.opendaylight.restconf.common.errors.RestconfError.ErrorTag;
import org.opendaylight.restconf.common.errors.RestconfError.ErrorType;
import org.opendaylight.yangtools.util.xml.UntrustedXML;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
static XPathExpression ERROR_APP_TAG;
static XPathExpression ERROR_INFO;
- private static SchemaContext schemaContext;
+ private static EffectiveModelContext schemaContext;
@BeforeClass
public static void init() throws Exception {
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
public class RestconfImplNotificationSubscribingTest {
private final String identifier = "data-change-event-subscription/datastore=OPERATIONAL/scope=ONE";
- private static SchemaContext schemaContext;
+ private static EffectiveModelContext schemaContext;
@Mock
private BrokerFacade broker;
import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode;
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
*/
public class RestconfImplTest {
- private static SchemaContext schemaContext;
+ private static EffectiveModelContext schemaContext;
private final BrokerFacade brokerFacade = mock(BrokerFacade.class);
private final ControllerContext controllerContext = TestRestconfUtils.newControllerContext(schemaContext);
@BeforeClass
public static void init() throws FileNotFoundException, ReactorException {
schemaContext = TestUtils.loadSchemaContext("/full-versions/yangs");
- final Set<Module> allModules = schemaContext.getModules();
- assertNotNull(allModules);
}
@AfterClass
import java.nio.charset.StandardCharsets;
import java.text.ParseException;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.xml.transform.OutputKeys;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapEntryNodeBuilder;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
}
- public static SchemaContext loadSchemaContext(final String... yangPath) throws FileNotFoundException {
+ public static EffectiveModelContext loadSchemaContext(final String... yangPath) throws FileNotFoundException {
final List<File> files = new ArrayList<>();
for (final String path : yangPath) {
final String pathToFile = TestUtils.class.getResource(path).getPath();
return YangParserTestUtils.parseYangFiles(files);
}
- public static Module findModule(final Set<Module> modules, final String moduleName) {
+ public static Module findModule(final Collection<? extends Module> modules, final String moduleName) {
for (final Module module : modules) {
if (module.getName().equals(moduleName)) {
return module;
* module set has only one element then this element is returned.
*
*/
- public static Module resolveModule(final String searchedModuleName, final Set<Module> modules) {
+ public static Module resolveModule(final String searchedModuleName, final Collection<? extends Module> modules) {
assertNotNull("Modules can't be null.", modules);
if (searchedModuleName != null) {
for (final Module m : modules) {
import com.google.common.base.Preconditions;
import java.io.FileNotFoundException;
-import java.util.Set;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.UriBuilder;
import javax.ws.rs.core.UriInfo;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.netconf.sal.restconf.impl.BrokerFacade;
import org.opendaylight.netconf.sal.restconf.impl.ControllerContext;
import org.opendaylight.netconf.sal.restconf.impl.RestconfImpl;
import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.util.SchemaNodeUtils;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
}
private NormalizedNodeContext prepareDomRpcNode(final String datastore, final String scope) {
- final SchemaContext schema = this.controllerContext.getGlobalSchema();
+ final EffectiveModelContext schema = this.controllerContext.getGlobalSchema();
final Module rpcSalRemoteModule = schema.findModule("sal-remote", Revision.of("2014-01-14")).get();
- final Set<RpcDefinition> setRpcs = rpcSalRemoteModule.getRpcs();
final QName rpcQName =
QName.create(rpcSalRemoteModule.getQNameModule(), "create-data-change-event-subscription");
final QName rpcInputQName =
QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote", "2014-01-14", "input");
final RpcDefinition rpcDef = Mockito.mock(RpcDefinition.class);
ContainerSchemaNode rpcInputSchemaNode = null;
- for (final RpcDefinition rpc : setRpcs) {
+ for (final RpcDefinition rpc : rpcSalRemoteModule.getRpcs()) {
if (rpcQName.isEqualWithoutRevision(rpc.getQName())) {
rpcInputSchemaNode = SchemaNodeUtils.getRpcDataSchema(rpc, rpcInputQName);
break;
import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
public class URITest {
- private static SchemaContext schemaContext;
- private static SchemaContext mountSchemaContext;
+ private static EffectiveModelContext schemaContext;
+ private static EffectiveModelContext mountSchemaContext;
private final DOMMountPoint mountInstance = mock(DOMMountPoint.class);
private final ControllerContext controllerContext =
import static org.junit.Assert.assertNotNull;
import java.io.FileNotFoundException;
-import java.util.Set;
+import java.util.Collection;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.Module;
public abstract class YangAndXmlAndDataSchemaLoader {
-
- protected static Set<Module> modules;
+ protected static Collection<? extends Module> modules;
protected static DataSchemaNode dataSchemaNode;
protected static String searchedModuleName;
protected static String searchedDataSchemaName;
import org.opendaylight.netconf.sal.restconf.impl.BrokerFacade;
import org.opendaylight.netconf.sal.restconf.impl.ControllerContext;
import org.opendaylight.netconf.sal.restconf.impl.RestconfImpl;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
public class RestStreamTest extends JerseyTest {
- private static SchemaContext schemaContextYangsIetf;
+ private static EffectiveModelContext schemaContextYangsIetf;
private BrokerFacade brokerFacade;
private RestconfImpl restconfImpl;
createAndSubscribe("odl-leaf-nodes-only", "true");
}
- private void createAndSubscribe(String queryParamName, Object... values)
+ private void createAndSubscribe(final String queryParamName, final Object... values)
throws UnsupportedEncodingException, InterruptedException {
String uri = "/operations/sal-remote:create-data-change-event-subscription";
String rpcInput = getRpcInput();
return target(uri).request(mediaType).post(Entity.entity(data, mediaType));
}
- private Response get(final String uri, final String mediaType, String queryParam, Object... values) {
+ private Response get(final String uri, final String mediaType, final String queryParam, final Object... values) {
if (queryParam != null) {
return target(uri).queryParam(queryParam, values).request(mediaType).get();
} else {
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
public class InstanceIdentifierCodecImplTest {
- private static SchemaContext schemaContext;
+ private static EffectiveModelContext schemaContext;
private InstanceIdentifierCodecImpl instanceIdentifierDTO;
private YangInstanceIdentifier instanceIdentifierBadNamespace;
import org.opendaylight.yang.gen.v1.urn.sal.restconf.event.subscription.rev140708.NotificationOutputTypeGrouping;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
import org.skyscreamer.jsonassert.JSONAssert;
import org.slf4j.Logger;
private static final YangInstanceIdentifier PATCH_CONT_YIID =
YangInstanceIdentifier.create(new YangInstanceIdentifier.NodeIdentifier(PatchCont.QNAME));
- private static SchemaContext schemaContext;
+ private static EffectiveModelContext schemaContext;
private DataBroker dataBroker;
private DOMDataBroker domDataBroker;
MyList1Builder builder = new MyList1Builder().setMyLeaf11("Jed").setName("Althea");
InstanceIdentifier<MyList1> iid = InstanceIdentifier.create(PatchCont.class)
.child(MyList1.class, new MyList1Key("Althea"));
- writeTransaction.put(LogicalDatastoreType.CONFIGURATION, iid, builder.build(), true);
+ writeTransaction.mergeParentStructurePut(LogicalDatastoreType.CONFIGURATION, iid, builder.build());
writeTransaction.commit();
adapter.assertGot(getNotifJson(JSON_NOTIF_LEAVES_CREATE));
writeTransaction = dataBroker.newWriteOnlyTransaction();
builder = new MyList1Builder().withKey(new MyList1Key("Althea")).setMyLeaf12("Bertha");
- writeTransaction.merge(LogicalDatastoreType.CONFIGURATION, iid, builder.build(), true);
+ writeTransaction.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, iid, builder.build());
writeTransaction.commit();
adapter.assertGot(getNotifJson(JSON_NOTIF_LEAVES_UPDATE));
MyList1Builder builder = new MyList1Builder().setMyLeaf11("Jed").setName("Althea");
InstanceIdentifier<MyList1> iid = InstanceIdentifier.create(PatchCont.class)
.child(MyList1.class, new MyList1Key("Althea"));
- writeTransaction.put(LogicalDatastoreType.CONFIGURATION, iid, builder.build(), true);
+ writeTransaction.mergeParentStructurePut(LogicalDatastoreType.CONFIGURATION, iid, builder.build());
writeTransaction.commit();
adapter.assertGot(getNotifJson(JSON_NOTIF_CREATE));
writeTransaction = dataBroker.newWriteOnlyTransaction();
builder = new MyList1Builder().withKey(new MyList1Key("Althea")).setMyLeaf12("Bertha");
- writeTransaction.merge(LogicalDatastoreType.CONFIGURATION, iid, builder.build(), true);
+ writeTransaction.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, iid, builder.build());
writeTransaction.commit();
adapter.assertGot(getNotifJson(JSON_NOTIF_UPDATE));
import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
public class NotificationListenerTest {
private static final QNameModule MODULE = QNameModule.create(URI.create("notifi:mod"), Revision.of("2016-11-23"));
- private static SchemaContext schemaContext;
+ private static EffectiveModelContext schemaContext;
private ControllerContext controllerContext;
private static void collectInstanceDataNodeContainers(final List<DataSchemaNode> potentialSchemaNodes,
final DataNodeContainer container, final String name) {
- final Iterable<DataSchemaNode> nodes =
+ final Iterable<? extends DataSchemaNode> nodes =
Iterables.filter(container.getChildNodes(), node -> name.equals(node.getQName().getLocalName()));
// Can't combine this loop with the filter above because the filter is
final Iterable<ChoiceSchemaNode> choiceNodes =
Iterables.filter(container.getChildNodes(), ChoiceSchemaNode.class);
- final Iterable<Collection<CaseSchemaNode>> map = Iterables.transform(choiceNodes,
- choice -> choice.getCases().values());
+ final Iterable<Collection<? extends CaseSchemaNode>> map = Iterables.transform(choiceNodes,
+ choice -> choice.getCases());
for (final CaseSchemaNode caze : Iterables.concat(map)) {
collectInstanceDataNodeContainers(potentialSchemaNodes, caze, name);
}
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.tree.ConflictingModificationAppliedException;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private final TransactionChainHandler transactionChainHandler;
private final DOMSchemaService domSchemaService;
- private ListenerRegistration<SchemaContextListener> listenerRegistration;
+ private ListenerRegistration<?> listenerRegistration;
- private volatile SchemaContext schemaContext;
+ private volatile EffectiveModelContext schemaContext;
/**
* Constructor.
@Override
@SuppressWarnings("checkstyle:hiddenField")
- public void onGlobalContextUpdated(final SchemaContext context) {
+ public void onModelContextUpdated(final EffectiveModelContext context) {
schemaContext = requireNonNull(context);
final Module ietfYangLibraryModule =
}
@Override
- public SchemaContext get() {
+ public EffectiveModelContext get() {
return schemaContext;
}
*/
package org.opendaylight.restconf.nb.rfc8040.handlers;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextListener;
-interface SchemaContextListenerHandler extends Handler<SchemaContext>, SchemaContextListener {
+interface SchemaContextListenerHandler extends Handler<EffectiveModelContext>, EffectiveModelContextListener {
}
import java.net.URISyntaxException;
import java.util.ArrayDeque;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Deque;
import java.util.List;
import javax.ws.rs.Consumes;
final String namespace) {
final Deque<Object> result = new ArrayDeque<>();
final ArrayList<ChoiceSchemaNode> choiceSchemaNodes = new ArrayList<>();
- final Collection<DataSchemaNode> children = ((DataNodeContainer) schemaNode).getChildNodes();
- for (final DataSchemaNode child : children) {
+ for (final DataSchemaNode child : ((DataNodeContainer) schemaNode).getChildNodes()) {
if (child instanceof ChoiceSchemaNode) {
choiceSchemaNodes.add((ChoiceSchemaNode) child);
} else if (child.getQName().getLocalName().equalsIgnoreCase(elementName)
}
for (final ChoiceSchemaNode choiceNode : choiceSchemaNodes) {
- for (final CaseSchemaNode caseNode : choiceNode.getCases().values()) {
+ for (final CaseSchemaNode caseNode : choiceNode.getCases()) {
final Deque<Object> resultFromRecursion = findPathToSchemaNodeByName(caseNode, elementName, namespace);
if (!resultFromRecursion.isEmpty()) {
resultFromRecursion.push(choiceNode);
import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
import org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants;
import org.opendaylight.restconf.nb.rfc8040.utils.parser.ParserIdentifier;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
public abstract class AbstractIdentifierAwareJaxRsProvider<T> implements MessageBodyReader<T> {
return this.uriInfo;
}
- protected SchemaContext getSchemaContext() {
+ protected EffectiveModelContext getSchemaContext() {
return schemaContextHandler.get();
}
import java.lang.ref.SoftReference;
import java.net.URI;
+import java.util.Collection;
import java.util.Date;
import java.util.Optional;
-import java.util.Set;
import org.opendaylight.mdsal.dom.api.DOMMountPoint;
import org.opendaylight.restconf.nb.rfc8040.Rfc8040;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.Revision;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
/**
- * This class creates {@link SoftReference} of actual {@link SchemaContext}
+ * This class creates {@link SoftReference} of actual {@link EffectiveModelContext}
* object and even if the {@link SchemaContext} changes, this will be sticks
* reference to the old {@link SchemaContext} and provides work with the old
- * {@link SchemaContext}.
+ * {@link EffectiveModelContext}.
*
*/
public final class SchemaContextRef {
- private final SoftReference<SchemaContext> schemaContextRef;
+ private final SoftReference<EffectiveModelContext> schemaContextRef;
/**
- * Create {@link SoftReference} of actual {@link SchemaContext}.
+ * Create {@link SoftReference} of actual {@link EffectiveModelContext}.
*
* @param schemaContext
- * actual {@link SchemaContext}
+ * actual {@link EffectiveModelContext}
*/
- public SchemaContextRef(final SchemaContext schemaContext) {
+ public SchemaContextRef(final EffectiveModelContext schemaContext) {
this.schemaContextRef = new SoftReference<>(schemaContext);
}
/**
- * Get {@link SchemaContext} from reference.
+ * Get {@link EffectiveModelContext} from reference.
*
- * @return {@link SchemaContext}
+ * @return {@link EffectiveModelContext}
*/
- public SchemaContext get() {
+ public EffectiveModelContext get() {
return this.schemaContextRef.get();
}
/**
- * Get all modules like {@link Set} of {@link Module} from
- * {@link SchemaContext}.
+ * Get all modules like {@link Collection} of {@link Module} from {@link SchemaContext}.
*
- * @return {@link Set} of {@link Module}
+ * @return {@link Collection} of {@link Module}
*/
- public Set<Module> getModules() {
+ public Collection<? extends Module> getModules() {
return get().getModules();
}
ref = new SchemaContextRef(this.schemaContextHandler.get());
} else {
localTransactionChainHandler = transactionChainOfMountPoint(mountPoint);
- ref = new SchemaContextRef(mountPoint.getSchemaContext());
+ ref = new SchemaContextRef(mountPoint.getEffectiveModelContext());
}
final TransactionVarsWrapper transactionNode = new TransactionVarsWrapper(
ref = new SchemaContextRef(this.schemaContextHandler.get());
} else {
localTransactionChainHandler = transactionChainOfMountPoint(mountPoint);
- ref = new SchemaContextRef(mountPoint.getSchemaContext());
+ ref = new SchemaContextRef(mountPoint.getEffectiveModelContext());
}
final TransactionVarsWrapper transactionNode = new TransactionVarsWrapper(
private SchemaContextRef getSchemaContext(final DOMMountPoint mountPoint) {
return mountPoint == null ? new SchemaContextRef(schemaContextHandler.get())
- : new SchemaContextRef(mountPoint.getSchemaContext());
+ : new SchemaContextRef(mountPoint.getEffectiveModelContext());
}
/**
if (mountPoint != null) {
response = RestconfInvokeOperationsUtil.invokeActionViaMountPoint(mountPoint, (ContainerNode) data,
schemaPath, yangIIdContext);
- schemaContextRef = new SchemaContextRef(mountPoint.getSchemaContext());
+ schemaContextRef = new SchemaContextRef(mountPoint.getEffectiveModelContext());
} else {
response = RestconfInvokeOperationsUtil.invokeAction((ContainerNode) data, schemaPath,
this.actionServiceHandler, yangIIdContext);
schemaContextRef = new SchemaContextRef(this.schemaContextHandler.get());
} else {
response = RestconfInvokeOperationsUtil.invokeRpcViaMountPoint(mountPoint, payload.getData(), schemaPath);
- schemaContextRef = new SchemaContextRef(mountPoint.getSchemaContext());
+ schemaContextRef = new SchemaContextRef(mountPoint.getEffectiveModelContext());
}
final DOMRpcResult result = RestconfInvokeOperationsUtil.checkResponse(response);
package org.opendaylight.restconf.nb.rfc8040.rests.utils;
import com.google.common.util.concurrent.FluentFuture;
-
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
-
import org.opendaylight.mdsal.common.api.CommitInfo;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
/**
* Util class for plain patch data to DS.
- *
*/
public final class PlainPatchDataTransactionUtil {
import org.opendaylight.yangtools.yang.data.api.schema.OrderedMapNode;
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
*/
private static FluentFuture<? extends CommitInfo> submitData(final YangInstanceIdentifier path,
final NormalizedNode<?, ?> data, final TransactionVarsWrapper transactionNode,
- final SchemaContext schemaContext, final String insert, final String point) {
+ final EffectiveModelContext schemaContext, final String insert, final String point) {
final DOMTransactionChain transactionChain = transactionNode.getTransactionChain();
final DOMDataTreeReadWriteTransaction newReadWriteTransaction = transactionChain.newReadWriteTransaction();
if (insert == null) {
private static void insertWithPointLeafListPost(final DOMDataTreeReadWriteTransaction rwTransaction,
final LogicalDatastoreType datastore, final YangInstanceIdentifier path, final NormalizedNode<?, ?> payload,
- final SchemaContext schemaContext, final String point, final OrderedLeafSetNode<?> readLeafList,
+ final EffectiveModelContext schemaContext, final String point, final OrderedLeafSetNode<?> readLeafList,
final boolean before, final DOMTransactionChain transactionChain) {
rwTransaction.delete(datastore, path.getParent().getParent());
final InstanceIdentifierContext<?> instanceIdentifier =
private static void insertWithPointListPost(final DOMDataTreeReadWriteTransaction rwTransaction,
final LogicalDatastoreType datastore, final YangInstanceIdentifier path, final NormalizedNode<?, ?> payload,
- final SchemaContext schemaContext, final String point, final MapNode readList, final boolean before,
+ final EffectiveModelContext schemaContext, final String point, final MapNode readList, final boolean before,
final DOMTransactionChain transactionChain) {
rwTransaction.delete(datastore, path.getParent().getParent());
final InstanceIdentifierContext<?> instanceIdentifier =
import org.opendaylight.yangtools.yang.data.util.DataSchemaContextNode;
import org.opendaylight.yangtools.yang.data.util.DataSchemaContextTree;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
public static Response putData(final NormalizedNodeContext payload, final SchemaContextRef schemaCtxRef,
final TransactionVarsWrapper transactionNode, final String insert, final String point) {
final YangInstanceIdentifier path = payload.getInstanceIdentifierContext().getInstanceIdentifier();
- final SchemaContext schemaContext = schemaCtxRef.get();
+ final EffectiveModelContext schemaContext = schemaCtxRef.get();
final DOMDataTreeReadWriteTransaction readWriteTransaction =
transactionNode.getTransactionChain().newReadWriteTransaction();
* @return {@link FluentFuture}
*/
private static FluentFuture<? extends CommitInfo> submitData(final YangInstanceIdentifier path,
- final SchemaContext schemaContext, final TransactionChainHandler transactionChainHandler,
+ final EffectiveModelContext schemaContext, final TransactionChainHandler transactionChainHandler,
final DOMDataTreeReadWriteTransaction readWriteTransaction,
final NormalizedNode<?, ?> data, final String insert, final String point) {
if (insert == null) {
}
}
- public static NormalizedNode<?, ?> readList(final YangInstanceIdentifier path, final SchemaContext schemaContext,
- final TransactionChainHandler transactionChainHandler, final DataSchemaNode schemaNode) {
+ public static NormalizedNode<?, ?> readList(final YangInstanceIdentifier path,
+ final EffectiveModelContext schemaContext, final TransactionChainHandler transactionChainHandler,
+ final DataSchemaNode schemaNode) {
final InstanceIdentifierContext<?> iid = new InstanceIdentifierContext<SchemaNode>(
path.getParent(), schemaNode, null, schemaContext);
final TransactionVarsWrapper transactionNode = new TransactionVarsWrapper(iid, null, transactionChainHandler);
private static void insertWithPointLeafListPut(final DOMDataTreeReadWriteTransaction rwTransaction,
final LogicalDatastoreType datastore, final YangInstanceIdentifier path,
- final NormalizedNode<?, ?> data, final SchemaContext schemaContext, final String point,
+ final NormalizedNode<?, ?> data, final EffectiveModelContext schemaContext, final String point,
final OrderedLeafSetNode<?> readLeafList, final boolean before) {
rwTransaction.delete(datastore, path.getParent());
final InstanceIdentifierContext<?> instanceIdentifier =
private static void insertWithPointListPut(final DOMDataTreeReadWriteTransaction writeTx,
final LogicalDatastoreType datastore, final YangInstanceIdentifier path,
- final NormalizedNode<?, ?> data, final SchemaContext schemaContext, final String point,
+ final NormalizedNode<?, ?> data, final EffectiveModelContext schemaContext, final String point,
final OrderedMapNode readList, final boolean before) {
writeTx.delete(datastore, path.getParent());
final InstanceIdentifierContext<?> instanceIdentifier =
/**
* Util class for rpc.
- *
*/
public final class RestconfInvokeOperationsUtil {
-
private static final Logger LOG = LoggerFactory.getLogger(RestconfInvokeOperationsUtil.class);
private RestconfInvokeOperationsUtil() {
final SchemaPath schemaPath) {
final Optional<DOMRpcService> mountPointService = mountPoint.getService(DOMRpcService.class);
if (mountPointService.isPresent()) {
- final ListenableFuture<DOMRpcResult> rpc = mountPointService.get().invokeRpc(schemaPath, data);
- return prepareResult(rpc);
+ return prepareResult(mountPointService.get().invokeRpc(schemaPath, data));
}
final String errmsg = "RPC service is missing.";
LOG.debug(errmsg);
throw new RestconfDocumentedException(Status.SERVICE_UNAVAILABLE);
}
- final ListenableFuture<DOMRpcResult> rpc = rpcService.invokeRpc(schemaPath, data);
- return prepareResult(rpc);
+ return prepareResult(rpcService.invokeRpc(schemaPath, data));
}
/**
}
}
- private static DOMRpcResult prepareResult(final ListenableFuture<DOMRpcResult> rpc) {
+ private static DOMRpcResult prepareResult(final ListenableFuture<? extends DOMRpcResult> rpc) {
final RpcResultFactory dataFactory = new RpcResultFactory();
FutureCallbackTx.addCallback(rpc, RestconfDataServiceConstant.PostData.POST_TX_TYPE, dataFactory);
return dataFactory.build();
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
final URI uri = prepareUriByStreamName(uriInfo, streamName);
final DOMTransactionChain transactionChain = handlersHolder.getTransactionChainHandler().get();
final DOMDataTreeReadWriteTransaction writeTransaction = transactionChain.newReadWriteTransaction();
- final SchemaContext schemaContext = handlersHolder.getSchemaHandler().get();
+ final EffectiveModelContext schemaContext = handlersHolder.getSchemaHandler().get();
final boolean exist = checkExist(schemaContext, writeTransaction);
final NormalizedNode mapToStreams = RestconfMappingNodeUtil
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
@Path("/")
@Override
public NormalizedNodeContext getLibraryVersion() {
- final SchemaContext context = this.schemaContextHandler.get();
+ final EffectiveModelContext context = this.schemaContextHandler.get();
SchemaNode schemaNode = null;
for (final GroupingDefinition groupingDefinition : context
.findModule(RestconfModule.IETF_RESTCONF_QNAME.getModule()).get().getGroupings()) {
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Collection;
+import java.util.List;
import java.util.Optional;
-import java.util.Set;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.restconf.nb.rfc8040.Rfc8040.IetfYangLibrary;
import org.opendaylight.restconf.nb.rfc8040.Rfc8040.MonitoringModule;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.Deviation;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.FeatureDefinition;
import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
* @return mapped data as {@link NormalizedNode}
*/
public static NormalizedNode<NodeIdentifier, Collection<DataContainerChild<? extends PathArgument, ?>>>
- mapModulesByIetfYangLibraryYang(final Set<Module> modules, final Module ietfYangLibraryModule,
- final SchemaContext context, final String moduleSetId) {
+ mapModulesByIetfYangLibraryYang(final Collection<? extends Module> modules,
+ final Module ietfYangLibraryModule, final SchemaContext context, final String moduleSetId) {
final DataSchemaNode modulesStateSch =
ietfYangLibraryModule.getDataChildByName(IetfYangLibrary.MODUELS_STATE_CONT_QNAME);
final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> modulesStateBuilder =
for (final Deviation deviation : module.getDeviations()) {
final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> deviationEntryNode =
Builders.mapEntryBuilder((ListSchemaNode) deviationsSchema);
- final QName lastComponent = deviation.getTargetPath().getLastComponent();
+ final List<QName> ids = deviation.getTargetPath().getNodeIdentifiers();
+ final QName lastComponent = ids.get(ids.size() - 1);
addCommonLeafs(context.findModule(lastComponent.getModule()).get(), deviationEntryNode,
ietfYangLibraryModule);
deviations.withChild(deviationEntryNode.build());
*/
private static void addFeatureLeafList(final QName qnameOfFeaturesLeafList,
final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> mapEntryBuilder,
- final Set<FeatureDefinition> features, final Module ietfYangLibraryModule) {
+ final Collection<? extends FeatureDefinition> features, final Module ietfYangLibraryModule) {
final DataSchemaNode schemaNode =
findSchemaInListOfModulesSchema(qnameOfFeaturesLeafList, ietfYangLibraryModule);
final ListNodeBuilder<Object, LeafSetEntryNode<Object>> leafSetBuilder =
*/
@SuppressWarnings("rawtypes")
public static NormalizedNode mapYangNotificationStreamByIetfRestconfMonitoring(final QName notifiQName,
- final Set<NotificationDefinition> notifications, final Instant start, final String outputType,
- final URI uri, final Module monitoringModule, final boolean existParent) {
+ final Collection<? extends NotificationDefinition> notifications, final Instant start,
+ final String outputType, final URI uri, final Module monitoringModule, final boolean existParent) {
for (final NotificationDefinition notificationDefinition : notifications) {
if (notificationDefinition.getQName().equals(notifiQName)) {
final DataSchemaNode streamListSchema = ((ContainerSchemaNode) ((ContainerSchemaNode) monitoringModule
@SuppressWarnings("rawtypes")
public static NormalizedNode mapDataChangeNotificationStreamByIetfRestconfMonitoring(
final YangInstanceIdentifier path, final Instant start, final String outputType, final URI uri,
- final Module monitoringModule, final boolean existParent, final SchemaContext schemaContext) {
+ final Module monitoringModule, final boolean existParent, final EffectiveModelContext schemaContext) {
final SchemaNode schemaNode = ParserIdentifier
.toInstanceIdentifier(ParserIdentifier.stringFromYangInstanceIdentifier(path, schemaContext),
schemaContext, Optional.empty())
import org.opendaylight.yangtools.yang.model.api.ActionDefinition;
import org.opendaylight.yangtools.yang.model.api.ActionNodeContainer;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
* - mount point service
* @return {@link InstanceIdentifierContext}
*/
- public static InstanceIdentifierContext<?> toInstanceIdentifier(
- final String identifier,
- final SchemaContext schemaContext,
- final Optional<DOMMountPointService> mountPointService) {
+ public static InstanceIdentifierContext<?> toInstanceIdentifier(final String identifier,
+ final EffectiveModelContext schemaContext, final Optional<DOMMountPointService> mountPointService) {
if (identifier == null || !identifier.contains(RestconfConstants.MOUNT)) {
return createIIdContext(schemaContext, identifier, null);
}
.orElseThrow(() -> new RestconfDocumentedException("Mount point does not exist.",
ErrorType.PROTOCOL, ErrorTag.DATA_MISSING));
- final SchemaContext mountSchemaContext = mountPoint.getSchemaContext();
+ final EffectiveModelContext mountSchemaContext = mountPoint.getEffectiveModelContext();
final String pathId = pathsIt.next().replaceFirst("/", "");
return createIIdContext(mountSchemaContext, pathId, mountPoint);
}
* @return {@link InstanceIdentifierContext}
* @throws RestconfDocumentedException if the path cannot be resolved
*/
- private static InstanceIdentifierContext<?> createIIdContext(final SchemaContext schemaContext, final String url,
- final @Nullable DOMMountPoint mountPoint) {
+ private static InstanceIdentifierContext<?> createIIdContext(final EffectiveModelContext schemaContext,
+ final String url, final @Nullable DOMMountPoint mountPoint) {
final YangInstanceIdentifier urlPath = IdentifierCodec.deserialize(url, schemaContext);
return new InstanceIdentifierContext<>(urlPath, getPathSchema(schemaContext, urlPath), mountPoint,
schemaContext);
* {@link SchemaExportContext}.
*
* @param schemaContext
- * {@link SchemaContext}
+ * {@link EffectiveModelContext}
* @param identifier
* path parameter
* @param domMountPointService
* {@link DOMMountPointService}
* @return {@link SchemaExportContext}
*/
- public static SchemaExportContext toSchemaExportContextFromIdentifier(final SchemaContext schemaContext,
+ public static SchemaExportContext toSchemaExportContextFromIdentifier(final EffectiveModelContext schemaContext,
final String identifier, final DOMMountPointService domMountPointService,
final DOMYangTextSourceProvider sourceProvider) {
final Iterable<String> pathComponents = RestconfConstants.SLASH_SPLITTER.split(identifier);
private static <T extends DataNodeContainer & SchemaNode & ActionNodeContainer> QName getQNameOfDataSchemaNode(
final T parent, final String nodeName) {
- final Optional<ActionDefinition> actionDef = findActionDefinition(parent, nodeName);
+ final Optional<? extends ActionDefinition> actionDef = findActionDefinition(parent, nodeName);
final SchemaNode node;
if (actionDef.isPresent()) {
node = actionDef.get();
return node.getQName();
}
- private static Optional<ActionDefinition> findActionDefinition(final SchemaNode dataSchemaNode,
+ private static Optional<? extends ActionDefinition> findActionDefinition(final SchemaNode dataSchemaNode,
final String nodeName) {
requireNonNull(dataSchemaNode, "DataSchema Node must not be null.");
if (dataSchemaNode instanceof ActionNodeContainer) {
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
import org.slf4j.Logger;
}
@SuppressWarnings("checkstyle:IllegalCatch")
- public static SchemaContext loadSchemaContext(final String yangPath, final SchemaContext schemaContext) {
+ public static EffectiveModelContext loadSchemaContext(final String yangPath,
+ final EffectiveModelContext schemaContext) {
try {
Preconditions.checkArgument(yangPath != null, "Path can not be null.");
Preconditions.checkArgument(!yangPath.isEmpty(), "Path can not be empty.");
@SuppressWarnings("checkstyle:IllegalCatch")
public static NormalizedNodeContext loadNormalizedContextFromXmlFile(final String pathToInputFile,
- final String uri, final SchemaContext schemaContext) {
+ final String uri, final EffectiveModelContext schemaContext) {
final InstanceIdentifierContext<?> iiContext =
ParserIdentifier.toInstanceIdentifier(uri, schemaContext, Optional.empty());
final InputStream inputStream = TestRestconfUtils.class.getResourceAsStream(pathToInputFile);
final String schemaNodeName = iiContext.getSchemaNode().getQName().getLocalName();
if (!schemaNodeName.equalsIgnoreCase(docRootElm)) {
- final Collection<DataSchemaNode> children = ((DataNodeContainer) schemaNode).getChildNodes();
- for (final DataSchemaNode child : children) {
+ for (final DataSchemaNode child : ((DataNodeContainer) schemaNode).getChildNodes()) {
if (child.getQName().getLocalName().equalsIgnoreCase(docRootElm)) {
schemaNode = child;
break;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapEntryNodeBuilder;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
}
- public static SchemaContext loadSchemaContext(final String... yangPath)
+ public static EffectiveModelContext loadSchemaContext(final String... yangPath)
throws FileNotFoundException {
final List<File> files = new ArrayList<>();
for (final String path : yangPath) {
return mapEntryNode.build();
}
- public static SchemaContextHandler newSchemaContextHandler(final SchemaContext schemaContext) {
+ public static SchemaContextHandler newSchemaContextHandler(final EffectiveModelContext schemaContext) {
DOMDataBroker mockDataBroker = mock(DOMDataBroker.class);
DOMTransactionChain mockChain = mock(DOMTransactionChain.class);
DOMDataTreeWriteTransaction mockTx = mock(DOMDataTreeWriteTransaction.class);
doReturn(mockChain).when(mockDataBroker).createTransactionChain(any());
SchemaContextHandler schemaContextHandler = SchemaContextHandler.newInstance(
new TransactionChainHandler(mockDataBroker), Mockito.mock(DOMSchemaService.class));
- schemaContextHandler.onGlobalContextUpdated(schemaContext);
+ schemaContextHandler.onModelContextUpdated(schemaContext);
return schemaContextHandler;
}
}
import org.opendaylight.mdsal.dom.api.DOMTransactionChain;
import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
private static final String PATH_FOR_NEW_SCHEMA_CONTEXT = "/modules/modules-behind-mount-point";
private SchemaContextHandler schemaContextHandler;
- private SchemaContext schemaContext;
+ private EffectiveModelContext schemaContext;
private final DOMSchemaService mockDOMSchemaService = Mockito.mock(DOMSchemaService.class);
@Before
this.schemaContext =
YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles(PATH_FOR_ACTUAL_SCHEMA_CONTEXT));
- this.schemaContextHandler.onGlobalContextUpdated(this.schemaContext);
+ this.schemaContextHandler.onModelContextUpdated(this.schemaContext);
}
/**
@Test
public void onGlobalContextUpdateTest() throws Exception {
// create new SchemaContext and update SchemaContextHandler
- final SchemaContext newSchemaContext =
+ final EffectiveModelContext newSchemaContext =
YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles(PATH_FOR_NEW_SCHEMA_CONTEXT));
- this.schemaContextHandler.onGlobalContextUpdated(newSchemaContext);
+ this.schemaContextHandler.onModelContextUpdated(newSchemaContext);
assertNotEquals("SchemaContextHandler should not has reference to old SchemaContext",
this.schemaContext, this.schemaContextHandler.get());
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes;
import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
public class XmlBodyReaderMountPointTest extends AbstractBodyReaderTest {
private final XmlNormalizedNodeBodyReader xmlBodyReader;
- private static SchemaContext schemaContext;
+ private static EffectiveModelContext schemaContext;
private static final QNameModule INSTANCE_IDENTIFIER_MODULE_QNAME = QNameModule.create(
URI.create("instance:identifier:module"), Revision.of("2014-01-17"));
import org.opendaylight.restconf.common.patch.PatchContext;
import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.AbstractBodyReaderTest;
import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.JsonBodyReaderTest;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
public class JsonPatchBodyReaderMountPointTest extends AbstractBodyReaderTest {
private static final String MOUNT_POINT = "instance-identifier-module:cont/yang-ext:mount/";
- private static SchemaContext schemaContext;
+ private static EffectiveModelContext schemaContext;
private final JsonToPatchBodyReader jsonToPatchBodyReader;
public JsonPatchBodyReaderMountPointTest() throws Exception {
import org.opendaylight.restconf.common.patch.PatchContext;
import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.AbstractBodyReaderTest;
import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.JsonBodyReaderTest;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
public class JsonPatchBodyReaderTest extends AbstractBodyReaderTest {
private final JsonToPatchBodyReader jsonToPatchBodyReader;
- private static SchemaContext schemaContext;
+ private static EffectiveModelContext schemaContext;
public JsonPatchBodyReaderTest() throws Exception {
super(schemaContext);
import org.opendaylight.restconf.common.patch.PatchContext;
import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.AbstractBodyReaderTest;
import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.XmlBodyReaderTest;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
public class XmlPatchBodyReaderMountPointTest extends AbstractBodyReaderTest {
private final XmlToPatchBodyReader xmlToPatchBodyReader;
- private static SchemaContext schemaContext;
+ private static EffectiveModelContext schemaContext;
private static final String MOUNT_POINT = "instance-identifier-module:cont/yang-ext:mount/";
public XmlPatchBodyReaderMountPointTest() throws Exception {
import org.opendaylight.restconf.common.patch.PatchContext;
import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.AbstractBodyReaderTest;
import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.XmlBodyReaderTest;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
public class XmlPatchBodyReaderTest extends AbstractBodyReaderTest {
private final XmlToPatchBodyReader xmlToPatchBodyReader;
- private static SchemaContext schemaContext;
+ private static EffectiveModelContext schemaContext;
public XmlPatchBodyReaderTest() throws Exception {
super(schemaContext);
import static org.junit.Assert.assertNotNull;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doCallRealMethod;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import org.opendaylight.restconf.nb.rfc8040.jersey.providers.spi.AbstractIdentifierAwareJaxRsProvider;
import org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
public abstract class AbstractBodyReaderTest {
protected final SchemaContextHandler schemaContextHandler;
protected final DOMMountPointServiceHandler mountPointServiceHandler;
- protected AbstractBodyReaderTest(final SchemaContext schemaContext) throws NoSuchFieldException,
+ protected AbstractBodyReaderTest(final EffectiveModelContext schemaContext) throws NoSuchFieldException,
IllegalAccessException {
mediaType = getMediaType();
final DOMMountPointService mountPointService = mock(DOMMountPointService.class);
final DOMMountPoint mountPoint = mock(DOMMountPoint.class);
doReturn(Optional.of(mountPoint)).when(mountPointService).getMountPoint(any(YangInstanceIdentifier.class));
- doReturn(schemaContext).when(mountPoint).getSchemaContext();
+ doReturn(schemaContext).when(mountPoint).getEffectiveModelContext();
+ doCallRealMethod().when(mountPoint).getSchemaContext();
mountPointServiceHandler = DOMMountPointServiceHandler.newInstance(mountPointService);
}
protected abstract MediaType getMediaType();
- protected static SchemaContext schemaContextLoader(final String yangPath,
- final SchemaContext schemaContext) {
+ protected static EffectiveModelContext schemaContextLoader(final String yangPath,
+ final EffectiveModelContext schemaContext) {
return TestRestconfUtils.loadSchemaContext(yangPath, schemaContext);
}
import org.opendaylight.yangtools.yang.model.api.ActionDefinition;
import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
public class JsonBodyReaderTest extends AbstractBodyReaderTest {
private final JsonNormalizedNodeBodyReader jsonBodyReader;
- private static SchemaContext schemaContext;
+ private static EffectiveModelContext schemaContext;
private static final QNameModule INSTANCE_IDENTIFIER_MODULE_QNAME = QNameModule.create(
URI.create("instance:identifier:module"), Revision.of("2014-01-17"));
import org.opendaylight.yangtools.yang.model.api.ActionDefinition;
import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
public class XmlBodyReaderTest extends AbstractBodyReaderTest {
private final XmlNormalizedNodeBodyReader xmlBodyReader;
- private static SchemaContext schemaContext;
+ private static EffectiveModelContext schemaContext;
private static final QNameModule INSTANCE_IDENTIFIER_MODULE_QNAME = QNameModule.create(
URI.create("instance:identifier:module"), Revision.of("2014-01-17"));
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.ArgumentMatchers.notNull;
+import static org.mockito.Mockito.doCallRealMethod;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
static final QName TEST_OUTPUT_QNAME = QName.create(TOASTER_MODULE_NS, TOASTER_MODULE_VERSION, "testOutput");
static final QName TEXT_OUT_QNAME = QName.create(TOASTER_MODULE_NS, TOASTER_MODULE_VERSION, "textOut");
- private static SchemaContext schemaContext;
+ private static EffectiveModelContext schemaContext;
@Mock
private DOMTransactionChain mockTxChain;
DOMMountPoint setupTestMountPoint() throws FileNotFoundException, ReactorException {
final SchemaContext schemaContextTestModule = TestUtils.loadSchemaContext("/full-versions/test-module");
final DOMMountPoint mockMountPoint = mock(DOMMountPoint.class);
- doReturn(schemaContextTestModule).when(mockMountPoint).getSchemaContext();
+ doReturn(schemaContextTestModule).when(mockMountPoint).getEffectiveModelContext();
+ doCallRealMethod().when(mockMountPoint).getSchemaContext();
doReturn(Optional.of(mockDOMDataBroker)).when(mockMountPoint).getService(DOMDataBroker.class);
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doCallRealMethod;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.opendaylight.restconf.common.patch.PatchEditOperation.CREATE;
final SchemaContextHandler schemaContextHandler = SchemaContextHandler.newInstance(transactionChainHandler,
Mockito.mock(DOMSchemaService.class));
- schemaContextHandler.onGlobalContextUpdated(this.contextRef.get());
+ schemaContextHandler.onModelContextUpdated(this.contextRef.get());
this.dataService = new RestconfDataServiceImpl(schemaContextHandler, this.transactionChainHandler,
DOMMountPointServiceHandler.newInstance(mountPointService), this.delegRestconfSubscrService,
this.actionServiceHandler);
doReturn(Optional.of(this.mountPoint)).when(this.mountPointService)
.getMountPoint(any(YangInstanceIdentifier.class));
- doReturn(this.contextRef.get()).when(this.mountPoint).getSchemaContext();
+ doCallRealMethod().when(this.mountPoint).getSchemaContext();
+ doReturn(this.contextRef.get()).when(this.mountPoint).getEffectiveModelContext();
doReturn(Optional.of(this.mountDataBroker)).when(this.mountPoint).getService(DOMDataBroker.class);
doReturn(this.mountTransactionChain).when(this.mountDataBroker)
.createTransactionChain(any(DOMTransactionChainListener.class));
doReturn(CommitInfo.emptyFluentFuture()).when(wTx).commit();
final SchemaContextHandler schemaContextHandler = SchemaContextHandler.newInstance(txHandler,
mock(DOMSchemaService.class));
- schemaContextHandler.onGlobalContextUpdated(contextRef.get());
+ schemaContextHandler.onModelContextUpdated(contextRef.get());
this.invokeOperationsService =
new RestconfInvokeOperationsServiceImpl(this.rpcServiceHandler, schemaContextHandler);
when(this.rpcServiceHandler.get()).thenReturn(this.rpcService);
doReturn(schemaNode).when(context).getSchemaNode();
final NormalizedNode<?, ?> data = mock(NormalizedNode.class);
final DOMRpcResult domRpcResult = mock(DOMRpcResult.class);
- when(this.rpcService.invokeRpc(schemaPath, data)).thenReturn(immediateFluentFuture(domRpcResult));
+ doReturn(immediateFluentFuture(domRpcResult)).when(this.rpcService).invokeRpc(schemaPath, data);
doReturn(result).when(domRpcResult).getResult();
return new NormalizedNodeContext(context, data);
}
when(uriInfo.getBaseUriBuilder()).thenReturn(baseUriBuilder);
final URI uri = new URI("http://127.0.0.1/" + URI);
when(uriInfo.getAbsolutePath()).thenReturn(uri);
- this.schemaHandler.onGlobalContextUpdated(
+ this.schemaHandler.onModelContextUpdated(
YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/notifications")));
}
import static org.junit.Assert.assertTrue;
import java.util.Collections;
-import java.util.Set;
import org.junit.Before;
import org.junit.Test;
import org.mockito.MockitoAnnotations;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.util.SchemaNodeUtils;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
private NormalizedNodeContext prepareDomPayload(final String rpcName, final String inputOutput,
final String toasterValue, final String inputOutputName) {
- final SchemaContext schema = this.refSchemaCtx.get();
+ final EffectiveModelContext schema = this.refSchemaCtx.get();
final Module rpcModule = schema.findModules("sal-remote").iterator().next();
final QName rpcQName = QName.create(rpcModule.getQNameModule(), rpcName);
final QName rpcInputQName = QName.create(rpcModule.getQNameModule(), inputOutput);
- final Set<RpcDefinition> setRpcs = rpcModule.getRpcs();
ContainerSchemaNode rpcInputSchemaNode = null;
- for (final RpcDefinition rpc : setRpcs) {
+ for (final RpcDefinition rpc : rpcModule.getRpcs()) {
if (rpcQName.isEqualWithoutRevision(rpc.getQName())) {
rpcInputSchemaNode = SchemaNodeUtils.getRpcDataSchema(rpc, rpcInputQName);
break;
import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
import org.opendaylight.yangtools.yang.data.util.DataSchemaContextTree;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
public class PlainPatchDataTransactionUtilTest {
private LeafNode leafGap;
private ContainerNode jukeboxContainerWithPlayer;
private ContainerNode jukeboxContainerWithPlaylist;
- private SchemaContext schema;
+ private EffectiveModelContext schema;
private DataSchemaNode schemaNodeForGap;
private YangInstanceIdentifier iidGap;
private DataSchemaNode schemaNodeForJukebox;
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.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
import org.w3c.dom.DOMException;
private TransactionChainHandler transactionChainHandler;
private SchemaContextRef refSchemaCtx;
private ContainerNode buildBaseCont;
- private SchemaContext schema;
+ private EffectiveModelContext schema;
private YangInstanceIdentifier iid2;
private MapNode buildList;
import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
import org.opendaylight.yangtools.yang.data.util.DataSchemaContextTree;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
public class PutDataTransactionUtilTest {
private ContainerNode buildBaseCont;
private ContainerNode buildBaseContWithList;
private MapEntryNode buildListEntry;
- private SchemaContext schema;
+ private EffectiveModelContext schema;
private DataSchemaNode schemaNode;
private YangInstanceIdentifier iid;
private DataSchemaNode schemaNode2;
import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode;
import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
public class ReadDataTransactionUtilTest {
@Mock
private DOMDataTreeReadTransaction read;
@Mock
- private SchemaContext schemaContext;
+ private EffectiveModelContext schemaContext;
@Mock
private ContainerSchemaNode containerSchemaNode;
@Mock
import org.opendaylight.restconf.nb.rfc8040.TestUtils;
import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
public class RestconfImplTest {
-
@Test
public void restImplTest() throws Exception {
- final SchemaContext schemaContext =
- YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/restconf/impl"));
- final SchemaContextHandler schemaContextHandler = TestUtils.newSchemaContextHandler(schemaContext);
+ final SchemaContextHandler schemaContextHandler = TestUtils.newSchemaContextHandler(
+ YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/restconf/impl")));
final RestconfImpl restconfImpl = new RestconfImpl(schemaContextHandler);
final NormalizedNodeContext libraryVersion = restconfImpl.getLibraryVersion();
final LeafNode<?> value = (LeafNode<?>) libraryVersion.getData();
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
public class RestconfOperationsServiceTest {
@Mock
private UriInfo uriInfo;
- private SchemaContext schemaContext;
+ private EffectiveModelContext schemaContext;
private SchemaContextHandler schemaContextHandler;
private DOMMountPointServiceHandler domMountPointServiceHandler;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.Revision;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
/**
private DOMYangTextSourceProvider sourceProvider;
// schema context with modules
- private SchemaContext schemaContext;
+ private EffectiveModelContext schemaContext;
// schema context with modules behind mount point
- private SchemaContext schemaContextBehindMountPoint;
+ private EffectiveModelContext schemaContextBehindMountPoint;
// schema context with mount points
- private SchemaContext schemaContextWithMountPoints;
+ private EffectiveModelContext schemaContextWithMountPoints;
// mount point service
private DOMMountPointService mountPointService;
when(this.mockContextHandler.get()).thenReturn(this.schemaContextWithMountPoints);
// make test - call service on mount point with null schema context
- this.thrown.expect(NullPointerException.class);
+ this.thrown.expect(IllegalStateException.class);
// NULL_MOUNT_POINT contains null schema context
this.schemaService.getSchema(NULL_MOUNT_POINT + TEST_MODULE_BEHIND_MOUNT_POINT);
}
import org.opendaylight.yang.gen.v1.urn.sal.restconf.event.subscription.rev140708.NotificationOutputTypeGrouping;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
import org.skyscreamer.jsonassert.JSONAssert;
import org.slf4j.Logger;
private static final YangInstanceIdentifier PATCH_CONT_YIID =
YangInstanceIdentifier.create(new YangInstanceIdentifier.NodeIdentifier(PatchCont.QNAME));
- private static SchemaContext SCHEMA_CONTEXT;
+ private static EffectiveModelContext SCHEMA_CONTEXT;
private DataBroker dataBroker;
private DOMDataBroker domDataBroker;
transactionChainHandler = new TransactionChainHandler(domDataBroker);
schemaContextHandler = SchemaContextHandler.newInstance(transactionChainHandler,
Mockito.mock(DOMSchemaService.class));
- schemaContextHandler.onGlobalContextUpdated(SCHEMA_CONTEXT);
+ schemaContextHandler.onModelContextUpdated(SCHEMA_CONTEXT);
}
class ListenerAdapterTester extends ListenerAdapter {
MyList1Builder builder = new MyList1Builder().setMyLeaf11("Jed").setName("Althea");
InstanceIdentifier<MyList1> iid = InstanceIdentifier.create(PatchCont.class)
.child(MyList1.class, new MyList1Key("Althea"));
- writeTransaction.put(LogicalDatastoreType.CONFIGURATION, iid, builder.build(), true);
+ writeTransaction.mergeParentStructurePut(LogicalDatastoreType.CONFIGURATION, iid, builder.build());
writeTransaction.commit();
adapter.assertGot(getNotifJson(JSON_NOTIF_LEAVES_CREATE));
writeTransaction = dataBroker.newWriteOnlyTransaction();
builder = new MyList1Builder().withKey(new MyList1Key("Althea")).setMyLeaf12("Bertha");
- writeTransaction.merge(LogicalDatastoreType.CONFIGURATION, iid, builder.build(), true);
+ writeTransaction.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, iid, builder.build());
writeTransaction.commit();
adapter.assertGot(getNotifJson(JSON_NOTIF_LEAVES_UPDATE));
MyList1Builder builder = new MyList1Builder().setMyLeaf11("Jed").setName("Althea");
InstanceIdentifier<MyList1> iid = InstanceIdentifier.create(PatchCont.class)
.child(MyList1.class, new MyList1Key("Althea"));
- writeTransaction.put(LogicalDatastoreType.CONFIGURATION, iid, builder.build(), true);
+ writeTransaction.mergeParentStructurePut(LogicalDatastoreType.CONFIGURATION, iid, builder.build());
writeTransaction.commit();
adapter.assertGot(getNotifJson(JSON_NOTIF_CREATE));
writeTransaction = dataBroker.newWriteOnlyTransaction();
builder = new MyList1Builder().withKey(new MyList1Key("Althea")).setMyLeaf12("Bertha");
- writeTransaction.merge(LogicalDatastoreType.CONFIGURATION, iid, builder.build(), true);
+ writeTransaction.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, iid, builder.build());
writeTransaction.commit();
adapter.assertGot(getNotifJson(JSON_NOTIF_UPDATE));
import java.net.URISyntaxException;
import javax.inject.Inject;
import javax.inject.Singleton;
+import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.opendaylight.aaa.filterchain.configuration.CustomFilterAdapterConfiguration;
import org.opendaylight.restconf.nb.rfc8040.streams.websockets.WebSocketConfiguration;
import org.opendaylight.restconf.nb.rfc8040.test.incubate.InMemoryMdsalModule;
import org.opendaylight.restconf.nb.rfc8040.web.WebInitializer;
-import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextProvider;
/**
* Tests if the {@link Rfc8040RestConfWiring} works.
*
* @author Michael Vorburger.ch
*/
+@Ignore
public class Rfc8040RestConfWiringTest {
public static class TestModule extends AbstractModule {
@Inject WebServer webServer;
@Inject TestWebClient webClient;
- @Inject SchemaContextProvider schemaContextProvider;
+ @Inject EffectiveModelContextProvider schemaContextProvider;
@Inject SchemaContextHandler schemaContextHandler;
@Test
public void testWiring() throws IOException, InterruptedException, URISyntaxException {
- schemaContextHandler.onGlobalContextUpdated(schemaContextProvider.getSchemaContext());
+ schemaContextHandler.onModelContextUpdated(schemaContextProvider.getEffectiveModelContext());
assertEquals(200, webClient.request("GET", "/rests/yang-library-version").statusCode());
}
}
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
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.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Mock private LeafSchemaNode leafReplayLog;
@Mock private LeafSchemaNode leafEvents;
- private static Set<Module> modules;
- private static SchemaContext schemaContext;
- private static SchemaContext schemaContextMonitoring;
+ private static Collection<? extends Module> modules;
+ private static EffectiveModelContext schemaContext;
+ private static EffectiveModelContext schemaContextMonitoring;
- private static Set<Module> modulesRest;
+ private static Collection<? extends Module> modulesRest;
@BeforeClass
public static void loadTestSchemaContextAndModules() throws Exception {
* @param expectedModules Modules from <code>SchemaContext</code>
* @param loadedModules Loaded modules into Restconf module
*/
- private static void verifyLoadedModules(final Set<Module> expectedModules,
+ private static void verifyLoadedModules(final Collection<? extends Module> expectedModules,
final Map<String, String> loadedModules) {
assertEquals("Number of loaded modules is not as expected", expectedModules.size(), loadedModules.size());
for (final Module m : expectedModules) {
import org.opendaylight.yangtools.yang.common.QNameModule;
import org.opendaylight.yangtools.yang.common.Revision;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
/**
@Before
public void setUp() throws Exception {
- final SchemaContext schemaContextJukebox =
+ final EffectiveModelContext schemaContextJukebox =
YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/jukebox"));
initJukeboxSchemaNodes(schemaContextJukebox);
- final SchemaContext schemaContextTestServices =
+ final EffectiveModelContext schemaContextTestServices =
YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/test-services"));
initTestServicesSchemaNodes(schemaContextTestServices);
}
- private void initJukeboxSchemaNodes(final SchemaContext schemaContext) {
+ private void initJukeboxSchemaNodes(final EffectiveModelContext schemaContext) {
Mockito.when(identifierJukebox.getSchemaContext()).thenReturn(schemaContext);
Mockito.when(containerJukebox.getQName()).thenReturn(JUKEBOX_Q_NAME);
Mockito.when(identifierJukebox.getSchemaNode()).thenReturn(containerJukebox);
Mockito.when(listAlbum.getDataChildByName(NAME_Q_NAME)).thenReturn(leafName);
}
- private void initTestServicesSchemaNodes(final SchemaContext schemaContext) {
+ private void initTestServicesSchemaNodes(final EffectiveModelContext schemaContext) {
Mockito.when(identifierTestServices.getSchemaContext()).thenReturn(schemaContext);
Mockito.when(containerTestData.getQName()).thenReturn(TEST_DATA_Q_NAME);
Mockito.when(identifierTestServices.getSchemaNode()).thenReturn(containerTestData);
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.Revision;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
/**
"parser-identifier:cont2/listTest/list-in-grouping=name/leaf-A.B";
// schema context with test modules
- private SchemaContext schemaContext;
+ private EffectiveModelContext schemaContext;
// contains the same modules but it is different object (it can be compared with equals)
- private SchemaContext schemaContextOnMountPoint;
+ private EffectiveModelContext schemaContextOnMountPoint;
private static final String TEST_MODULE_NAME = "test-module";
private static final String TEST_MODULE_REVISION = "2016-06-02";
.getInstance();
// register mount point with null schema context
- when(this.mockMountPoint.getSchemaContext()).thenReturn(null);
+ when(this.mockMountPoint.getEffectiveModelContext()).thenReturn(null);
when(this.mockMountPointService.getMountPoint(YangInstanceIdentifier.empty()))
.thenReturn(Optional.of(this.mockMountPoint));
}
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
-
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
-
import org.opendaylight.netconf.sal.rest.doc.api.ApiDocService;
import org.opendaylight.netconf.sal.rest.doc.mountpoints.MountPointSwagger;
import org.opendaylight.netconf.sal.rest.doc.swagger.ApiDeclaration;
* Return list of modules converted to swagger compliant resource list.
*/
public ResourceList getResourceListing(final UriInfo uriInfo, final SchemaContext schemaContext,
- final String context, final int pageNum, boolean all, final URIType uriType) {
+ final String context, final int pageNum, final boolean all, final URIType uriType) {
final ResourceList resourceList = createResourceList();
final List<Api> apis = new ArrayList<>();
boolean hasAddRootPostLink = false;
- final Collection<DataSchemaNode> dataSchemaNodes = module.getChildNodes();
+ final Collection<? extends DataSchemaNode> dataSchemaNodes = module.getChildNodes();
LOG.debug("child nodes size [{}]", dataSchemaNodes.size());
for (final DataSchemaNode node : dataSchemaNodes) {
if (node instanceof ListSchemaNode || node instanceof ContainerSchemaNode) {
}
}
- final Set<RpcDefinition> rpcs = module.getRpcs();
- for (final RpcDefinition rpcDefinition : rpcs) {
+ for (final RpcDefinition rpcDefinition : module.getRpcs()) {
final String resourcePath;
resourcePath = getDataStorePath("operations", context);
addOperations(rpcDefinition, apis, resourcePath, schemaContext);
LOG.debug("Adding path: [{}]", resourcePath);
api.setPath(resourcePath.concat(getContent(dataStore)));
- Iterable<DataSchemaNode> childSchemaNodes = Collections.emptySet();
+ Iterable<? extends DataSchemaNode> childSchemaNodes = Collections.emptySet();
if (node instanceof ListSchemaNode || node instanceof ContainerSchemaNode) {
final DataNodeContainer dataNodeContainer = (DataNodeContainer) node;
childSchemaNodes = dataNodeContainer.getChildNodes();
apis.add(api);
if (uriType.equals(URIType.RFC8040)) {
- ((ActionNodeContainer) node).getActions().forEach((actionDef -> {
+ ((ActionNodeContainer) node).getActions().forEach(actionDef -> {
addOperations(actionDef, apis, resourcePath, schemaContext);
- }));
+ });
}
for (final DataSchemaNode childNode : childSchemaNodes) {
public abstract String getContent(String dataStore);
- private static boolean containsListOrContainer(final Iterable<DataSchemaNode> nodes) {
+ private static boolean containsListOrContainer(final Iterable<? extends DataSchemaNode> nodes) {
for (final DataSchemaNode child : nodes) {
if (child instanceof ListSchemaNode || child instanceof ContainerSchemaNode) {
return true;
}
private static List<Operation> operation(final DataSchemaNode node, final List<Parameter> pathParams,
- final boolean isConfig, final Iterable<DataSchemaNode> childSchemaNodes, final String parentName) {
+ final boolean isConfig, final Iterable<? extends DataSchemaNode> childSchemaNodes,
+ final String parentName) {
final List<Operation> operations = new ArrayList<>();
final Get getBuilder = new Get(node, isConfig);
return new TreeSet<>();
}
- final Set<Module> modules = schemaContext.getModules();
-
final SortedSet<Module> sortedModules = new TreeSet<>((module1, module2) -> {
int result = module1.getName().compareTo(module2.getName());
if (result == 0) {
}
return result;
});
- for (final Module m : modules) {
+ for (final Module m : schemaContext.getModules()) {
if (m != null) {
sortedModules.add(m);
}
import com.google.common.collect.RangeSet;
import com.mifmif.common.regex.Generex;
import java.io.IOException;
+import java.util.Collection;
import java.util.List;
import java.util.Optional;
-import java.util.Set;
import java.util.regex.Pattern;
import org.opendaylight.netconf.sal.rest.doc.model.builder.OperationBuilder;
import org.opendaylight.netconf.sal.rest.doc.model.builder.OperationBuilder.Post;
processModules(module, models, schemaContext);
processContainersAndLists(module, models, schemaContext);
processRPCs(module, models, schemaContext);
- processIdentities(module, models);
+ processIdentities(schemaContext, module, models);
return models;
}
* @param module The module from which the identity stmt will be processed
* @param models The ObjectNode in which the parsed identity will be put as a 'model' obj
*/
- private static void processIdentities(final Module module, final ObjectNode models) {
+ private static void processIdentities(final SchemaContext schemaContext, final Module module,
+ final ObjectNode models) {
final String moduleName = module.getName();
- final Set<IdentitySchemaNode> idNodes = module.getIdentities();
+ final Collection<? extends IdentitySchemaNode> idNodes = module.getIdentities();
LOG.debug("Processing Identities for module {} . Found {} identity statements", moduleName, idNodes.size());
for (final IdentitySchemaNode idNode : idNodes) {
* This is a base identity. So lets see if it has sub types. If it does, then add them to the model
* definition.
*/
- final Set<IdentitySchemaNode> derivedIds = idNode.getDerivedIdentities();
-
- if (derivedIds != null) {
+ final Collection<? extends IdentitySchemaNode> derivedIds = schemaContext.getDerivedIdentities(idNode);
+ if (!derivedIds.isEmpty()) {
final ArrayNode subTypes = new ArrayNode(JsonNodeFactory.instance);
for (final IdentitySchemaNode derivedId : derivedIds) {
subTypes.add(derivedId.getQName().getLocalName());
}
identityObj.set(SUB_TYPES_KEY, subTypes);
-
}
} else {
/*
final DataNodeContainer dataNode, final String parentName, final ObjectNode models, final boolean isConfig,
final SchemaContext schemaContext) throws IOException {
if (dataNode instanceof ListSchemaNode || dataNode instanceof ContainerSchemaNode) {
- final Iterable<DataSchemaNode> containerChildren = dataNode.getChildNodes();
final String localName = ((SchemaNode) dataNode).getQName().getLocalName();
- final ObjectNode properties =
- processChildren(containerChildren, parentName + "/" + localName, models, isConfig, schemaContext);
+ final ObjectNode properties = processChildren(dataNode.getChildNodes(), parentName + "/" + localName,
+ models, isConfig, schemaContext);
final String nodeName = parentName + (isConfig ? OperationBuilder.CONFIG : OperationBuilder.OPERATIONAL)
+ localName;
* Processes the nodes.
*/
private ObjectNode processChildren(
- final Iterable<DataSchemaNode> nodes, final String parentName, final ObjectNode models,
+ final Iterable<? extends DataSchemaNode> nodes, final String parentName, final ObjectNode models,
final boolean isConfig, final SchemaContext schemaContext) throws IOException {
final ObjectNode properties = JsonNodeFactory.instance.objectNode();
for (final DataSchemaNode node : nodes) {
property = processLeafListNode((LeafListSchemaNode) node, schemaContext);
} else if (node instanceof ChoiceSchemaNode) {
- if (((ChoiceSchemaNode) node).getCases().values().iterator().hasNext()) {
- processChoiceNode(((ChoiceSchemaNode) node).getCases().values().iterator().next()
+ if (((ChoiceSchemaNode) node).getCases().iterator().hasNext()) {
+ processChoiceNode(((ChoiceSchemaNode) node).getCases().iterator().next()
.getChildNodes(), parentName, models, schemaContext, isConfig, properties);
}
continue;
}
private void processChoiceNode(
- final Iterable<DataSchemaNode> nodes, final String moduleName, final ObjectNode models,
+ final Iterable<? extends DataSchemaNode> nodes, final String moduleName, final ObjectNode models,
final SchemaContext schemaContext, final boolean isConfig, final ObjectNode properties)
throws IOException {
for (final DataSchemaNode node : nodes) {
property = processLeafListNode((LeafListSchemaNode) node, schemaContext);
} else if (node instanceof ChoiceSchemaNode) {
- if (((ChoiceSchemaNode) node).getCases().values().iterator().hasNext()) {
- processChoiceNode(((ChoiceSchemaNode) node).getCases().values().iterator().next().getChildNodes(),
+ if (((ChoiceSchemaNode) node).getCases().iterator().hasNext()) {
+ processChoiceNode(((ChoiceSchemaNode) node).getCases().iterator().next().getChildNodes(),
moduleName, models, schemaContext, isConfig, properties);
}
continue;
property.put(MIN_ITEMS, 0);
property.put(UNIQUE_ITEMS_KEY, true);
ArrayNode enumNames = new ArrayNode(JsonNodeFactory.instance);
- final List<Bit> bits = bitsType.getBits();
- for (final Bit bit : bits) {
+ for (final Bit bit : bitsType.getBits()) {
enumNames.add(new TextNode(bit.getName()));
}
property.set(ENUM, enumNames);
import org.opendaylight.netconf.sal.rest.doc.swagger.Parameter;
import org.opendaylight.netconf.sal.rest.doc.swagger.Resource;
import org.opendaylight.netconf.sal.rest.doc.swagger.ResourceList;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
public class ApiDocGeneratorTest {
private static final Date REVISION_2 = Date.valueOf(STRING_DATE);
private ApiDocGeneratorDraftO2 generator;
private DocGenTestHelper helper;
- private SchemaContext schemaContext;
+ private EffectiveModelContext schemaContext;
@Before
public void setUp() throws Exception {
import org.opendaylight.netconf.sal.rest.doc.impl.MountPointSwaggerGeneratorRFC8040;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
public class ApiDocServiceImplTest {
private static final String HTTP_URL = "http://localhost/path";
this.helper = new DocGenTestHelper();
this.helper.setUp();
- final SchemaContext context = this.helper.createMockSchemaContext();
+ final EffectiveModelContext context = this.helper.createMockSchemaContext();
final DOMSchemaService schemaService = this.helper.createMockSchemaService(context);
final DOMMountPoint mountPoint = mock(DOMMountPoint.class);
package org.opendaylight.controller.sal.rest.doc.impl;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
import java.util.Optional;
-import java.util.Set;
import javax.ws.rs.core.UriBuilder;
import javax.ws.rs.core.UriInfo;
import org.mockito.ArgumentCaptor;
import org.opendaylight.mdsal.dom.api.DOMSchemaService;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
public class DocGenTestHelper {
- private Set<Module> modules;
+ private Collection<? extends Module> modules;
private ObjectMapper mapper;
- private SchemaContext schemaContext;
+ private EffectiveModelContext schemaContext;
- public Set<Module> loadModules(final String resourceDirectory) throws URISyntaxException, FileNotFoundException {
+ public Collection<? extends Module> loadModules(final String resourceDirectory)
+ throws URISyntaxException, FileNotFoundException {
final URI resourceDirUri = getClass().getResource(resourceDirectory).toURI();
final File testDir = new File(resourceDirUri);
return this.schemaContext.getModules();
}
- public Collection<Module> getModules() {
+ public Collection<? extends Module> getModules() {
return this.modules;
}
this.mapper.configure(SerializationFeature.INDENT_OUTPUT, true);
}
- public SchemaContext getSchemaContext() {
+ public EffectiveModelContext getSchemaContext() {
return this.schemaContext;
}
- public DOMSchemaService createMockSchemaService(SchemaContext mockContext) {
+ public DOMSchemaService createMockSchemaService(EffectiveModelContext mockContext) {
if (mockContext == null) {
mockContext = createMockSchemaContext();
}
return mockSchemaService;
}
- public SchemaContext createMockSchemaContext() {
- final SchemaContext mockContext = mock(SchemaContext.class);
- when(mockContext.getModules()).thenReturn(this.modules);
+ public EffectiveModelContext createMockSchemaContext() {
+ final EffectiveModelContext mockContext = mock(EffectiveModelContext.class);
+ doReturn(this.modules).when(mockContext).getModules();
final ArgumentCaptor<String> moduleCapture = ArgumentCaptor.forClass(String.class);
final ArgumentCaptor<Optional> dateCapture = ArgumentCaptor.forClass(Optional.class);
invocation -> {
final String module = moduleCapture.getValue();
final Optional<?> date = dateCapture.getValue();
- for (final Module m : Collections.unmodifiableSet(DocGenTestHelper.this.modules)) {
+ for (final Module m : DocGenTestHelper.this.modules) {
if (m.getName().equals(module) && m.getRevision().equals(date)) {
return Optional.of(m);
}
invocation -> {
final URI namespace = namespaceCapture.getValue();
final Optional<?> date = dateCapture.getValue();
- for (final Module m : Collections.unmodifiableSet(DocGenTestHelper.this.modules)) {
+ for (final Module m : DocGenTestHelper.this.modules) {
if (m.getNamespace().equals(namespace) && m.getRevision().equals(date)) {
return Optional.of(m);
}
import org.opendaylight.netconf.sal.rest.doc.swagger.ResourceList;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
public class MountPointSwaggerTest {
// We are sharing the global schema service and the mount schema service
// in our test.
// OK for testing - real thing would have seperate instances.
- final SchemaContext context = this.helper.createMockSchemaContext();
+ final EffectiveModelContext context = this.helper.createMockSchemaContext();
final DOMSchemaService schemaService = this.helper.createMockSchemaService(context);
final DOMMountPoint mountPoint = mock(DOMMountPoint.class);