@Test public void testFloodPacket_NullList() throws Exception { HashMap<String, List<NodeConnectorRef>> switchNodeConnectors = Mockito.mock(HashMap.class); when(switchNodeConnectors.get(any(String.class))).thenReturn(null); when(inventoryReader.getSwitchNodeConnectors()).thenReturn(switchNodeConnectors); packetDispatcher.floodPacket("", null, new NodeConnectorRef(InstanceIdentifier.create(NodeConnector.class)), new NodeConnectorRef(InstanceIdentifier.create(NodeConnector.class))); verify(inventoryReader, times(1)).setRefreshData(true); verify(inventoryReader, times(1)).readInventory(); verify(packetProcessingService, times(0)).transmitPacket(any(TransmitPacketInput.class)); }
public void floodPacket(String nodeId, byte[] payload, NodeConnectorRef origIngress, NodeConnectorRef controllerNodeConnector) { List<NodeConnectorRef> nodeConnectors = inventoryReader.getSwitchNodeConnectors().get(nodeId); if (nodeConnectors == null) { refreshInventoryReader(); nodeConnectors = inventoryReader.getSwitchNodeConnectors().get(nodeId); if (nodeConnectors == null) { LOG.info("Cannot flood packets, as inventory doesn't have any node connectors for node {}", nodeId); return; } } for (NodeConnectorRef ncRef : nodeConnectors) { String ncId = ncRef.getValue().firstIdentifierOf(NodeConnector.class) .firstKeyOf(NodeConnector.class, NodeConnectorKey.class).getId().getValue(); if (!ncId.equals(origIngress.getValue().firstIdentifierOf(NodeConnector.class) .firstKeyOf(NodeConnector.class, NodeConnectorKey.class).getId().getValue())) { sendPacketOut(payload, origIngress, ncRef); } } }
PacketDispatcher { public void floodPacket(String nodeId, byte[] payload, NodeConnectorRef origIngress, NodeConnectorRef controllerNodeConnector) { List<NodeConnectorRef> nodeConnectors = inventoryReader.getSwitchNodeConnectors().get(nodeId); if (nodeConnectors == null) { refreshInventoryReader(); nodeConnectors = inventoryReader.getSwitchNodeConnectors().get(nodeId); if (nodeConnectors == null) { LOG.info("Cannot flood packets, as inventory doesn't have any node connectors for node {}", nodeId); return; } } for (NodeConnectorRef ncRef : nodeConnectors) { String ncId = ncRef.getValue().firstIdentifierOf(NodeConnector.class) .firstKeyOf(NodeConnector.class, NodeConnectorKey.class).getId().getValue(); if (!ncId.equals(origIngress.getValue().firstIdentifierOf(NodeConnector.class) .firstKeyOf(NodeConnector.class, NodeConnectorKey.class).getId().getValue())) { sendPacketOut(payload, origIngress, ncRef); } } } }
PacketDispatcher { public void floodPacket(String nodeId, byte[] payload, NodeConnectorRef origIngress, NodeConnectorRef controllerNodeConnector) { List<NodeConnectorRef> nodeConnectors = inventoryReader.getSwitchNodeConnectors().get(nodeId); if (nodeConnectors == null) { refreshInventoryReader(); nodeConnectors = inventoryReader.getSwitchNodeConnectors().get(nodeId); if (nodeConnectors == null) { LOG.info("Cannot flood packets, as inventory doesn't have any node connectors for node {}", nodeId); return; } } for (NodeConnectorRef ncRef : nodeConnectors) { String ncId = ncRef.getValue().firstIdentifierOf(NodeConnector.class) .firstKeyOf(NodeConnector.class, NodeConnectorKey.class).getId().getValue(); if (!ncId.equals(origIngress.getValue().firstIdentifierOf(NodeConnector.class) .firstKeyOf(NodeConnector.class, NodeConnectorKey.class).getId().getValue())) { sendPacketOut(payload, origIngress, ncRef); } } }  }
PacketDispatcher { public void floodPacket(String nodeId, byte[] payload, NodeConnectorRef origIngress, NodeConnectorRef controllerNodeConnector) { List<NodeConnectorRef> nodeConnectors = inventoryReader.getSwitchNodeConnectors().get(nodeId); if (nodeConnectors == null) { refreshInventoryReader(); nodeConnectors = inventoryReader.getSwitchNodeConnectors().get(nodeId); if (nodeConnectors == null) { LOG.info("Cannot flood packets, as inventory doesn't have any node connectors for node {}", nodeId); return; } } for (NodeConnectorRef ncRef : nodeConnectors) { String ncId = ncRef.getValue().firstIdentifierOf(NodeConnector.class) .firstKeyOf(NodeConnector.class, NodeConnectorKey.class).getId().getValue(); if (!ncId.equals(origIngress.getValue().firstIdentifierOf(NodeConnector.class) .firstKeyOf(NodeConnector.class, NodeConnectorKey.class).getId().getValue())) { sendPacketOut(payload, origIngress, ncRef); } } }  void setPacketProcessingService(PacketProcessingService packetProcessingService); void setInventoryReader(InventoryReader inventoryReader); void dispatchPacket(byte[] payload, NodeConnectorRef ingress, MacAddress srcMac, MacAddress destMac); void floodPacket(String nodeId, byte[] payload, NodeConnectorRef origIngress,
            NodeConnectorRef controllerNodeConnector); void sendPacketOut(byte[] payload, NodeConnectorRef ingress, NodeConnectorRef egress); }
PacketDispatcher { public void floodPacket(String nodeId, byte[] payload, NodeConnectorRef origIngress, NodeConnectorRef controllerNodeConnector) { List<NodeConnectorRef> nodeConnectors = inventoryReader.getSwitchNodeConnectors().get(nodeId); if (nodeConnectors == null) { refreshInventoryReader(); nodeConnectors = inventoryReader.getSwitchNodeConnectors().get(nodeId); if (nodeConnectors == null) { LOG.info("Cannot flood packets, as inventory doesn't have any node connectors for node {}", nodeId); return; } } for (NodeConnectorRef ncRef : nodeConnectors) { String ncId = ncRef.getValue().firstIdentifierOf(NodeConnector.class) .firstKeyOf(NodeConnector.class, NodeConnectorKey.class).getId().getValue(); if (!ncId.equals(origIngress.getValue().firstIdentifierOf(NodeConnector.class) .firstKeyOf(NodeConnector.class, NodeConnectorKey.class).getId().getValue())) { sendPacketOut(payload, origIngress, ncRef); } } }  void setPacketProcessingService(PacketProcessingService packetProcessingService); void setInventoryReader(InventoryReader inventoryReader); void dispatchPacket(byte[] payload, NodeConnectorRef ingress, MacAddress srcMac, MacAddress destMac); void floodPacket(String nodeId, byte[] payload, NodeConnectorRef origIngress,
            NodeConnectorRef controllerNodeConnector); void sendPacketOut(byte[] payload, NodeConnectorRef ingress, NodeConnectorRef egress);  }