Ipv6NsHelper { public void transmitNeighborSolicitationToOfGroup(Uint64 dpId, MacAddress srcMacAddress, Ipv6Address srcIpv6Address, Ipv6Address targetIpv6Address, long ofGroupId) { byte[] txPayload = frameNeighborSolicitationRequest(srcMacAddress, srcIpv6Address, targetIpv6Address); List<ActionInfo> lstActionInfo = new ArrayList<>(); lstActionInfo.add(new ActionGroup(ofGroupId)); TransmitPacketInput input = MDSALUtil.getPacketOutDefault(lstActionInfo, txPayload, dpId); LOG.debug( "Transmitting Neighbor Solicitation packet out. srcMacAddress={}, srcIpv6Address={}, " + "targetIpv6Address={}, dpId={}, ofGroupId={}", srcMacAddress.getValue(), srcIpv6Address.getValue(), targetIpv6Address.getValue(), dpId, ofGroupId); LoggingFutures.addErrorLogging(packetService.transmitPacket(input), LOG, "transmitPacket"); } @Inject  Ipv6NsHelper(final PacketProcessingService packetService); boolean transmitNeighborSolicitation(Uint64 dpnId, NodeConnectorRef nodeRef, MacAddress srcMacAddress,
            Ipv6Address srcIpv6Address, Ipv6Address targetIpv6Address); void transmitNeighborSolicitationToOfGroup(Uint64 dpId, MacAddress srcMacAddress,
            Ipv6Address srcIpv6Address, Ipv6Address targetIpv6Address, long ofGroupId);  }
@Test public void testTransmitNeighborSolicitationToOfGroup() { doReturn(RpcResultBuilder.status(true).buildFuture()).when(pktProcessService) .transmitPacket(any(TransmitPacketInput.class)); Uint64 dpnId = Uint64.ONE; MacAddress srcMacAddress = new MacAddress("08:00:27:FE:8F:95"); Ipv6Address srcIpv6Address = new Ipv6Address("2001:db8::1"); Ipv6Address targetIpv6Address = new Ipv6Address("2001:db8::2"); long ofGroupId = 20000; instance.transmitNeighborSolicitationToOfGroup(dpnId, srcMacAddress, srcIpv6Address, targetIpv6Address, ofGroupId); verify(pktProcessService, times(1)).transmitPacket(any(TransmitPacketInput.class)); }
@Test public void testTransmitNeighborSolicitationToOfGroupWithInvalidInput() { doReturn(RpcResultBuilder.status(true).buildFuture()).when(pktProcessService) .transmitPacket(any(TransmitPacketInput.class)); Uint64 dpnId = Uint64.ONE; MacAddress srcMacAddress = new MacAddress("08:00:27:FE:8F:95"); Ipv6Address srcIpv6Address = new Ipv6Address("2001:db8::1"); Ipv6Address targetIpv6Address = new Ipv6Address("2001:db8::2"); long invalidOfGroupId = -1; assertThrows(IllegalArgumentException.class, () -> { instance.transmitNeighborSolicitationToOfGroup(dpnId, srcMacAddress, srcIpv6Address, targetIpv6Address, invalidOfGroupId); }); verify(pktProcessService, times(0)).transmitPacket(any(TransmitPacketInput.class)); long ofGroupId = 20000; byte[] expectedPayload = buildPacket( "33 33 00 00 00 02", "08 00 27 FE 8F 95", "86 DD", "60 00 00 00", "00 20", "3A", "FF", "20 01 0D B8 00 00 00 00 00 00 00 00 00 00 00 01", "FF 02 00 00 00 00 00 00 00 00 00 01 FF 00 00 02", "87", "00", "5E 95", "00 00 00 00", "20 01 0D B8 00 00 00 00 00 00 00 00 00 00 00 02", "01", "01", "08 00 27 FE 8F 95" ); List<ActionInfo> lstActionInfo = new ArrayList<>(); lstActionInfo.add(new ActionGroup(ofGroupId)); TransmitPacketInput expectedInput = MDSALUtil.getPacketOutDefault(lstActionInfo, expectedPayload, dpnId); instance.transmitNeighborSolicitationToOfGroup(dpnId, srcMacAddress, srcIpv6Address, targetIpv6Address, ofGroupId); verify(pktProcessService, times(0)).transmitPacket(expectedInput); expectedPayload = buildPacket( "33 33 00 00 00 02", "08 00 27 FE 8F 95", "86 DD", "60 00 00 00", "00 20", "3A", "FF", "20 01 0D B8 00 00 00 00 00 00 00 00 00 00 00 01", "FF 02 00 00 00 00 00 00 00 00 00 01 FF 00 00 02", "88", "00", "5E 94", "00 00 00 00", "20 01 0D B8 00 00 00 00 00 00 00 00 00 00 00 02", "01", "01", "08 00 27 FE 8F 95" ); expectedInput = MDSALUtil.getPacketOutDefault(lstActionInfo, expectedPayload, dpnId); instance.transmitNeighborSolicitationToOfGroup(dpnId, srcMacAddress, srcIpv6Address, targetIpv6Address, ofGroupId); verify(pktProcessService, times(0)).transmitPacket(expectedInput); }