Search in sources :

Example 26 with DataTreeModification

use of org.opendaylight.controller.md.sal.binding.api.DataTreeModification in project openflowplugin by opendaylight.

the class TerminationPointChangeListenerImplTest method testOnNodeConnectorUpdatedWithLinkStateDown.

@SuppressWarnings("rawtypes")
@Test
public void testOnNodeConnectorUpdatedWithLinkStateDown() {
    org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey nodeKey = newInvNodeKey("node1");
    org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey ncKey = newInvNodeConnKey("tp1");
    final InstanceIdentifier<?> invNodeConnID = newNodeConnID(nodeKey, ncKey);
    List<Link> linkList = Arrays.asList(newLink("link1", newSourceTp("tp1"), newDestTp("dest")));
    Topology topology = new TopologyBuilder().setLink(linkList).build();
    ReadWriteTransaction mockTx = mock(ReadWriteTransaction.class);
    doReturn(Futures.immediateCheckedFuture(Optional.of(topology))).when(mockTx).read(LogicalDatastoreType.OPERATIONAL, topologyIID);
    setupStubbedSubmit(mockTx);
    CountDownLatch deleteLatch = new CountDownLatch(1);
    ArgumentCaptor<InstanceIdentifier> deletedLinkIDs = ArgumentCaptor.forClass(InstanceIdentifier.class);
    setupStubbedDeletes(mockTx, deletedLinkIDs, deleteLatch);
    doReturn(mockTx).when(mockTxChain).newReadWriteTransaction();
    DataTreeModification dataTreeModification = setupDataTreeChange(WRITE, invNodeConnID);
    when(dataTreeModification.getRootNode().getDataAfter()).thenReturn(provideFlowCapableNodeConnector(true, false));
    terminationPointListener.onDataTreeChanged(Collections.singleton(dataTreeModification));
    waitForDeletes(1, deleteLatch);
    InstanceIdentifier<TerminationPoint> expTpPath = topologyIID.child(Node.class, new NodeKey(new NodeId("node1"))).child(TerminationPoint.class, new TerminationPointKey(new TpId("tp1")));
    verify(mockTx).merge(eq(LogicalDatastoreType.OPERATIONAL), eq(expTpPath), any(TerminationPoint.class), eq(true));
    assertDeletedIDs(new InstanceIdentifier[] { topologyIID.child(Link.class, linkList.get(0).getKey()) }, deletedLinkIDs);
}
Also used : DataTreeModification(org.opendaylight.controller.md.sal.binding.api.DataTreeModification) TopologyBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyBuilder) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) TestUtils.newInvNodeKey(org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.newInvNodeKey) NodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey) TerminationPointKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey) Topology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology) CountDownLatch(java.util.concurrent.CountDownLatch) Mockito.doReturn(org.mockito.Mockito.doReturn) TpId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) ReadWriteTransaction(org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction) TestUtils.newLink(org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.newLink) Link(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint) Test(org.junit.Test)

Example 27 with DataTreeModification

use of org.opendaylight.controller.md.sal.binding.api.DataTreeModification in project openflowplugin by opendaylight.

the class TerminationPointChangeListenerImplTest method testOnNodeConnectorRemovedWithNoTopology.

@SuppressWarnings("rawtypes")
@Test
public void testOnNodeConnectorRemovedWithNoTopology() {
    NodeKey topoNodeKey = new NodeKey(new NodeId("node1"));
    TerminationPointKey terminationPointKey = new TerminationPointKey(new TpId("tp1"));
    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());
    org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey ncKey = newInvNodeConnKey(terminationPointKey.getTpId().getValue());
    final InstanceIdentifier<?> invNodeConnID = newNodeConnID(nodeKey, ncKey);
    final InstanceIdentifier[] expDeletedIIDs = { topologyIID.child(Node.class, new NodeKey(new NodeId("node1"))).child(TerminationPoint.class, new TerminationPointKey(new TpId("tp1"))) };
    ReadWriteTransaction mockTx = mock(ReadWriteTransaction.class);
    doReturn(Futures.immediateCheckedFuture(Optional.absent())).when(mockTx).read(LogicalDatastoreType.OPERATIONAL, topologyIID);
    final CountDownLatch submitLatch = setupStubbedSubmit(mockTx);
    SettableFuture<Optional<Node>> readFutureNode = SettableFuture.create();
    readFutureNode.set(Optional.of(topoNode));
    doReturn(Futures.makeChecked(readFutureNode, ReadFailedException.MAPPER)).when(mockTx).read(LogicalDatastoreType.OPERATIONAL, topoNodeII);
    CountDownLatch deleteLatch = new CountDownLatch(1);
    ArgumentCaptor<InstanceIdentifier> deletedLinkIDs = ArgumentCaptor.forClass(InstanceIdentifier.class);
    setupStubbedDeletes(mockTx, deletedLinkIDs, deleteLatch);
    doReturn(mockTx).when(mockTxChain).newReadWriteTransaction();
    DataTreeModification dataTreeModification = setupDataTreeChange(DELETE, invNodeConnID);
    terminationPointListener.onDataTreeChanged(Collections.singleton(dataTreeModification));
    waitForSubmit(submitLatch);
    waitForDeletes(1, deleteLatch);
    assertDeletedIDs(expDeletedIIDs, deletedLinkIDs);
}
Also used : DataTreeModification(org.opendaylight.controller.md.sal.binding.api.DataTreeModification) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) NodeBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) TestUtils.newInvNodeKey(org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.newInvNodeKey) NodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey) Optional(com.google.common.base.Optional) TerminationPointKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey) CountDownLatch(java.util.concurrent.CountDownLatch) TpId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId) Mockito.doReturn(org.mockito.Mockito.doReturn) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) ReadWriteTransaction(org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint) Test(org.junit.Test)

Example 28 with DataTreeModification

use of org.opendaylight.controller.md.sal.binding.api.DataTreeModification in project openflowplugin by opendaylight.

the class FlowNotificationSupplierImplTest method testUpdateChangeEvent.

@Test
public void testUpdateChangeEvent() {
    final TestData testData = new TestData(createTestFlowPath(), createTestFlow(), createUpdatedTestFlow(), DataObjectModification.ModificationType.SUBTREE_MODIFIED);
    Collection<DataTreeModification<Flow>> collection = new ArrayList<>();
    collection.add(testData);
    notifSupplierImpl.onDataTreeChanged(collection);
    verify(notifProviderService, times(1)).publish(Matchers.any(FlowUpdated.class));
}
Also used : DataTreeModification(org.opendaylight.controller.md.sal.binding.api.DataTreeModification) FlowUpdated(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowUpdated) TestData(org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestData) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 29 with DataTreeModification

use of org.opendaylight.controller.md.sal.binding.api.DataTreeModification in project openflowplugin by opendaylight.

the class FlowNotificationSupplierImplTest method testDeleteChangeEvent.

@Test
public void testDeleteChangeEvent() {
    final TestData testData = new TestData(createTestFlowPath(), createTestFlow(), null, DataObjectModification.ModificationType.DELETE);
    Collection<DataTreeModification<Flow>> collection = new ArrayList<>();
    collection.add(testData);
    notifSupplierImpl.onDataTreeChanged(collection);
    verify(notifProviderService, times(1)).publish(Matchers.any(FlowRemoved.class));
}
Also used : DataTreeModification(org.opendaylight.controller.md.sal.binding.api.DataTreeModification) TestData(org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestData) ArrayList(java.util.ArrayList) FlowRemoved(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved) Test(org.junit.Test)

Example 30 with DataTreeModification

use of org.opendaylight.controller.md.sal.binding.api.DataTreeModification in project openflowplugin by opendaylight.

the class GroupNotificationSupplierImplTest method testCreateChangeEvent.

@Test
public void testCreateChangeEvent() {
    final TestData testData = new TestData(createTestGroupPath(), null, createTestGroup(), DataObjectModification.ModificationType.WRITE);
    Collection<DataTreeModification<Group>> collection = new ArrayList<>();
    collection.add(testData);
    notifSupplierImpl.onDataTreeChanged(collection);
    verify(notifProviderService, times(1)).publish(Matchers.any(GroupAdded.class));
}
Also used : DataTreeModification(org.opendaylight.controller.md.sal.binding.api.DataTreeModification) TestData(org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestData) GroupAdded(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.GroupAdded) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

DataTreeModification (org.opendaylight.controller.md.sal.binding.api.DataTreeModification)42 Test (org.junit.Test)38 ArrayList (java.util.ArrayList)20 TestData (org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestData)19 CountDownLatch (java.util.concurrent.CountDownLatch)8 Mockito.doReturn (org.mockito.Mockito.doReturn)8 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)8 TestUtils.newInvNodeKey (org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.newInvNodeKey)8 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)8 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)8 NodeKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey)8 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)7 FlowCapableNodeConnector (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector)5 TpId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId)5 TerminationPoint (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint)5 TerminationPointKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey)5 Optional (com.google.common.base.Optional)4 DataTreeIdentifier (org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier)4 TestUtils.newLink (org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.newLink)4 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)4