import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
+import static org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType.DELETE;
+import static org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType.WRITE;
import static org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.assertDeletedIDs;
import static org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.newDestNode;
import static org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.newInvNodeKey;
import java.util.concurrent.CountDownLatch;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
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.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-/**
- * @author joe
- *
- */
-public class NodeChangeListenerImplTest extends DataChangeListenerBase {
+public class NodeChangeListenerImplTest extends DataTreeChangeListenerBase {
@SuppressWarnings({ "rawtypes" })
@Test
public void testOnNodeRemoved() {
-
NodeKey topoNodeKey = new NodeKey(new NodeId("node1"));
- InstanceIdentifier<Node> topoNodeII = topologyIID.child(Node.class, topoNodeKey);
+ final InstanceIdentifier<Node> topoNodeII = topologyIID.child(Node.class, topoNodeKey);
Node topoNode = new NodeBuilder().setKey(topoNodeKey).build();
- org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey
- nodeKey = newInvNodeKey(topoNodeKey.getNodeId().getValue());
- InstanceIdentifier<?> invNodeID = InstanceIdentifier.create(Nodes.class).child(
+ org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819
+ .nodes.NodeKey nodeKey = newInvNodeKey(topoNodeKey.getNodeId().getValue());
+ final InstanceIdentifier<?> invNodeID = InstanceIdentifier.create(Nodes.class).child(
org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node.class,
nodeKey);
newLink("link2", newSourceNode("source2"), newDestNode("dest2")));
final Topology topology = new TopologyBuilder().setLink(linkList).build();
- InstanceIdentifier[] expDeletedIIDs = {
+ final InstanceIdentifier[] expDeletedIIDs = {
topologyIID.child(Link.class, linkList.get(0).getKey()),
topologyIID.child(Link.class, linkList.get(1).getKey()),
topologyIID.child(Node.class, new NodeKey(new NodeId("node1")))
doReturn(Futures.makeChecked(readFutureNode, ReadFailedException.MAPPER)).when(mockTx1)
.read(LogicalDatastoreType.OPERATIONAL, topoNodeII);
- CountDownLatch submitLatch1 = setupStubbedSubmit(mockTx1);
+ final CountDownLatch submitLatch1 = setupStubbedSubmit(mockTx1);
int expDeleteCalls = expDeletedIIDs.length;
CountDownLatch deleteLatch = new CountDownLatch(expDeleteCalls);
doReturn(mockTx1).when(mockTxChain).newReadWriteTransaction();
- mockDataChangeListener(null, null, Collections.singleton(invNodeID));
- nodeChangeListener.onDataChanged(mockedDataChangeListener);
+ DataTreeModification dataTreeModification = setupDataTreeChange(DELETE, invNodeID);
+ nodeChangeListener.onDataTreeChanged(Collections.singleton(dataTreeModification));
waitForSubmit(submitLatch1);
org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey
nodeKey = newInvNodeKey(topoNodeKey.getNodeId().getValue());
- InstanceIdentifier<?> invNodeID = InstanceIdentifier.create(Nodes.class).child(
+ final InstanceIdentifier<?> invNodeID = InstanceIdentifier.create(Nodes.class).child(
org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node.class,
nodeKey);
- InstanceIdentifier[] expDeletedIIDs = {
+ final InstanceIdentifier[] expDeletedIIDs = {
topologyIID.child(Node.class, new NodeKey(new NodeId("node1")))
};
ReadWriteTransaction mockTx = mock(ReadWriteTransaction.class);
doReturn(Futures.immediateCheckedFuture(Optional.absent())).when(mockTx)
.read(LogicalDatastoreType.OPERATIONAL, topologyIID);
- CountDownLatch submitLatch = setupStubbedSubmit(mockTx);
+ final CountDownLatch submitLatch = setupStubbedSubmit(mockTx);
SettableFuture<Optional<Node>> readFutureNode = SettableFuture.create();
readFutureNode.set(Optional.of(topoNode));
doReturn(mockTx).when(mockTxChain).newReadWriteTransaction();
- mockDataChangeListener(null,null,Collections.singleton(invNodeID));
- nodeChangeListener.onDataChanged(mockedDataChangeListener);
+ DataTreeModification dataTreeModification = setupDataTreeChange(DELETE, invNodeID);
+ nodeChangeListener.onDataTreeChanged(Collections.singleton(dataTreeModification));
waitForSubmit(submitLatch);
CountDownLatch submitLatch = setupStubbedSubmit(mockTx);
doReturn(mockTx).when(mockTxChain).newReadWriteTransaction();
- mockDataChangeListener(Collections.<InstanceIdentifier<?>, DataObject> singletonMap(
- invNodeID, null), null, null);
- nodeChangeListener.onDataChanged(mockedDataChangeListener);
+ DataTreeModification dataTreeModification = setupDataTreeChange(WRITE, invNodeID);
+ nodeChangeListener.onDataTreeChanged(Collections.singleton(dataTreeModification));
waitForSubmit(submitLatch);