@Test public void testOfNodeAdded() throws Exception { Node node = mock(Node.class); NodeKey nodeKey = mock(NodeKey.class); NodeId nodeId = mock(NodeId.class); NodeConnector nodeConnector = mock(NodeConnector.class); List<NodeConnector> nodeConnectors = new ArrayList<>(); PhysicalNode physicalNode = mock(PhysicalNode.class); WriteTransaction writeTransaction = mock(WriteTransaction.class); CheckedFuture checkedFuture_write = mock(CheckedFuture.class); NodeConnectorId nodeConnectorId = mock(NodeConnectorId.class); NodeConnectorKey nodeConnectorKey = mock(NodeConnectorKey.class); CheckedFuture checkedFuture_read = mock(CheckedFuture.class); ReadOnlyTransaction readOnlyTransaction = mock(ReadOnlyTransaction.class); when(node.getKey()).thenReturn(nodeKey); when(node.getId()).thenReturn(nodeId); when(nodeId.getValue()).thenReturn(new String("test")); when(node.getNodeConnector()).thenReturn(nodeConnectors); when(phyConfigLoader.getPhysicalNode(any(PhysicalNodeId.class))) .thenReturn(null) .thenReturn(physicalNode); when(dataBroker.newWriteOnlyTransaction()).thenReturn(writeTransaction); when(writeTransaction.submit()).thenReturn(checkedFuture_write); physicalNetworkAdapter.ofNodeAdded(node); physicalNetworkAdapter.ofNodeAdded(node); verify(phyConfigLoader,times(2)).getPhysicalNode(any(PhysicalNodeId.class)); verify(writeTransaction,times(2)).submit(); verify(node,times(3)).getKey(); nodeConnectors.add(nodeConnector); when(nodeConnector.getId()).thenReturn(nodeConnectorId); when(nodeConnectorId.getValue()) .thenReturn(new String("LOCAL")) .thenReturn(new String("test1")); when(nodeConnector.getKey()).thenReturn(nodeConnectorKey); physicalNetworkAdapter.ofNodeAdded(node); verify(node,times(5)).getKey(); when(dataBroker.newReadOnlyTransaction()).thenReturn(readOnlyTransaction); when(readOnlyTransaction.read(any(LogicalDatastoreType.class),any(InstanceIdentifier.class))).thenReturn(checkedFuture_read); }
protected void ofNodeAdded(Node node) { log.debug("OF node added: {}.", node.getKey()); String strNodeId = node.getId().getValue(); PhysicalNodeId nodeId = new PhysicalNodeId(strNodeId); PhysicalNodeBuilder nodeBuilder = new PhysicalNodeBuilder(); nodeBuilder.setNodeId(nodeId); nodeBuilder.setKey(new PhysicalNodeKey(nodeId)); List<PhysicalPort> physicalPortList = new ArrayList<>(); List<NodeConnector> nodeConnectors = node.getNodeConnector(); if (nodeConnectors == null || nodeConnectors.size() == 0) { log.error("Node : {}, without port.", strNodeId); } if (nodeConnectors != null) { for (NodeConnector nodeConnector : nodeConnectors) { PhysicalPort physicalPort = getPhysicalPort(node.getKey(), nodeConnector); if (physicalPort != null) { physicalPortList.add(physicalPort); } } } nodeBuilder.setPhysicalPort(physicalPortList); PhysicalNode confPhyNode = phyConfigLoader.getPhysicalNode(nodeId); if (confPhyNode != null) { nodeBuilder.setNodeType(confPhyNode.getNodeType()); nodeBuilder.setAttribute(confPhyNode.getAttribute()); } else { log.warn("Find one OF Node {},does not have info in config file.", node.getKey()); } boolean result = dataBrokerAdapter.addPhysicalNode(nodeBuilder.build()); nodeIdSet.add(strNodeId); log.debug("Add....{}\r\n{}", strNodeId, nodeIdSet); }
PhysicalNetworkAdapter { protected void ofNodeAdded(Node node) { log.debug("OF node added: {}.", node.getKey()); String strNodeId = node.getId().getValue(); PhysicalNodeId nodeId = new PhysicalNodeId(strNodeId); PhysicalNodeBuilder nodeBuilder = new PhysicalNodeBuilder(); nodeBuilder.setNodeId(nodeId); nodeBuilder.setKey(new PhysicalNodeKey(nodeId)); List<PhysicalPort> physicalPortList = new ArrayList<>(); List<NodeConnector> nodeConnectors = node.getNodeConnector(); if (nodeConnectors == null || nodeConnectors.size() == 0) { log.error("Node : {}, without port.", strNodeId); } if (nodeConnectors != null) { for (NodeConnector nodeConnector : nodeConnectors) { PhysicalPort physicalPort = getPhysicalPort(node.getKey(), nodeConnector); if (physicalPort != null) { physicalPortList.add(physicalPort); } } } nodeBuilder.setPhysicalPort(physicalPortList); PhysicalNode confPhyNode = phyConfigLoader.getPhysicalNode(nodeId); if (confPhyNode != null) { nodeBuilder.setNodeType(confPhyNode.getNodeType()); nodeBuilder.setAttribute(confPhyNode.getAttribute()); } else { log.warn("Find one OF Node {},does not have info in config file.", node.getKey()); } boolean result = dataBrokerAdapter.addPhysicalNode(nodeBuilder.build()); nodeIdSet.add(strNodeId); log.debug("Add....{}\r\n{}", strNodeId, nodeIdSet); } }
PhysicalNetworkAdapter { protected void ofNodeAdded(Node node) { log.debug("OF node added: {}.", node.getKey()); String strNodeId = node.getId().getValue(); PhysicalNodeId nodeId = new PhysicalNodeId(strNodeId); PhysicalNodeBuilder nodeBuilder = new PhysicalNodeBuilder(); nodeBuilder.setNodeId(nodeId); nodeBuilder.setKey(new PhysicalNodeKey(nodeId)); List<PhysicalPort> physicalPortList = new ArrayList<>(); List<NodeConnector> nodeConnectors = node.getNodeConnector(); if (nodeConnectors == null || nodeConnectors.size() == 0) { log.error("Node : {}, without port.", strNodeId); } if (nodeConnectors != null) { for (NodeConnector nodeConnector : nodeConnectors) { PhysicalPort physicalPort = getPhysicalPort(node.getKey(), nodeConnector); if (physicalPort != null) { physicalPortList.add(physicalPort); } } } nodeBuilder.setPhysicalPort(physicalPortList); PhysicalNode confPhyNode = phyConfigLoader.getPhysicalNode(nodeId); if (confPhyNode != null) { nodeBuilder.setNodeType(confPhyNode.getNodeType()); nodeBuilder.setAttribute(confPhyNode.getAttribute()); } else { log.warn("Find one OF Node {},does not have info in config file.", node.getKey()); } boolean result = dataBrokerAdapter.addPhysicalNode(nodeBuilder.build()); nodeIdSet.add(strNodeId); log.debug("Add....{}\r\n{}", strNodeId, nodeIdSet); } PhysicalNetworkAdapter(DataBroker dataBroker
            , NotificationProviderService notificationProviderService
            , PhyConfigLoader phyConfigLoader
            , FlowUtils ofFlowUtils); }
PhysicalNetworkAdapter { protected void ofNodeAdded(Node node) { log.debug("OF node added: {}.", node.getKey()); String strNodeId = node.getId().getValue(); PhysicalNodeId nodeId = new PhysicalNodeId(strNodeId); PhysicalNodeBuilder nodeBuilder = new PhysicalNodeBuilder(); nodeBuilder.setNodeId(nodeId); nodeBuilder.setKey(new PhysicalNodeKey(nodeId)); List<PhysicalPort> physicalPortList = new ArrayList<>(); List<NodeConnector> nodeConnectors = node.getNodeConnector(); if (nodeConnectors == null || nodeConnectors.size() == 0) { log.error("Node : {}, without port.", strNodeId); } if (nodeConnectors != null) { for (NodeConnector nodeConnector : nodeConnectors) { PhysicalPort physicalPort = getPhysicalPort(node.getKey(), nodeConnector); if (physicalPort != null) { physicalPortList.add(physicalPort); } } } nodeBuilder.setPhysicalPort(physicalPortList); PhysicalNode confPhyNode = phyConfigLoader.getPhysicalNode(nodeId); if (confPhyNode != null) { nodeBuilder.setNodeType(confPhyNode.getNodeType()); nodeBuilder.setAttribute(confPhyNode.getAttribute()); } else { log.warn("Find one OF Node {},does not have info in config file.", node.getKey()); } boolean result = dataBrokerAdapter.addPhysicalNode(nodeBuilder.build()); nodeIdSet.add(strNodeId); log.debug("Add....{}\r\n{}", strNodeId, nodeIdSet); } PhysicalNetworkAdapter(DataBroker dataBroker
            , NotificationProviderService notificationProviderService
            , PhyConfigLoader phyConfigLoader
            , FlowUtils ofFlowUtils); void close(); PhyConfigLoader getPhyConfigLoader(); }
PhysicalNetworkAdapter { protected void ofNodeAdded(Node node) { log.debug("OF node added: {}.", node.getKey()); String strNodeId = node.getId().getValue(); PhysicalNodeId nodeId = new PhysicalNodeId(strNodeId); PhysicalNodeBuilder nodeBuilder = new PhysicalNodeBuilder(); nodeBuilder.setNodeId(nodeId); nodeBuilder.setKey(new PhysicalNodeKey(nodeId)); List<PhysicalPort> physicalPortList = new ArrayList<>(); List<NodeConnector> nodeConnectors = node.getNodeConnector(); if (nodeConnectors == null || nodeConnectors.size() == 0) { log.error("Node : {}, without port.", strNodeId); } if (nodeConnectors != null) { for (NodeConnector nodeConnector : nodeConnectors) { PhysicalPort physicalPort = getPhysicalPort(node.getKey(), nodeConnector); if (physicalPort != null) { physicalPortList.add(physicalPort); } } } nodeBuilder.setPhysicalPort(physicalPortList); PhysicalNode confPhyNode = phyConfigLoader.getPhysicalNode(nodeId); if (confPhyNode != null) { nodeBuilder.setNodeType(confPhyNode.getNodeType()); nodeBuilder.setAttribute(confPhyNode.getAttribute()); } else { log.warn("Find one OF Node {},does not have info in config file.", node.getKey()); } boolean result = dataBrokerAdapter.addPhysicalNode(nodeBuilder.build()); nodeIdSet.add(strNodeId); log.debug("Add....{}\r\n{}", strNodeId, nodeIdSet); } PhysicalNetworkAdapter(DataBroker dataBroker
            , NotificationProviderService notificationProviderService
            , PhyConfigLoader phyConfigLoader
            , FlowUtils ofFlowUtils); void close(); PhyConfigLoader getPhyConfigLoader();  }