* 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.topology.singleton.impl;
import static org.awaitility.Awaitility.await;
import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
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.util.Timeout;
-import com.google.common.base.Optional;
import com.google.common.collect.ImmutableSet;
import io.netty.util.concurrent.EventExecutor;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
-import javax.annotation.Nonnull;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.opendaylight.controller.cluster.ActorSystemProvider;
import org.opendaylight.controller.config.threadpool.ScheduledThreadPool;
import org.opendaylight.controller.config.threadpool.ThreadPool;
-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.binding.api.DataTreeModification;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.binding.test.ConstantSchemaAbstractDataBrokerTest;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+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.binding.api.DataTreeModification;
+import org.opendaylight.mdsal.binding.api.ReadTransaction;
+import org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataBrokerTest;
+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.mdsal.dom.api.DOMMountPointService;
+import org.opendaylight.mdsal.dom.api.DOMRpcProviderService;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
import org.opendaylight.netconf.client.NetconfClientDispatcher;
+import org.opendaylight.netconf.sal.connect.api.DeviceActionFactory;
import org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologySetup;
import org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologyUtils;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Host;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
-import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
public class NetconfTopologyManagerTest {
private static final int ACTOR_RESPONSE_WAIT_TIME = 10;
public void setUp() throws Exception {
initMocks(this);
- ConstantSchemaAbstractDataBrokerTest dataBrokerTest = new ConstantSchemaAbstractDataBrokerTest(false) {
+ AbstractDataBrokerTest dataBrokerTest = new AbstractDataBrokerTest() {
@Override
- protected Iterable<YangModuleInfo> getModuleInfos() throws Exception {
+ protected Set<YangModuleInfo> getModuleInfos() throws Exception {
return ImmutableSet.of(BindingReflections.getModuleInfo(NetworkTopology.class),
BindingReflections.getModuleInfo(Topology.class));
}
dataBrokerTest.setup();
dataBroker = spy(dataBrokerTest.getDataBroker());
- final RpcProviderRegistry rpcProviderRegistry = mock(RpcProviderRegistry.class);
+ final DOMRpcProviderService rpcProviderRegistry = mock(DOMRpcProviderService.class);
final ScheduledThreadPool keepaliveExecutor = mock(ScheduledThreadPool.class);
- final ThreadPool processingExecutor = mock(ThreadPool.class);
+ final ThreadPool processingThreadPool = mock(ThreadPool.class);
+ final ExecutorService processingService = mock(ExecutorService.class);
+ doReturn(processingService).when(processingThreadPool).getExecutor();
final ActorSystemProvider actorSystemProvider = mock(ActorSystemProvider.class);
final EventExecutor eventExecutor = mock(EventExecutor.class);
final NetconfClientDispatcher clientDispatcher = mock(NetconfClientDispatcher.class);
final DOMMountPointService mountPointService = mock(DOMMountPointService.class);
final AAAEncryptionService encryptionService = mock(AAAEncryptionService.class);
+ final DeviceActionFactory deviceActionFactory = mock(DeviceActionFactory.class);
+ final DOMActionProviderService actionProviderRegistry = mock(DOMActionProviderService.class);
final Config config = new ConfigBuilder().setWriteTransactionIdleTimeout(0).build();
- netconfTopologyManager = new NetconfTopologyManager(dataBroker, rpcProviderRegistry,
- clusterSingletonServiceProvider, keepaliveExecutor, processingExecutor,
+ netconfTopologyManager = new NetconfTopologyManager(dataBroker, rpcProviderRegistry, actionProviderRegistry,
+ clusterSingletonServiceProvider, keepaliveExecutor, processingThreadPool,
actorSystemProvider, eventExecutor, clientDispatcher, TOPOLOGY_ID, config,
- mountPointService, encryptionService) {
+ mountPointService, encryptionService, deviceActionFactory) {
@Override
- protected NetconfTopologyContext newNetconfTopologyContext(NetconfTopologySetup setup,
- ServiceGroupIdentifier serviceGroupIdent, Timeout actorResponseWaitTime) {
+ protected NetconfTopologyContext newNetconfTopologyContext(final NetconfTopologySetup setup,
+ final ServiceGroupIdentifier serviceGroupIdent, final Timeout actorResponseWaitTime,
+ final DeviceActionFactory deviceActionFactory) {
assertEquals(ACTOR_RESPONSE_WAIT_TIME, actorResponseWaitTime.duration().toSeconds());
return Objects.requireNonNull(mockContextMap.get(setup.getInstanceIdentifier()),
"No mock context for " + setup.getInstanceIdentifier()).apply(setup);
netconfTopologyManager.init();
await().atMost(5, TimeUnit.SECONDS).until(() -> {
- ReadOnlyTransaction readTx = dataBroker.newReadOnlyTransaction();
+ ReadTransaction readTx = dataBroker.newReadOnlyTransaction();
Optional<Topology> config = readTx.read(LogicalDatastoreType.CONFIGURATION,
NetconfTopologyUtils.createTopologyListPath(TOPOLOGY_ID)).get(3, TimeUnit.SECONDS);
Optional<Topology> oper = readTx.read(LogicalDatastoreType.OPERATIONAL,
// verify registration is called with right parameters
verify(dataBroker).registerDataTreeChangeListener(
- new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, NetconfTopologyUtils
+ DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION, NetconfTopologyUtils
.createTopologyListPath(TOPOLOGY_ID).child(Node.class)), netconfTopologyManager);
netconfTopologyManager.close();
final DataObjectModification<Node> dataObjectModification1 = mock(DataObjectModification.class);
doReturn(WRITE).when(dataObjectModification1).getModificationType();
doReturn(node1).when(dataObjectModification1).getDataAfter();
- doReturn(new InstanceIdentifier.IdentifiableItem<>(Node.class, new NodeKey(nodeId1)))
+ doReturn(InstanceIdentifier.IdentifiableItem.of(Node.class, new NodeKey(nodeId1)))
.when(dataObjectModification1).getIdentifier();
final NetconfNode netconfNode2 = new NetconfNodeBuilder()
final DataObjectModification<Node> dataObjectModification2 = mock(DataObjectModification.class);
doReturn(WRITE).when(dataObjectModification2).getModificationType();
doReturn(node2).when(dataObjectModification2).getDataAfter();
- doReturn(new InstanceIdentifier.IdentifiableItem<>(Node.class, new NodeKey(nodeId2)))
+ doReturn(InstanceIdentifier.IdentifiableItem.of(Node.class, new NodeKey(nodeId2)))
.when(dataObjectModification2).getIdentifier();
final NetconfTopologyContext mockContext1 = mock(NetconfTopologyContext.class);
.registerClusterSingletonService(mockContext2);
netconfTopologyManager.onDataTreeChanged(Arrays.asList(
- new CustomTreeModification(new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION,
+ new CustomTreeModification(DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION,
nodeInstanceId1), dataObjectModification1),
- new CustomTreeModification(new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION,
+ new CustomTreeModification(DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION,
nodeInstanceId2), dataObjectModification2)));
verify(clusterSingletonServiceProvider).registerClusterSingletonService(mockContext1);
doNothing().when(mockContext2).refresh(any());
netconfTopologyManager.onDataTreeChanged(Arrays.asList(
- new CustomTreeModification(new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION,
+ new CustomTreeModification(DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION,
nodeInstanceId1), dataObjectModification1),
- new CustomTreeModification(new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION,
+ new CustomTreeModification(DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION,
nodeInstanceId2), dataObjectModification2)));
ArgumentCaptor<NetconfTopologySetup> mockContext1Setup = ArgumentCaptor.forClass(NetconfTopologySetup.class);
doReturn(null).when(dataObjectModification1).getDataAfter();
netconfTopologyManager.onDataTreeChanged(Arrays.asList(
- new CustomTreeModification(new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION,
+ new CustomTreeModification(DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION,
nodeInstanceId1), dataObjectModification1)));
verify(mockClusterRegistration1).close();
});
netconfTopologyManager.onDataTreeChanged(Arrays.asList(
- new CustomTreeModification(new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION,
+ new CustomTreeModification(DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION,
nodeInstanceId1), dataObjectModification1)));
verify(clusterSingletonServiceProvider, times(2)).registerClusterSingletonService(newMockContext1);
final DataObjectModification<Node> dataObjectModification = mock(DataObjectModification.class);
doReturn(WRITE).when(dataObjectModification).getModificationType();
doReturn(node).when(dataObjectModification).getDataAfter();
- doReturn(new InstanceIdentifier.IdentifiableItem<>(Node.class, new NodeKey(nodeId)))
+ doReturn(InstanceIdentifier.IdentifiableItem.of(Node.class, new NodeKey(nodeId)))
.when(dataObjectModification).getIdentifier();
final NetconfTopologyContext mockContext = mock(NetconfTopologyContext.class);
netconfTopologyManager.init();
netconfTopologyManager.onDataTreeChanged(Arrays.asList(
- new CustomTreeModification(new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION,
+ new CustomTreeModification(DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION,
nodeInstanceId), dataObjectModification)));
verify(clusterSingletonServiceProvider, times(3)).registerClusterSingletonService(mockContext);
this.rootNode = rootNode;
}
- @Nonnull
@Override
public DataTreeIdentifier<Node> getRootPath() {
return rootPath;
}
- @Nonnull
@Override
public DataObjectModification<Node> getRootNode() {
return rootNode;