Search in sources :

Example 61 with NodeBuilder

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder in project openflowplugin by opendaylight.

the class NodeChangeListenerImplTest method testOnNodeRemovedWithNoTopology.

@SuppressWarnings({ "rawtypes" })
@Test
public void testOnNodeRemovedWithNoTopology() {
    NodeKey topoNodeKey = new NodeKey(new NodeId("node1"));
    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());
    final InstanceIdentifier<?> invNodeID = InstanceIdentifier.create(Nodes.class).child(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node.class, nodeKey);
    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);
    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, invNodeID);
    nodeChangeListener.onDataTreeChanged(Collections.singleton(dataTreeModification));
    waitForSubmit(submitLatch);
    waitForDeletes(1, deleteLatch);
    assertDeletedIDs(expDeletedIIDs, deletedLinkIDs);
}
Also used : DataTreeModification(org.opendaylight.controller.md.sal.binding.api.DataTreeModification) Optional(com.google.common.base.Optional) InventoryNode(org.opendaylight.yang.gen.v1.urn.opendaylight.model.topology.inventory.rev131030.InventoryNode) TestUtils.newDestNode(org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.newDestNode) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) TestUtils.newSourceNode(org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.newSourceNode) NodeBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder) CountDownLatch(java.util.concurrent.CountDownLatch) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) Mockito.doReturn(org.mockito.Mockito.doReturn) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) ReadWriteTransaction(org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction) 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) Test(org.junit.Test)

Example 62 with NodeBuilder

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder 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 63 with NodeBuilder

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder in project openflowplugin by opendaylight.

the class OpenflowPluginBulkGroupTransactionProvider method createTestNode.

private void createTestNode() {
    NodeBuilder builder = new NodeBuilder();
    builder.setId(new NodeId(OpenflowpluginTestActivator.NODE_ID));
    builder.setKey(new NodeKey(builder.getId()));
    testNode12 = builder.build();
}
Also used : NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) NodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)

Example 64 with NodeBuilder

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder in project openflowplugin by opendaylight.

the class OpenflowpluginGroupTestCommandProvider method createTestNode.

private void createTestNode() {
    NodeBuilder builder = new NodeBuilder();
    builder.setId(new NodeId(OpenflowpluginTestActivator.NODE_ID));
    builder.setKey(new NodeKey(builder.getId()));
    testNode = builder.build();
}
Also used : NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) NodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)

Example 65 with NodeBuilder

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder in project openflowplugin by opendaylight.

the class OpenflowpluginGroupTestCommandProvider method createUserNode.

private void createUserNode(String nodeRef) {
    NodeBuilder builder = new NodeBuilder();
    builder.setId(new NodeId(nodeRef));
    builder.setKey(new NodeKey(builder.getId()));
    testNode = builder.build();
}
Also used : NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) NodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)

Aggregations

NodeBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder)35 NodeBuilder (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder)30 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)21 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)21 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)18 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)17 Test (org.junit.Test)11 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)11 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)11 FlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder)11 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)11 NodeKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey)11 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)10 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)8 ArrayList (java.util.ArrayList)7 Optional (com.google.common.base.Optional)6 BigInteger (java.math.BigInteger)6 TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)6 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)6 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)5