### Question:
ArpUtils { public static String getArpFrameToStringFormat(Ethernet eth) { String ethernetString = "Ethernet [getEtherType()=" + EtherTypes.loadFromString(String.valueOf(eth.getEtherType())) + ", getSourceMACAddress()=" + HexEncode.bytesToHexStringFormat(eth.getSourceMACAddress()) + ", getDestinationMACAddress()=" + HexEncode.bytesToHexStringFormat(eth.getDestinationMACAddress()) + "]\n"; Packet potentialArp = eth.getPayload(); String arpString = null; if (potentialArp instanceof Arp) { Arp arp = (Arp) potentialArp; arpString = ArpUtils.getArpToStringFormat(arp); } else { arpString = "ARP was not found in Ethernet frame."; } return ethernetString.concat(arpString); } private  ArpUtils(); static String getArpFrameToStringFormat(Ethernet eth); static String getArpToStringFormat(Arp arp); static byte[] macToBytes(MacAddress mac); static @Nullable MacAddress bytesToMac(byte[] macBytes); static byte[] ipToBytes(Ipv4Address ip); static @Nullable Ipv4Address bytesToIp(byte[] ipv4AsBytes);  }### Answer:
@Test public void getArpFrameToStringFormatTest() throws Exception { MacAddress destMac = new MacAddress("00:00:00:00:00:01"); MacAddress srcMac = new MacAddress("00:00:00:00:00:02"); Arp arp = new Arp(); byte[] sha = HexEncode.bytesFromHexString(srcMac.getValue()); byte[] spa = InetAddress.getByName("192.168.0.1").getAddress(); byte[] tha = HexEncode.bytesFromHexString(destMac.getValue()); byte[] tpa = InetAddress.getByName("192.168.0.2").getAddress(); int htype = 2; int ptype = EtherTypes.IPv6.intValue(); short hlen = 8; short plen = 8; int operation = 32; arp.setSenderHardwareAddress(sha); arp.setSenderProtocolAddress(spa); arp.setTargetHardwareAddress(tha); arp.setTargetProtocolAddress(tpa); arp.setOperation(operation); arp.setHardwareLength(hlen); arp.setProtocolLength(plen); arp.setHardwareType(htype); arp.setProtocolType(ptype); Ethernet eth = new Ethernet().setEtherType(EtherTypes.IPv4.shortValue()) .setDestinationMACAddress(ArpUtils.macToBytes(destMac)) .setSourceMACAddress(ArpUtils.macToBytes(srcMac)); eth.setPayload(arp); String daco = InetAddress.getByAddress(spa).getHostAddress(); String result = ArpUtils.getArpFrameToStringFormat(eth); Assert.assertTrue(result.contains("getSourceMACAddress()=" + srcMac.getValue())); Assert.assertTrue(result.contains("getDestinationMACAddress()=" + destMac.getValue())); Assert.assertTrue( result.contains("getEtherType()=" + EtherTypes.loadFromString(String.valueOf(eth.getEtherType())))); Assert.assertTrue(result.contains("getHardwareType()=" + htype)); Assert.assertTrue(result.contains("getProtocolType()=" + ptype)); Assert.assertTrue(result.contains("getHardwareLength()=" + hlen)); Assert.assertTrue(result.contains("getProtocolLength()=" + plen)); Assert.assertTrue(result.contains("getOperation()=" + ArpOperation.loadFromInt(arp.getOperation()))); Assert.assertTrue(result.contains("getSenderHardwareAddress()=" + HexEncode.bytesToHexStringFormat(sha))); Assert.assertTrue(result.contains("getTargetHardwareAddress()=" + HexEncode.bytesToHexStringFormat(tha))); Assert.assertTrue( result.contains("getSenderProtocolAddress()=" + InetAddress.getByAddress(spa).getHostAddress())); Assert.assertTrue( result.contains("getTargetProtocolAddress()=" + InetAddress.getByAddress(tpa).getHostAddress())); }