@Test
public void testDispatchPacket_toFloodPacket() throws Exception {

    InstanceIdentifier<NodeConnector> ncInsId1 = InstanceIdentifier.builder(Nodes.class)
            .child(Node.class, new NodeKey(new NodeId("1")))
            .child(NodeConnector.class, new NodeConnectorKey(new NodeConnectorId("1"))).build();
    NodeConnectorRef ncRef1 = new NodeConnectorRef(ncInsId1);
    HashMap<String, NodeConnectorRef> controllerSwitchConnectors = Mockito.mock(HashMap.class);
    when(controllerSwitchConnectors.get(any(String.class))).thenReturn(ncRef1);
    when(inventoryReader.getControllerSwitchConnectors()).thenReturn(controllerSwitchConnectors);
    when(inventoryReader.getNodeConnector(any(InstanceIdentifier.class), any(MacAddress.class))).thenReturn(null);
    List<NodeConnectorRef> nodeConnectors = new ArrayList<>();
    InstanceIdentifier<NodeConnector> ncInsId2 = InstanceIdentifier.builder(Nodes.class)
            .child(Node.class, new NodeKey(new NodeId("2")))
            .child(NodeConnector.class, new NodeConnectorKey(new NodeConnectorId("2"))).build();
    nodeConnectors.add(new NodeConnectorRef(ncInsId1));
    nodeConnectors.add(new NodeConnectorRef(ncInsId1));
    nodeConnectors.add(new NodeConnectorRef(ncInsId2));
    HashMap<String, List<NodeConnectorRef>> switchNodeConnectors = Mockito.mock(HashMap.class);
    when(switchNodeConnectors.get(any(String.class))).thenReturn(nodeConnectors);
    when(inventoryReader.getSwitchNodeConnectors()).thenReturn(switchNodeConnectors);
    packetDispatcher.dispatchPacket(null, new NodeConnectorRef(ncInsId2), null, null);
    verify(inventoryReader, times(1)).readInventory();
    verify(inventoryReader, times(0)).setRefreshData(true);
    verify(packetProcessingService, times(2)).transmitPacket(any(TransmitPacketInput.class));
}