PhysicalNetworkAdapter { protected void ofNodeRemoved(Node node) { log.debug("OF node removed: {}.", node.getKey()); String strNodeId = node.getId().getValue(); PhysicalNodeId nodeId = new PhysicalNodeId(strNodeId); PhysicalNode confPhyNode = phyConfigLoader.getPhysicalNode(nodeId); if (confPhyNode == null) { log.warn("Find one OF Node removed {},does not have info in config file.", node.getKey()); } boolean result = dataBrokerAdapter.removePhysicalNode(new PhysicalNodeKey(nodeId)); nodeIdSet.remove(strNodeId); log.debug("Remove....{}\r\n{}", strNodeId, nodeIdSet); } PhysicalNetworkAdapter(DataBroker dataBroker
            , NotificationProviderService notificationProviderService
            , PhyConfigLoader phyConfigLoader
            , FlowUtils ofFlowUtils); void close(); PhyConfigLoader getPhyConfigLoader();  }
@Test public void testOfNodeRemoved() throws Exception { Class<PhysicalNetworkAdapter> class1 = PhysicalNetworkAdapter.class; Method method = class1.getDeclaredMethod("ofNodeRemoved", new Class[]{Node.class}); method.setAccessible(true); Node node = mock(Node.class); NodeKey nodeKey = mock(NodeKey.class); NodeId nodeId = mock(NodeId.class); PhysicalNode physicalNode = mock(PhysicalNode.class); WriteTransaction writeTransaction = mock(WriteTransaction.class); CheckedFuture checkedFuture = mock(CheckedFuture.class); when(node.getKey()).thenReturn(nodeKey); when(node.getId()).thenReturn(nodeId); when(nodeId.getValue()).thenReturn(new String("test")); when(phyConfigLoader.getPhysicalNode(any(PhysicalNodeId.class))) .thenReturn(null) .thenReturn(physicalNode); when(dataBroker.newWriteOnlyTransaction()).thenReturn(writeTransaction); when(writeTransaction.submit()).thenReturn(checkedFuture); physicalNetworkAdapter.ofNodeRemoved(node); physicalNetworkAdapter.ofNodeRemoved(node); verify(phyConfigLoader,times(2)).getPhysicalNode(any(PhysicalNodeId.class)); verify(writeTransaction,times(2)).submit(); }