use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.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);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.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);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.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();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.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();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.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();
}
Aggregations