import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.MockitoAnnotations.initMocks;
-import static org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType.DELETE;
-import static org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType.SUBTREE_MODIFIED;
-import static org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType.WRITE;
+import static org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType.DELETE;
+import static org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType.SUBTREE_MODIFIED;
+import static org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType.WRITE;
import akka.actor.ActorSystem;
import akka.actor.Props;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
-import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
-import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
-import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.DataObjectModification;
+import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.dom.api.DOMActionService;
+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.api.NetconfDeviceSchemasResolver;
import org.opendaylight.netconf.sal.connect.netconf.NetconfDevice;
import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
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;
*
* @author Thomas Pantelis
*/
-public class NetconfNodeManagerTest {
+public class NetconfNodeManagerTest extends AbstractBaseSchemasTest {
private static final String ACTOR_SYSTEM_NAME = "test";
private static final RemoteDeviceId DEVICE_ID = new RemoteDeviceId("device", new InetSocketAddress(65535));
private static final List<SourceIdentifier> SOURCE_IDENTIFIERS =
@Mock
private DOMRpcService mockRpcService;
+ @Mock
+ private DOMActionService mockActionService;
+
@Mock
private NetconfDeviceSchemasResolver mockSchemasResolver;
@Mock
- private SchemaContextFactory mockSchemaContextFactory;
+ private EffectiveModelContextFactory mockSchemaContextFactory;
private ActorSystem slaveSystem;
private ActorSystem masterSystem;
NetconfTopologySetup masterSetup = new NetconfTopologySetup.NetconfTopologySetupBuilder()
.setActorSystem(masterSystem).setDataBroker(mockDataBroker).setSchemaResourceDTO(
new NetconfDevice.SchemaResourcesDTO(masterSchemaRepository, masterSchemaRepository,
- mockSchemaContextFactory, mockSchemasResolver)).build();
+ mockSchemaContextFactory, mockSchemasResolver)).setBaseSchemas(BASE_SCHEMAS).build();
testMasterActorRef = TestActorRef.create(masterSystem, Props.create(TestMasterActor.class, masterSetup,
DEVICE_ID, responseTimeout, mockMountPointService).withDispatcher(Dispatchers.DefaultDispatcherId()),
NetconfTopologySetup slaveSetup = new NetconfTopologySetup.NetconfTopologySetupBuilder()
.setActorSystem(slaveSystem).setDataBroker(mockDataBroker).setSchemaResourceDTO(
new NetconfDevice.SchemaResourcesDTO(slaveSchemaRepository, slaveSchemaRepository,
- mockSchemaContextFactory, mockSchemasResolver)).build();
+ mockSchemaContextFactory, mockSchemasResolver)).setBaseSchemas(BASE_SCHEMAS).build();
netconfNodeManager = new NetconfNodeManager(slaveSetup, DEVICE_ID, responseTimeout,
mockMountPointService);
// 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();
doReturn(node).when(mockDataObjModification).getDataAfter();
netconfNodeManager.onDataTreeChanged(Collections.singletonList(
- new NetconfTopologyManagerTest.CustomTreeModification(new DataTreeIdentifier<>(
+ new NetconfTopologyManagerTest.CustomTreeModification(DataTreeIdentifier.create(
LogicalDatastoreType.OPERATIONAL, nodeListPath), mockDataObjModification)));
verify(mockMountPointBuilder, timeout(5000)).register();
doReturn(null).when(mockDataObjModification).getDataAfter();
netconfNodeManager.onDataTreeChanged(Collections.singletonList(
- new NetconfTopologyManagerTest.CustomTreeModification(new DataTreeIdentifier<>(
+ new NetconfTopologyManagerTest.CustomTreeModification(DataTreeIdentifier.create(
LogicalDatastoreType.OPERATIONAL, nodeListPath), mockDataObjModification)));
verify(mockMountPointReg, timeout(5000)).close();
doReturn(node).when(mockDataObjModification).getDataAfter();
netconfNodeManager.onDataTreeChanged(Collections.singletonList(
- new NetconfTopologyManagerTest.CustomTreeModification(new DataTreeIdentifier<>(
+ new NetconfTopologyManagerTest.CustomTreeModification(DataTreeIdentifier.create(
LogicalDatastoreType.OPERATIONAL, nodeListPath), mockDataObjModification)));
verify(mockMountPointBuilder, timeout(5000)).register();
doReturn(node).when(mockDataObjModification).getDataBefore();
netconfNodeManager.onDataTreeChanged(Collections.singletonList(
- new NetconfTopologyManagerTest.CustomTreeModification(new DataTreeIdentifier<>(
+ new NetconfTopologyManagerTest.CustomTreeModification(DataTreeIdentifier.create(
LogicalDatastoreType.OPERATIONAL, nodeListPath), mockDataObjModification)));
verify(mockMountPointReg, timeout(5000)).close();
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();
doReturn(updatedNode).when(mockDataObjModification).getDataAfter();
netconfNodeManager.onDataTreeChanged(Collections.singletonList(
- new NetconfTopologyManagerTest.CustomTreeModification(new DataTreeIdentifier<>(
+ new NetconfTopologyManagerTest.CustomTreeModification(DataTreeIdentifier.create(
LogicalDatastoreType.OPERATIONAL, nodeListPath), mockDataObjModification)));
verify(mockMountPointReg, timeout(5000)).close();
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();
// First try the registration where the perceived master hasn't been initialized as the master.
netconfNodeManager.onDataTreeChanged(Collections.singletonList(
- new NetconfTopologyManagerTest.CustomTreeModification(new DataTreeIdentifier<>(
+ new NetconfTopologyManagerTest.CustomTreeModification(DataTreeIdentifier.create(
LogicalDatastoreType.OPERATIONAL, nodeListPath), mockDataObjModification)));
verify(mockMountPointBuilder, after(1000).never()).register();
yangTextSchemaSourceRequestFuture);
netconfNodeManager.onDataTreeChanged(Collections.singletonList(
- new NetconfTopologyManagerTest.CustomTreeModification(new DataTreeIdentifier<>(
+ new NetconfTopologyManagerTest.CustomTreeModification(DataTreeIdentifier.create(
LogicalDatastoreType.OPERATIONAL, nodeListPath), mockDataObjModification)));
yangTextSchemaSourceRequestFuture.get(5, TimeUnit.SECONDS);
askForMasterMountPointFuture);
netconfNodeManager.onDataTreeChanged(Collections.singletonList(
- new NetconfTopologyManagerTest.CustomTreeModification(new DataTreeIdentifier<>(
+ new NetconfTopologyManagerTest.CustomTreeModification(DataTreeIdentifier.create(
LogicalDatastoreType.OPERATIONAL, nodeListPath), mockDataObjModification)));
askForMasterMountPointFuture.get(5, TimeUnit.SECONDS);
private NetconfNode newNetconfNode() {
return new NetconfNodeBuilder()
.setHost(new Host(new IpAddress(new Ipv4Address("127.0.0.1"))))
- .setPort(new PortNumber(9999))
+ .setPort(new PortNumber(Uint16.valueOf(9999)))
.setConnectionStatus(NetconfNodeConnectionStatus.ConnectionStatus.Connected)
.setClusteredConnectionStatus(new ClusteredConnectionStatusBuilder()
.setNetconfMasterNode(masterAddress).build())
TestKit kit = new TestKit(masterSystem);
testMasterActorRef.tell(new CreateInitialMasterActorData(mockDeviceDataBroker, SOURCE_IDENTIFIERS,
- mockRpcService), kit.getRef());
+ mockRpcService, mockActionService), kit.getRef());
kit.expectMsgClass(MasterActorDataInitialized.class);
}
private static class TestMasterActor extends NetconfNodeActor {
final Map<Class<?>, CompletableFuture<? extends Object>> messagesToDrop = new ConcurrentHashMap<>();
- TestMasterActor(NetconfTopologySetup setup, RemoteDeviceId deviceId, Timeout actorResponseWaitTime,
- DOMMountPointService mountPointService) {
- super(setup, deviceId, setup.getSchemaResourcesDTO().getSchemaRegistry(),
- setup.getSchemaResourcesDTO().getSchemaRepository(), actorResponseWaitTime, mountPointService);
+ TestMasterActor(final NetconfTopologySetup setup, final RemoteDeviceId deviceId,
+ final Timeout actorResponseWaitTime, final DOMMountPointService mountPointService) {
+ super(setup, deviceId, actorResponseWaitTime, mountPointService);
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
- public void handleReceive(Object message) {
+ public void handleReceive(final Object message) {
CompletableFuture dropFuture = messagesToDrop.remove(message.getClass());
if (dropFuture != null) {
dropFuture.complete(message);