PacketDispatcher { public void sendPacketOut(byte[] payload, NodeConnectorRef ingress, NodeConnectorRef egress) { if (ingress == null || egress == null) { return; } InstanceIdentifier<Node> egressNodePath = getNodePath(egress.getValue()); TransmitPacketInput input = new TransmitPacketInputBuilder() .setPayload(payload) .setNode(new NodeRef(egressNodePath)) .setEgress(egress) .setIngress(ingress) .build(); Futures.addCallback(JdkFutureAdapters.listenInPoolThread(packetProcessingService.transmitPacket(input)), new FutureCallback<RpcResult<Void>>() { @Override public void onSuccess(RpcResult<Void> result) { LOG.debug("transmitPacket was successful"); } @Override public void onFailure(Throwable failure) { LOG.debug("transmitPacket for {} failed", input, failure); } }, MoreExecutors.directExecutor()); }  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);  }
@Test public void testSendPacketOut() throws Exception { InstanceIdentifier<NodeConnector> ncInsId1 = InstanceIdentifier.builder(Nodes.class).child(Node.class) .child(NodeConnector.class, new NodeConnectorKey(new NodeConnectorId("1"))).build(); packetDispatcher.sendPacketOut(null, new NodeConnectorRef(ncInsId1), new NodeConnectorRef(ncInsId1)); verify(packetProcessingService, times(1)).transmitPacket(any(TransmitPacketInput.class)); }
@Test public void testSendPacketOut_NullIngress() throws Exception { packetDispatcher.sendPacketOut(null, null, new NodeConnectorRef(InstanceIdentifier.create(NodeConnector.class))); verify(packetProcessingService, times(0)).transmitPacket(any(TransmitPacketInput.class)); }
@Test public void testSendPacketOut_NullEgress() throws Exception { packetDispatcher.sendPacketOut(null, new NodeConnectorRef(InstanceIdentifier.create(NodeConnector.class)), null); verify(packetProcessingService, times(0)).transmitPacket(any(TransmitPacketInput.class)); }